From: Jarkko Sakkinen <jarkko@kernel.org>
To: Stefan Mahnke-Hartmann <stefan.mahnke-hartmann@infineon.com>
Cc: Marten.Lindahl@axis.com, jgg@ziepe.ca,
johannes.holland@infineon.com, jsnitsel@redhat.com,
linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
martenli@axis.com, nayna@linux.vnet.ibm.com, peterhuewe@gmx.de
Subject: Re: [PATCH 2/2] tpm: Add Field Upgrade mode support for Infineon TPM2 modules
Date: Wed, 11 May 2022 18:12:16 +0300 [thread overview]
Message-ID: <YnvSULFUC9gADu0z@kernel.org> (raw)
In-Reply-To: <20220509125018.246093-1-stefan.mahnke-hartmann@infineon.com>
On Mon, May 09, 2022 at 02:50:18PM +0200, Stefan Mahnke-Hartmann wrote:
> On 07.05.22 21:43, Jarkko Sakkinen wrote:
> > 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 <stefan.mahnke-hartmann@infineon.com>
> >> ---
> >> 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.
>
> Resetting the error code was to avoid code duplication, while following the
> same rationale as Mårten's patch. I can also add the -ENODATA to the if clause
> below or duplicate the code block (similar to Mårten's). Do you have a better
> suggestion?
I'd do that instead. It documents better the conditions.
BR, Jarkko
next prev parent reply other threads:[~2022-05-11 15:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-06 12:31 [PATCH 1/2] tpm: Fix buffer access in tpm2_get_tpm_pt() Stefan Mahnke-Hartmann
2022-05-06 12:31 ` [PATCH 2/2] tpm: Add Field Upgrade mode support for Infineon TPM2 modules Stefan Mahnke-Hartmann
2022-05-07 19:43 ` Jarkko Sakkinen
2022-05-09 12:50 ` Stefan Mahnke-Hartmann
2022-05-11 15:12 ` Jarkko Sakkinen [this message]
2022-05-07 19:43 ` [PATCH 1/2] tpm: Fix buffer access in tpm2_get_tpm_pt() Jarkko Sakkinen
2022-05-09 11:48 ` Stefan Mahnke-Hartmann
2022-05-11 15:11 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YnvSULFUC9gADu0z@kernel.org \
--to=jarkko@kernel.org \
--cc=Marten.Lindahl@axis.com \
--cc=jgg@ziepe.ca \
--cc=johannes.holland@infineon.com \
--cc=jsnitsel@redhat.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martenli@axis.com \
--cc=nayna@linux.vnet.ibm.com \
--cc=peterhuewe@gmx.de \
--cc=stefan.mahnke-hartmann@infineon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).