Skip to content

Enable DICE-based TDX Quoting Extension

Xu Yilun kvm linux-coco lkml sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest17 patches 87 repliesIn review

Changes in v2 from the cover letter

- Support runtime TDX module update
- Refine quoting patches, drop RFC tag
- Change the patch order. (Xiaoyao & Tony)
- Fold metadata readings changes into patches that use them.
- Read the extensions metadata at init_tdx_ext() (Rick & Xiaoyao)
- Don't do get_tdx_sys_info() a 2nd time after TDH.SYS.CONFIG (Rick & Xiaoyao)
- Delete tdx_clflush_hpa_list() (Rick)
- s/TDX Module/TDX module (Sohil)
- s/Extensions/extensions (Dave)
- Change the data type of ext_required to bool (Rick)
- Change the data type of memory_pool_required_pages from u16 to u32, the Module team see this problem and promise the change (Sohil)
- s/init_tdx_ext()/init_tdx_module_extensions() to disambiguate from tdx_ext_init() (Kishen)
- Cover-letter & change log re-phrase (All reviewers)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17x86/virt/tdx: Embed version info in SEAMCALL leaf function definitionsarch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+15 -112 replies
2/17x86/virt/tdx: Configure add-on features on TDX module init and updatearch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+30 -411 replies
3/17x86/virt/tdx: Detect if the extensions initialization is requiredarch/x86/include/asm/tdx.h arch/x86/include/asm/tdx_global_metadata.h arch/x86/virt/vmx/tdx/tdx.c +1 more+44 -014 replies
4/17x86/virt/tdx: Add extra memory to TDX module for the extensionsarch/x86/include/asm/tdx_global_metadata.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h +1 more+112 -35 replies
5/17x86/virt/tdx: Make TDX module initialize the extensionsarch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+22 -13 replies
6/17x86/virt/tdx: Re-initialize the extensions on runtime TDX module updatearch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx_global_metadata.c+31 -29 replies
7/17x86/virt/tdx: Initialize Quoting extensionarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+35 -13 replies
8/17x86/virt/tdx: Prepare Quote buffer during extension bringuparch/x86/include/asm/tdx_global_metadata.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx_global_metadata.c+129 -46 replies
9/17x86/virt/tdx: Add interface to check Quoting availabilityarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c+12 -01 reply
10/17x86/virt/tdx: Move tdx_tdr_pa() up in the filearch/x86/virt/vmx/tdx/tdx.c+5 -51 reply
11/17x86/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+80 -03 replies
12/17x86/virt/tdx: Reinitialize the Quoting extension after TDX module updatearch/x86/virt/vmx/tdx/tdx.c+28 -33 replies
13/17x86/virt/tdx: Enable Quoting extensionarch/x86/virt/vmx/tdx/tdx.c+2 -41 reply
14/17x86/tdx: Move and rename Quote request structurearch/x86/include/asm/tdx.h drivers/virt/coco/tdx-guest/tdx-guest.c+34 -331 reply
15/17KVM: TDX: Factor out userspace return path from tdx_get_quote()arch/x86/kvm/vmx/tdx.c+16 -91 reply
16/17KVM: TDX: Add in-kernel Quote generationDocumentation/arch/x86/tdx.rst Documentation/virt/kvm/api.rst arch/x86/include/asm/tdx.h +3 more+163 -1021 replies
17/17KVM: TDX: Support event-notify interrupts only with userspace Quotingarch/x86/kvm/vmx/tdx.c+17 -32 replies

Reviews trailers per patch

8 of 17 patches have a Reviewed-by or Acked-by.

PatchXiaoyao LiTony LindgrenAdrian HunterRick EdgecombeDan Williams
1/17
2/17
3/17R-b
4/17
5/17R-b R-b R-b
6/17
7/17
8/17
9/17R-b
10/17R-b R-b
11/17
12/17R-b
13/17R-b
14/17R-b R-b
15/17R-b
16/17
17/17

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/17] Enable DICE-based TDX Quoting Extension

This series adds infrastructure to enable TDX module extensions and then implements DICE-based TDX Quoting extension. This is the 2nd version and a significant change is that we want the quoting part to merge along with the basic TDX module extensions part, rather than serving as an example. So the quoting part drops RFC tags and requires initial review. The basic extensions part addresses v1 comments and needs more detailed review.

