Skip to content

Commit 6155a3b

Browse files
committed
Merge tag 'tpmdd-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd
Pull more tpm updates from Jarkko Sakkinen: "Two more bug fixes for tpm_crb, categorically disabling rng for AMD CPU's in the tpm_crb driver, discarding the earlier probing approach" * tag 'tpmdd-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd: tpm: Enable hwrng only for Pluton on AMD CPUs tpm_crb: Fix an error handling path in crb_acpi_add()
2 parents 61401a8 + 8f7f35e commit 6155a3b

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

drivers/char/tpm/tpm_crb.c

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -463,28 +463,6 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
463463
return (cancel & CRB_CANCEL_INVOKE) == CRB_CANCEL_INVOKE;
464464
}
465465

466-
static int crb_check_flags(struct tpm_chip *chip)
467-
{
468-
u32 val;
469-
int ret;
470-
471-
ret = crb_request_locality(chip, 0);
472-
if (ret)
473-
return ret;
474-
475-
ret = tpm2_get_tpm_pt(chip, TPM2_PT_MANUFACTURER, &val, NULL);
476-
if (ret)
477-
goto release;
478-
479-
if (val == 0x414D4400U /* AMD */)
480-
chip->flags |= TPM_CHIP_FLAG_HWRNG_DISABLED;
481-
482-
release:
483-
crb_relinquish_locality(chip, 0);
484-
485-
return ret;
486-
}
487-
488466
static const struct tpm_class_ops tpm_crb = {
489467
.flags = TPM_OPS_AUTO_STARTUP,
490468
.status = crb_status,
@@ -797,12 +775,13 @@ static int crb_acpi_add(struct acpi_device *device)
797775
FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n",
798776
buf->header.length,
799777
ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON);
800-
return -EINVAL;
778+
rc = -EINVAL;
779+
goto out;
801780
}
802781
crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf));
803782
rc = crb_map_pluton(dev, priv, buf, crb_pluton);
804783
if (rc)
805-
return rc;
784+
goto out;
806785
}
807786

808787
priv->sm = sm;
@@ -826,9 +805,14 @@ static int crb_acpi_add(struct acpi_device *device)
826805
if (rc)
827806
goto out;
828807

829-
rc = crb_check_flags(chip);
830-
if (rc)
831-
goto out;
808+
#ifdef CONFIG_X86
809+
/* A quirk for https://www.amd.com/en/support/kb/faq/pa-410 */
810+
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
811+
priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) {
812+
dev_info(dev, "Disabling hwrng\n");
813+
chip->flags |= TPM_CHIP_FLAG_HWRNG_DISABLED;
814+
}
815+
#endif /* CONFIG_X86 */
832816

833817
rc = tpm_chip_register(chip);
834818

0 commit comments

Comments
 (0)