Re: [PATCH v2 1/2] virt: tdx-guest: Fix timeout detection in wait_for_quote_completion()
From: Kuppuswamy Sathyanarayanan
Date: Fri Oct 23 2026 - 16:48:50 EST
Hi,
On 10/22/2026 9:31 AM, Moe Mahhouk via B4 Relay wrote:
> From: Moe Mahhouk <moe@xxxxxxxxxxxxx>
>
> wait_for_quote_completion() counts the seconds it has waited in i and
> reports a timeout when i == timeout. That gets both outcomes of the
> last second wrong:
>
> - If the request is still in flight after the last sleep, the loop
> condition increments i once more before it fails, so the loop ends
> with i == timeout + 1 and the function returns 0. The caller then
> returns -EIO instead of -ETIMEDOUT, without the "GetQuote request
> timedout" message. Before commit 0f409eaea53e ("virt: tdx-guest:
> Return error for GetQuote failures") a timed-out request even
> returned success with an empty Quote.
>
> - If the VMM completes the request during the last sleep, the loop ends
> on the status check with i == timeout, and the function returns
> -ETIMEDOUT for a completed request, discarding the Quote.
>
> Decide on the Quote buffer instead: the request timed out if it is
> still in flight when the wait ends.
>
> Fixes: f4738f56d1dc ("virt: tdx-guest: Add Quote generation support using TSM_REPORTS")
> Reported-by: Kiryl Shutsemau <kas@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/atoHWgQF-0vlTRK4@thinkstation/
> Signed-off-by: Moe Mahhouk <moe@xxxxxxxxxxxxx>
> ---
Since it can be back ported add Cc: stable@xxxxxxxxxxxxxxx
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
> drivers/virt/coco/tdx-guest/tdx-guest.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c
> index 11d741da3b35..a5a53174f9d9 100644
> --- a/drivers/virt/coco/tdx-guest/tdx-guest.c
> +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c
> @@ -282,7 +282,7 @@ static int wait_for_quote_completion(struct tdx_quote_buf *buf, u32 timeout)
> return -EINTR;
> }
>
> - return (i == timeout) ? -ETIMEDOUT : 0;
> + return (buf->status == GET_QUOTE_IN_FLIGHT) ? -ETIMEDOUT : 0;
> }
>
> static int tdx_report_new_locked(struct tsm_report *report)
>
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer