Skip to content

TDX vCPU/VM creation

Rick Edgecombe kvm lkml 2 versions – Applied

Status from this message: Applied to kvm-coco-queue, thanks. Tomorrow I will go through the

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest25 patches 76 repliesApplied
  2. v125 patches 165 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/25x86/virt/tdx: Share the global metadata structure for KVM to usearch/x86/include/asm/tdx.h arch/x86/include/asm/tdx_global_metadata.h arch/x86/virt/vmx/tdx/tdx.c +1 more+25 -70 replies
2/25KVM: TDX: Get TDX global informationarch/x86/kvm/vmx/tdx.c+11 -00 replies
3/25x86/virt/tdx: Read essential global metadata for KVMarch/x86/include/asm/tdx_global_metadata.h arch/x86/virt/vmx/tdx/tdx_global_metadata.c+65 -08 replies
4/25x86/virt/tdx: Add tdx_guest_keyid_alloc/free() to alloc and free TDX guest KeyIDarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c+20 -00 replies
5/25x86/virt/tdx: Add SEAMCALL wrappers for TDX KeyID managementarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+33 -72 replies
6/25x86/virt/tdx: Add SEAMCALL wrappers for TDX TD creationarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+45 -03 replies
7/25x86/virt/tdx: Add SEAMCALL wrappers for TDX vCPU creationarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+65 -00 replies
8/25x86/virt/tdx: Add SEAMCALL wrappers for TDX page cache managementarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+50 -113 replies
9/25x86/virt/tdx: Add SEAMCALL wrappers for TDX VM/vCPU field accessarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+53 -02 replies
10/25x86/virt/tdx: Add SEAMCALL wrappers for TDX flush operationsarch/x86/include/asm/tdx.h arch/x86/virt/vmx/tdx/tdx.c arch/x86/virt/vmx/tdx/tdx.h+24 -04 replies
11/25KVM: TDX: Add placeholders for TDX VM/vCPU structuresarch/x86/kvm/vmx/main.c arch/x86/kvm/vmx/tdx.c arch/x86/kvm/vmx/tdx.h+100 -43 replies
12/25KVM: TDX: Define TDX architectural definitionsarch/x86/kvm/vmx/tdx.h arch/x86/kvm/vmx/tdx_arch.h+160 -02 replies
13/25KVM: TDX: Add TDX "architectural" error codesarch/x86/include/asm/shared/tdx.h arch/x86/kvm/vmx/tdx.h arch/x86/kvm/vmx/tdx_errno.h+43 -10 replies
14/25KVM: TDX: Add helper functions to print TDX SEAMCALL errorarch/x86/kvm/vmx/tdx.c+15 -00 replies
15/25KVM: TDX: Add place holder for TDX VM specific mem_enc_op ioctlarch/x86/include/asm/kvm-x86-ops.h arch/x86/include/uapi/asm/kvm.h arch/x86/kvm/vmx/main.c +3 more+73 -50 replies
16/25KVM: TDX: Get system-wide info about TDX module on initializationarch/x86/include/uapi/asm/kvm.h arch/x86/kvm/vmx/tdx.c+146 -011 replies
17/25KVM: TDX: create/destroy VM structurearch/x86/include/asm/kvm-x86-ops.h arch/x86/include/asm/kvm_host.h arch/x86/kvm/Kconfig +5 more+501 -32 replies
18/25KVM: TDX: Support per-VM KVM_CAP_MAX_VCPUS extension checkarch/x86/kvm/vmx/main.c arch/x86/kvm/vmx/tdx.c arch/x86/kvm/x86.c+54 -02 replies
19/25KVM: TDX: initialize VM with TDX specific parametersarch/x86/include/uapi/asm/kvm.h arch/x86/kvm/cpuid.c arch/x86/kvm/cpuid.h +2 more+306 -100 replies
20/25KVM: TDX: Make pmu_intel.c ignore guest TD casearch/x86/kvm/vmx/pmu_intel.c arch/x86/kvm/vmx/pmu_intel.h arch/x86/kvm/vmx/vmx.h+78 -340 replies
21/25KVM: TDX: Don't offline the last cpu of one package when there's TDX guestarch/x86/kvm/vmx/tdx.c+42 -10 replies
22/25KVM: TDX: create/free TDX vcpu structurearch/x86/kvm/vmx/main.c arch/x86/kvm/vmx/tdx.c arch/x86/kvm/vmx/x86_ops.h+80 -40 replies
23/25KVM: TDX: Do TDX specific vcpu initializationarch/x86/include/asm/kvm-x86-ops.h arch/x86/include/asm/kvm_host.h arch/x86/include/uapi/asm/kvm.h +6 more+219 -20 replies
24/25KVM: x86: Introduce KVM_TDX_GET_CPUIDarch/x86/include/uapi/asm/kvm.h arch/x86/kvm/vmx/tdx.c arch/x86/kvm/vmx/tdx_arch.h +1 more+174 -010 replies
25/25KVM: x86/mmu: Taking guest pa into consideration when calculate tdp levelarch/x86/kvm/cpuid.c arch/x86/kvm/cpuid.h arch/x86/kvm/mmu/mmu.c+23 -10 replies

