* [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 18:36 ` sashiko-bot
` (2 more replies)
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, 3 replies; 23+ 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] 23+ 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 18:36 ` sashiko-bot
2026-12-04 19:15 ` Dave Hansen
2026-12-04 21:44 ` Adrian Hunter
2 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-12-04 18:36 UTC (permalink / raw)
To: Peter Fang; +Cc: kvm
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] x86/virt/tdx: uninit HPA list nodes and tail read in
tdx_quote_generate()
- [Medium] x86/virt/tdx: missing cond_resched() in tdx_quote_get() retry
loop
--
commit 822505db95798a7ae7ce913170aae5958aefcee1
Author: Peter Fang <peter.fang@intel.com>
x86/virt/tdx: Add interface to generate a Quote
This commit adds tdx_quote_generate() and a TDH.QUOTE.GET SEAMCALL wrapper so
KVM can request a signed TDX Quote using caller-provided host pages.
> 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)
> +{
[ ... ]
> + do {
> + r = seamcall_ret(TDH_QUOTE_GET, &args);
> + } while (r == TDX_INTERRUPTED_RESUMABLE);
[Severity: Medium]
Should this retry loop call cond_resched()?
seamcall_ret() only calls preempt_enable(), which does not reschedule on
CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY kernels. In sleepable
runtime context, spinning across TDX_INTERRUPTED_RESUMABLE retries can starve
other tasks and delay RCU quiescent states, unlike init_tdmr().
[ ... ]
> +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);
> + }
[Severity: Medium]
Can node_head and new_node pass uninitialized slab memory to TDH_QUOTE_GET
and read an uninitialized next pointer in out_free_nodes?
Both allocations use kmalloc() instead of kzalloc(), and the loop only sets
entries for pages < num_quote_pages and the next pointer when chaining a new
node. Unused trailing HPA slots and the final node's next pointer remain
uninitialized, which can cause TDH_QUOTE_GET to fail or walk bad addresses.
The final iteration of out_free_nodes also unconditionally reads
node_head[HPAS_PER_NODE - 1] on every call, including -ENOMEM, triggering an
uninitialized heap read. Allocating nodes with kzalloc() and skipping the
next-pointer read on the last node avoids both issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204182022.324230-1-peter.fang@intel.com?part=1
^ permalink raw reply [flat|nested] 23+ 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 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
2 siblings, 1 reply; 23+ 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] 23+ messages in thread* Re: [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote
2026-12-04 19:15 ` Dave Hansen
@ 2026-12-04 22:02 ` Edgecombe, Rick P
0 siblings, 0 replies; 23+ messages in thread
From: Edgecombe, Rick P @ 2026-12-04 22:02 UTC (permalink / raw)
To: pbonzini@redhat.com, Hansen, Dave, kas@kernel.org, Fang, Peter,
dave.hansen@linux.intel.com, seanjc@google.com
Cc: kvm@vger.kernel.org, Li, Xiaoyao, linux-coco@lists.linux.dev,
Hunter, Adrian, Reshetova, Elena, linux-kernel@vger.kernel.org,
mingo@redhat.com, binbin.wu@linux.intel.com,
tony.lindgren@linux.intel.com, jgg@nvidia.com,
nik.borisov@suse.com, hpa@zytor.com, Mehta, Sohil,
tglx@kernel.org, Gao, Chao, bp@alien8.de, Maloor, Kishen,
yilun.xu@linux.intel.com, x86@kernel.org
On Fri, 2026-12-04 at 11:15 -0800, Dave Hansen wrote:
> 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?
Oh this is horrible. Was the intention to address this from Nikolay?
https://lore.kernel.org/lkml/d13c4073-b248-40ac-aa28-1c0dfc6b9043@suse.com/#t
I don't think this is what he meant, but actually I'm not sure what he did.
^ permalink raw reply [flat|nested] 23+ 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 18:36 ` sashiko-bot
2026-12-04 19:15 ` Dave Hansen
@ 2026-12-04 21:44 ` Adrian Hunter
2026-12-04 22:04 ` Edgecombe, Rick P
2 siblings, 1 reply; 23+ 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] 23+ messages in thread* Re: [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote
2026-12-04 21:44 ` Adrian Hunter
@ 2026-12-04 22:04 ` Edgecombe, Rick P
0 siblings, 0 replies; 23+ messages in thread
From: Edgecombe, Rick P @ 2026-12-04 22:04 UTC (permalink / raw)
To: pbonzini@redhat.com, Hunter, Adrian, kas@kernel.org, Fang, Peter,
dave.hansen@linux.intel.com, seanjc@google.com
Cc: kvm@vger.kernel.org, Li, Xiaoyao, linux-coco@lists.linux.dev,
Reshetova, Elena, linux-kernel@vger.kernel.org, mingo@redhat.com,
binbin.wu@linux.intel.com, tony.lindgren@linux.intel.com,
jgg@nvidia.com, nik.borisov@suse.com, hpa@zytor.com, Mehta, Sohil,
tglx@kernel.org, Gao, Chao, bp@alien8.de, Bityutskiy, Artem,
Maloor, Kishen, yilun.xu@linux.intel.com, x86@kernel.org
On Fri, 2026-12-04 at 23:44 +0200, Adrian Hunter wrote:
> 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.
No thanks. We can refactor when we get to the migration patches if appropriate
when that stuff is getting reviewed.
^ permalink raw reply [flat|nested] 23+ 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: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
` (6 subsequent siblings)
8 siblings, 1 reply; 23+ 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] 23+ messages in thread* Re: [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities
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
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-12-04 18:44 UTC (permalink / raw)
To: Peter Fang; +Cc: kvm
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 <peter.fang@intel.com>
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);
>
> +/*
> + * 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;
[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 = sysinfo_quote.max_quote_size;
> + *num_sessions = sysinfo_quote.num_sessions;
> + *num_threads = 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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204182022.324230-1-peter.fang@intel.com?part=2
^ permalink raw reply [flat|nested] 23+ 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: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
` (5 subsequent siblings)
8 siblings, 1 reply; 23+ 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] 23+ messages in thread* Re: [PATCH v3 3/8] KVM: TDX: Require at least one quoting session and thread per CPU
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
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-12-04 18:44 UTC (permalink / raw)
To: Peter Fang; +Cc: kvm
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: TDX: quoting checks return -EINVAL and abort kvm-intel
load
--
commit ad2ff9af18e518d36b330f0d2e71d20814ddc017
Author: Peter Fang <peter.fang@intel.com>
KVM: TDX: Require at least one quoting session and thread per CPU
This commit checks that the TDX-Module provides at least as many quoting
sessions and threads as present logical CPUs when quoting is enabled,
returning -EINVAL from __tdx_hardware_setup() if either count is too
small.
Link: https://lore.kernel.org/all/arRXqpG_4hCrhQLM@intel.com/ # [1]
Link: https://lore.kernel.org/all/DS4PPFA84FA90FC58F88D79B0EF19B34596E7832@DS4PPFA84FA90FC.namprd11.prod.outlook.com/ # [2]
> 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
[ ... ]
> @@ -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;
> + }
> + }
[Severity: Medium]
Does returning -EINVAL here abort kvm-intel loading instead of only
disabling TDX?
In tdx_hardware_setup(), only -ENODEV from __tdx_hardware_setup() jumps
to success_disable_tdx to clear enable_tdx and return 0. Any other
error propagates through vt_hardware_setup() -> kvm_x86_vendor_init()
and fails kvm-intel loading, breaking regular VMX guests as well.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204182022.324230-1-peter.fang@intel.com?part=3
^ permalink raw reply [flat|nested] 23+ 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:51 ` sashiko-bot
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, 1 reply; 23+ 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] 23+ messages in thread* Re: [PATCH v3 4/8] KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting
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
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-12-04 18:51 UTC (permalink / raw)
To: Peter Fang; +Cc: kvm
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] KVM: TDX: unzeroed report page and zero report_size in
tdx_td_get_quote()
- [Medium] KVM: TDX: contiguous kmalloc_objs() for quote_pages in
tdx_td_get_quote()
- [Medium] KVM: TDX: pin_user_pages_fast() errors overwritten in
tdx_td_get_quote()
- [Medium] KVM: TDX: clean quote pages dirtied on ida_alloc_range()
failure
- [Medium] x86/virt/tdx: uninitialized HPA list memory read in
tdx_quote_generate()
- [Low] KVM: TDX: unmarked race on kvm_tdx->state in tdx_td_get_quote()
--
commit 526e1862a4da2b03176c7fc18e3c7f4437ef1528
Author: Peter Fang <peter.fang@intel.com>
KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting
This commit adds the KVM_TDX_GET_QUOTE VM sub-ioctl so userspace can
request a DICE-based Quote directly from the TDX module for a finalized
TD. It serializes quoting per TD with a mutex, limits concurrent
sessions across TDs using an IDA bounded by num_present_cpus(), and pins
the userspace quote buffer with GUP.
Link: https://lore.kernel.org/all/20260211001712.1531955-1-sathyanarayanan.kuppuswamy@linux.intel.com/ # [1]
> 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
[ ... ]
> @@ -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)
> +{
[ ... ]
> + if (kvm_tdx->state != TD_STATE_RUNNABLE)
> + return -EINVAL;
[Severity: Low]
Can this unmarked read of kvm_tdx->state trigger KCSAN data-race reports?
Because KVM_TDX_GET_QUOTE bypasses tdx_vm_state_guard, a concurrent thread
running KVM_TDX_INIT_VM (tdx_td_init()) or KVM_TDX_FINALIZE_VM
(tdx_td_finalize()) on the same VM fd can write kvm_tdx->state at the same
time. The VFS file-reference ordering only synchronizes sequential ioctls,
not concurrent ones.
Pairing READ_ONCE(kvm_tdx->state) here with WRITE_ONCE() on the state
transitions avoids the data race.
[ ... ]
> + /* 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;
> + }
[Severity: Medium]
Does this pass uninitialized kernel slab memory in the tail of report to
the TDX module?
For a standard 1024-byte TDREPORT, copy_from_user() leaves the remaining
3072 bytes of the kmalloc() page uninitialized when virt_to_page(report) is
handed to tdx_quote_generate().
Also, gq.report_size == 0 is not rejected here (unlike !gq.quote_buf_size
below), so report_uaddr == 0 with report_size == 0 bypasses
copy_from_user() and proceeds to pin pages, take a quoting session, run
TDH.QUOTE.GET on an uninitialized page, and dirty the quote buffer.
Rejecting !gq.report_size with -EINVAL and allocating report with
kzalloc(PAGE_SIZE, GFP_KERNEL) addresses both issues.
[ ... ]
> + 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;
> + }
[Severity: Medium]
Should quote_pages use kvmalloc_objs() and kvfree() instead of
kmalloc_objs()?
DICE quotes can reach several megabytes (for example, a 16-32 MB quote
needs a 32-64 KB order-3 or order-4 physically contiguous array), which can
cause direct reclaim stalls or spurious -ENOMEM failures on fragmented TDX
hosts. quote_pages is only iterated in software, so physical contiguity is
unnecessary (compare sev_pin_memory() in arch/x86/kvm/svm/sev.c).
> +
> + 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;
> + }
[Severity: Medium]
Should this preserve negative error codes from pin_user_pages_fast()
instead of unconditionally returning -ENOMEM?
When userspace passes an unmapped, read-only, or wrapping quote_buf_uaddr,
pin_user_pages_fast() returns -EFAULT or -EOVERFLOW (or a short count on a
partial failure), which is overwritten with -ENOMEM here. Setting
ret = ret < 0 ? ret : -EFAULT preserves the underlying error and matches
copy_from_user() and put_user() in this function.
> +
> + /*
> + * 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);
[Severity: Medium]
Does tdx_quote_generate() read uninitialized slab memory on every call?
In commit "x86/virt/tdx: Add interface to generate a Quote",
tdx_quote_generate() allocates node_head and each chained new_node with
kmalloc(PAGE_SIZE, GFP_KERNEL), only writing node_entry[HPAS_PER_NODE - 1]
when allocating a subsequent node:
arch/x86/virt/vmx/tdx/tdx.c:tdx_quote_generate() {
...
node_head = kmalloc(PAGE_SIZE, GFP_KERNEL);
...
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);
}
}
On the final cleanup iteration (and on mid-loop allocation failure),
out_free_nodes unconditionally passes the never-written terminal
next-pointer slot to __va(), triggering KMSAN uninitialized-value reports.
The unused trailing HPA slots and terminal next pointer in the final node
are also passed uninitialized to TDH.QUOTE.GET.
Allocating the HPA list nodes with kzalloc(PAGE_SIZE, GFP_KERNEL) and only
reading the next pointer when i + 1 < num_nodes fixes both issues.
> +
> + 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);
[Severity: Medium]
Should this avoid dirtying quote_pages when ida_alloc_range() fails?
When TDs are oversubscribed and ida_alloc_range() returns -ENOSPC
(converted to -EBUSY), the jump to out_unpin_quote passes make_dirty = true
even though tdx_quote_generate() never ran. That acquires folio_lock() and
marks dirty every clean folio in the multi-megabyte buffer on every -EBUSY
retry, causing unnecessary contention and writeback on file-backed
mappings.
Allocating the session ID before pinning quote_pages, or unpinning without
dirtying when tdx_quote_generate() was not called, avoids this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204182022.324230-1-peter.fang@intel.com?part=4
^ permalink raw reply [flat|nested] 23+ 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; 23+ 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] 23+ 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:36 ` sashiko-bot
2026-12-04 18:18 ` [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension Peter Fang
` (2 subsequent siblings)
8 siblings, 1 reply; 23+ 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] 23+ messages in thread* Re: [PATCH v3 6/8] KVM: TDX: Document KVM_TDX_GET_QUOTE
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
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-12-04 18:36 UTC (permalink / raw)
To: Peter Fang; +Cc: kvm
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] KVM: TDX: KVM_TDX_GET_QUOTE misdocuments hw_error as must be 0
(out)
- [Low] KVM: TDX: KVM_TDX_GET_QUOTE quote_buf_size minimum not enforced
in code
--
commit 42ca18a6ac06953778ef9347240a920d55d409db
Author: Peter Fang <peter.fang@intel.com>
KVM: TDX: Document KVM_TDX_GET_QUOTE
This commit documents the KVM_TDX_GET_QUOTE VM ioctl and its
quote_max_size capability field in
Documentation/virt/kvm/x86/intel-tdx.rst, and updates the
TDVMCALL_GET_QUOTE description in Documentation/virt/kvm/api.rst.
> 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
[ ... ]
> @@ -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.
[Severity: Low]
Does tdx_td_get_quote() actually enforce that quote_buf_size is at least
quote_max_size?
tdx_td_get_quote() clamps quote_buf_size to max_quote_size with umin()
and only returns -EINVAL when it is zero. A smaller non-zero buffer is
passed to tdx_quote_generate() and may succeed or fail with -EIO, while
larger values are silently capped.
Either tdx_td_get_quote() should reject quote_buf_size < max_quote_size,
or the documentation should state that quote_buf_size must be non-zero,
should be at least quote_max_size to guarantee the Quote fits, and is
capped at quote_max_size.
Also, tdx_td_get_quote() rejects non-zero reserved[27] in struct
kvm_tdx_get_quote with -EINVAL, which is not mentioned here.
[ ... ]
> +- 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)
[Severity: Low]
Should hw_error be documented as an in/out field that must be 0 on input
and returns the TDX SEAMCALL status code on output?
tdx_get_cmd() returns -EINVAL if cmd->hw_error is non-zero on input.
tdx_td_get_quote() -> tdx_quote_generate() then writes the TDH.QUOTE.GET
SEAMCALL status code to cmd->hw_error (returning -EIO on failure), and
tdx_vm_ioctl() copies it back to userspace.
Documenting it as "must be 0 (out)" could mislead userspace into not
zeroing hw_error on input or ignoring the returned SEAMCALL status on
-EIO.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204182022.324230-1-peter.fang@intel.com?part=6
^ permalink raw reply [flat|nested] 23+ 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: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
8 siblings, 1 reply; 23+ 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] 23+ messages in thread* Re: [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension
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
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-12-04 18:52 UTC (permalink / raw)
To: Peter Fang; +Cc: kvm
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
^ permalink raw reply [flat|nested] 23+ 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; 23+ 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] 23+ 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; 23+ 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] 23+ 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; 23+ 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] 23+ 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; 23+ 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] 23+ 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; 23+ 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] 23+ messages in thread