From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65C48EE49AE for ; Wed, 23 Aug 2023 08:37:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234185AbjHWIhC (ORCPT ); Wed, 23 Aug 2023 04:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234887AbjHWIdy (ORCPT ); Wed, 23 Aug 2023 04:33:54 -0400 Received: from mx3.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F36B10DA; Wed, 23 Aug 2023 01:24:12 -0700 (PDT) Received: from [192.168.0.185] (ip5f5ae831.dynamic.kabel-deutschland.de [95.90.232.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 0A28361E5FE01; Wed, 23 Aug 2023 10:23:14 +0200 (CEST) Message-ID: <705b9769-4132-450b-bd47-2423c419db2a@molgen.mpg.de> Date: Wed, 23 Aug 2023 10:23:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] tpm: Enable hwrng only for Pluton on AMD CPUs Content-Language: en-US To: Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, Jerry Snitselaar , stable@vger.kernel.org, Todd Brandt , Peter Huewe , Jason Gunthorpe , Mario Limonciello , linux-kernel@vger.kernel.org, Patrick Steinhardt , Ronan Pigott , Raymond Jay Golo References: <20230822231510.2263255-1-jarkko@kernel.org> From: Paul Menzel In-Reply-To: <20230822231510.2263255-1-jarkko@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Jarkko, Thank you for your patch. Am 23.08.23 um 01:15 schrieb Jarkko Sakkinen: > 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 > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217804 > Signed-off-by: Jarkko Sakkinen Mario’s patch also had the three reporters below listed: Reported-by: Patrick Steinhardt Reported-by: Ronan Pigott Reported-by: Raymond Jay Golo > --- > v3: > * Forgot to amend config flags. > v2: > * CONFIG_X86 > * Removed "Reviewed-by: Jarkko Sakkinen " > * Removed "Signed-off-by: Mario Limonciello " > --- > 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"); A more elaborate log message would be helpful for the user. Maybe: Disabling hwrng in AMD's fTPM to avoid stutter (AMD article PA 410) > + chip->flags |= TPM_CHIP_FLAG_HWRNG_DISABLED; > + } > +#endif /* CONFIG_X86 */ > > rc = tpm_chip_register(chip); > Kind regards, Paul