Skip to content

Commit 8f7f35e

Browse files
committed
tpm: Enable hwrng only for Pluton on AMD CPUs
The vendor check introduced by commit 554b841 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe on Lenovo Legion Y540 laptop. Since only Microsoft Pluton is the only known combination of AMD CPU and fTPM from other vendor, disable hwrng otherwise. In order to make sysadmin aware of this, print also info message to the klog. Cc: stable@vger.kernel.org Fixes: 554b841 ("tpm: Disable RNG for all AMD fTPMs") Reported-by: Todd Brandt <todd.e.brandt@intel.com> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217804 Reported-by: Patrick Steinhardt <ps@pks.im> Reported-by: Raymond Jay Golo <rjgolo@gmail.com> Reported-by: Ronan Pigott <ronan@rjp.ie> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
1 parent 9c37785 commit 8f7f35e

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

drivers/char/tpm/tpm_crb.c

Lines changed: 8 additions & 25 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,
@@ -827,9 +805,14 @@ static int crb_acpi_add(struct acpi_device *device)
827805
if (rc)
828806
goto out;
829807

830-
rc = crb_check_flags(chip);
831-
if (rc)
832-
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 */
833816

834817
rc = tpm_chip_register(chip);
835818

0 commit comments

Comments
 (0)