From: Peter Fang <peter.fang@intel.com>
To: Dave Hansen <dave.hansen@linux.intel.com>,
Kiryl Shutsemau <kas@kernel.org>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
"Sean Christopherson" <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>, <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>, <linux-kernel@vger.kernel.org>,
<linux-coco@lists.linux.dev>, <kvm@vger.kernel.org>,
Xu Yilun <yilun.xu@linux.intel.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Tony Lindgren <tony.lindgren@linux.intel.com>,
Chao Gao <chao.gao@intel.com>, Xiaoyao Li <xiaoyao.li@intel.com>,
Binbin Wu <binbin.wu@linux.intel.com>,
Sohil Mehta <sohil.mehta@intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Kishen Maloor" <kishen.maloor@intel.com>,
Nikolay Borisov <nik.borisov@suse.com>,
Elena Reshetova <elena.reshetova@intel.com>,
Peter Fang <peter.fang@intel.com>
Subject: [PATCH v3 0/8] Enable DICE-based TDX quoting
Date: Fri, 4 Dec 2026 10:18:21 -0800 [thread overview]
Message-ID: <20261204182022.324230-1-peter.fang@intel.com> (raw)
Hi,
This is v3 of the host side of DICE-based TDX quoting. It underwent a
redesign after the v2 review and a couple of PUCK discussions, so there
is quite a bit of delta. The biggest changes are keeping userspace in
the GetQuote flow and supporting concurrent quoting. Userspace now
requests a Quote with a new KVM VM ioctl. There is no longer a big lock
serializing TDH.QUOTE.GET calls in the entire system, and as a result
the static global Quote buffer is gone too. The TDX module extensions
part of v2 is now its own series [1]. That series can (re)initialize
quoting implicitly, so the kernel no longer needs TDH.QUOTE.INIT calls.
To keep things simple, only enable quoting when there is no Dynamic
PAMT.
One upside of this redesign is that it keeps the optional use of event
notify interrupts in userspace. Userspace can generate the Quote in a
separate thread, and use event notify to tell the guest when the Quote
is ready. Also, the kernel doesn't have to worry about end-to-end
attestation ABI issues. Userspace decides how quoting should be done, so
a kernel upgrade shouldn't break attestation for TDs on existing
platforms.
Patches 1, 2, 7 and 8 are for tip, and patches 3-6 are for KVM. The plan
is for this series to go through tip, so Sean, I'd appreciate it if you
could take a look at the KVM patches. Jason, this is initial host
enabling only. It doesn't address the guest-side Quote type and labeling
feedback [2].
Background
==========
In TDX attestation, a "Quote" is a TD Report converted into a signed
form that a remote party can verify. To get a Quote, a TD passes its
report to the host using the GetQuote TDVMCALL. Host KVM then exits to
userspace, which sends the report to an SGX quoting enclave. SGX-based
attestation requires per-platform certificates from Intel's servers, so
this needs an extra step to register the platform and fetch the
certificates. Now, TDX modules on newer platforms can generate
DICE-based Quotes themselves. These Quotes carry layered certificate
chains built from the platform, so there is no need for any extra step.
DICE-based quoting runs as a TDX module extension, a separate execution
environment inside the TDX module for long-running work [3]. The TDX
module generates these Quotes itself. Its signing key is certified by
dedicated security hardware like the S3M. The time it takes to generate
this type of Quote using the CPU should be on the order of milliseconds.
Each Quote request consists of a quoting "session" (about 16KB of
memory), which holds its state, and a quoting "thread" (think struct
task_struct or struct kvm_vcpu, about 24KB of memory), which runs the
session. Sessions and threads come from a fixed global pool shared by
all TDs. A Quote request can be interrupted and resumed later, on any
CPU, similar to a preempted task. Once a thread starts a request, it
isn't released back to the pool until the request finishes.
Design
======
With this series, userspace can ask KVM for a Quote, and KVM does the
quoting via a SEAMCALL. The design has two goals:
1. Continue using the existing GetQuote flow, to avoid disturbing the
guest driver.
2. Allow as much concurrency as is reasonable, to minimize
vCPU stalls.
Add a new TDX sub-ioctl, KVM_TDX_GET_QUOTE, to request a Quote from
userspace. It's a VM ioctl because the SEAMCALL needs the TD's TDR page.
To have a stable and maintainable ABI, both the report and the Quote
buffers are page-aligned, so KVM doesn't have to deal with unaligned
data in perpetuity. Userspace should check how big a Quote can be in
KVM_TDX_CAPABILITIES to know how much memory the Quote buffer needs.
Every CPU should be able to generate a Quote at the same time, to avoid
a noisy-neighbor problem between TDs. So when the kernel enables
quoting, KVM requires at least one quoting session and thread per
logical CPU. That takes up about 40KB of TDX module memory per CPU,
adding up to tens of megabytes on a large system. KVM manages the
quoting sessions, and it handles one request per TD at a time. A typical
setup doesn't oversubscribe TDs, meaning there are no more TDs than
logical CPUs. Every TD is then guaranteed to get a session whenever it
asks for a Quote. On an oversubscribed host, userspace sees -EBUSY if
KVM runs out of sessions, and it can retry later. The global session
allocator should add a few microseconds of delay at most, which is
minuscule compared to generating the Quote itself.
A DICE-based Quote can be up to several megabytes in size. When there
are a large number of Quote requests in flight, using bounce buffers
could cost gigabytes of kernel memory on a large system. So KVM uses GUP
to pin the Quote buffer instead. This also helps reduce another
noisy-neighbor problem. When userspace frees its buffer, the TLB
shootdown only hits the CPUs the VMM runs on, whereas a vfree() on the
kernel bounce buffer would eventually trigger a shootdown on every CPU.
As a result, a TD that does aggressive quoting mostly throttles itself.
TDH.QUOTE.GET takes shared locks on the TD, so it doesn't collide with
the other runtime SEAMCALLs, only with the ones that build or tear down
the TD. So, instead of taking KVM's heavy tdx_vm_state_guard, only allow
quoting at runtime, after the TD is finalized. This avoids causing a
build-time SEAMCALL to fail and bug the VM. See patch 4 for more
details.
In order to not break TDX quoting, after a compatible runtime TDX module
update, the module must keep the maximum Quote size the same, and still
support at least one quoting session and thread per logical CPU.
Alternatives considered
=======================
Sean suggested doing all of this quoting in the guest, with a new
TDCALL. After some discussion [4] and a follow-up PUCK call on 9/23, the
consensus was to go back to the host-based design and rely on the
current GetQuote flow. Quotes signed directly by the S3M are out of
scope for this series.
I also considered other ways to manage quoting sessions. sbitmap usually
scales better than an IDA under heavy contention, but that felt like
premature optimization and made the code less intuitive. It also mostly
exists in the storage subsystem. A per-CPU session ID only works if the
whole request is non-preemptible. A per-CPU lock, on the other hand, can
protect each CPU's session, but it can cause unnecessary cross-VM
contention even when there is no oversubscription.
Testing
=======
Tested with a TDX module that mocks the interruptible quoting ABI and
returns a fake Quote. For the userspace side, I used a mocked quoting
service in QEMU. Multiple TDs were able to receive Quotes at the same
time through GetQuote and the new KVM ioctl.
What's in this series
=====================
Patches 1-2 add the core TDX interfaces, and patches 3-6 add the KVM
side of quoting and document the new uABI. Patch 7 then enables
DICE-based quoting, and patch 8 adds documentation for it.
Patch 1/8: Generate a Quote with TDH.QUOTE.GET.
Patch 2/8: Report the TDX module's quoting capabilities.
Patch 3/8: Require a quoting session and thread per logical CPU.
Patch 4/8: Add the KVM_TDX_GET_QUOTE sub-ioctl.
Patch 5/8: Report the maximum Quote size to userspace.
Patch 6/8: Document KVM_TDX_GET_QUOTE.
Patch 7/8: Enable quoting at TDX init.
Patch 8/8: Document DICE-based quoting.
Base
====
This is based on v7.4-rc1, plus v6 of the TDX module extensions series
[1]. You can find the full branch at [5]. A matching QEMU is at [6].
AI use
======
I used AI to polish my code, this cover letter, and the commit messages.
I also used it to collect review feedback and to verify details against
the TDX specs. AI generated the QEMU quoting service used for testing.
The series underwent AI code review, which caught a corner case where
quoting threads could run out and a few TDX documentation bugs. The
other comments were limited to style suggestions.
v2: https://lore.kernel.org/all/20260618081355.3253581-1-yilun.xu@linux.intel.com/
v1: https://lore.kernel.org/all/20260522034128.3144354-1-yilun.xu@linux.intel.com/
Changes in v3:
- Rebase onto v6 of the TDX module extensions series.
- Redesign the Quote generation path. Keep the GetQuote flow unchanged,
and add the KVM_TDX_GET_QUOTE sub-ioctl. [Sean, Rick]
- Redesign the core TDX interface. Drop the global Quote buffer and its
big lock to support concurrent quoting. [Sean, Dave, Rick, Tony]
- Use all-0s as the Quote type instead of all-1s in TDH.QUOTE.GET to
improve code readability. No functional change.
- Drop the tdx_tdr_pa() move (patch 10 in v2) as it's no longer needed.
- Drop TDH.QUOTE.INIT. The TDX module now folds it into TDH.EXT.INIT.
- Drop Rick's, Dan's and Tony's RB tags on the v2 patches, as those
patches were either dropped or changed substantially.
[1] https://lore.kernel.org/all/20261202-tdx-module-ext-v6-0-f6d8510fe498@linux.intel.com/
[2] https://lore.kernel.org/all/3860f37059d4c8807fa588c9f03b3a18e9449cec.camel@intel.com/
[3] Intel TDX Module Extension for Quoting, February 2026 (draft)
[4] https://lore.kernel.org/all/24a751d16ba0dc37aa7774df5739f39734cf9aca.camel@intel.com/
[5] https://github.com/peterfang/linux/tree/tdx-host-dice-v3
[6] https://github.com/peterfang/qemu/tree/dice-mock
Peter Fang (8):
x86/virt/tdx: Add interface to generate a Quote
x86/virt/tdx: Add interface to check quoting capabilities
KVM: TDX: Require at least one quoting session and thread per CPU
KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting
KVM: TDX: Report maximum Quote size in TDX capabilities
KVM: TDX: Document KVM_TDX_GET_QUOTE
x86/virt/tdx: Enable the quoting extension
x86/virt/tdx: Add documentation for DICE-based quoting
Documentation/arch/x86/tdx.rst | 23 ++-
Documentation/virt/kvm/api.rst | 21 ++-
Documentation/virt/kvm/x86/intel-tdx.rst | 47 ++++-
arch/x86/include/asm/tdx.h | 7 +
arch/x86/include/asm/tdx_global_metadata.h | 5 +
arch/x86/include/uapi/asm/kvm.h | 16 +-
arch/x86/kvm/vmx/tdx.c | 180 ++++++++++++++++++++
arch/x86/kvm/vmx/tdx.h | 6 +
arch/x86/virt/vmx/tdx/tdx.c | 125 +++++++++++++-
arch/x86/virt/vmx/tdx/tdx.h | 1 +
arch/x86/virt/vmx/tdx/tdx_global_metadata.c | 26 +++
11 files changed, 438 insertions(+), 19 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
prerequisite-patch-id: 5fbf78c6f40c69edec7a5016c950c35486f3ce81
prerequisite-patch-id: 3be62622e14be3de67212102aebbec7347773946
prerequisite-patch-id: ff98c5e54482da8ba3206ce825b299c29b3ca445
prerequisite-patch-id: 644cf6ce49ea8ed32adbfeba2234265537bc8576
prerequisite-patch-id: 6f9d56b183bb6344776bf837e2ca0d7f648bb81d
prerequisite-patch-id: 52e5e348d4b196e0cf79bb448b4edd6a4d4b4d9a
--
2.53.0
next reply other threads:[~2026-12-04 18:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:18 Peter Fang [this message]
2026-12-04 18:18 ` [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote Peter Fang
2026-12-04 19:15 ` Dave Hansen
2026-12-04 18:18 ` [PATCH v3 2/8] x86/virt/tdx: Add interface to check quoting capabilities Peter Fang
2026-12-04 18:18 ` [PATCH v3 3/8] KVM: TDX: Require at least one quoting session and thread per CPU Peter Fang
2026-12-04 18:18 ` [PATCH v3 4/8] KVM: TDX: Add KVM_TDX_GET_QUOTE sub-ioctl for quoting Peter Fang
2026-12-04 18:18 ` [PATCH v3 5/8] KVM: TDX: Report maximum Quote size in TDX capabilities Peter Fang
2026-12-04 18:18 ` [PATCH v3 6/8] KVM: TDX: Document KVM_TDX_GET_QUOTE Peter Fang
2026-12-04 18:18 ` [PATCH v3 7/8] x86/virt/tdx: Enable the quoting extension Peter Fang
2026-12-04 18:18 ` [PATCH v3 8/8] x86/virt/tdx: Add documentation for DICE-based quoting Peter Fang
2026-12-04 18:40 ` [PATCH v3 0/8] Enable DICE-based TDX quoting Jason Gunthorpe
2026-12-04 18:47 ` Edgecombe, Rick P
2026-12-04 18:50 ` Jason Gunthorpe
2026-12-04 19:11 ` Edgecombe, Rick P
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204182022.324230-1-peter.fang@intel.com \
--to=peter.fang@intel.com \
--cc=adrian.hunter@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=elena.reshetova@intel.com \
--cc=hpa@zytor.com \
--cc=jgg@nvidia.com \
--cc=kas@kernel.org \
--cc=kishen.maloor@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nik.borisov@suse.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=sohil.mehta@intel.com \
--cc=tglx@kernel.org \
--cc=tony.lindgren@linux.intel.com \
--cc=x86@kernel.org \
--cc=xiaoyao.li@intel.com \
--cc=yilun.xu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox