tdx-guest: Make Quote buffer size dynamic
Status from this message: The following commit has been merged into the x86/tdx branch of tip:
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v6 Latest6 patches 6 repliesApplied
- v56 patches 33 repliesSuperseded
- v44 patches 24 repliesSuperseded
Earlier versions · 3
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v3 | 4 patches | 49 replies | Superseded | |
| v2 | 2 patches | 11 replies | Superseded | |
| v1 | 2 patches | 18 replies | Superseded |
Changes in v6 from the cover letter
- Rebase onto tip/x86/tdx.
- Use struct_size()/struct_size_t() directly, without the macro. [Dave]
- Don't cache the Quote buffer size in the helper. [Rick]
- Let the callers page-align the Quote buffer size. [Rick]
- Add a comment for the Quote buffer size helper. [Dave]
- Document that the reported size is fixed. [Dave, Rick]
- Improve comments and changelogs. [Dave, Rick, Binbin]
- Add Reviewed-by tags to patches 1 and 2. [Rick, Sathya, Binbin]
Patches in v6 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | x86/tdx: Take the Quote buffer as a generic pointerarch/ arch/ | +2 | 0 replies | |
| 2/6 | virt: tdx-guest: Give the Quote buffer an explicit typedrivers/ | +17 | 0 replies | |
| 3/6 | virt: tdx-guest: Calculate the Quote buffer size safelydrivers/ | +1 | 0 replies | |
| 4/6 | virt: tdx-guest: Add a helper for the Quote buffer sizedrivers/ | +21 | 3 replies | |
| 5/6 | x86/tdx: Add a helper to query maximum Quote sizearch/ arch/ arch/ | +19 | 0 replies | |
| 6/6 | virt: tdx-guest: Make the Quote buffer size dynamicarch/ drivers/ | +15 | 1 reply |
Reviews trailers per patch
3 of 6 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Kuppuswamy Sathyanarayanan | Tony Lindgren | Xiaoyao Li | Binbin Wu | Kiryl Shutsemau (Meta) | Rick Edgecombe |
|---|---|---|---|---|---|---|
| Series | R-b | |||||
| 1/6 | R-b | |||||
| 2/6 | R-b | R-b | R-b | |||
| 3/6 | R-b | R-b | R-b | R-b | R-b | |
| 4/6 | ||||||
| 5/6 | ||||||
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.
Cover letter [PATCH v6 0/6] tdx-guest: Make Quote buffer size dynamic
Hi,
This is a quick v6 of the dynamic Quote buffer size series. It mainly simplifies the buffer size helper. It no longer caches the size in a static variable and leaves the page alignment decision to the callers. So overall this version adds fewer LOC (7 lines fewer).
The no-cache implementation is based on the expectation that the TDX module always reports the same size limit. So there is no need to do defensive programming against it. If the host somehow manages to load a broken TDX module, the guest is already compromised.
Another behavioral change versus v5 is in the existing -EFBIG defense against a weird data size (introduced in [1]). v5 uses the page-aligned buffer size for the check, while v6 uses the actual maximum size without the page padding. Even though v5 doesn't cause the kernel to expose an innocent page, v6 is the more correct behavior. Thanks to Rick for calling out the page alignment issues [2].
Newer TDX modules have an ABI that tells the guest how big a Quote can get. The Quote buffer no longer has to be a fixed size. So effectively:
s/FIXED_BUF_SIZE/queried_buf_size/
... in the TDX guest driver.
Terminology
===========
A "TD Quote" is an attestation structure signed with a platform key. It contains information about a TDX guest and the platform it's running on.
The "Quote buffer" in the TDX guest driver is a memory buffer shared between the TDX guest and the host VMM to retrieve TD Quotes. It has a header defined in the GHCI spec [3].
Device Identifier Composition Engine ("DICE") provides a framework for layering attestation evidence. This replaces the SGX model of contacting an Intel server to obtain a certificate.
Problem
=======
The fixed-size Quote buffer approach is not sustainable. As cryptographic algorithms evolve, TD Quote sizes also grow. A previous commit [4] increased the guest driver's fixed-size Quote buffer to 128KB to accommodate DICE Quotes, but it may still be insufficient when those Quotes use post-quantum cryptography (PQC). PQC certificate chains are roughly 10x-15x larger than conventional ones, which can increase Quote sizes significantly.
What's in this series
=====================
To avoid changing the driver whenever the Quote buffer becomes too small, newer TDX modules report their largest possible Quote size via a metadata field [5]. The guest driver uses this value, plus room for the header, for its Quote buffer when available. Older TDX modules continue to use the 128KB buffer.
Patches 1-4 refactor the existing fixed buffer handling. Patch 5 adds a helper to query the new metadata field, and patch 6 then makes the buffer size dynamic.
Patch 1/6: Take the Quote buffer as a generic pointer.
Patch 2/6: Give the Quote buffer an explicit type.
Patch 3/6: Calculate the Quote buffer size with struct_size(). Patch 4/6: Read the Quote buffer size from a helper.
Patch 5/6: Add a helper to read the QUOTE_MAX_SIZE metadata field. Patch 6/6: The final s/FIXED_BUF_SIZE/queried_buf_size/, when available.
Base
====
This is based on tip/x86/tdx.
AI use
======
I used AI to help edit this cover letter and the changelogs, and to collect and apply the review feedback on lore under my supervision. The series also underwent AI code review. In v6, it caught a missing page alignment for the GetQuote hypercall. The other comments were limited to style suggestions and existing issues. Sashiko's __GFP_NOWARN suggestion was adopted in v2, but it was dropped in v3.
v5: https://lore.kernel.org/all/[email protected]/
Changes in v6:
- Rebase onto tip/x86/tdx.
- Use struct_size()/struct_size_t() directly, without the macro. [Dave]
- Don't cache the Quote buffer size in the helper. [Rick]
- Let the callers page-align the Quote buffer size. [Rick]
- Add a comment for the Quote buffer size helper. [Dave]
- Document that the reported size is fixed. [Dave, Rick]
- Improve comments and changelogs. [Dave, Rick, Binbin]
- Add Reviewed-by tags to patches 1 and 2. [Rick, Sathya, Binbin]
v4: https://lore.kernel.org/all/[email protected]/
Changes in v5:
- Give the Quote buffer an explicit type. [Dave]
- Replace the quote_data_len global with a helper. [Dave, Xiaoyao]
- Simplify tdx_get_max_quote_size(). [Dave]
- Use EXPORT_SYMBOL_FOR_MODULES() instead of EXPORT_SYMBOL_GPL(). [Xiaoyao, Dave]
- Rename GET_QUOTE_DEFAULT_BUF_SIZE to TDX_DEFAULT_QUOTE_SIZE. [Dave]
- Pick "size" over "len" when renaming TDX_QUOTE_BUF_LEN(). [Dave]
- Drop the comment about the buddy allocator. [Dave]
- Reorder the patches so that cleanups/refactoring come before the feature.
- Add Kiryl's Reviewed-by to patch 3.
- Drop the Reviewed-by tags from patches 4-6 as they were reworked.
- Change the author of patch 6 to me, and credit Sathya in the log.
v3: https://lore.kernel.org/all/[email protected]/
Changes in v4:
- Update the TDCS_QUOTE_MAX_SIZE encoding to 0x9010000200000007.
- Provide documentation for the metadata field. [Rick, Kiryl]
- Document the reported size's properties. [Xiaoyao, Tony]
- Page align quote_data_len unconditionally. [Xiaoyao]
- Collect Reviewed-by tags. [Sathya, Tony, Xiaoyao, Binbin]
v2: https://lore.kernel.org/all/[email protected]/
Changes in v3:
- Split the v2 "Allocate Quote buffer dynamically" patch to do the refactoring first, then make the buffer size dynamic. [Dave]
- Improve patterns for readability. [Dave]
- Drop __GFP_NOWARN so an allocation failure warns. [Dave, Rick, Kiryl]
- Add Binbin's Reviewed-by to patch 1.
- Drop the Reviewed-by tags (Kiryl, Binbin) as the patch was reworked.
v1: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Collect Reviewed-by tags. [Kiryl, Xiaoyao, Binbin, Sathya]
- Keep the explicit (u32) cast in tdx_get_max_quote_size(). [Binbin]
- Calculate the Quote buffer size with struct_size_t(). [Kiryl, Binbin]
- Add __GFP_NOWARN to the allocation since its size comes from the host. [sashiko]
- Rename quote_data_size to quote_data_len. [Sathya]
- Drop the Assisted-by tags, as AI was not used to write the code.
[1] c3fd16c3b98e ("virt: tdx-guest: Fix handling of host controlled
'quote' buffer length")
[2] https://lore.kernel.org/all/[email protected]/
[3] Guest Hypervisor Communication Interface (GHCI) Specification,
Version 1.5, Section "TDG.VP.VMCALL<GetQuote>"
[4] 43185067c6fd ("configfs-tsm-report: tdx_guest: Increase Quote buffer
size to 128KB")
[5] Intel TDX Module ABI Definitions, August 2026 (community review), TD-scope metadata field "TD_QUOTE_MAX_SIZE"
Peter Fang (6):
x86/tdx: Take the Quote buffer as a generic pointer
virt: tdx-guest: Give the Quote buffer an explicit type
virt: tdx-guest: Calculate the Quote buffer size safely
virt: tdx-guest: Add a helper for the Quote buffer size x86/tdx: Add a helper to query maximum Quote size
virt: tdx-guest: Make the Quote buffer size dynamic
arch/x86/coco/tdx/tdx.c | 19 ++++++- arch/x86/include/asm/shared/tdx.h | 1 + arch/x86/include/asm/tdx.h | 4 +- drivers/virt/coco/tdx-guest/tdx-guest.c | 76 ++++++++++++++++--------- 4 files changed, 70 insertions(+), 30 deletions(-)
base-commit: a49e2d257594931772ab8f0024708c3076f3aa1d
Signature · 1 line
2.53.0