Reviews trailers per patch

11 of 25 patches have a Reviewed-by or Acked-by.

PatchBinbin WuYuan YaoPaolo BonziniXiaoyao LiDave Hansen
1/25
2/25
3/25
4/25
5/25R-b R-b A-b
6/25R-b R-b
7/25R-b R-b
8/25R-b R-b
9/25R-b R-b
10/25R-b R-b
11/25
12/25R-b R-b
13/25R-b R-b R-b
14/25R-b R-b
15/25
16/25R-b
17/25
18/25
19/25
20/25
21/25R-b
22/25
23/25
24/25
25/25

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/25] TDX vCPU/VM creation

Hi,

Here is v2 of TDX VM/vCPU creation series. As discussed earlier, non-nits from v1[0] have been applied and it’s ready to hand off to Paolo. A few items remain that may be worth further discussion:
- Disable CET/PT in tdx_get_supported_xfam(), as these features haven’t been been tested.
- The Retry loop around tdh_phymem_page_reclaim() in “KVM: TDX:
create/destroy VM structure” likely can be dropped.
- Drop support for TDX Module’s that don’t support MD_FIELD_ID_FEATURES0_TOPOLOGY_ENUM. [1]
- Type-safety in to_vmx()/to_tdx(). [2]

This series has 9 commits intended to collect acks from x86 maintainers. The first group of commits is for reading TDX static metadata for KVM to use:
x86/virt/tdx: Share the global metadata structure for KVM to use x86/virt/tdx: Read essential global metadata for KVM

The second group is for exporting a TDX keyid allocator for KVM to use:
x86/virt/tdx: Add tdx_guest_keyid_alloc/free() to alloc and free
TDX guest KeyID

The third group is for exporting various SEAMCALLs needed by KVM for this series. SEAMCALL patches for the later TDX sections will come with those series’:
x86/virt/tdx: Add SEAMCALL wrappers for TDX KeyID management x86/virt/tdx: Add SEAMCALL wrappers for TDX TD creation x86/virt/tdx: Add SEAMCALL wrappers for TDX vCPU creation x86/virt/tdx: Add SEAMCALL wrappers for TDX page cache management x86/virt/tdx: Add SEAMCALL wrappers for TDX VM/vCPU field access x86/virt/tdx: Add SEAMCALL wrappers for TDX flush operations

This series is based off of a kvm-coco-queue commit and some pre-req series:
1. d659088d46df "KVM: x86/mmu: Prevent aliased memslot GFNs" (in kvm-coco-queue).
2. v6 of “TDX host: metadata reading tweaks, bug fix and info dump”
3. “KVM: VMX: Initialize TDX when loading KVM module” re-ordered from the commits in kvm-coco-queue

It requires TDX module 1.5.06.00.0744[3], or later. This is due to removal of the workarounds for the lack of NO_RBP_MOD. Now NO_RBP_MOD is enabled, and this particular version of the TDX module has a NO_RBP_MOD related bug fix.

The full KVM branch is here:
https://github.com/intel/tdx/tree/tdx_kvm_dev-2024-10-30

Matching QEMU:
https://github.com/intel-staging/qemu-tdx/tree/tdx-qemu-wip-2024-10-11

