[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8112fd6c-4be7-4d61-9d5e-372e2499cdea@gmail.com>
Date: Fri, 20 Jun 2025 18:23:23 +0100
From: "Orlov, Ivan" <ivan.orlov0322@...il.com>
To: Jonathan McDowell <noodles@...th.li>, "Orlov, Ivan" <iorlov@...zon.co.uk>
Cc: "peterhuewe@....de" <peterhuewe@....de>,
"jarkko@...nel.org" <jarkko@...nel.org>, "jgg@...pe.ca" <jgg@...pe.ca>,
"linux-integrity@...r.kernel.org" <linux-integrity@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Woodhouse, David" <dwmw@...zon.co.uk>
Subject: Re: [PATCH] tpm: Fix the timeout & use ktime
On 20/06/2025 14:24, Jonathan McDowell wrote:
> This looks similar to the issue I fixed in 7146dffa875c ('Fix timeout
> handling when waiting for TPM status'), I assume you're actually seeing
> it in your systems? I think we're starting to see it (rarely) now the
> other issues are fixed in our builds. As a similar approach does the
> following work?
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-
> interface.c
> index 8d7e4da6ed53..18ae0767fa60 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -127,7 +127,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip
> *chip, void *buf, size_t bufsiz)
> goto out_recv;
>
> stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
> - do {
> + while (true) {
> u8 status = tpm_chip_status(chip);
> if ((status & chip->ops->req_complete_mask) ==
> chip->ops->req_complete_val)
> @@ -138,9 +138,12 @@ static ssize_t tpm_try_transmit(struct tpm_chip
> *chip, void *buf, size_t bufsiz)
> return -ECANCELED;
> }
>
<-- This would solve the problem with usleep_range taking arbitrary
time, but unfortunately won't solve it for the guest VM scenario: if
vCPU gets interrupted here, then it still will account the steal time
and time out when it's woken up before checking for completion again
> + if (time_after(jiffies, stop))
> + break;
> +
> tpm_msleep(TPM_TIMEOUT_POLL);
> rmb();
> - } while (time_before(jiffies, stop));
> + }
>
> tpm_chip_cancel(chip);
> dev_err(&chip->dev, "Operation Timed out\n");
--
Kind regards,
Ivan Orlov
Powered by blists - more mailing lists