struct page to PFN conversion for TDX guest private memory
Status from this message: Applied to kvm-x86 mmu, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest4 patches 21 repliesApplied
- v12 patches 32 repliesSuperseded
Patches in v2 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | x86/tdx: Use PFN directly for mapping guest private memoryarch/ arch/ arch/ | +19 | 5 replies | |
| 2/4 | x86/tdx: Use PFN directly for unmapping guest private memoryarch/ arch/ arch/ | +13 | 8 replies | |
| 3/4 | x86/tdx: Drop exported function tdx_quirk_reset_page()arch/ arch/ arch/ | +2 | 3 replies | |
| 4/4 | x86/virt/tdx: Move mk_keyed_paddr() to tdx.c due to no external usersarch/ arch/ | +6 | 2 replies |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Ackerley Tng | Xiaoyao Li | Kiryl Shutsemau | Dave Hansen |
|---|---|---|---|---|
| Series | A-b | |||
| 1/4 | R-b | R-b | A-b | |
| 2/4 | R-b | R-b | A-b | |
| 3/4 | R-b | R-b | A-b | |
| 4/4 | R-b | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.
Cover letter [PATCH v2 0/4] struct page to PFN conversion for TDX guest private memory
Hi
This is v2 of the struct page to PFN conversion series, which converts TDX guest private memory mapping/unmapping APIs from taking struct page to taking PFN as input.
v2 is based on v7.1.0-rc1 + Sean's 4 cleanup patches (see details in section "Base" below). The purpose is to get Dave's Ack, so Sean can take it from the KVM x86 tree. The full stack of v2 is available at [14].
Compared to v1, v2:
- Rewrote commit messages of patches 1/2 (the conversion patches for mapping and unmapping) by specifically explaining the downside of assuming guest private memory must be backed by struct page, and incorporating Dave's rewording that also works for Sean.
- Updated patch 2 (which is for unmapping) to use tdx_quirk_reset_paddr() directly for unmapping guest private memory, and added patch 3 to drop the exported function tdx_quirk_reset_page() by having KVM invoke tdx_quirk_reset_paddr() in all scenarios, as suggested by Paolo and Xiaoyao.
- Split patch 4 (moving mk_keyed_paddr() to .c) out of patch 2, so patch 2 can focus on the struct page to PFN conversion for unmapping.
Note: as agreed in v1, Kirill's concern about AUG "level" will be addressed in a separate patch later.
Background
----------
TDX SEAMCALL wrappers take struct page as input, which provides:
1. Type safety
2. Make it harder to misuse and make it obvious that physical pages in RAM are expected from just looking at the API declaration [2][3][4][5].
This is appropriate for SEAMCALL wrappers for TDX control pages (e.g., TDR page, TDCS pages, TDX SEPT pages), since KVM manages and allocates those pages explicitly from core MM.
However, unlike TDX control pages, KVM guest memory is not necessarily backed by refcounted struct page or even struct page (e.g., VM_PFNMAP memory [6]). Taking struct page as input for SEAMCALL wrappers for mapping/unmapping guest private memory imposes unnecessary assumptions on how KVM and guest_memfd manage memory [7]. So, Sean suggested converting from using struct page to PFN for SEAMCALL wrappers operating on guest private memory [8].
This series therefore converts struct page to PFN for guest private memory while keeping struct page for TDX control pages, and uses kvm_pfn_t for type safety.
Sanity check
------------
Reasonable PFN sanity checks in the guest private memory mapping/unmapping APIs are still agreed upon [9][10], such as checking TDX convertibility to avoid SEAMCALL failure.
However, we decided not to provide any in-kernel sanity checks to avoid introducing unnecessary overhead, both because those failures are supposed to only occur when there are kernel bugs, and due to the lack of satisfactory tiny checks to ensure convertibility. When unexpected non-TDX-convertible PFNs are passed in, just let SEAMCALLs fail or have #MCs or #PFs generated, which are obvious enough in themselves.
Base:
----
This v2 is rebased on top of v7.1.0-rc1 (kvm/next, commit 39f1c201b93f) + the first 4 patches from Sean's v5 "TDX: Dynamic PAMT + S-EPT Hugepage" series [11].
Note: due to the instability of v7.1.0-rc1, I also applied series [12] and
[13] to pass CI.
Changelogs:
-----------
v1 [1] --> v2:
1. Updated patch logs of patches 1/2. (Dave).
2. Added patch 3 to drop tdx_quirk_reset_page() and export tdx_quirk_reset_paddr() only. (Paolo, Xiaoyao)
3. Split out patch 4 to move mk_keyed_paddr() from .h to .c.
4. Rebased to v7.1.0-rc1 + Sean's 4 cleanup patches.
Sean's original patch [0] --> v1:
1. Rebased to kvm-x86-next-2026.03.13.
2. Split to 2 patches for easy review. (Rick)
3. Replaced "u64 pfn" with "kvm_pfn_t pfn" (Rick)
4. Dropped using PFN as input to tdx_reclaim_page(). (Rick)
5. Move mk_keyed_paddr() from tdx.h to tdx.c.
Thanks
Yan
[0] https://lore.kernel.org/kvm/[email protected]
[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/all/[email protected]
[3] https://lore.kernel.org/kvm/[email protected]
[4] https://lore.kernel.org/kvm/[email protected]
[5] https://lore.kernel.org/kvm/[email protected]
[6] https://lore.kernel.org/all/[email protected]
[7] https://lore.kernel.org/all/[email protected]
[8] https://lore.kernel.org/all/[email protected]
[9] https://lore.kernel.org/all/[email protected]
[10] https://lore.kernel.org/all/[email protected]
[11] https://lore.kernel.org/all/[email protected]
[12] https://lore.kernel.org/all/[email protected]
[13] https://lore.kernel.org/all/[email protected]
[14] https://github.com/intel-staging/tdx/tree/struct_page_to_pfn_v2
Sean Christopherson (2):
x86/tdx: Use PFN directly for mapping guest private memory x86/tdx: Use PFN directly for unmapping guest private memory
Yan Zhao (2):
x86/tdx: Drop exported function tdx_quirk_reset_page() x86/virt/tdx: Move mk_keyed_paddr() to tdx.c due to no external users
arch/x86/include/asm/tdx.h | 21 ++++++------------- arch/x86/kvm/vmx/tdx.c | 17 ++++++++-------- arch/x86/virt/vmx/tdx/tdx.c | 40 +++++++++++++++++++++---------------- 3 files changed, 37 insertions(+), 41 deletions(-)
Signature · 1 line
2.43.2