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=1796409841; b=De3ypKpQovGEs5sR6BavrLK0ehKs71dnQ5RhMTQ6Qbk5wDR5g7v3oyNox/H9rG9Gl7GC xjzGBn7T5ctdbARyj23CyKi6Pu7Tvcz8LbNkXeV9SFJ+AW7OgFDxjrMM2AcHFVUxws0Cn 1ua3pZlpJwwd+4T/2bytyTqB8PpNQ5pkwYIGHX9UtoFgpzQeII55Vb2BkSpcQFa/9MBMn BYlZVN8B+vQ/Z/wnXfbmQiTFPfn9fdbAmComeOhpMW8y+OQKO/RB+Am/LCQ5R6NB05bTo C8mBFUvhOr/2O6xSu1VsbCmKTWki2DMT7O3whPUcM4eVk//tM/wyGcpMBvpMiNIvi7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796409841; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=L9JxHoS7GtghiarRLv73GtFq8rwcfgh6jnHHaB3aNZY=; b=WFbwG2cAaLIZeGycNZYAANasFo6LnG2eBnZHKQrDdbBPp+B5Tv4PqwMyv62oWh/nvrsq KqKaQNGGSLB9oy6JW/TOBdN43jklZVHy4LHMRxjxCFb/8zrCp4UqdxiqhydanddZtZ+Qn fEnORqhk1eCWBBJAdZc/VOSkbFPp4VV55OCqgoX4HMapM6Isxv4NL0GQnCzZ/AfIjmS+8 GLGYlJxfeEN47oERlB1L80SRvoQlab15dPV0bYmQFEOVZuIyW3aMXSSXg4BOUujVXIhfA k1kFFyPsBW0yKgxHWnOiaR4a/maH+dfdlmOku3zHJX4IGcOJ5dBvOW9pk/zcHcpsnSg== 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=EzGKmhWJ; 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 AEF49606A322 for ; Fri, 4 Dec 2026 18:44:01 +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=EzGKmhWJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 477261F0093B; Fri, 4 Dec 2026 18:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796409841; bh=L9JxHoS7GtghiarRLv73GtFq8rwcfgh6jnHHaB3aNZY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=EzGKmhWJ5APXairwgom76APKFB9YzLmqFyIn+XPKdGvkS5MTox3DB4BeRX93ZxHnk QiS6xbs5M6MAUv+4BqTR/P3tzNa8o5dLLvpiy4PqEyaHsPQ8CD2eceJzYszGcYpEno l8pQvvx9kb3U8LBTRqdOaAZHEzq/JyQxYM/mMu8ndUgrNYfQ7b1qQYw9upMPDa+0o+ C3SdeRwd+l7ZU1dzLb12SpVC3o3n1pHilxrxU4QUJ/+58JpTPfxpd5P2yu7Dx0TYtz s9G5QBPSM7hKXEPyWSQXNFGBCswlloLGZfD3BDEQaqDGLm5mh3lFJrYgsgcnaJlRxM +9Zp1IahATDMg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities Reply-To: sashiko-reviews@lists.linux.dev To: "Peter Fang" Cc: kvm@vger.kernel.org In-Reply-To: <20261204182022.324230-3-peter.fang@intel.com> References: <20261204182022.324230-1-peter.fang@intel.com> <20261204182022.324230-3-peter.fang@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 18:44:00 +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 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 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); > =20 > +/* > + * 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 =3D 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 =3D sysinfo_quote.max_quote_size; > + *num_sessions =3D sysinfo_quote.num_sessions; > + *num_threads =3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204182022.3242= 30-1-peter.fang@intel.com?part=3D2