The quoting part contains some KVM patches, so we sorted the series for easier review and pick:

  Patches  1-6:  Enable the TDX module extensions support
  Patches  7-14: DICE-based TDX Quoting, x86/tdx part
  Patches  15-N: DICE-based TDX Quoting, KVM part

== Overview ==

To date, SEAMCALLs have been short lived routines that monopolize the CPU for their duration. This limits their utility for implementing higher order security protocols, or pushes complexity into Linux - such as by fragmenting a protocol setup service into several SEAMCALLs. The Linux appetite for ingesting complexity is low, so TDX now adds a new class of SEAMCALLs that are preemptible and resumable. This capability allows for higher-level API constructions - like "create a DICE-based quote" - which are more aligned to what is a good fit for Linux.

This new "extension SEAMCALL" capability is akin to ARM CCA's "Stateful RMI Operations (SRO)", and achieves similar externalized complexity relief as a dedicated hardware co-processor like AMD SEV-SNP. The mechanism is "give the service environment some memory", "invoke the service API", and "continue invoking until complete". All protocol state is internal to the service API.

TDX introduces "TDX module extensions" as the service environment for some add-on features - such as DICE-based quoting, TDISP, and live migration - to use "extension SEAMCALLs".

The extension SEAMCALLs are designed to be transparent to the host, using the same interface as normal SEAMCALLs, but the service environment should be initialized in several steps. First, configure/select (via TDH.SYS.CONFIG) add-on features during basic TDX initialization. Second, check if TDX module extensions are required to support these add-on features by reading TDX global metadata. Third, add extra memory to the TDX module via a SEAMCALL (TDH.EXT.MEM.ADD). Finally, use another SEAMCALL (TDH.EXT.INIT) to initialize the extensions.

== DICE-based Quoting extension ==

The first feature to use these extensions is the TDX Quoting extension [1], which converts guest launch attestation reports into a document that can be verified externally.

Today, the TDX host requires a separate software service to generate Quotes. The Quoting extension allows the TDX module to generate Quotes directly, without relying on a discrete Quoting engine. This simplifies the overall attestation flow: KVM no longer needs to return to userspace for Quote generation. Instead, Quote generation is handled directly by the TDX module through an extension SEAMCALL. See [2] for an overview of TDX attestation.

The Device Identifier Composition Engine ("DICE") provides a standardized framework for layering attestation evidence. It replaces SGX-based attestation and moves away from Intel-proprietary formats. It also eliminates the SGX requirement to contact an Intel service to obtain a certificate first. Instead, all attestation evidence is embedded in the Quote itself.

== The trade-off ==

The extensions create an extension instance for each feature that requires extension SEAMCALLs. More memory is consumed when more extension instances are created. There are 3 extensions (quoting, TDISP, Migration) in the foreseeable future. Turning on them all will require tens of megabytes. Note that the host can never reclaim the memory added to the extensions.

According to the TDX module design, basic TDX functionalities can run without the extensions. So theoretically the extensions don't need to be enabled at basic TDX initialization time. They could be lazily enabled right before the first extension SEAMCALL is issued.

However, Linux applies a simple policy for TDX: turn on all the features that Linux knows about all the time, unless and until any evidence makes this approach untenable. Enabling the extensions along with the basic TDX at boot time aligns with the policy, and offers several good reasons:

1. Simplify TDX state management, avoid runtime state transitions that could introduce race conditions or unexpected failure modes.

2. The kernel doesn't have to keep track of which SEAMCALLs need the extensions, as there is no HW/FW enumeration for this.

3. When no extension is configured, the extensions initialization is virtually skipped. So no impact on existing kernels.

4. A small trade-off is that eager initialization allocates memory (tens of megabytes) at boot time before any feature starts to work. However, these features provide critical security capabilities in confidential computing. They are expected to be enabled eventually when available. So this merely advances the timing of memory allocation.

== Restore the extensions after runtime TDX module update ==

Runtime TDX module update introduces a mechanism to update the module firmware while preserving and restoring TDX operations. As part of the restoration process, TDX module extensions must also be re-initialized to re-enable extension SEAMCALLs.

Similar to TDH.SYS.CONFIG, TDX module extends TDH.SYS.UPDATE with more parameters for the host to re-enable desired add-on features. Then host must re-execute all extensions initialization steps to restore extension SEAMCALL functionality.

However, Linux runs the update in stop_machine() context, which prevents memory allocation. This introduces a hard restriction that the updated TDX environment must not consume more memory for the extensions.

Fortunately, Linux applies another policy that no newer features should be added during runtime update to avoid disrupting live TDX operations. To adhere to this, TDH.SYS.UPDATE must enable the same features as the TDH.SYS.CONFIG. This policy mitigates the memory allocation problem a lot by minimizing the chance of increased memory demand. So now the restriction only affects the compatibility rule for choosing the update image.

The same memory constraint applies to the Quoting extension. A compatible runtime update must not increase the size limit of its Quotes, because the buffer used for Quote generation is allocated during TDX bringup. Otherwise, attestation could fail after the update if the TDX module requires a larger buffer for Quotes.

== Some history ==

The TDX module extensions support part was first posted along with TDX TDISP [3]. But quoting is the simplest consumer and is chosen as the lead vehicle over TDISP.

== Misc ==

This series is based on tip/x86/tdx [4], because we need the extensions play nice with runtime TDX module update.

== Changelog ==

v2:
- Support runtime TDX module update
- Refine quoting patches, drop RFC tag
- Change the patch order. (Xiaoyao & Tony)
- Fold metadata readings changes into patches that use them.
- Read the extensions metadata at init_tdx_ext() (Rick & Xiaoyao)
- Don't do get_tdx_sys_info() a 2nd time after TDH.SYS.CONFIG (Rick & Xiaoyao)
- Delete tdx_clflush_hpa_list() (Rick)
- s/TDX Module/TDX module (Sohil)
- s/Extensions/extensions (Dave)
- Change the data type of ext_required to bool (Rick)
- Change the data type of memory_pool_required_pages from u16 to u32, the Module team see this problem and promise the change (Sohil)
- s/init_tdx_ext()/init_tdx_module_extensions() to disambiguate from tdx_ext_init() (Kishen)
- Cover-letter & change log re-phrase (All reviewers)

v1: https://lore.kernel.org/all/[email protected]/

Peter Fang (11):
x86/virt/tdx: Initialize Quoting extension
x86/virt/tdx: Prepare Quote buffer during extension bringup x86/virt/tdx: Add interface to check Quoting availability x86/virt/tdx: Move tdx_tdr_pa() up in the file x86/virt/tdx: Add interface to generate a Quote x86/virt/tdx: Reinitialize the Quoting extension after TDX module
update
x86/virt/tdx: Enable Quoting extension
x86/tdx: Move and rename Quote request structure
KVM: TDX: Factor out userspace return path from tdx_get_quote()
KVM: TDX: Add in-kernel Quote generation
KVM: TDX: Support event-notify interrupts only with userspace Quoting

Xu Yilun (6):
x86/virt/tdx: Embed version info in SEAMCALL leaf function definitions x86/virt/tdx: Configure add-on features on TDX module init and update x86/virt/tdx: Detect if the extensions initialization is required x86/virt/tdx: Add extra memory to TDX module for the extensions x86/virt/tdx: Make TDX module initialize the extensions x86/virt/tdx: Re-initialize the extensions on runtime TDX module
update

 Documentation/arch/x86/tdx.rst              |  19 +-
 Documentation/virt/kvm/api.rst              |   3 +
 arch/x86/include/asm/tdx.h                  |  35 ++
 arch/x86/include/asm/tdx_global_metadata.h  |   9 +
 arch/x86/kvm/vmx/tdx.h                      |   6 +
 arch/x86/virt/vmx/tdx/tdx.h                 |  33 +-
 arch/x86/kvm/vmx/tdx.c                      | 176 +++++++-
 arch/x86/virt/vmx/tdx/tdx.c                 | 465 +++++++++++++++++++-
 arch/x86/virt/vmx/tdx/tdx_global_metadata.c |  34 ++
 drivers/virt/coco/tdx-guest/tdx-guest.c     |  47 +-
 virt/kvm/kvm_main.c                         |   1 +
 11 files changed, 755 insertions(+), 73 deletions(-)

base-commit: 2b9ad7a6154e0938b9458691536296dd0224942d

Signature · 1 line
2.25.1