Skip to content

Enable DICE-based TDX quoting

Peter Fang kvm linux-coco lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v3 Latest8 patches 10 repliesIn review

Changes in v3 from the cover letter

- 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/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] Intel TDX Module Extension for Quoting, February 2026 (draft)
[4] https://lore.kernel.org/all/[email protected]/
[5] https://github.com/peterfang/linux/tree/tdx-host-dice-v3
[6] https://github.com/peterfang/qemu/tree/dice-mock

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8x86/virt/tdx: Add interface to generate a Quotearch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+101 -04 replies
2/8x86/virt/tdx: Add interface to check quoting capabilitiesarch/x86/include/asm/tdx.h arch/x86/include/asm/tdx_global_metadata.h arch/x86/virt/vmx/tdx/tdx.c +1 more+60 -10 replies
3/8KVM: TDX: Require at least one quoting session and thread per CPUarch/x86/kvm/vmx/tdx.c+22 -00 replies
4/8KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quotingarch/x86/include/uapi/asm/kvm.h arch/x86/kvm/vmx/tdx.c arch/x86/kvm/vmx/tdx.h+170 -00 replies
5/8KVM: TDX: Report maximum Quote size in TDX capabilitiesarch/x86/include/uapi/asm/kvm.h arch/x86/kvm/vmx/tdx.c+9 -10 replies
6/8KVM: TDX: Document KVM_TDX_GET_QUOTEDocumentation/virt/kvm/api.rst Documentation/virt/kvm/x86/intel-tdx.rst+58 -100 replies
7/8x86/virt/tdx: Enable the quoting extensionarch/x86/virt/vmx/tdx/tdx.c+1 -10 replies
8/8x86/virt/tdx: Add documentation for DICE-based quotingDocumentation/arch/x86/tdx.rst+17 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/8] Enable DICE-based TDX quoting

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/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

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/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] Intel TDX Module Extension for Quoting, February 2026 (draft)
[4] https://lore.kernel.org/all/[email protected]/
[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

Signature · 1 line
2.53.0