From: Jarkko Sakkinen <jarkko@kernel.org>
To: Jonathan McDowell <noodles@earth.li>
Cc: "Michal Suchánek" <msuchanek@suse.de>, linux-integrity@vger.kernel.org
Subject: Re: TPM operation times out (very rarely)
Date: Thu, 6 Feb 2025 22:35:32 +0200 [thread overview]
Message-ID: <Z6UdFCdqCNZ8VGOL@kernel.org> (raw)
In-Reply-To: <Z6N10NQY75hpX0Ed@earth.li>
On Wed, Feb 05, 2025 at 02:29:36PM +0000, Jonathan McDowell wrote:
> Interesting. TPM2_CC_CONTEXT_LOAD (353) / TPM2_CC_FLUSH_CONTEXT (357) /
> TPM2_CC_CONTEXT_SAVE (354) I kinda expect to maybe take a bit longer,
> but TPM2_CC_GET_RANDOM (379) is a little surprising.
The whole arithmetic with timeout_a/b/c is mostly gibberish and could
be replaced with a single "max" constant without issues (just set it
large enough).
They could be all be replaced with let's say 3s timeout in a constant.
> > Failure is observed with another chip type as well:
> >
> > localhost kernel: tpm_tis MSFT0101:00: 2.0 TPM (device-id 0x1B, rev-id
> > 22)
> >
> > TPM Device
> > Vendor ID: IFX
> > Specification Version: 2.0
> > Firmware Revision: 7.83
> > Description: TPM 2.0, ManufacturerID: IFX , Firmware Version: 7.83.3358.0
> > Characteristics:
> > Family configurable via firmware update
> > Family configurable via OEM proprietary mechanism
> > OEM-specific Information: 0x00000000
>
> That looks like an SLB9670, not running the latest firmware (7.85). I
> think that might have the errata I've been trying to work around; my
> current patch in testing (with logging to see how effective it is):
>
> commit d8c680ec34e7f42f731e7d64605a670fb7b3b4d1
> Author: Jonathan McDowell <noodles@meta.com>
> Date: Mon Aug 19 09:22:46 2024 -0700
>
> tpm: Workaround failed command reception on Infineon devices
>
> Some Infineon devices have a issue where the status register will get
> stuck with a quick REQUEST_USE / COMMAND_READY sequence. The work around
> is to retry the command submission. Add appropriate logic to do this in
> the send path.
>
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index fdef214b9f6b..561d6801e299 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -464,7 +464,12 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
>
> if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
> &priv->int_queue, false) < 0) {
> - rc = -ETIME;
> + if (test_bit(TPM_TIS_STATUS_WORKAROUND, &priv->flags)) {
> + dev_err(&chip->dev, "Timed out waiting for status valid in send, retrying\n");
> + rc = -EAGAIN;
I'm not sure why wait_for_tpm_stat() return value is ignored but it
should not be like that. E.g. it can return -ERESTARTSYS. Probably
would be better to check all the call sites for it that they do
same thing.
I.e. rc = wait_for_tpm_stat(...);
/* ... */
BR, Jarkko
next prev parent reply other threads:[~2025-02-06 20:35 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-29 15:27 TPM operation times out (very rarely) Michal Suchánek
2025-01-29 16:02 ` Jonathan McDowell
2025-01-29 16:20 ` Michal Suchánek
2025-01-29 17:14 ` Jonathan McDowell
2025-01-29 17:25 ` Michal Suchánek
2025-01-30 23:31 ` Jarkko Sakkinen
2025-01-31 8:35 ` Michal Suchánek
2025-01-31 10:25 ` Jarkko Sakkinen
2025-01-31 13:02 ` Michal Suchánek
2025-01-31 17:12 ` Jarkko Sakkinen
2025-01-31 17:28 ` Michal Suchánek
2025-01-31 19:31 ` Jarkko Sakkinen
2025-02-05 13:26 ` Michal Suchánek
2025-02-05 13:45 ` Michal Suchánek
2025-02-05 14:29 ` Jonathan McDowell
2025-02-05 15:29 ` Michal Suchánek
2025-02-06 20:35 ` Jarkko Sakkinen [this message]
2025-02-07 9:26 ` Jonathan McDowell
2025-02-07 9:40 ` Michal Suchánek
2025-02-07 9:47 ` Jonathan McDowell
2025-02-07 9:58 ` Michal Suchánek
2025-02-10 16:13 ` Jonathan McDowell
2025-02-10 17:30 ` Jarkko Sakkinen
2025-02-08 20:29 ` Jarkko Sakkinen
2025-02-10 16:18 ` Jonathan McDowell
2025-02-10 17:32 ` Jarkko Sakkinen
2025-02-24 13:04 ` Michal Suchánek
2025-03-01 2:13 ` Jarkko Sakkinen
2025-03-05 12:20 ` Michal Suchánek
2025-03-06 22:29 ` Jarkko Sakkinen
2025-03-27 12:57 ` Michal Suchánek
2025-03-27 13:15 ` Jarkko Sakkinen
2025-02-19 22:29 ` Jonathan McDowell
2025-02-20 8:42 ` Michal Suchánek
2025-02-21 12:44 ` Jonathan McDowell
2025-02-24 12:21 ` Michal Suchánek
2025-02-24 12:56 ` Michal Suchánek
2025-03-01 2:03 ` 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=Z6UdFCdqCNZ8VGOL@kernel.org \
--to=jarkko@kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=msuchanek@suse.de \
--cc=noodles@earth.li \
/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).