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 F37F3C433F5 for ; Sat, 7 May 2022 19:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446878AbiEGTqC (ORCPT ); Sat, 7 May 2022 15:46:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235918AbiEGTqB (ORCPT ); Sat, 7 May 2022 15:46:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0402B275; Sat, 7 May 2022 12:42:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DA3DF60AF6; Sat, 7 May 2022 19:42:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C62C1C385A6; Sat, 7 May 2022 19:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651952533; bh=dYodBgcYGaNPGX2CTgOKuHFZPVy+BN1PA48Kg/9BtXI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=McPiCwj3keKXl+EaovmCcxp4VUQiZKgyBCXYTrEuT2i5EC+Z8fQB1ACaEjDcq604S IyRyFBTAHe56QDUUlKQxPQL+xh4wq7axS6AeiaJIPjsinmLWhW7savo/0Gwu7iP3sP yBvBP5bx2I9zTFbrWYVla9aWz1ZJkb+mOWn0yaJ7QGKppWDtpg3U25P7U0QPom1v2i IqKtepjkUS/zemNxOFc8xcPIaiRfm1A/CLTMTFgRAo0m+MfkcA7rpM8onJQE7HC3RF p8y0DxxyzfxKfnn3May0eFVATK+OU81zrYXifykPhkZ5xgd8KfPFW0OovBUe1NJjdg z6cCm0Wt1a+Bw== Date: Sat, 7 May 2022 22:43:48 +0300 From: Jarkko Sakkinen To: Stefan Mahnke-Hartmann Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Marten.Lindahl@axis.com, martenli@axis.com, jgg@ziepe.ca, jsnitsel@redhat.com, nayna@linux.vnet.ibm.com, johannes.holland@infineon.com, peterhuewe@gmx.de Subject: Re: [PATCH 2/2] tpm: Add Field Upgrade mode support for Infineon TPM2 modules Message-ID: References: <20220506123145.229058-1-stefan.mahnke-hartmann@infineon.com> <20220506123145.229058-2-stefan.mahnke-hartmann@infineon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220506123145.229058-2-stefan.mahnke-hartmann@infineon.com> Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org On Fri, May 06, 2022 at 02:31:48PM +0200, Stefan Mahnke-Hartmann wrote: > TPM2_GetCapability with a capability that has the property type value > of TPM_PT_TOTAL_COMMANDS returns a zero length list, when an Infineon > TPM2 is in Field Upgrade mode. > Since an Infineon TPM2.0 in Field Upgrade mode returns RC_SUCCESS on > TPM2_Startup, the Field Upgrade mode has to be detected by > TPM2_GetCapability. > > Signed-off-by: Stefan Mahnke-Hartmann > --- > drivers/char/tpm/tpm2-cmd.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c > index e62a644ce26b..659130e2936e 100644 > --- a/drivers/char/tpm/tpm2-cmd.c > +++ b/drivers/char/tpm/tpm2-cmd.c > @@ -746,6 +746,12 @@ int tpm2_auto_startup(struct tpm_chip *chip) > } > > rc = tpm2_get_cc_attrs_tbl(chip); > + /* > + * Infineon TPM in Field Upgrade mode will return no data for the number > + * of supported commands. > + */ > + if (rc == -ENODATA) > + rc = TPM2_RC_UPGRADE; Injecting hardware error codes like this is not considered a great idea. > > out: > if (rc == TPM2_RC_UPGRADE) { > -- > 2.25.1 > BR, Jarkko