[0] https://lore.kernel.org/kvm/[email protected]/
[1] https://lore.kernel.org/kvm/[email protected]/
[2] https://lore.kernel.org/kvm/[email protected]/
[3] https://github.com/intel/tdx-module/releases/tag/TDX_1.5.06

Isaku Yamahata (19):
x86/virt/tdx: Add tdx_guest_keyid_alloc/free() to alloc and free TDX
guest KeyID
x86/virt/tdx: Add SEAMCALL wrappers for TDX KeyID management x86/virt/tdx: Add SEAMCALL wrappers for TDX TD creation x86/virt/tdx: Add SEAMCALL wrappers for TDX vCPU creation x86/virt/tdx: Add SEAMCALL wrappers for TDX page cache management x86/virt/tdx: Add SEAMCALL wrappers for TDX VM/vCPU field access x86/virt/tdx: Add SEAMCALL wrappers for TDX flush operations
KVM: TDX: Add placeholders for TDX VM/vCPU structures
KVM: TDX: Define TDX architectural definitions
KVM: TDX: Add helper functions to print TDX SEAMCALL error
KVM: TDX: Add place holder for TDX VM specific mem_enc_op ioctl
KVM: TDX: Get system-wide info about TDX module on initialization
KVM: TDX: create/destroy VM structure
KVM: TDX: Support per-VM KVM_CAP_MAX_VCPUS extension check
KVM: TDX: initialize VM with TDX specific parameters
KVM: TDX: Make pmu_intel.c ignore guest TD case
KVM: TDX: Don't offline the last cpu of one package when there's TDX
guest
KVM: TDX: create/free TDX vcpu structure
KVM: TDX: Do TDX specific vcpu initialization

Kai Huang (3):
x86/virt/tdx: Share the global metadata structure for KVM to use
KVM: TDX: Get TDX global information
x86/virt/tdx: Read essential global metadata for KVM

Sean Christopherson (1):
KVM: TDX: Add TDX "architectural" error codes

Xiaoyao Li (2):
KVM: x86: Introduce KVM_TDX_GET_CPUID
KVM: x86/mmu: Taking guest pa into consideration when calculate tdp
level

 arch/x86/include/asm/kvm-x86-ops.h            |    4 +-
 arch/x86/include/asm/kvm_host.h               |    2 +
 arch/x86/include/asm/shared/tdx.h             |    7 +-
 arch/x86/include/asm/tdx.h                    |   25 +
 .../tdx => include/asm}/tdx_global_metadata.h |   19 +
 arch/x86/include/uapi/asm/kvm.h               |   59 +
 arch/x86/kvm/Kconfig                          |    2 +
 arch/x86/kvm/cpuid.c                          |   21 +
 arch/x86/kvm/cpuid.h                          |    3 +
 arch/x86/kvm/mmu/mmu.c                        |    9 +-
 arch/x86/kvm/vmx/main.c                       |  143 +-
 arch/x86/kvm/vmx/pmu_intel.c                  |   50 +-
 arch/x86/kvm/vmx/pmu_intel.h                  |   28 +
 arch/x86/kvm/vmx/tdx.c                        | 1369 ++++++++++++++++-
 arch/x86/kvm/vmx/tdx.h                        |   92 ++
 arch/x86/kvm/vmx/tdx_arch.h                   |  165 ++
 arch/x86/kvm/vmx/tdx_errno.h                  |   37 +
 arch/x86/kvm/vmx/vmx.h                        |   34 +-
 arch/x86/kvm/vmx/x86_ops.h                    |   24 +
 arch/x86/kvm/x86.c                            |   15 +-
 arch/x86/virt/vmx/tdx/tdx.c                   |  264 +++-
 arch/x86/virt/vmx/tdx/tdx.h                   |   39 +-
 arch/x86/virt/vmx/tdx/tdx_global_metadata.c   |   46 +
 23 files changed, 2391 insertions(+), 66 deletions(-)
 rename arch/x86/{virt/vmx/tdx => include/asm}/tdx_global_metadata.h (68%)
 create mode 100644 arch/x86/kvm/vmx/pmu_intel.h
 create mode 100644 arch/x86/kvm/vmx/tdx_arch.h
 create mode 100644 arch/x86/kvm/vmx/tdx_errno.h
Signature · 1 line
2.47.0