linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] tpm: Enable hwrng only for Pluton on AMD CPUs
@ 2023-08-22 23:15 Jarkko Sakkinen
  2023-08-23  8:23 ` Paul Menzel
                   ` (3 more replies)
  0 siblings, 4 replies; 23+ messages in thread
From: Jarkko Sakkinen @ 2023-08-22 23:15 UTC (permalink / raw)
  To: linux-integrity
  Cc: Jerry Snitselaar, Jarkko Sakkinen, stable, Todd Brandt,
	Peter Huewe, Jason Gunthorpe, Mario Limonciello, linux-kernel

The vendor check introduced by commit 554b841d4703 ("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.

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: 554b841d4703 ("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
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
v3:
* Forgot to amend config flags.
v2:
* CONFIG_X86
* Removed "Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>"
* Removed "Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>"
---
 drivers/char/tpm/tpm_crb.c | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index 65ff4d2fbe8d..ea085b14ab7c 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -463,28 +463,6 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 	return (cancel & CRB_CANCEL_INVOKE) == CRB_CANCEL_INVOKE;
 }
 
-static int crb_check_flags(struct tpm_chip *chip)
-{
-	u32 val;
-	int ret;
-
-	ret = crb_request_locality(chip, 0);
-	if (ret)
-		return ret;
-
-	ret = tpm2_get_tpm_pt(chip, TPM2_PT_MANUFACTURER, &val, NULL);
-	if (ret)
-		goto release;
-
-	if (val == 0x414D4400U /* AMD */)
-		chip->flags |= TPM_CHIP_FLAG_HWRNG_DISABLED;
-
-release:
-	crb_relinquish_locality(chip, 0);
-
-	return ret;
-}
-
 static const struct tpm_class_ops tpm_crb = {
 	.flags = TPM_OPS_AUTO_STARTUP,
 	.status = crb_status,
@@ -827,9 +805,14 @@ static int crb_acpi_add(struct acpi_device *device)
 	if (rc)
 		goto out;
 
-	rc = crb_check_flags(chip);
-	if (rc)
-		goto out;
+#ifdef CONFIG_X86
+	/* A quirk for https://www.amd.com/en/support/kb/faq/pa-410 */
+	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
+	    priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) {
+		dev_info(dev, "Disabling hwrng\n");
+		chip->flags |= TPM_CHIP_FLAG_HWRNG_DISABLED;
+	}
+#endif /* CONFIG_X86 */
 
 	rc = tpm_chip_register(chip);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2023-09-11 21:58 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-22 23:15 [PATCH v3] tpm: Enable hwrng only for Pluton on AMD CPUs Jarkko Sakkinen
2023-08-23  8:23 ` Paul Menzel
2023-08-23 17:40   ` Jarkko Sakkinen
2023-08-23 18:58     ` Mario Limonciello
2023-08-27 18:12       ` Jarkko Sakkinen
2023-08-28  0:35         ` Mario Limonciello
2023-08-29  8:38           ` Linux regression tracking (Thorsten Leemhuis)
2023-09-01  8:49             ` Thorsten Leemhuis
2023-09-04 22:32               ` Jarkko Sakkinen
2023-09-05 12:01                 ` Thorsten Leemhuis
2023-09-11 10:40                   ` Jarkko Sakkinen
2023-09-11 10:42                     ` Jarkko Sakkinen
2023-09-04 18:00           ` Jarkko Sakkinen
2023-09-04 18:18             ` Jarkko Sakkinen
2023-08-23 19:24     ` checkpatch complains about Reported-by block (was: [PATCH v3] tpm: Enable hwrng only for Pluton on AMD CPUs) Paul Menzel
2023-08-24  4:43       ` Joe Perches
2023-08-27 18:29         ` Jarkko Sakkinen
2023-08-27 18:26       ` Jarkko Sakkinen
2023-08-28  1:05 ` [PATCH v3] tpm: Enable hwrng only for Pluton on AMD CPUs Jerry Snitselaar
2023-08-29 19:03 ` Jerry Snitselaar
2023-08-30 18:25   ` Jerry Snitselaar
2023-09-04 20:51     ` Jarkko Sakkinen
2023-09-04 18:12 ` [PATCH v4] " Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).