All of lore.kernel.org
 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 0/2] tpm: Stop retrying TPMs that have stopped working
Date: Thu, 12 Nov 2026 03:57:25 +0200	[thread overview]
Message-ID: <avUdBbvxxFgXkUJI@kernel.org> (raw)
In-Reply-To: <avTwXhEGwVj71VmH@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 788 bytes --]

On Thu, Nov 12, 2026 at 12:46:57AM +0200, Jarkko Sakkinen wrote:
> On Thu, Nov 12, 2026 at 12:43:59AM +0200, Jarkko Sakkinen wrote:
> > $ tpm2sh return-code 256
> > TPM_RC_INITIALIZE
> > 
> > I.e. TPM has not been properly initialized by TPM2_Startup().
> > 
> > I.e. TPM is also saying that it is *disabled*.
> > 
> > So acting on this proven fact  makes most sense to me.
> 
> 
> Actually, should we even disable TPM if it returns this error code
> already at the level of tpm_transmit(). It is a guaranteed dead-end
> to any possible TPM operation.
> 
> I.e. while this fixes hwrng issue I think it might be addressing the
> issue at a wrong level.

I leave room for figuring out 1/2 but for the second issue I would just
do what the attached patch does and call it a day.

Br, Jarkko

[-- Attachment #2: 0001-tpm-Disable-TPM-on-TPM_RC_INITIALIZE.patch --]
[-- Type: text/x-diff, Size: 1466 bytes --]

From 093124e51a26de8191e21ce41988532ea7e0bc8a Mon Sep 17 00:00:00 2001
From: Jarkko Sakkinen <jarkko@kernel.org>
Date: Thu, 12 Nov 2026 03:55:00 +0200
Subject: [PATCH] tpm: Disable TPM on TPM_RC_INITIALIZE

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>
---
 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 470b2da3234e..1f1e22341155 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -256,6 +256,11 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz)
 		if (rc == TPM2_RC_TESTING && cc == TPM2_CC_SELF_TEST)
 			break;
 
+		if (rc == TPM_RC_INITIALIZE) {
+			chip->flag |= TPM_CHIP_FLAG_DISABLE;
+			break;
+		}
+
 		if (delay_msec > TPM2_DURATION_LONG) {
 			if (rc == TPM2_RC_RETRY)
 				dev_err(&chip->dev, "in retry loop\n");
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 7fe00b4f8e7d..8d76e78cd92e 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -1021,6 +1021,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.47.3


  reply	other threads:[~2026-11-12  1:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  9:57 [PATCH 0/2] tpm: Stop retrying TPMs that have stopped working Breno Leitao
2026-11-11  9:57 ` [PATCH 1/2] tpm: Disable a TPM that stops responding Breno Leitao
2026-11-11 22:14   ` Jarkko Sakkinen
2026-11-11  9:57 ` [PATCH 2/2] tpm: Disable a TPM whose hwrng reads keep failing Breno Leitao
2026-11-11 22:16   ` Jarkko Sakkinen
2026-11-11 22:20     ` Jarkko Sakkinen
2026-11-11 22:30 ` [PATCH 0/2] tpm: Stop retrying TPMs that have stopped working Jarkko Sakkinen
2026-11-11 22:43   ` Jarkko Sakkinen
2026-11-11 22:46     ` Jarkko Sakkinen
2026-11-12  1:57       ` Jarkko Sakkinen [this message]
2026-11-12  2:01         ` Jarkko Sakkinen
2026-11-12 12:20           ` Breno Leitao

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=avUdBbvxxFgXkUJI@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.