From: sashiko-bot@kernel.org
To: "Peter Fang" <peter.fang@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension
Date: Fri, 04 Dec 2026 18:52:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-250464@kernel.org> (raw)
In-Reply-To: <20261204182022.324230-8-peter.fang@intel.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] x86/virt/tdx: uninitialized HPA list node read in
tdx_quote_generate()
- [Medium] x86/virt/tdx: missing cond_resched() in tdx_quote_get() retry
loop
- [Medium] x86/virt/tdx: tdx_quoting_enabled() omits
tdx_module_state.initialized check
- [Medium] x86/virt/tdx: missing KeyID-0 cache flush in
tdx_ext_mem_setup()
--
commit c7e2931035267288fee2d4fbd9d3880b83fc43c8
Author: Peter Fang <peter.fang@intel.com>
x86/virt/tdx: Enable the quoting extension
This commit adds TDX_FEATURES0_QUOTE to
TDX_KERNEL_SUPPORTED_ADDON_FEATURES0 so the kernel requests the TDX
quoting extension during TDX module initialization when Dynamic PAMT is
not enabled.
Link: https://lore.kernel.org/all/DS4PPFA84FA90FC58F88D79B0EF19B34596E7832@DS4PPFA84FA90FC.namprd11.prod.outlook.com/ # [1]
> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> index c958fdac3c2a6..87d7305313536 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c
> @@ -1034,7 +1034,7 @@ static __init int construct_tdmrs(struct list_head *tmb_list,
> #define TDX_SYS_CONFIG_DYNAMIC_PAMT BIT(16)
>
> /* List kernel-supported add-on features0 bits here */
> -#define TDX_KERNEL_SUPPORTED_ADDON_FEATURES0 (0)
> +#define TDX_KERNEL_SUPPORTED_ADDON_FEATURES0 (TDX_FEATURES0_QUOTE)
>
> static u64 get_tdx_usable_addon_features0(void)
> {
[Severity: Medium]
Now that enabling TDX_FEATURES0_QUOTE makes tdx_quote_generate() reachable,
does its cleanup loop read uninitialized slab memory from node_head[]?
Both node_head and each chained new_node are allocated with
kmalloc(PAGE_SIZE, GFP_KERNEL), so node_entry[HPAS_PER_NODE - 1] is never
written on the final node (or when a chained allocation fails). At
out_free_nodes, the loop still reads it on the last iteration:
arch/x86/virt/vmx/tdx/tdx.c:tdx_quote_generate() {
...
for (int i = 0; i < num_nodes; i++) {
node_entry = node_head;
node_head = __va(node_head[HPAS_PER_NODE - 1]);
kfree(node_entry);
}
}
Every KVM_TDX_GET_QUOTE call hits this uninitialized read (triggering
KMSAN) and passes uninitialized trailing entries in the final HPA list
page to TDH_QUOTE_GET. Allocating the nodes with kzalloc() and only
reading the next pointer when i + 1 < num_nodes would avoid both.
Similarly, tdx_td_get_quote() in arch/x86/kvm/vmx/tdx.c allocates the 4KB
report page with kmalloc(), leaving bytes beyond gq.report_size
uninitialized when passed to TDH_QUOTE_GET.
[Severity: Medium]
Can tdx_quote_get() monopolize the CPU on non-preemptible kernels by
retrying TDH_QUOTE_GET without calling cond_resched()?
Once quoting is enabled, KVM_TDX_GET_QUOTE reaches tdx_quote_get(), which
loops while seamcall_ret(TDH_QUOTE_GET, &args) returns
TDX_INTERRUPTED_RESUMABLE. On CONFIG_PREEMPT_NONE or
CONFIG_PREEMPT_VOLUNTARY, preempt_enable() in sc_retry() will not schedule.
Because quote generation is long-running, this can starve co-scheduled
tasks and risk RCU stalls or soft-lockup warnings. Adding cond_resched()
in the retry loop, as init_tdmr() does in the same file, would allow the
scheduler to run between iterations.
[Severity: Medium]
Should tdx_quoting_enabled() check tdx_module_state.initialized before
querying quoting metadata?
During a runtime TDX module update, tdx_module_shutdown() clears
tdx_module_state.initialized, and tdx_module_run_update() only sets it
again after reinit_tdx_module_extensions() succeeds. If the update fails,
KVM stays loaded while the module or its extensions are uninitialized.
Unlike tdx_get_sysinfo(), tdx_quoting_enabled() only checks cached
boot-time features and calls get_tdx_sys_info_quote() (TDH_SYS_RD). Later
KVM_TDX_CAPABILITIES or KVM_TDX_GET_QUOTE ioctls can falsely report
quoting as available or emit unratelimited pr_err() logs on every call.
[Severity: Medium]
Does tdx_ext_mem_setup() need to flush dirty KeyID-0 cachelines before
passing newly allocated extension pages to TDH_EXT_MEM_ADD?
Enabling TDX_FEATURES0_QUOTE makes ext.required_pages non-zero, activating
tdx_ext_mem_setup() after config_global_keyid()'s wbinvd_on_all_cpus().
It allocates fresh pages with alloc_contig_pages() and passes them to
tdx_ext_mem_add() without clflush_cache_range() or wbinvd_on_all_cpus().
Both config_global_keyid() and tdx_clflush_page() flush KeyID-0 cachelines
because hardware does not guarantee coherency across KeyIDs. Unless
TDH_EXT_MEM_ADD flushes them internally, later writeback of dirty KeyID-0
cachelines could corrupt encrypted extension memory or trigger #MC.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204182022.324230-1-peter.fang@intel.com?part=7
next prev parent reply other threads:[~2026-12-04 18:52 UTC|newest]
Thread overview: 25+ 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
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 [this message]
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
2026-12-04 23:51 ` Jason Gunthorpe
2026-12-05 1:50 ` 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-250464@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 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.