From: sashiko-bot@kernel.org
To: "Jun Miao" <jun.miao@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v2] virt: tdx-guest: Use read_poll_timeout() to shorten get-quote polling interval
Date: Thu, 17 Sep 2026 09:06:15 +0000 [thread overview]
Message-ID: <20260917090615.A498A1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260917085533.750434-1-jun.miao@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] virt: tdx-guest: wait_for_quote_completion() discards successful quote on pending signal
--
commit c4b6f45a215285a9c5c32f569a08072ce93e37a2
Author: Jun Miao <jun.miao@intel.com>
virt: tdx-guest: Use read_poll_timeout() to shorten get-quote polling interval
This commit replaces the manual msleep_interruptible() loop with
read_poll_timeout() to wait for TDX quote completion. It reduces the check
interval from 1s to 5ms and overall timeout from 30s to 2s to improve
performance.
> diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c
> index d0303e31e8161..a73d1f0335bee 100644
> --- a/drivers/virt/coco/tdx-guest/tdx-guest.c
> +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c
[ ... ]
> @@ -251,18 +252,31 @@ 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 5 milliseconds to recheck the status is fine for this use
> + * case. Fixed-interval polling doesn't scale well since QE response
> + * times vary by implementation; an interrupt-based approach would be
> + * the proper long-term solution.
> + *
> + * 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),
> + 5 * USEC_PER_MSEC, timeout * USEC_PER_SEC,
> + false, quote_buf->status);
> + if (ret)
> + return ret;
> +
> + if (signal_pending(current))
> + return -EINTR;
[Severity: Medium]
Will this discard a successfully completed quote if a signal happens to be
pending?
If read_poll_timeout() completes successfully because the break condition
status != GET_QUOTE_IN_FLIGHT is met, it returns 0.
However, the subsequent unconditional check for signal_pending(current) will
evaluate to true if a signal was received, causing the function to return
-EINTR instead of success.
Since the caller logs any non-zero return value from this function as a
timeout, does this force userspace to needlessly retry an expensive
hypercall while incorrectly logging a timeout error?
>
> - return (i == timeout) ? -ETIMEDOUT : 0;
> + return 0;
> }
>
> static int tdx_report_new_locked(struct tsm_report *report, void *data)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917085533.750434-1-jun.miao@intel.com?part=1
prev parent reply other threads:[~2026-09-17 9:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 8:55 [PATCH v2] virt: tdx-guest: Use read_poll_timeout() to shorten get-quote polling interval Jun Miao
2026-09-17 9:06 ` 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=20260917090615.A498A1F00893@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.