2022-05-14 01:05:02

by Stefan Mahnke-Hartmann

[permalink] [raw]
Subject: [PATCH v2 2/2] tpm: Add field upgrade mode support for Infineon TPM2 modules

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 <[email protected]>
---
Changelog:
* v2:
* Move check of -ENODATA to if condition below.
* Change 'field upgrade mode' to lower case.

drivers/char/tpm/tpm2-cmd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 04a3e23a4afc..c1eb5d223839 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -754,7 +754,11 @@ int tpm2_auto_startup(struct tpm_chip *chip)
rc = tpm2_get_cc_attrs_tbl(chip);

out:
- if (rc == TPM2_RC_UPGRADE) {
+ /*
+ * Infineon TPM in field upgrade mode will return no data for the number
+ * of supported commands.
+ */
+ if (rc == TPM2_RC_UPGRADE || rc == -ENODATA) {
dev_info(&chip->dev, "TPM in field upgrade mode, requires firmware upgrade\n");
chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE;
rc = 0;
--
2.25.1



2022-05-17 02:22:19

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] tpm: Add field upgrade mode support for Infineon TPM2 modules

On Fri, May 13, 2022 at 03:41:53PM +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 <[email protected]>
> ---
> Changelog:
> * v2:
> * Move check of -ENODATA to if condition below.
> * Change 'field upgrade mode' to lower case.
>
> drivers/char/tpm/tpm2-cmd.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> index 04a3e23a4afc..c1eb5d223839 100644
> --- a/drivers/char/tpm/tpm2-cmd.c
> +++ b/drivers/char/tpm/tpm2-cmd.c
> @@ -754,7 +754,11 @@ int tpm2_auto_startup(struct tpm_chip *chip)
> rc = tpm2_get_cc_attrs_tbl(chip);
>
> out:
> - if (rc == TPM2_RC_UPGRADE) {
> + /*
> + * Infineon TPM in field upgrade mode will return no data for the number
> + * of supported commands.
> + */
> + if (rc == TPM2_RC_UPGRADE || rc == -ENODATA) {
> dev_info(&chip->dev, "TPM in field upgrade mode, requires firmware upgrade\n");
> chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE;
> rc = 0;
> --
> 2.25.1
>

Looks good to me.

Reviewed-by: Jarkko Sakkinen <[email protected]>

BR, Jarkko