From: Peter Fang <peter.fang@intel.com>
To: Dave Hansen <dave.hansen@linux.intel.com>,
Kiryl Shutsemau <kas@kernel.org>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
"Sean Christopherson" <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>, <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>, <linux-kernel@vger.kernel.org>,
<linux-coco@lists.linux.dev>, <kvm@vger.kernel.org>,
Xu Yilun <yilun.xu@linux.intel.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Tony Lindgren <tony.lindgren@linux.intel.com>,
Chao Gao <chao.gao@intel.com>, Xiaoyao Li <xiaoyao.li@intel.com>,
Binbin Wu <binbin.wu@linux.intel.com>,
Sohil Mehta <sohil.mehta@intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Kishen Maloor" <kishen.maloor@intel.com>,
Nikolay Borisov <nik.borisov@suse.com>,
Elena Reshetova <elena.reshetova@intel.com>,
Peter Fang <peter.fang@intel.com>
Subject: [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities
Date: Fri, 4 Dec 2026 10:18:23 -0800 [thread overview]
Message-ID: <20261204182022.324230-3-peter.fang@intel.com> (raw)
In-Reply-To: <20261204182022.324230-1-peter.fang@intel.com>
KVM will need to know the TDX module's quoting capabilities so it can
expose the feature to userspace and manage the Quote requests.
To support concurrent requests, tell KVM how many quoting sessions and
threads the TDX module supports. A "session" saves the state of a Quote
request inside the TDX module, and a "thread" runs a request on a
logical CPU. Also, tell KVM how big a Quote can be.
Signed-off-by: Peter Fang <peter.fang@intel.com>
---
v3:
- Redesign the interface. Use the add-on feature bit instead of the
original static Quote buffer check, and also read the quoting
metadata fields.
- Drop Tony's Reviewed-by, as the code changed substantially.
---
arch/x86/include/asm/tdx.h | 3 +++
arch/x86/include/asm/tdx_global_metadata.h | 5 ++++
arch/x86/virt/vmx/tdx/tdx.c | 27 ++++++++++++++++++++-
arch/x86/virt/vmx/tdx/tdx_global_metadata.c | 26 ++++++++++++++++++++
4 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
index 22946d910a6f2..d5997475e51b5 100644
--- a/arch/x86/include/asm/tdx.h
+++ b/arch/x86/include/asm/tdx.h
@@ -38,6 +38,7 @@
#define TDX_FEATURES0_NO_RBP_MOD BIT_ULL(18)
#define TDX_FEATURES0_DYNAMIC_PAMT BIT_ULL(36)
#define TDX_FEATURES0_EXT BIT_ULL(39)
+#define TDX_FEATURES0_QUOTE BIT_ULL(50)
#ifndef __ASSEMBLER__
@@ -202,6 +203,8 @@ u64 tdh_mem_page_remove(struct tdx_td *td, u64 gpa, enum pg_level level, u64 *ex
u64 tdh_phymem_cache_wb(bool resume);
u64 tdh_phymem_page_wbinvd_tdr(struct tdx_td *td);
u64 tdh_phymem_page_wbinvd_hkid(u64 hkid, kvm_pfn_t pfn);
+bool tdx_quoting_enabled(u32 *max_quote_size, u16 *num_sessions,
+ u16 *num_threads);
int tdx_quote_generate(struct tdx_td *td, u16 session_id,
struct page *report_page, u64 report_size,
struct page **quote_pages, u64 quote_buf_size,
diff --git a/arch/x86/include/asm/tdx_global_metadata.h b/arch/x86/include/asm/tdx_global_metadata.h
index f18e63b671c29..08b4364567b2e 100644
--- a/arch/x86/include/asm/tdx_global_metadata.h
+++ b/arch/x86/include/asm/tdx_global_metadata.h
@@ -59,4 +59,9 @@ struct tdx_sys_info {
struct tdx_sys_info_td_conf td_conf;
};
+struct tdx_sys_info_quote {
+ u32 max_quote_size;
+ u16 num_sessions;
+ u16 num_threads;
+};
#endif
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
@@ -1036,7 +1036,7 @@ static __init int construct_tdmrs(struct list_head *tmb_list,
/* List kernel-supported add-on features0 bits here */
#define TDX_KERNEL_SUPPORTED_ADDON_FEATURES0 (0)
-static __init u64 get_tdx_usable_addon_features0(void)
+static u64 get_tdx_usable_addon_features0(void)
{
/*
* The kernel doesn't yet support TDX module extensions with DPAMT.
@@ -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;
+
+ *max_quote_size = sysinfo_quote.max_quote_size;
+ *num_sessions = sysinfo_quote.num_sessions;
+ *num_threads = sysinfo_quote.num_threads;
+
+ return true;
+}
+EXPORT_SYMBOL_FOR_KVM(tdx_quoting_enabled);
+
static u64 tdx_quote_get(struct tdx_td *td, u16 session_id,
struct page *report_page, u64 report_size,
u64 *quote_hpa_list, u64 quote_buf_size,
diff --git a/arch/x86/virt/vmx/tdx/tdx_global_metadata.c b/arch/x86/virt/vmx/tdx/tdx_global_metadata.c
index 9ab4d021017f9..1acac59a50345 100644
--- a/arch/x86/virt/vmx/tdx/tdx_global_metadata.c
+++ b/arch/x86/virt/vmx/tdx/tdx_global_metadata.c
@@ -139,6 +139,32 @@ static __init int get_tdx_sys_info_ext(struct tdx_sys_info_ext *sysinfo_ext)
return 0;
}
+static int get_tdx_sys_info_quote(struct tdx_sys_info_quote *sysinfo_quote)
+{
+ int ret;
+ u64 val;
+
+ ret = read_sys_metadata_field(0x2300000200000002, &val);
+ if (ret)
+ return ret;
+
+ sysinfo_quote->max_quote_size = val;
+
+ ret = read_sys_metadata_field(0x2300000100000005, &val);
+ if (ret)
+ return ret;
+
+ sysinfo_quote->num_sessions = val;
+
+ ret = read_sys_metadata_field(0x2300000100000006, &val);
+ if (ret)
+ return ret;
+
+ sysinfo_quote->num_threads = val;
+
+ return 0;
+}
+
static __init int get_tdx_sys_info(struct tdx_sys_info *sysinfo)
{
int ret = 0;
--
2.53.0
next prev parent reply other threads:[~2026-12-04 18:21 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 ` Peter Fang [this message]
2026-12-04 18:44 ` [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities 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
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=20261204182022.324230-3-peter.fang@intel.com \
--to=peter.fang@intel.com \
--cc=adrian.hunter@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=elena.reshetova@intel.com \
--cc=hpa@zytor.com \
--cc=jgg@nvidia.com \
--cc=kas@kernel.org \
--cc=kishen.maloor@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nik.borisov@suse.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=sohil.mehta@intel.com \
--cc=tglx@kernel.org \
--cc=tony.lindgren@linux.intel.com \
--cc=x86@kernel.org \
--cc=xiaoyao.li@intel.com \
--cc=yilun.xu@linux.intel.com \
/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