From: sashiko-bot@kernel.org
To: "Peter Fang" <peter.fang@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities
Date: Fri, 04 Dec 2026 18:44:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-250449@kernel.org> (raw)
In-Reply-To: <20261204182022.324230-3-peter.fang@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] x86/virt/tdx: tdx_quoting_enabled() omits
tdx_module_state.initialized check
- [Low] x86/virt/tdx: tdx_quoting_enabled() unpacks struct
tdx_sys_info_quote fields
--
commit e4978984b33087f0b69c4ea714b47633406601de
Author: Peter Fang <peter.fang@intel.com>
x86/virt/tdx: Add interface to check quoting capabilities
This commit adds tdx_quoting_enabled() and a global metadata helper to
expose the TDX module's quoting capabilities (maximum quote size, number
of sessions, and number of threads) to KVM.
[ ... ]
> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> index 39f280190b73d..c958fdac3c2a6 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c
[ ... ]
> @@ -2529,6 +2529,31 @@ void tdx_free_control_page(struct page *page)
> }
> EXPORT_SYMBOL_FOR_KVM(tdx_free_control_page);
>
> +/*
> + * Read the TDX module's quoting capabilities.
> + */
> +bool tdx_quoting_enabled(u32 *max_quote_size, u16 *num_sessions,
> + u16 *num_threads)
> +{
> + struct tdx_sys_info_quote sysinfo_quote;
> + int ret;
> +
> + /* All usable add-on features are enabled at TDX init. */
> + if (!(get_tdx_usable_addon_features0() & TDX_FEATURES0_QUOTE))
> + return false;
> +
> + ret = get_tdx_sys_info_quote(&sysinfo_quote);
> + if (ret)
> + return false;
[Severity: Medium]
Should tdx_quoting_enabled() check tdx_module_state.initialized before
reading tdx_sysinfo and issuing TDH.SYS.RD?
During a runtime TDX module update, tdx_module_shutdown() clears
tdx_module_state.initialized without clearing tdx_sysinfo. If
tdx_module_run_update() fails in reinit_tdx_module_extensions(),
tdx_module_state.initialized stays false while KVM stays active.
When TDH.SYS.RD still succeeds in that state, tdx_quoting_enabled() falsely
returns true even though the quoting extension is uninitialized. When
TDH.SYS.RD fails, read_sys_metadata_field() logs three unratelimited
pr_err() lines via seamcall_prerr_ret() on each call.
Checking !tdx_module_state.initialized at the start of tdx_quoting_enabled(),
matching tdx_get_sysinfo(), avoids both.
> + *max_quote_size = sysinfo_quote.max_quote_size;
> + *num_sessions = sysinfo_quote.num_sessions;
> + *num_threads = sysinfo_quote.num_threads;
> +
> + return true;
> +}
[Severity: Low]
Could tdx_quoting_enabled() take a struct tdx_sys_info_quote * directly
instead of three separate output pointers?
struct tdx_sys_info_quote is already exposed via asm/tdx_global_metadata.h
(included by asm/tdx.h) with these exact fields. Passing two adjacent u16 *
pointers (num_sessions and num_threads) makes argument-order swaps compile
without warning and forces callers to declare unused local variables.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204182022.324230-1-peter.fang@intel.com?part=2
next prev parent reply other threads:[~2026-12-04 18:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:18 [PATCH v3 0/8] Enable DICE-based TDX quoting Peter Fang
2026-12-04 18:18 ` [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote Peter Fang
2026-12-04 18:36 ` sashiko-bot
2026-12-04 19:15 ` Dave Hansen
2026-12-04 22:02 ` Edgecombe, Rick P
2026-12-04 21:44 ` Adrian Hunter
2026-12-04 22:04 ` Edgecombe, Rick P
2026-12-04 18:18 ` [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities Peter Fang
2026-12-04 18:44 ` sashiko-bot [this message]
2026-12-04 18:18 ` [PATCH v3 3/8] KVM: TDX: Require at least one quoting session and thread per CPU Peter Fang
2026-12-04 18:44 ` sashiko-bot
2026-12-04 18:18 ` [PATCH v3 4/8] KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting Peter Fang
2026-12-04 18:51 ` sashiko-bot
2026-12-04 18:18 ` [PATCH v3 5/8] KVM: TDX: Report maximum Quote size in TDX capabilities Peter Fang
2026-12-04 18:18 ` [PATCH v3 6/8] KVM: TDX: Document KVM_TDX_GET_QUOTE Peter Fang
2026-12-04 18:36 ` sashiko-bot
2026-12-04 18:18 ` [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension Peter Fang
2026-12-04 18:52 ` sashiko-bot
2026-12-04 18:18 ` [PATCH v3 8/8] x86/virt/tdx: Add documentation for DICE-based quoting Peter Fang
2026-12-04 18:40 ` [PATCH v3 0/8] Enable DICE-based TDX quoting Jason Gunthorpe
2026-12-04 18:47 ` Edgecombe, Rick P
2026-12-04 18:50 ` Jason Gunthorpe
2026-12-04 19:11 ` Edgecombe, Rick P
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=sashiko-outbox-250449@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=peter.fang@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox