Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Stefan Mahnke-Hartmann <stefan.mahnke-hartmann@infineon.com>
Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	peterhuewe@gmx.de, jgg@ziepe.ca
Subject: Re: [PATCH v3] tpm: Add upgrade/reduced mode support for TPM1.2 modules
Date: Tue, 7 Jun 2022 12:49:08 +0300	[thread overview]
Message-ID: <Yp8fFNMzBLAXdNig@iki.fi> (raw)
In-Reply-To: <20220603084156.7090-1-stefan.mahnke-hartmann@infineon.com>

On Fri, Jun 03, 2022 at 10:41:58AM +0200, Stefan Mahnke-Hartmann wrote:
> In case a TPM in failure mode is detected, the TPM should be accessible
> through a transparent communication channel for analysing purposes (e.g.
> TPM_GetTestResult) or a field upgrade. Since a TPM in failure mode has
> similar reduced functionality as in field upgrade mode, the flag
> TPM_CHIP_FLAG_FIRMWARE_UPGRADE is also valid.
> 
> As described in TCG TPM Main Part1 Design Principles, Revision 116,
> chapter 9.2.1. the TPM also allows an update function in case a TPM is
> in failure mode.
> 
> If the TPM in failure mode is detected, the function tpm1_auto_startup()
> sets TPM_CHIP_FLAG_FIRMWARE_UPGRADE flag, which is used later during
> driver initialization/deinitialization to disable functionality which
> makes no sense or will fail in the current TPM state. The following
> functionality is affected:
>  * Do not register TPM as a hwrng
>  * Do not get pcr allocation
>  * Do not register sysfs entries which provide information impossible to
>    obtain in limited mode
> 
> Signed-off-by: Stefan Mahnke-Hartmann <stefan.mahnke-hartmann@infineon.com>
> ---
> Changelog:
>  * v3:
>    * Change kernel messages
> 
>  drivers/char/tpm/tpm.h      | 1 +
>  drivers/char/tpm/tpm1-cmd.c | 7 ++++++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index 2163c6ee0d36..24ee4e1cc452 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -55,6 +55,7 @@ enum tpm_addr {
>  #define TPM_WARN_DOING_SELFTEST 0x802
>  #define TPM_ERR_DEACTIVATED     0x6
>  #define TPM_ERR_DISABLED        0x7
> +#define TPM_ERR_FAILEDSELFTEST  0x1C
>  #define TPM_ERR_INVALID_POSTINIT 38
>  
>  #define TPM_TAG_RQU_COMMAND 193
> diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c
> index f7dc986fa4a0..cf64c7385105 100644
> --- a/drivers/char/tpm/tpm1-cmd.c
> +++ b/drivers/char/tpm/tpm1-cmd.c
> @@ -709,7 +709,12 @@ int tpm1_auto_startup(struct tpm_chip *chip)
>  	if (rc)
>  		goto out;
>  	rc = tpm1_do_selftest(chip);
> -	if (rc) {
> +	if (rc == TPM_ERR_FAILEDSELFTEST) {
> +		dev_warn(&chip->dev, "TPM self test failed, switching to the firmware upgrade mode\n");
> +		/* A TPM in this state possibly allows or needs a firmware upgrade */
> +		chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE;
> +		return 0;
> +	} else if (rc) {
>  		dev_err(&chip->dev, "TPM self test failed\n");
>  		goto out;
>  	}
> -- 
> 2.25.1
> 

I think this looks good now, thanks for patience:

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

  reply	other threads:[~2022-06-07  9:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03  8:41 [PATCH v3] tpm: Add upgrade/reduced mode support for TPM1.2 modules Stefan Mahnke-Hartmann
2022-06-07  9:49 ` Jarkko Sakkinen [this message]
2022-06-07  9:52   ` 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=Yp8fFNMzBLAXdNig@iki.fi \
    --to=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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