From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410374; b=zN7V2JpRoLFzqkgCFK2WZpPZmcAGDXXvwTadNSQZKOlA3PjWs251kSPmmoAWBYQ9zjc8 jUBjvWDRoSnTOEqf4vH2dJPKgdTxTMGKhpqZ5gyyqMG8mVY4qTCdmrSOcGZ1PrGrVnMxA AMV36eVDPMIFdTx+0NAG6sPxurdtl3C2XXcH+mleqSJ+pI28bO0Px24ZsRfhfj3RF5vHX ERdjTSVvge0f5uVbr5cExPFVkoT5JwCWS+D4ASRG9Ik0zOHnG76GmK07ywbOexuJv/3Ek 7B5rQQxDGpJCzxkBecoZ263I7wfzjoQeuWtfkDwtF6Rx0EFxR/rhWpF7MxkzLIHZpkA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410374; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=t7Bk4wI3U/00ygxaD/usEgdz3i0B1/hap/KpVECNv1A=; b=gyiuf6/8F7K8mkCuiDb7Zo7ACrvVzKSXU7tDV3dt6/5JXhDEvo8fTobi3JnIen23/B+6 M/Tg9iPAgd+NQGogUGDZfpRd5S+ofVPiUf3xsoOnObpdcNtaDh1dVODzqz+DNU+tGaV4i dcIC7upO9SeDQP/XIEeP8ekTo4NawKVazIS96wf+zgFfB5fYWU1dd6ksUUlAGI6SGtulC HVz8ADAZjLFOV3x8ER56rTwmXgx97tZXyASZoCZDcC2VhfDW0nRKHKH0WXPtoWAQZPzuS uXgWvNg1oy0IpfuwF35ApYyLOOfWQKAUfCiedHmsce2dotDU3OjzaULDSbxZzxh8LYw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JYcUaBDW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC7AD606A336 for ; Fri, 4 Dec 2026 18:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JYcUaBDW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E4CF1F00A13; Fri, 4 Dec 2026 18:52:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796410374; bh=t7Bk4wI3U/00ygxaD/usEgdz3i0B1/hap/KpVECNv1A=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JYcUaBDWUF+67ZSnUcnDNMTQWAKXR/wBBepG0JeI0B8qGxIBdhIWB+dflHEPjKogx m9iT+Z0nOLJGe8rJn7b6Q6nHPoajDnoKg3eWOcJsnxKaF8ggl+SkF4WGci+vCzMyox FrzxfrRNOAd+YxMrKTnN3EFpHHX03X6sH9vsDPmeXmVJxx6D9XltGfhyKqRwjN4ogl M+3lhyR4ASlUz9YuSvQsS1b5xOz0Kmq0fFtcWVzaEVuxUfI5qbBPcRzpP+0Bj1jNF6 w+5BWps5zz/A/H+XXlmoT2lUiQe472DfctxdjfdCt0xU+pkkaoWKnwfUdaynYTskdX VkjDJffiOH0fw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension Reply-To: sashiko-reviews@lists.linux.dev To: "Peter Fang" Cc: kvm@vger.kernel.org In-Reply-To: <20261204182022.324230-8-peter.fang@intel.com> References: <20261204182022.324230-1-peter.fang@intel.com> <20261204182022.324230-8-peter.fang@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 18:52:53 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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) > =20 > /* List kernel-supported add-on features0 bits here */ > -#define TDX_KERNEL_SUPPORTED_ADDON_FEATURES0 (0) > +#define TDX_KERNEL_SUPPORTED_ADDON_FEATURES0 (TDX_FEATURES0_QUOTE) > =20 > 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 =3D 0; i < num_nodes; i++) { node_entry =3D node_head; node_head =3D __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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204182022.3242= 30-1-peter.fang@intel.com?part=3D7