From: sashiko-bot@kernel.org
To: "Jun Miao" <jun.miao@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3] virt: tdx-guest: Use read_poll_timeout() to shorten get-quote polling interval
Date: Thu, 17 Sep 2026 10:32:28 +0000 [thread overview]
Message-ID: <20260917103229.40A421F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260917102202.750895-1-jun.miao@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] virt: tdx-guest: successful quote dropped on pending signal
--
commit 1145f13c13d7adf73665778fb8d08dcfab69ccfc
Author: Jun Miao <jun.miao@intel.com>
virt: tdx-guest: Use read_poll_timeout() to shorten get-quote polling interval
This commit reduces the get-quote polling interval from 1 second to 2
milliseconds to improve performance and throughput. It introduces
read_poll_timeout() to handle the polling and timeout logic. The maximum wait
time is also reduced from 30 seconds to 1 second.
> diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c
> index d0303e31e8161..bac7cb9403f94 100644
> --- a/drivers/virt/coco/tdx-guest/tdx-guest.c
> +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c
[ ... ]
> @@ -251,18 +252,29 @@ static void *alloc_quote_buf(void)
> */
> static int wait_for_quote_completion(struct tdx_quote_buf *quote_buf, u32 timeout)
> {
> - int i = 0;
> + u64 status;
> + int ret;
>
> /*
> - * Quote requests usually take a few seconds to complete, so waking up
> - * once per second to recheck the status is fine for this use case.
> + * Quote requests usually take a few milliseconds to complete, so waking
> + * up once per 2 milliseconds to recheck the status is fine for this use
> + * case.
> + *
> + * Also break out early if a signal is pending so the caller can be
> + * interrupted while waiting.
> */
> - while (quote_buf->status == GET_QUOTE_IN_FLIGHT && i++ < timeout) {
> - if (msleep_interruptible(MSEC_PER_SEC))
> - return -EINTR;
> - }
> + ret = read_poll_timeout(READ_ONCE, status,
> + status != GET_QUOTE_IN_FLIGHT ||
> + signal_pending(current),
> + 2 * USEC_PER_MSEC, timeout * USEC_PER_SEC,
> + false, quote_buf->status);
> + if (ret)
> + return ret;
> +
> + if (signal_pending(current))
> + return -EINTR;
[Severity: Medium]
Does this code inadvertently discard a successful quote if a signal happens to
be pending at the exact same time the quote completes?
When read_poll_timeout() evaluates its break condition:
status != GET_QUOTE_IN_FLIGHT || signal_pending(current)
It will terminate and return 0 if the quote completes successfully, such as
when status is GET_QUOTE_SUCCESS.
However, if a signal is also concurrently pending, the unconditional check
after the loop will return -EINTR instead.
This causes the caller tdx_report_new_locked() to propagate -EINTR, dropping
the successful quote and potentially causing user-space to retry and overwrite
it.
Could we verify that the quote is actually still in-flight before returning
-EINTR? For example, by checking:
if (quote_buf->status == GET_QUOTE_IN_FLIGHT && signal_pending(current))
> - return (i == timeout) ? -ETIMEDOUT : 0;
> + return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917102202.750895-1-jun.miao@intel.com?part=1
prev parent reply other threads:[~2026-09-17 10:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 10:22 [PATCH v3] virt: tdx-guest: Use read_poll_timeout() to shorten get-quote polling interval Jun Miao
2026-09-17 10:32 ` sashiko-bot [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=20260917103229.40A421F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jun.miao@intel.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.