* [PATCH v3 0/8] Enable DICE-based TDX quoting
@ 2026-12-04 18:18 Peter Fang
2026-12-04 18:18 ` [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote Peter Fang
` (8 more replies)
0 siblings, 9 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
Hi,
This is v3 of the host side of DICE-based TDX quoting. It underwent a
redesign after the v2 review and a couple of PUCK discussions, so there
is quite a bit of delta. The biggest changes are keeping userspace in
the GetQuote flow and supporting concurrent quoting. Userspace now
requests a Quote with a new KVM VM ioctl. There is no longer a big lock
serializing TDH.QUOTE.GET calls in the entire system, and as a result
the static global Quote buffer is gone too. The TDX module extensions
part of v2 is now its own series [1]. That series can (re)initialize
quoting implicitly, so the kernel no longer needs TDH.QUOTE.INIT calls.
To keep things simple, only enable quoting when there is no Dynamic
PAMT.
One upside of this redesign is that it keeps the optional use of event
notify interrupts in userspace. Userspace can generate the Quote in a
separate thread, and use event notify to tell the guest when the Quote
is ready. Also, the kernel doesn't have to worry about end-to-end
attestation ABI issues. Userspace decides how quoting should be done, so
a kernel upgrade shouldn't break attestation for TDs on existing
platforms.
Patches 1, 2, 7 and 8 are for tip, and patches 3-6 are for KVM. The plan
is for this series to go through tip, so Sean, I'd appreciate it if you
could take a look at the KVM patches. Jason, this is initial host
enabling only. It doesn't address the guest-side Quote type and labeling
feedback [2].
Background
==========
In TDX attestation, a "Quote" is a TD Report converted into a signed
form that a remote party can verify. To get a Quote, a TD passes its
report to the host using the GetQuote TDVMCALL. Host KVM then exits to
userspace, which sends the report to an SGX quoting enclave. SGX-based
attestation requires per-platform certificates from Intel's servers, so
this needs an extra step to register the platform and fetch the
certificates. Now, TDX modules on newer platforms can generate
DICE-based Quotes themselves. These Quotes carry layered certificate
chains built from the platform, so there is no need for any extra step.
DICE-based quoting runs as a TDX module extension, a separate execution
environment inside the TDX module for long-running work [3]. The TDX
module generates these Quotes itself. Its signing key is certified by
dedicated security hardware like the S3M. The time it takes to generate
this type of Quote using the CPU should be on the order of milliseconds.
Each Quote request consists of a quoting "session" (about 16KB of
memory), which holds its state, and a quoting "thread" (think struct
task_struct or struct kvm_vcpu, about 24KB of memory), which runs the
session. Sessions and threads come from a fixed global pool shared by
all TDs. A Quote request can be interrupted and resumed later, on any
CPU, similar to a preempted task. Once a thread starts a request, it
isn't released back to the pool until the request finishes.
Design
======
With this series, userspace can ask KVM for a Quote, and KVM does the
quoting via a SEAMCALL. The design has two goals:
1. Continue using the existing GetQuote flow, to avoid disturbing the
guest driver.
2. Allow as much concurrency as is reasonable, to minimize
vCPU stalls.
Add a new TDX sub-ioctl, KVM_TDX_GET_QUOTE, to request a Quote from
userspace. It's a VM ioctl because the SEAMCALL needs the TD's TDR page.
To have a stable and maintainable ABI, both the report and the Quote
buffers are page-aligned, so KVM doesn't have to deal with unaligned
data in perpetuity. Userspace should check how big a Quote can be in
KVM_TDX_CAPABILITIES to know how much memory the Quote buffer needs.
Every CPU should be able to generate a Quote at the same time, to avoid
a noisy-neighbor problem between TDs. So when the kernel enables
quoting, KVM requires at least one quoting session and thread per
logical CPU. That takes up about 40KB of TDX module memory per CPU,
adding up to tens of megabytes on a large system. KVM manages the
quoting sessions, and it handles one request per TD at a time. A typical
setup doesn't oversubscribe TDs, meaning there are no more TDs than
logical CPUs. Every TD is then guaranteed to get a session whenever it
asks for a Quote. On an oversubscribed host, userspace sees -EBUSY if
KVM runs out of sessions, and it can retry later. The global session
allocator should add a few microseconds of delay at most, which is
minuscule compared to generating the Quote itself.
A DICE-based Quote can be up to several megabytes in size. When there
are a large number of Quote requests in flight, using bounce buffers
could cost gigabytes of kernel memory on a large system. So KVM uses GUP
to pin the Quote buffer instead. This also helps reduce another
noisy-neighbor problem. When userspace frees its buffer, the TLB
shootdown only hits the CPUs the VMM runs on, whereas a vfree() on the
kernel bounce buffer would eventually trigger a shootdown on every CPU.
As a result, a TD that does aggressive quoting mostly throttles itself.
TDH.QUOTE.GET takes shared locks on the TD, so it doesn't collide with
the other runtime SEAMCALLs, only with the ones that build or tear down
the TD. So, instead of taking KVM's heavy tdx_vm_state_guard, only allow
quoting at runtime, after the TD is finalized. This avoids causing a
build-time SEAMCALL to fail and bug the VM. See patch 4 for more
details.
In order to not break TDX quoting, after a compatible runtime TDX module
update, the module must keep the maximum Quote size the same, and still
support at least one quoting session and thread per logical CPU.
Alternatives considered
=======================
Sean suggested doing all of this quoting in the guest, with a new
TDCALL. After some discussion [4] and a follow-up PUCK call on 9/23, the
consensus was to go back to the host-based design and rely on the
current GetQuote flow. Quotes signed directly by the S3M are out of
scope for this series.
I also considered other ways to manage quoting sessions. sbitmap usually
scales better than an IDA under heavy contention, but that felt like
premature optimization and made the code less intuitive. It also mostly
exists in the storage subsystem. A per-CPU session ID only works if the
whole request is non-preemptible. A per-CPU lock, on the other hand, can
protect each CPU's session, but it can cause unnecessary cross-VM
contention even when there is no oversubscription.
Testing
=======
Tested with a TDX module that mocks the interruptible quoting ABI and
returns a fake Quote. For the userspace side, I used a mocked quoting
service in QEMU. Multiple TDs were able to receive Quotes at the same
time through GetQuote and the new KVM ioctl.
What's in this series
=====================
Patches 1-2 add the core TDX interfaces, and patches 3-6 add the KVM
side of quoting and document the new uABI. Patch 7 then enables
DICE-based quoting, and patch 8 adds documentation for it.
Patch 1/8: Generate a Quote with TDH.QUOTE.GET.
Patch 2/8: Report the TDX module's quoting capabilities.
Patch 3/8: Require a quoting session and thread per logical CPU.
Patch 4/8: Add the KVM_TDX_GET_QUOTE sub-ioctl.
Patch 5/8: Report the maximum Quote size to userspace.
Patch 6/8: Document KVM_TDX_GET_QUOTE.
Patch 7/8: Enable quoting at TDX init.
Patch 8/8: Document DICE-based quoting.
Base
====
This is based on v7.4-rc1, plus v6 of the TDX module extensions series
[1]. You can find the full branch at [5]. A matching QEMU is at [6].
AI use
======
I used AI to polish my code, this cover letter, and the commit messages.
I also used it to collect review feedback and to verify details against
the TDX specs. AI generated the QEMU quoting service used for testing.
The series underwent AI code review, which caught a corner case where
quoting threads could run out and a few TDX documentation bugs. The
other comments were limited to style suggestions.
v2: https://lore.kernel.org/all/20260618081355.3253581-1-yilun.xu@linux.intel.com/
v1: https://lore.kernel.org/all/20260522034128.3144354-1-yilun.xu@linux.intel.com/
Changes in v3:
- Rebase onto v6 of the TDX module extensions series.
- Redesign the Quote generation path. Keep the GetQuote flow unchanged,
and add the KVM_TDX_GET_QUOTE sub-ioctl. [Sean, Rick]
- Redesign the core TDX interface. Drop the global Quote buffer and its
big lock to support concurrent quoting. [Sean, Dave, Rick, Tony]
- Use all-0s as the Quote type instead of all-1s in TDH.QUOTE.GET to
improve code readability. No functional change.
- Drop the tdx_tdr_pa() move (patch 10 in v2) as it's no longer needed.
- Drop TDH.QUOTE.INIT. The TDX module now folds it into TDH.EXT.INIT.
- Drop Rick's, Dan's and Tony's RB tags on the v2 patches, as those
patches were either dropped or changed substantially.
[1] https://lore.kernel.org/all/20261202-tdx-module-ext-v6-0-f6d8510fe498@linux.intel.com/
[2] https://lore.kernel.org/all/3860f37059d4c8807fa588c9f03b3a18e9449cec.camel@intel.com/
[3] Intel TDX Module Extension for Quoting, February 2026 (draft)
[4] https://lore.kernel.org/all/24a751d16ba0dc37aa7774df5739f39734cf9aca.camel@intel.com/
[5] https://github.com/peterfang/linux/tree/tdx-host-dice-v3
[6] https://github.com/peterfang/qemu/tree/dice-mock
Peter Fang (8):
x86/virt/tdx: Add interface to generate a Quote
x86/virt/tdx: Add interface to check quoting capabilities
KVM: TDX: Require at least one quoting session and thread per CPU
KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting
KVM: TDX: Report maximum Quote size in TDX capabilities
KVM: TDX: Document KVM_TDX_GET_QUOTE
x86/virt/tdx: Enable the quoting extension
x86/virt/tdx: Add documentation for DICE-based quoting
Documentation/arch/x86/tdx.rst | 23 ++-
Documentation/virt/kvm/api.rst | 21 ++-
Documentation/virt/kvm/x86/intel-tdx.rst | 47 ++++-
arch/x86/include/asm/tdx.h | 7 +
arch/x86/include/asm/tdx_global_metadata.h | 5 +
arch/x86/include/uapi/asm/kvm.h | 16 +-
arch/x86/kvm/vmx/tdx.c | 180 ++++++++++++++++++++
arch/x86/kvm/vmx/tdx.h | 6 +
arch/x86/virt/vmx/tdx/tdx.c | 125 +++++++++++++-
arch/x86/virt/vmx/tdx/tdx.h | 1 +
arch/x86/virt/vmx/tdx/tdx_global_metadata.c | 26 +++
11 files changed, 438 insertions(+), 19 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
prerequisite-patch-id: 5fbf78c6f40c69edec7a5016c950c35486f3ce81
prerequisite-patch-id: 3be62622e14be3de67212102aebbec7347773946
prerequisite-patch-id: ff98c5e54482da8ba3206ce825b299c29b3ca445
prerequisite-patch-id: 644cf6ce49ea8ed32adbfeba2234265537bc8576
prerequisite-patch-id: 6f9d56b183bb6344776bf837e2ca0d7f648bb81d
prerequisite-patch-id: 52e5e348d4b196e0cf79bb448b4edd6a4d4b4d9a
--
2.53.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote
2026-12-04 18:18 [PATCH v3 0/8] Enable DICE-based TDX quoting Peter Fang
@ 2026-12-04 18:18 ` Peter Fang
2026-12-04 19:15 ` Dave Hansen
2026-12-04 21:44 ` Adrian Hunter
2026-12-04 18:18 ` [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities Peter Fang
` (7 subsequent siblings)
8 siblings, 2 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
During TDX attestation, the TDX guest asks the host for a signed,
verifiable report (a "Quote"). With the quoting extension, the TDX
module generates the Quote and returns it in host pages.
Provide an interface for it. The SEAMCALL (TDH.QUOTE.GET) takes the host
pages in a custom linked list format. Each node is a page-sized array
holding the physical addresses of these pages. The last entry in a node
is the 'next' pointer. See [1] for details.
Each Quote request needs its own session in the TDX module. Only a
limited number of sessions are available. Let KVM manage the sessions by
assigning a session ID and a Quote buffer to each request. This avoids
resource sharing between these requests.
[1] Intel TDX Module ABI specification, Section "Physical Memory
Management Types"
Signed-off-by: Peter Fang <peter.fang@intel.com>
---
v3:
- Redesign the interface. Drop the global Quote buffer and its mutex,
and let KVM pass in the Quote buffer pages. [Sean, Dave, Rick, Tony]
- Use kmalloc() for the linked list nodes, plus cleanups. [Nikolay]
- Take a session ID so KVM can generate Quotes concurrently.
- Drop DEFAULT_QUOTE_ID and use [63:32] = 0 for the default quote type.
---
arch/x86/include/asm/tdx.h | 4 ++
arch/x86/virt/vmx/tdx/tdx.c | 96 +++++++++++++++++++++++++++++++++++++
arch/x86/virt/vmx/tdx/tdx.h | 1 +
3 files changed, 101 insertions(+)
diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
index 89e7628796b00..22946d910a6f2 100644
--- a/arch/x86/include/asm/tdx.h
+++ b/arch/x86/include/asm/tdx.h
@@ -202,6 +202,10 @@ 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);
+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,
+ u64 *quote_size, u64 *seamcall_err);
#else
static inline void tdx_init(void) { }
static inline u32 tdx_get_nr_guest_keyids(void) { return 0; }
diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index dbe17a136dced..39f280190b73d 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -2529,6 +2529,102 @@ void tdx_free_control_page(struct page *page)
}
EXPORT_SYMBOL_FOR_KVM(tdx_free_control_page);
+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,
+ u64 *quote_size)
+{
+ struct tdx_module_args args = {
+ .rcx = tdx_tdr_pa(td),
+ /* RDX[63:32] == 0 means the TDX module picks the quote type. */
+ .rdx = session_id,
+ .r8 = page_to_phys(report_page),
+ .r9 = report_size,
+ .r10 = __pa(quote_hpa_list),
+ .r11 = quote_buf_size,
+ };
+ u64 r;
+
+ do {
+ r = seamcall_ret(TDH_QUOTE_GET, &args);
+ } while (r == TDX_INTERRUPTED_RESUMABLE);
+
+ *quote_size = args.rcx;
+
+ return r;
+}
+
+#define HPAS_PER_NODE (PAGE_SIZE / sizeof(u64))
+
+/*
+ * Convert a local report to a remotely verifiable quote. The caller
+ * allocates a free session ID.
+ *
+ * Returns 0 on success, -ENOMEM on allocation failure, or -EIO if the
+ * SEAMCALL fails, with the TDX module's error code in seamcall_err.
+ */
+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,
+ u64 *quote_size, u64 *seamcall_err)
+{
+ int num_quote_pages, num_nodes, ret = 0;
+ u64 *node_head, *node_entry;
+ u64 r;
+
+ /*
+ * Pass the quote buffer to the TDX module as an HPA linked list. Each
+ * node holds 4KB page HPAs and the last entry points to the next node.
+ */
+ node_head = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!node_head)
+ return -ENOMEM;
+
+ node_entry = node_head;
+ num_quote_pages = PFN_UP(quote_buf_size);
+ num_nodes = 1;
+
+ /* Populate the linked list. Allocate new nodes as needed. */
+ for (int i = 0, pages = 0; pages < num_quote_pages;
+ i = (i + 1) % HPAS_PER_NODE) {
+ if (i == HPAS_PER_NODE - 1) {
+ u64 *new_node = kmalloc(PAGE_SIZE, GFP_KERNEL);
+
+ if (!new_node) {
+ ret = -ENOMEM;
+ goto out_free_nodes;
+ }
+
+ /* Write the 'next' pointer. */
+ node_entry[i] = __pa(new_node);
+ node_entry = new_node;
+ num_nodes++;
+ continue;
+ }
+
+ node_entry[i] = page_to_phys(quote_pages[pages]);
+ pages++;
+ }
+
+ r = tdx_quote_get(td, session_id, report_page, report_size, node_head,
+ quote_buf_size, quote_size);
+
+ *seamcall_err = r;
+
+ if (r != TDX_SUCCESS)
+ ret = -EIO;
+
+out_free_nodes:
+ for (int i = 0; i < num_nodes; i++) {
+ node_entry = node_head;
+ node_head = __va(node_head[HPAS_PER_NODE - 1]);
+ kfree(node_entry);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_FOR_KVM(tdx_quote_generate);
+
void tdx_sys_disable(void)
{
struct tdx_module_args args = {};
diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h
index cac0a5abbff1d..612ad84968c33 100644
--- a/arch/x86/virt/vmx/tdx/tdx.h
+++ b/arch/x86/virt/vmx/tdx/tdx.h
@@ -53,6 +53,7 @@
#define TDH_EXT_INIT 60
#define TDH_EXT_MEM_ADD 61
#define TDH_SYS_DISABLE 69
+#define TDH_QUOTE_GET 98
/* TDX page types */
#define PT_NDA 0x0
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities
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:18 ` Peter Fang
2026-12-04 18:18 ` [PATCH v3 3/8] KVM: TDX: Require at least one quoting session and thread per CPU Peter Fang
` (6 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
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
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 3/8] KVM: TDX: Require at least one quoting session and thread per CPU
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:18 ` [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities Peter Fang
@ 2026-12-04 18:18 ` Peter Fang
2026-12-04 18:18 ` [PATCH v3 4/8] KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting Peter Fang
` (5 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
When the TDX-Module supports quoting, disable TDX if there are not
enough quoting sessions or threads for the whole system. This avoids
cross-TD contention for quoting resources in the normal setup, where TDs
aren't oversubscribed [1].
Quote generation is a long-running operation in the TDX-Module, and the
quoting sessions and threads come from a fixed system-wide pool shared
by all TDs. Inside the module, a session stores a Quote request's state,
and a thread runs the request on a logical CPU. Not having enough
quoting resources creates a noisy-neighbor problem, where a TD's Quote
request could fail or wait indefinitely just because other TDs are also
getting their Quotes. Oversubscribing TDs, i.e. more TDs than there are
logical CPUs, is less typical, so only require enough quoting resources
for the normal setup.
Expect one Quote request per TD at a time, and guarantee that:
- When TDs aren't oversubscribed, there is always a free session for a
Quote request.
- A quoting thread can always be scheduled on any available CPU.
Each quoting session and thread currently needs roughly 40KB of
pre-allocated TDX-Module memory. This adds up to tens of megabytes on a
large system with more than 1024 logical CPUs [2].
Since a platform with TDX enabled doesn't support CPU hotplug, use
num_present_cpus() for the number of logical CPUs.
Signed-off-by: Peter Fang <peter.fang@intel.com>
Link: https://lore.kernel.org/all/arRXqpG_4hCrhQLM@intel.com/ # [1]
Link: https://lore.kernel.org/all/DS4PPFA84FA90FC58F88D79B0EF19B34596E7832@DS4PPFA84FA90FC.namprd11.prod.outlook.com/ # [2]
---
v3:
- New patch.
---
arch/x86/kvm/vmx/tdx.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index 8a593159c9b7c..4ccb41f002dff 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -3435,6 +3435,8 @@ void tdx_hardware_unsetup(void)
static int __init __tdx_hardware_setup(void)
{
const struct tdx_sys_info_td_conf *td_conf;
+ u16 quoting_sessions, quoting_threads;
+ u32 quoting_max_size;
int i;
for (i = 0; i < ARRAY_SIZE(tdx_uret_msrs); i++) {
@@ -3500,6 +3502,26 @@ static int __init __tdx_hardware_setup(void)
return -EINVAL;
}
+ /*
+ * KVM only allows one quoting session per TD. Make sure a free session
+ * is always available as long as there is no oversubscription of TDs,
+ * i.e. no more TDs than logical CPUs, and that a quoting thread can
+ * always be scheduled on any logical CPU.
+ */
+ if (tdx_quoting_enabled("ing_max_size, "ing_sessions,
+ "ing_threads)) {
+ if (quoting_sessions < num_present_cpus()) {
+ pr_err("Disable TDX: QUOTING_NUM_SESSIONS (%u) smaller than number of logical CPUs (%u).\n",
+ quoting_sessions, num_present_cpus());
+ return -EINVAL;
+ }
+ if (quoting_threads < num_present_cpus()) {
+ pr_err("Disable TDX: QUOTING_NUM_THREADS (%u) smaller than number of logical CPUs (%u).\n",
+ quoting_threads, num_present_cpus());
+ return -EINVAL;
+ }
+ }
+
if (misc_cg_set_capacity(MISC_CG_RES_TDX, tdx_get_nr_guest_keyids()))
return -EINVAL;
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 4/8] KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting
2026-12-04 18:18 [PATCH v3 0/8] Enable DICE-based TDX quoting Peter Fang
` (2 preceding siblings ...)
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:18 ` Peter Fang
2026-12-04 18:18 ` [PATCH v3 5/8] KVM: TDX: Report maximum Quote size in TDX capabilities Peter Fang
` (4 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
Add a new VM sub-ioctl, KVM_TDX_GET_QUOTE, so userspace can generate a
DICE-based Quote through the TDX-Module if it supports quoting.
To convert the guest's local report into a remotely verifiable Quote,
the host currently forwards the guest's GetQuote request to an SGX
Quoting Enclave in userspace. Now the host can also request a DICE-based
Quote from the TDX-Module. These Quotes leverage Intel's security
hardware, such as the S3M, so they work without SGX. The GetQuote flow
remains unchanged, so existing TDX setups can continue to work.
The TDX-Module needs its internal TD states to generate a Quote, so the
quoting SEAMCALL (TDH.QUOTE.GET) takes the TD's TDR page as input. Make
KVM_TDX_GET_QUOTE a TDX VM sub-ioctl accordingly.
Only allow quoting after the TD is finalized, so it doesn't bump into
the TD build ioctls. These ioctls use SEAMCALLs that take an exclusive
lock on the TD, so the quoting SEAMCALL can't take a shared lock at the
same time. Doing so could fail a build-time SEAMCALL and bug the VM.
Use a plain read for the TD state without tdx_vm_state_guard. The read
could race with the following:
- KVM_TDX_INIT_VM: sets the state to initialized, so a racy read would
never observe a finalized state. Updating the state only changes its
lowest byte, so this is true even with a torn access.
- KVM_TDX_FINALIZE_VM: the only place that sets the state to
finalized, which is the stable state of a running TD.
Being a VM ioctl like KVM_TDX_FINALIZE_VM, KVM_TDX_GET_QUOTE's
observation of the TD state is governed by the VFS layer. Dropping and
grabbing a reference to the VM file have release and acquire semantics.
This guarantees that if userspace calls KVM_TDX_GET_QUOTE after
KVM_TDX_FINALIZE_VM returns, it must observe the state change fully. A
racy userspace implementation would at worst fail with -EINVAL, which
just means "not ready yet".
Add a mutex to allow one Quote request per TD at a time. This lets the
checks at TDX init guarantee that quoting sessions never run out when
there is no oversubscription of TDs. Each request has a unique "session
ID", so create a session ID allocator to support concurrent requests. To
keep the uABI predictable, always use the number of logical CPUs as the
session limit, since userspace has no way of knowing how many sessions
the TDX-Module actually supports. If userspace decides to oversubscribe
TDs, it must be prepared to handle -EBUSY, as KVM could run out of
quoting sessions in this case.
The TDX-Module takes quoting data blobs in pages. Rather than having to
support unaligned data in the uABI in perpetuity, require both the
report and the Quote blobs to be page-aligned from day one. This gives
KVM the freedom to change its implementation underneath later (e.g. pin
the report with GUP) without breaking userspace.
Pin the Quote buffer with GUP. DICE-based Quotes can reach several
megabytes in size [1], so using bounce buffers could at worst mean
gigabytes of kernel memory to shuffle data around on a large system.
Signed-off-by: Peter Fang <peter.fang@intel.com>
Link: https://lore.kernel.org/all/20260211001712.1531955-1-sathyanarayanan.kuppuswamy@linux.intel.com/ # [1]
---
v3:
- Redesign the Quote generation path. Keep the GetQuote flow unchanged,
and let userspace request a Quote with the new KVM_TDX_GET_QUOTE
sub-ioctl. [Sean, Rick]
- Allow one Quote request per TD at a time, and support concurrent
requests across TDs. [Sean]
---
arch/x86/include/uapi/asm/kvm.h | 12 +++
arch/x86/kvm/vmx/tdx.c | 152 ++++++++++++++++++++++++++++++++
arch/x86/kvm/vmx/tdx.h | 6 ++
3 files changed, 170 insertions(+)
diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
index 00ce265391e11..9326f48c0d377 100644
--- a/arch/x86/include/uapi/asm/kvm.h
+++ b/arch/x86/include/uapi/asm/kvm.h
@@ -980,6 +980,7 @@ enum kvm_tdx_cmd_id {
KVM_TDX_INIT_MEM_REGION,
KVM_TDX_FINALIZE_VM,
KVM_TDX_GET_CPUID,
+ KVM_TDX_GET_QUOTE,
KVM_TDX_CMD_NR_MAX,
};
@@ -1017,6 +1018,17 @@ struct kvm_tdx_capabilities {
struct kvm_cpuid2 cpuid;
};
+struct kvm_tdx_get_quote {
+ __u64 report_uaddr;
+ __u64 report_size;
+
+ __u64 quote_buf_uaddr;
+ __u64 quote_buf_size;
+ __u64 quote_size;
+
+ __u64 reserved[27];
+};
+
struct kvm_tdx_init_vm {
__u64 attributes;
__u64 xfam;
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index 4ccb41f002dff..704a267e9f8be 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -58,6 +58,8 @@ module_param_named(tdx, enable_tdx, bool, 0444);
static const struct tdx_sys_info *tdx_sysinfo;
+static DEFINE_IDA(tdx_quoting_ida);
+
void tdh_vp_rd_failed(struct vcpu_tdx *tdx, char *uclass, u32 field, u64 err)
{
KVM_BUG_ON(1, tdx->vcpu.kvm);
@@ -658,6 +660,8 @@ int tdx_vm_init(struct kvm *kvm)
*/
kvm->max_vcpus = min_t(int, kvm->max_vcpus, num_present_cpus());
+ mutex_init(&kvm_tdx->quote_lock);
+
kvm_tdx->state = TD_STATE_UNINITIALIZED;
return 0;
@@ -2363,6 +2367,146 @@ static int tdx_get_capabilities(struct kvm_tdx_cmd *cmd)
return ret;
}
+/*
+ * No need to take tdx_vm_state_guard here. Quoting takes TD locks as shared, so
+ * it doesn't run up against any other runtime SEAMCALLs.
+ */
+static int tdx_td_get_quote(struct kvm *kvm, struct kvm_tdx_cmd *cmd)
+{
+ struct kvm_tdx *kvm_tdx = to_kvm_tdx(kvm);
+ struct kvm_tdx_get_quote __user *ugq;
+ int num_quote_pages, ret, session_id;
+ struct kvm_tdx_get_quote gq;
+ struct page **quote_pages;
+ u16 sessions, threads;
+ u32 max_quote_size;
+ u64 quote_size;
+ void *report;
+
+ if (cmd->flags)
+ return -EINVAL;
+
+ /*
+ * TDH.QUOTE.GET needs the TD locks, so avoid colliding with
+ * build-time SEAMCALLs that lock the TD exclusively.
+ *
+ * The VFS syscall path guarantees that any VM ioctl issued after
+ * KVM_TDX_FINALIZE_VM succeeds observes the state change fully. It also
+ * ensures that tdx_vm_destroy() can't run and reset the state while
+ * this call is in progress.
+ */
+ if (kvm_tdx->state != TD_STATE_RUNNABLE)
+ return -EINVAL;
+
+ /* Grab the lock early to throttle the TD before pinning memory */
+ if (mutex_lock_killable(&kvm_tdx->quote_lock))
+ return -EINTR;
+
+ if (!tdx_quoting_enabled(&max_quote_size, &sessions, &threads)) {
+ ret = -EINVAL;
+ goto out_unlock;
+ }
+
+ ugq = u64_to_user_ptr(cmd->data);
+
+ if (copy_from_user(&gq, ugq, sizeof(gq))) {
+ ret = -EFAULT;
+ goto out_unlock;
+ }
+
+ if (memchr_inv(gq.reserved, 0, sizeof(gq.reserved))) {
+ ret = -EINVAL;
+ goto out_unlock;
+ }
+
+ /* The TDX-Module takes the report in a single 4K page */
+ if (!PAGE_ALIGNED(gq.report_uaddr) || gq.report_size > PAGE_SIZE) {
+ ret = -EINVAL;
+ goto out_unlock;
+ }
+
+ report = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!report) {
+ ret = -ENOMEM;
+ goto out_unlock;
+ }
+
+ if (copy_from_user(report, u64_to_user_ptr(gq.report_uaddr),
+ gq.report_size)) {
+ ret = -EFAULT;
+ goto out_free_report;
+ }
+
+ /* Avoid pinning an unreasonable number of pages */
+ gq.quote_buf_size = umin(gq.quote_buf_size, max_quote_size);
+
+ if (!PAGE_ALIGNED(gq.quote_buf_uaddr) || !gq.quote_buf_size) {
+ ret = -EINVAL;
+ goto out_free_report;
+ }
+
+ num_quote_pages = PFN_UP(gq.quote_buf_size);
+
+ quote_pages = kmalloc_objs(*quote_pages, num_quote_pages);
+ if (!quote_pages) {
+ ret = -ENOMEM;
+ goto out_free_report;
+ }
+
+ ret = pin_user_pages_fast(gq.quote_buf_uaddr, num_quote_pages,
+ FOLL_WRITE, quote_pages);
+ if (ret != num_quote_pages) {
+ if (ret > 0)
+ unpin_user_pages(quote_pages, ret);
+ ret = -ENOMEM;
+ goto out_free_quote;
+ }
+
+ /*
+ * There is a 1:1 mapping between a quoting session in use and a
+ * quoting thread in the TDX-Module. Since KVM guarantees there are at
+ * least as many threads as logical CPUs, limit the number of sessions
+ * to the same number to ensure there is always a free thread. Using
+ * the module's own limit would make the ABI unpredictable.
+ *
+ * In a typical setup where TDs aren't oversubscribed, there is always a
+ * free session since each TD runs at most one session at a time.
+ * Otherwise, let userspace handle -EBUSY when sessions run out.
+ */
+ session_id = ida_alloc_range(&tdx_quoting_ida, 0,
+ num_present_cpus() - 1, GFP_KERNEL);
+ if (session_id == -ENOSPC)
+ session_id = -EBUSY;
+ if (session_id < 0) {
+ ret = session_id;
+ goto out_unpin_quote;
+ }
+
+ ret = tdx_quote_generate(&kvm_tdx->td, session_id, virt_to_page(report),
+ gq.report_size, quote_pages, gq.quote_buf_size,
+ "e_size, &cmd->hw_error);
+
+ ida_free(&tdx_quoting_ida, session_id);
+
+out_unpin_quote:
+ /*
+ * The TDX-Module bypasses the kernel's page tables when writing the
+ * quote. Mark the pages dirty so reclaim doesn't drop them silently.
+ */
+ unpin_user_pages_dirty_lock(quote_pages, num_quote_pages, true);
+out_free_quote:
+ kfree(quote_pages);
+out_free_report:
+ kfree(report);
+out_unlock:
+ mutex_unlock(&kvm_tdx->quote_lock);
+
+ if (ret)
+ return ret;
+
+ return put_user(quote_size, &ugq->quote_size);
+}
+
/*
* KVM reports guest physical address in CPUID.0x800000008.EAX[23:16], which is
* similar to TDX's GPAW. Use this field as the interface for userspace to
@@ -2982,6 +3126,14 @@ int tdx_vm_ioctl(struct kvm *kvm, void __user *argp)
if (tdx_cmd.id == KVM_TDX_CAPABILITIES)
return tdx_get_capabilities(&tdx_cmd);
+ if (tdx_cmd.id == KVM_TDX_GET_QUOTE) {
+ r = tdx_td_get_quote(kvm, &tdx_cmd);
+ if (copy_to_user(argp, &tdx_cmd, sizeof(struct kvm_tdx_cmd)))
+ return -EFAULT;
+
+ return r;
+ }
+
CLASS(tdx_vm_state_guard, guard)(kvm);
if (IS_ERR(guard))
return PTR_ERR(guard);
diff --git a/arch/x86/kvm/vmx/tdx.h b/arch/x86/kvm/vmx/tdx.h
index fd368e3ee060b..f67d81f1aab73 100644
--- a/arch/x86/kvm/vmx/tdx.h
+++ b/arch/x86/kvm/vmx/tdx.h
@@ -47,6 +47,12 @@ struct kvm_tdx {
* Set/unset is protected with kvm->mmu_lock.
*/
bool wait_for_sept_zap;
+
+ /*
+ * Allow one quoting session per TD. This prevents a TD from hogging
+ * the quoting resources.
+ */
+ struct mutex quote_lock;
};
/* TDX module vCPU states */
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 5/8] KVM: TDX: Report maximum Quote size in TDX capabilities
2026-12-04 18:18 [PATCH v3 0/8] Enable DICE-based TDX quoting Peter Fang
` (3 preceding siblings ...)
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:18 ` Peter Fang
2026-12-04 18:18 ` [PATCH v3 6/8] KVM: TDX: Document KVM_TDX_GET_QUOTE Peter Fang
` (3 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
Add a "quote_max_size" field to KVM_TDX_CAPABILITIES so userspace knows
how big a Quote buffer should be for KVM_TDX_GET_QUOTE.
Quotes can have different size limits. They depend on the signing
algorithms and platform configuration. A value of 0 means quoting isn't
available in the TDX-Module.
Signed-off-by: Peter Fang <peter.fang@intel.com>
---
v3:
- New patch.
---
arch/x86/include/uapi/asm/kvm.h | 4 +++-
arch/x86/kvm/vmx/tdx.c | 6 ++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h
index 9326f48c0d377..ee32d5225985f 100644
--- a/arch/x86/include/uapi/asm/kvm.h
+++ b/arch/x86/include/uapi/asm/kvm.h
@@ -1012,7 +1012,9 @@ struct kvm_tdx_capabilities {
__u64 kernel_tdvmcallinfo_1_r12;
__u64 user_tdvmcallinfo_1_r12;
- __u64 reserved[250];
+ __u64 quote_max_size;
+
+ __u64 reserved[249];
/* Configurable CPUID bits for userspace */
struct kvm_cpuid2 cpuid;
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index 704a267e9f8be..5118498a3f351 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -189,6 +189,8 @@ static void td_init_cpuid_entry2(struct kvm_cpuid_entry2 *entry, unsigned char i
static int init_kvm_tdx_caps(const struct tdx_sys_info_td_conf *td_conf,
struct kvm_tdx_capabilities *caps)
{
+ u16 quoting_sessions, quoting_threads;
+ u32 quoting_max_size;
int i;
caps->supported_attrs = tdx_get_supported_attrs(td_conf);
@@ -207,6 +209,10 @@ static int init_kvm_tdx_caps(const struct tdx_sys_info_td_conf *td_conf,
for (i = 0; i < td_conf->num_cpuid_config; i++)
td_init_cpuid_entry2(&caps->cpuid.entries[i], i);
+ if (tdx_quoting_enabled("ing_max_size, "ing_sessions,
+ "ing_threads))
+ caps->quote_max_size = quoting_max_size;
+
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 6/8] KVM: TDX: Document KVM_TDX_GET_QUOTE
2026-12-04 18:18 [PATCH v3 0/8] Enable DICE-based TDX quoting Peter Fang
` (4 preceding siblings ...)
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 ` Peter Fang
2026-12-04 18:18 ` [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension Peter Fang
` (2 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
Document the KVM_TDX_GET_QUOTE command, which lets userspace request
DICE-based Quotes from the TDX module, without using a Quoting Enclave
on the host.
Signed-off-by: Peter Fang <peter.fang@intel.com>
---
v3:
- New patch based on the redesigned Quote generation path.
---
Documentation/virt/kvm/api.rst | 21 ++++++-----
Documentation/virt/kvm/x86/intel-tdx.rst | 47 +++++++++++++++++++++++-
2 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index e95c9cda085d9..f6418e91aa3e4 100644
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@ -7561,15 +7561,18 @@ inputs and outputs of the TDVMCALL. Currently the following values of
``nr`` are defined:
* ``TDVMCALL_GET_QUOTE``: the guest has requested to generate a TD-Quote
- signed by a service hosting TD-Quoting Enclave operating on the host.
- Parameters and return value are in the ``get_quote`` field of the union.
- The ``gpa`` field and ``size`` specify the guest physical address
- (without the shared bit set) and the size of a shared-memory buffer, in
- which the TDX guest passes a TD Report. The ``ret`` field represents
- the return value of the GetQuote request. When the request has been
- queued successfully, the TDX guest can poll the status field in the
- shared-memory area to check whether the Quote generation is completed or
- not. When completed, the generated Quote is returned via the same buffer.
+ from a TD Report, signed by a certified attestation key. Userspace can
+ get it from a TD-Quoting Enclave on the host. Or, if the TDX module
+ supports quoting, the ``KVM_TDX_GET_QUOTE`` command can generate a
+ DICE-based Quote. Parameters and return value are in the ``get_quote``
+ field of the union. The ``gpa`` field and ``size`` specify the guest
+ physical address (without the shared bit set) and the size of a
+ shared-memory buffer, in which the TDX guest passes a TD Report. The
+ ``ret`` field represents the return value of the GetQuote request. When
+ the request has been queued successfully, the TDX guest can poll the
+ status field in the shared-memory area to check whether the Quote
+ generation is completed or not. When completed, the generated Quote is
+ returned via the same buffer.
* ``TDVMCALL_GET_TD_VM_CALL_INFO``: the guest has requested the support
status of TDVMCALLs. The output values for the given leaf should be
diff --git a/Documentation/virt/kvm/x86/intel-tdx.rst b/Documentation/virt/kvm/x86/intel-tdx.rst
index d8d9409120e61..1bd95f6df49d6 100644
--- a/Documentation/virt/kvm/x86/intel-tdx.rst
+++ b/Documentation/virt/kvm/x86/intel-tdx.rst
@@ -38,6 +38,7 @@ ioctl with TDX specific sub-ioctl() commands.
KVM_TDX_INIT_MEM_REGION,
KVM_TDX_FINALIZE_VM,
KVM_TDX_GET_CPUID,
+ KVM_TDX_GET_QUOTE,
KVM_TDX_CMD_NR_MAX,
};
@@ -92,7 +93,12 @@ to be configured to the TDX guest.
__u64 kernel_tdvmcallinfo_1_r12;
__u64 user_tdvmcallinfo_1_r12;
- __u64 reserved[250];
+ /* Maximum size of a Quote for KVM_TDX_GET_QUOTE, or 0 if quoting isn't
+ * available
+ */
+ __u64 quote_max_size;
+
+ __u64 reserved[249];
/* Configurable CPUID bits for userspace */
struct kvm_cpuid2 cpuid;
@@ -197,6 +203,45 @@ Complete measurement of the initial TD contents and mark it ready to run.
- hw_error: must be 0
+KVM_TDX_GET_QUOTE
+-----------------
+:Type: vm ioctl
+:Returns: 0 on success, <0 on error
+
+Generate a DICE-based Quote from a TD Report. @report_uaddr points to the
+TD Report, and @report_size is its size. @quote_buf_uaddr points to the
+buffer for the Quote, and @quote_buf_size is its size. On success, KVM
+writes the Quote to the buffer, and the size of the Quote to @quote_size.
+This needs to be called after KVM_TDX_FINALIZE_VM succeeds.
+
+@report_uaddr and @quote_buf_uaddr must be page-aligned, and @report_size
+must not exceed the size of a page. @quote_buf_size must be at least the
+quote_max_size reported by KVM_TDX_CAPABILITIES.
+
+When TDs are oversubscribed, i.e. when there are more TDs than logical
+CPUs, KVM returns -EBUSY if there are as many Quote requests in progress
+as logical CPUs, and userspace can retry later. KVM never returns -EBUSY
+when TDs aren't oversubscribed.
+
+- id: KVM_TDX_GET_QUOTE
+- flags: must be 0
+- data: pointer to struct kvm_tdx_get_quote (in/out)
+- hw_error: must be 0 (out)
+
+::
+
+ struct kvm_tdx_get_quote {
+ __u64 report_uaddr;
+ __u64 report_size;
+
+ __u64 quote_buf_uaddr;
+ __u64 quote_buf_size;
+ __u64 quote_size;
+
+ __u64 reserved[27];
+ };
+
+
KVM_TDX_GET_CPUID
-----------------
:Type: vcpu ioctl
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension
2026-12-04 18:18 [PATCH v3 0/8] Enable DICE-based TDX quoting Peter Fang
` (5 preceding siblings ...)
2026-12-04 18:18 ` [PATCH v3 6/8] KVM: TDX: Document KVM_TDX_GET_QUOTE Peter Fang
@ 2026-12-04 18:18 ` Peter Fang
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
8 siblings, 0 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
The quoting extension generates TDX attestation Quotes in the TDX
module, without a separate host service. Enable this feature by
requesting it at TDX init when configuring the module.
For simplicity, when there is no Dynamic PAMT, the kernel enables every
recognizable add-on feature that the TDX module supports. So add quoting
to the list of add-on features. And once it's enabled, runtime module
updates guarantee it keeps working.
KVM expects the TDX module to support quoting on every logical CPU at
the same time. This takes about 40KB of memory per logical CPU. On a
large system with more than 1024 logical CPUs, this consumes tens of
megabytes of host RAM [1].
Signed-off-by: Peter Fang <peter.fang@intel.com>
Link: https://lore.kernel.org/all/DS4PPFA84FA90FC58F88D79B0EF19B34596E7832@DS4PPFA84FA90FC.namprd11.prod.outlook.com/ # [1]
---
v3:
- Enable through kernel-supported add-on features.
- Don't explicitly request quoting in TDH.SYS.UPDATE.
- Drop the "Quoting engine" term. [Nikolay]
- Drop Tony's Reviewed-by, as the code changed substantially.
---
arch/x86/virt/vmx/tdx/tdx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v3 8/8] x86/virt/tdx: Add documentation for DICE-based quoting
2026-12-04 18:18 [PATCH v3 0/8] Enable DICE-based TDX quoting Peter Fang
` (6 preceding siblings ...)
2026-12-04 18:18 ` [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension Peter Fang
@ 2026-12-04 18:18 ` Peter Fang
2026-12-04 18:40 ` [PATCH v3 0/8] Enable DICE-based TDX quoting Jason Gunthorpe
8 siblings, 0 replies; 15+ messages in thread
From: Peter Fang @ 2026-12-04 18:18 UTC (permalink / raw)
To: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova, Peter Fang
The attestation section only covers quoting through the SGX enclave.
Document the TDX module's DICE-based quoting capability, and bring the
TDX guest driver's side up to date.
Signed-off-by: Peter Fang <peter.fang@intel.com>
---
v3:
- New patch. Split from v2 16/17 and add DICE details.
---
Documentation/arch/x86/tdx.rst | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/Documentation/arch/x86/tdx.rst b/Documentation/arch/x86/tdx.rst
index a36ea2bd4301d..0ab1719100244 100644
--- a/Documentation/arch/x86/tdx.rst
+++ b/Documentation/arch/x86/tdx.rst
@@ -544,14 +544,25 @@ More details about the TDREPORT can be found in Intel TDX Module
specification, section titled "TDG.MR.REPORT Leaf".
After getting the TDREPORT, the second step of the attestation process
-is to send it to the Quoting Enclave (QE) to generate the Quote. TDREPORT
-by design can only be verified on the local platform as the MAC key is
-bound to the platform. To support remote verification of the TDREPORT,
-TDX leverages Intel SGX Quoting Enclave to verify the TDREPORT locally
-and convert it to a remotely verifiable Quote. Method of sending TDREPORT
+is to convert it to a Quote. TDREPORT by design can only be verified on
+the local platform as the MAC key is bound to the platform. To support
+remote verification of the TDREPORT, TDX can leverage Intel SGX Quoting
+Enclave (QE) to verify the TDREPORT locally and convert it to a remotely
+verifiable Quote in an Intel-specific format. Method of sending TDREPORT
to QE is implementation specific. Attestation software can choose
whatever communication channel available (i.e. vsock or TCP/IP) to
-send the TDREPORT to QE and receive the Quote.
+send the TDREPORT to QE and receive the Quote. If it uses the
+configfs-tsm ABI, the TDX guest driver asks the host for the Quote with
+TDG.VP.VMCALL<GetQuote>, as defined in TDX Guest Hypervisor Communication
+Interface specification.
+
+Alternatively, the TDX module can generate Quotes based on DICE, an
+industry standard, without a separate host service. Their certificates
+come from the platform itself rather than from Intel's servers, so there
+is no need to register the platform with Intel like there is for SGX. The
+host kernel enables quoting whenever the TDX module supports it and there
+is no Dynamic PAMT. The TDX guest driver then uses a GetQuote buffer that
+fits the largest possible Quote from the module.
References
==========
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v3 0/8] Enable DICE-based TDX quoting
2026-12-04 18:18 [PATCH v3 0/8] Enable DICE-based TDX quoting Peter Fang
` (7 preceding siblings ...)
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 ` Jason Gunthorpe
2026-12-04 18:47 ` Edgecombe, Rick P
8 siblings, 1 reply; 15+ messages in thread
From: Jason Gunthorpe @ 2026-12-04 18:40 UTC (permalink / raw)
To: Peter Fang
Cc: Dave Hansen, Kiryl Shutsemau, Rick Edgecombe, Sean Christopherson,
Paolo Bonzini, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu, Sohil Mehta,
Adrian Hunter, Kishen Maloor, Nikolay Borisov, Elena Reshetova
On Fri, Dec 04, 2026 at 10:18:21AM -0800, Peter Fang wrote:
> Sean suggested doing all of this quoting in the guest, with a new
> TDCALL. After some discussion [4] and a follow-up PUCK call on 9/23, the
> consensus was to go back to the host-based design and rely on the
> current GetQuote flow. Quotes signed directly by the S3M are out of
> scope for this series.
This would certainly match what the other architectures are doing,
maybe explain a bit more why Intel has to be so much more complicated?
Otherwise I don't have an issue with a design like this, there is no
useful purpose for the host to see a VM's signed quote so it is fine
for this to all be buried in KVM without involving attestation
subsystem..
Jason
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 0/8] Enable DICE-based TDX quoting
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
0 siblings, 1 reply; 15+ messages in thread
From: Edgecombe, Rick P @ 2026-12-04 18:47 UTC (permalink / raw)
To: jgg@nvidia.com, Fang, Peter
Cc: kvm@vger.kernel.org, Li, Xiaoyao, linux-coco@lists.linux.dev,
dave.hansen@linux.intel.com, Hunter, Adrian, Reshetova, Elena,
kas@kernel.org, seanjc@google.com, mingo@redhat.com,
linux-kernel@vger.kernel.org, pbonzini@redhat.com,
tony.lindgren@linux.intel.com, binbin.wu@linux.intel.com,
nik.borisov@suse.com, hpa@zytor.com, tglx@kernel.org,
Mehta, Sohil, Gao, Chao, bp@alien8.de, Maloor, Kishen,
yilun.xu@linux.intel.com, x86@kernel.org
On Fri, 2026-12-04 at 14:40 -0400, Jason Gunthorpe wrote:
> On Fri, Dec 04, 2026 at 10:18:21AM -0800, Peter Fang wrote:
>
> > Sean suggested doing all of this quoting in the guest, with a new
> > TDCALL. After some discussion [4] and a follow-up PUCK call on 9/23, the
> > consensus was to go back to the host-based design and rely on the
> > current GetQuote flow. Quotes signed directly by the S3M are out of
> > scope for this series.
>
> This would certainly match what the other architectures are doing,
> maybe explain a bit more why Intel has to be so much more complicated?
Heh, which complication in particular are you referring to here?
>
> Otherwise I don't have an issue with a design like this, there is no
> useful purpose for the host to see a VM's signed quote so it is fine
> for this to all be buried in KVM without involving attestation
> subsystem..
A TDs quote is a VM scoped thing. Extending VM lifecycle management outside of
KVM would be a huge change to how things work.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 0/8] Enable DICE-based TDX quoting
2026-12-04 18:47 ` Edgecombe, Rick P
@ 2026-12-04 18:50 ` Jason Gunthorpe
2026-12-04 19:11 ` Edgecombe, Rick P
0 siblings, 1 reply; 15+ messages in thread
From: Jason Gunthorpe @ 2026-12-04 18:50 UTC (permalink / raw)
To: Edgecombe, Rick P
Cc: Fang, Peter, kvm@vger.kernel.org, Li, Xiaoyao,
linux-coco@lists.linux.dev, dave.hansen@linux.intel.com,
Hunter, Adrian, Reshetova, Elena, kas@kernel.org,
seanjc@google.com, mingo@redhat.com, linux-kernel@vger.kernel.org,
pbonzini@redhat.com, tony.lindgren@linux.intel.com,
binbin.wu@linux.intel.com, nik.borisov@suse.com, hpa@zytor.com,
tglx@kernel.org, Mehta, Sohil, Gao, Chao, bp@alien8.de,
Maloor, Kishen, yilun.xu@linux.intel.com, x86@kernel.org
On Fri, Dec 04, 2026 at 06:47:52PM +0000, Edgecombe, Rick P wrote:
> On Fri, 2026-12-04 at 14:40 -0400, Jason Gunthorpe wrote:
> > On Fri, Dec 04, 2026 at 10:18:21AM -0800, Peter Fang wrote:
> >
> > > Sean suggested doing all of this quoting in the guest, with a new
> > > TDCALL. After some discussion [4] and a follow-up PUCK call on 9/23, the
> > > consensus was to go back to the host-based design and rely on the
> > > current GetQuote flow. Quotes signed directly by the S3M are out of
> > > scope for this series.
> >
> > This would certainly match what the other architectures are doing,
> > maybe explain a bit more why Intel has to be so much more complicated?
>
> Heh, which complication in particular are you referring to here?
Well this entire 8 part series, a related VMM series to N VMMs, and a
VMM/host API to carry it.
Vs.. None of that, like everyone else.
Naively the guest can call into TDX module just fine, so it is worth
explaining why all this is needed, at least a little bit.
Jason
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 0/8] Enable DICE-based TDX quoting
2026-12-04 18:50 ` Jason Gunthorpe
@ 2026-12-04 19:11 ` Edgecombe, Rick P
0 siblings, 0 replies; 15+ messages in thread
From: Edgecombe, Rick P @ 2026-12-04 19:11 UTC (permalink / raw)
To: jgg@nvidia.com
Cc: kvm@vger.kernel.org, Li, Xiaoyao, linux-coco@lists.linux.dev,
dave.hansen@linux.intel.com, Hunter, Adrian, Reshetova, Elena,
kas@kernel.org, binbin.wu@linux.intel.com, seanjc@google.com,
pbonzini@redhat.com, mingo@redhat.com,
linux-kernel@vger.kernel.org, nik.borisov@suse.com, hpa@zytor.com,
tglx@kernel.org, Fang, Peter, Gao, Chao,
tony.lindgren@linux.intel.com, Mehta, Sohil, bp@alien8.de,
Maloor, Kishen, yilun.xu@linux.intel.com, x86@kernel.org
On Fri, 2026-12-04 at 14:50 -0400, Jason Gunthorpe wrote:
> On Fri, Dec 04, 2026 at 06:47:52PM +0000, Edgecombe, Rick P wrote:
> > On Fri, 2026-12-04 at 14:40 -0400, Jason Gunthorpe wrote:
> > > On Fri, Dec 04, 2026 at 10:18:21AM -0800, Peter Fang wrote:
> > >
> > > > Sean suggested doing all of this quoting in the guest, with a new
> > > > TDCALL. After some discussion [4] and a follow-up PUCK call on 9/23, the
> > > > consensus was to go back to the host-based design and rely on the
> > > > current GetQuote flow. Quotes signed directly by the S3M are out of
> > > > scope for this series.
> > >
> > > This would certainly match what the other architectures are doing,
> > > maybe explain a bit more why Intel has to be so much more complicated?
> >
> > Heh, which complication in particular are you referring to here?
>
> Well this entire 8 part series, a related VMM series to N VMMs, and a
> VMM/host API to carry it.
>
> Vs.. None of that, like everyone else.
>
> Naively the guest can call into TDX module just fine, so it is worth
> explaining why all this is needed, at least a little bit.
There is a lot of history on this already, as Peter linked. Here was an earlier
writeup on that direction that might be a good jumping off point:
https://lore.kernel.org/kvm/24a751d16ba0dc37aa7774df5739f39734cf9aca.camel@intel.com/
SNP obviously has a much different model on the platform. I guess you are
thinking about ARM? TBH I don't know how their attestation works. If it is
different it would be useful to know why.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote
2026-12-04 18:18 ` [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote Peter Fang
@ 2026-12-04 19:15 ` Dave Hansen
2026-12-04 21:44 ` Adrian Hunter
1 sibling, 0 replies; 15+ messages in thread
From: Dave Hansen @ 2026-12-04 19:15 UTC (permalink / raw)
To: Peter Fang, Dave Hansen, Kiryl Shutsemau, Rick Edgecombe,
Sean Christopherson, Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Adrian Hunter, Kishen Maloor, Nikolay Borisov,
Elena Reshetova
On 12/4/26 10:18, Peter Fang wrote:
> + /* Populate the linked list. Allocate new nodes as needed. */
> + for (int i = 0, pages = 0; pages < num_quote_pages;
> + i = (i + 1) % HPAS_PER_NODE) {
> + if (i == HPAS_PER_NODE - 1) {
> + u64 *new_node = kmalloc(PAGE_SIZE, GFP_KERNEL);
Did a human write this code?
Do the humans on cc like this code?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote
2026-12-04 18:18 ` [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote Peter Fang
2026-12-04 19:15 ` Dave Hansen
@ 2026-12-04 21:44 ` Adrian Hunter
1 sibling, 0 replies; 15+ messages in thread
From: Adrian Hunter @ 2026-12-04 21:44 UTC (permalink / raw)
To: Peter Fang, Dave Hansen, Kiryl Shutsemau, Rick Edgecombe,
Sean Christopherson, Paolo Bonzini
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, linux-kernel, linux-coco, kvm, Xu Yilun,
Jason Gunthorpe, Tony Lindgren, Chao Gao, Xiaoyao Li, Binbin Wu,
Sohil Mehta, Kishen Maloor, Nikolay Borisov, Elena Reshetova,
Bityutskiy, Artem
On 04/12/2026 20:18, Peter Fang wrote:
> +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,
> + u64 *quote_size, u64 *seamcall_err)
> +{
> + int num_quote_pages, num_nodes, ret = 0;
> + u64 *node_head, *node_entry;
> + u64 r;
> +
> + /*
> + * Pass the quote buffer to the TDX module as an HPA linked list. Each
> + * node holds 4KB page HPAs and the last entry points to the next node.
> + */
> + node_head = kmalloc(PAGE_SIZE, GFP_KERNEL);
> + if (!node_head)
> + return -ENOMEM;
> +
> + node_entry = node_head;
> + num_quote_pages = PFN_UP(quote_buf_size);
> + num_nodes = 1;
> +
> + /* Populate the linked list. Allocate new nodes as needed. */
> + for (int i = 0, pages = 0; pages < num_quote_pages;
> + i = (i + 1) % HPAS_PER_NODE) {
> + if (i == HPAS_PER_NODE - 1) {
> + u64 *new_node = kmalloc(PAGE_SIZE, GFP_KERNEL);
> +
> + if (!new_node) {
> + ret = -ENOMEM;
> + goto out_free_nodes;
> + }
> +
> + /* Write the 'next' pointer. */
> + node_entry[i] = __pa(new_node);
> + node_entry = new_node;
> + num_nodes++;
> + continue;
> + }
> +
> + node_entry[i] = page_to_phys(quote_pages[pages]);
> + pages++;
> + }
TDX HPA_LINKED_LIST format is used also by TDX Live Migration, so
it needs to be separate from quote functions.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-12-04 21:44 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 19:15 ` Dave Hansen
2026-12-04 21:44 ` Adrian Hunter
2026-12-04 18:18 ` [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities Peter Fang
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:18 ` [PATCH v3 4/8] KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting Peter Fang
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:18 ` [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension Peter Fang
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox