Lines Matching +full:- +full:30000

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
31 chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); in tpm2_get_timeouts()
32 chip->timeout_b = msecs_to_jiffies(TPM2_TIMEOUT_B); in tpm2_get_timeouts()
33 chip->timeout_c = msecs_to_jiffies(TPM2_TIMEOUT_C); in tpm2_get_timeouts()
34 chip->timeout_d = msecs_to_jiffies(TPM2_TIMEOUT_D); in tpm2_get_timeouts()
35 chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS; in tpm2_get_timeouts()
53 {TPM2_CC_VERIFY_SIGNATURE, 30000},
59 {TPM2_CC_CREATE_PRIMARY, 30000},
60 {TPM2_CC_CREATE, 30000},
61 {TPM2_CC_CREATE_LOADED, 30000},
65 * tpm2_calc_ordinal_duration() - Calculate the maximum command duration
94 * tpm2_pcr_read() - read a PCR value
114 return -EINVAL; in tpm2_pcr_read()
117 for (i = 0; i < chip->nr_allocated_banks && in tpm2_pcr_read()
118 chip->allocated_banks[i].alg_id != digest->alg_id; i++) in tpm2_pcr_read()
121 if (i == chip->nr_allocated_banks) in tpm2_pcr_read()
122 return -EINVAL; in tpm2_pcr_read()
124 expected_digest_size = chip->allocated_banks[i].digest_size; in tpm2_pcr_read()
134 tpm_buf_append_u16(&buf, digest->alg_id); in tpm2_pcr_read()
144 digest_size = be16_to_cpu(out->digest_size); in tpm2_pcr_read()
145 if (digest_size > sizeof(digest->digest) || in tpm2_pcr_read()
147 rc = -EINVAL; in tpm2_pcr_read()
154 memcpy(digest->digest, out->digest, digest_size); in tpm2_pcr_read()
161 * tpm2_pcr_extend() - extend a PCR value
197 tpm_buf_append_u32(&buf, chip->nr_allocated_banks); in tpm2_pcr_extend()
199 for (i = 0; i < chip->nr_allocated_banks; i++) { in tpm2_pcr_extend()
202 chip->allocated_banks[i].digest_size); in tpm2_pcr_extend()
222 * tpm2_get_random() - get random bytes from the TPM RNG
230 * -errno otherwise (positive TPM return codes are masked to -EIO)
246 return -EINVAL; in tpm2_get_random()
272 err = -EIO; in tpm2_get_random()
279 if (be16_to_cpu(head->tag) == TPM2_ST_SESSIONS) in tpm2_get_random()
283 recd = min_t(u32, be16_to_cpu(out->size), num_bytes); in tpm2_get_random()
288 err = -EFAULT; in tpm2_get_random()
291 memcpy(dest_ptr, out->buffer, recd); in tpm2_get_random()
295 num_bytes -= recd; in tpm2_get_random()
296 } while (retries-- && total < max); in tpm2_get_random()
300 return total ? total : -EIO; in tpm2_get_random()
308 * tpm2_flush_context() - execute a TPM2_FlushContext command
319 dev_warn(&chip->dev, "0x%08x was not flushed, out of memory\n", in tpm2_flush_context()
340 * tpm2_get_tpm_pt() - get value of a TPM_CAP_TPM_PROPERTIES type property
348 * -errno or a TPM return code otherwise
373 if (be32_to_cpu(out->property_cnt) > 0) in tpm2_get_tpm_pt()
374 *value = be32_to_cpu(out->value); in tpm2_get_tpm_pt()
376 rc = -ENODATA; in tpm2_get_tpm_pt()
384 * tpm2_shutdown() - send a TPM shutdown command
407 * tpm2_do_selftest() - ensure that all self tests have passed
445 * tpm2_probe() - probe for the TPM 2.0 protocol
454 * -errno otherwise
472 if (be16_to_cpu(out->tag) == TPM2_ST_NO_SESSIONS) in tpm2_probe()
473 chip->flags |= TPM_CHIP_FLAG_TPM2; in tpm2_probe()
482 struct tpm_bank_info *bank = chip->allocated_banks + bank_index; in tpm2_init_bank_info()
483 struct tpm_digest digest = { .alg_id = bank->alg_id }; in tpm2_init_bank_info()
493 if (bank->alg_id != tpm2_hash_map[i].tpm_id) in tpm2_init_bank_info()
496 bank->digest_size = hash_digest_size[crypto_algo]; in tpm2_init_bank_info()
497 bank->crypto_id = crypto_algo; in tpm2_init_bank_info()
501 bank->crypto_id = HASH_ALGO__LAST; in tpm2_init_bank_info()
503 return tpm2_pcr_read(chip, 0, &digest, &bank->digest_size); in tpm2_init_bank_info()
542 chip->allocated_banks = kcalloc(nr_possible_banks, in tpm2_get_pcr_allocation()
543 sizeof(*chip->allocated_banks), in tpm2_get_pcr_allocation()
545 if (!chip->allocated_banks) { in tpm2_get_pcr_allocation()
546 rc = -ENOMEM; in tpm2_get_pcr_allocation()
559 rc = -EFAULT; in tpm2_get_pcr_allocation()
569 chip->allocated_banks[nr_alloc_banks].alg_id = hash_alg; in tpm2_get_pcr_allocation()
584 chip->nr_allocated_banks = nr_alloc_banks; in tpm2_get_pcr_allocation()
605 rc = -EFAULT; in tpm2_get_cc_attrs_tbl()
609 chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands, in tpm2_get_cc_attrs_tbl()
611 if (!chip->cc_attrs_tbl) { in tpm2_get_cc_attrs_tbl()
612 rc = -ENOMEM; in tpm2_get_cc_attrs_tbl()
632 rc = -EFAULT; in tpm2_get_cc_attrs_tbl()
637 chip->nr_commands = nr_commands; in tpm2_get_cc_attrs_tbl()
641 chip->cc_attrs_tbl[i] = be32_to_cpup(attrs); in tpm2_get_cc_attrs_tbl()
642 cc = chip->cc_attrs_tbl[i] & 0xFFFF; in tpm2_get_cc_attrs_tbl()
645 chip->cc_attrs_tbl[i] &= in tpm2_get_cc_attrs_tbl()
647 chip->cc_attrs_tbl[i] |= 1 << TPM2_CC_ATTR_CHANDLES; in tpm2_get_cc_attrs_tbl()
655 rc = -ENODEV; in tpm2_get_cc_attrs_tbl()
661 * tpm2_startup - turn on the TPM
676 dev_info(&chip->dev, "starting up the TPM manually\n"); in tpm2_startup()
690 * tpm2_auto_startup - Perform the standard automatic TPM initialization
719 if (rc == TPM2_RC_FAILURE || (rc < 0 && rc != -ENOMEM)) { in tpm2_auto_startup()
720 dev_info(&chip->dev, in tpm2_auto_startup()
722 chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE; in tpm2_auto_startup()
736 if (rc == TPM2_RC_UPGRADE || rc == -ENODATA) { in tpm2_auto_startup()
737 dev_info(&chip->dev, "TPM in field upgrade mode, requires firmware upgrade\n"); in tpm2_auto_startup()
738 chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE; in tpm2_auto_startup()
743 rc = -ENODEV; in tpm2_auto_startup()
753 for (i = 0; i < chip->nr_commands; i++) in tpm2_find_cc()
754 if (cc == (chip->cc_attrs_tbl[i] & cc_mask)) in tpm2_find_cc()
757 return -1; in tpm2_find_cc()