The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	surenkj@amazon.com, noodles@meta.com, kernel-team@meta.com
Subject: Re: [PATCH v2 2/2] tpm: Disable TPM on TPM_RC_INITIALIZE
Date: Thu, 12 Nov 2026 15:37:29 +0200	[thread overview]
Message-ID: <avXBGZegq9ptFz8H@kernel.org> (raw)
In-Reply-To: <20261112-tpm_unresponsive-v2-2-7454d2c899ef@debian.org>

On Thu, Nov 12, 2026 at 04:30:18AM -0800, Breno Leitao wrote:
> From: Jarkko Sakkinen <jarkko@kernel.org>
> 
> If the TPM has been spuriously disabled, the game is over. Let's reflect
> this truth with TPM_CHIP_FLAG_DISABLE.
> 
> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> [leitao@debian.org: check rc before the loop breaks out on anything but
>  RETRY/TESTING, skip TPM2_Startup, which a TPM that is already started
>  fails with TPM2_RC_INITIALIZE, and fix the TPM2_RC_INITIALIZE and
>  chip->flags typos]
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>  drivers/char/tpm/tpm-interface.c | 5 +++++
>  drivers/char/tpm/tpm2-cmd.c      | 2 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index b7865ccb799289..144e2dbae66853 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -252,6 +252,11 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz)
>  		if (ret < 0)
>  			break;
>  		rc = be32_to_cpu(header->return_code);
> +		/* A TPM that is already started fails TPM2_Startup this way. */
> +		if (rc == TPM2_RC_INITIALIZE && cc != TPM2_CC_STARTUP) {

Good catch! Thanks.

> +			chip->flags |= TPM_CHIP_FLAG_DISABLE;
> +			break;
> +		}
>  		if (rc != TPM2_RC_RETRY && rc != TPM2_RC_TESTING)
>  			break;
>  		/*
> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> index 4b2bb2ddc321a9..65928ae85b496c 100644
> --- a/drivers/char/tpm/tpm2-cmd.c
> +++ b/drivers/char/tpm/tpm2-cmd.c
> @@ -724,6 +724,8 @@ int tpm2_auto_startup(struct tpm_chip *chip)
>  		goto out;
>  
>  	if (rc == TPM2_RC_INITIALIZE) {
> +		chip->flags &= ~TPM_CHIP_FLAG_DISABLE;
> +
>  		rc = tpm2_startup(chip);
>  		if (rc)
>  			goto out;
> 
> -- 
> 2.53.0-Meta
> 

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

Br, Jarkko

      reply	other threads:[~2026-11-12 13:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 12:30 [PATCH v2 0/2] tpm: Stop retrying TPMs that have stopped working Breno Leitao
2026-11-12 12:30 ` [PATCH v2 1/2] tpm: Disable a TPM that stops responding Breno Leitao
2026-11-12 14:00   ` Jarkko Sakkinen
2026-11-12 14:03     ` Jarkko Sakkinen
2026-11-12 15:45       ` Breno Leitao
2026-11-12 12:30 ` [PATCH v2 2/2] tpm: Disable TPM on TPM_RC_INITIALIZE Breno Leitao
2026-11-12 13:37   ` Jarkko Sakkinen [this message]

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=avXBGZegq9ptFz8H@kernel.org \
    --to=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kernel-team@meta.com \
    --cc=leitao@debian.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noodles@meta.com \
    --cc=peterhuewe@gmx.de \
    --cc=surenkj@amazon.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