Skip to content

TDX QEMU support

Xiaoyao Li kvm qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest58 patches 61 repliesIn review

Changes in v2 from the cover letter

[v1] https://lore.kernel.org/qemu-devel/[email protected]/

- Switch to KVM gmem interface for private memory;
- Add TDVMCALL and its sub leaves support;
- mark LMCE as unsupported for TD VM;
- bing back the support of mrconfigid/mrowner/mrownerconfig;
- update documentation;

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/58*** HACK *** linux-headers: Update headers to pull in TDX API changeslinux-headers/asm-x86/kvm.h linux-headers/linux/kvm.h+177 -00 replies
2/58i386: Introduce tdx-guest objectconfigs/devices/i386-softmmu/default.mak hw/i386/Kconfig qapi/qom.json +3 more+79 -03 replies
3/58target/i386: Parse TDX vm typetarget/i386/kvm/kvm.c+9 -12 replies
4/58target/i386: Introduce kvm_confidential_guest_init()target/i386/kvm/kvm.c target/i386/sev.c target/i386/sev.h+12 -21 reply
5/58i386/tdx: Implement tdx_kvm_init() to initialize TDX VM contexttarget/i386/kvm/kvm.c target/i386/kvm/meson.build target/i386/kvm/tdx-stub.c +2 more+24 -100 replies
6/58i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIEStarget/i386/kvm/kvm.c target/i386/kvm/kvm_i386.h target/i386/kvm/tdx.c+95 -23 replies
7/58i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest objecttarget/i386/kvm/tdx.c target/i386/kvm/tdx.h+23 -02 replies
8/58i386/tdx: Adjust the supported CPUID based on TDX restrictionstarget/i386/cpu.h target/i386/kvm/kvm.c target/i386/kvm/tdx.c +1 more+276 -04 replies
9/58i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by tdx_caps.cpuid_config[]target/i386/kvm/tdx.c+30 -00 replies
10/58i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookuptarget/i386/cpu.c target/i386/cpu.h target/i386/kvm/tdx.c+27 -30 replies
11/58i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookuptarget/i386/cpu-internal.h target/i386/cpu.c target/i386/cpu.h +1 more+32 -90 replies
12/58i386/kvm: Move architectural CPUID leaf generation to separate helpertarget/i386/kvm/kvm.c target/i386/kvm/kvm_i386.h+235 -2220 replies
13/58kvm: Introduce kvm_arch_pre_create_vcpu()accel/kvm/kvm-all.c include/sysemu/kvm.h+13 -04 replies
14/58i386/tdx: Initialize TDX before creating TD vcpusaccel/kvm/kvm-all.c target/i386/kvm/kvm.c target/i386/kvm/tdx-stub.c +2 more+70 -11 reply
15/58i386/tdx: Add property sept-ve-disable for tdx-guest objectqapi/qom.json target/i386/kvm/tdx.c+27 -13 replies
16/58i386/tdx: Make sept_ve_disable set by defaulttarget/i386/kvm/tdx.c+1 -10 replies
17/58i386/tdx: Wire CPU features up with attributes of TD guesttarget/i386/kvm/tdx.c+13 -10 replies
18/58i386/tdx: Validate TD attributestarget/i386/kvm/tdx.c+25 -25 replies
19/58qom: implement property helper for sha384include/qom/object.h qom/object.c+93 -02 replies
20/58i386/tdx: Allows mrconfigid/mrowner/mrownerconfig for TDX_INIT_VMqapi/qom.json target/i386/kvm/tdx.c target/i386/kvm/tdx.h+26 -12 replies
21/58i386/tdx: Implement user specified tsc frequencytarget/i386/kvm/kvm.c target/i386/kvm/tdx.c+33 -01 reply
22/58i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VMtarget/i386/kvm/tdx.c+9 -00 replies
23/58i386/tdx: Make memory type private by defaulttarget/i386/kvm/tdx.c+22 -00 replies
24/58i386/tdx: Create kvm gmem for TDtarget/i386/kvm/tdx.c+25 -20 replies
25/58kvm/tdx: Don't complain when converting vMMIO region to sharedaccel/kvm/kvm-all.c+18 -21 reply
26/58kvm/tdx: Ignore memory conversion to shared of unassigned regionaccel/kvm/kvm-all.c+12 -00 replies
27/58i386/tdvf: Introduce function to parse TDVF metadatahw/i386/Kconfig hw/i386/meson.build hw/i386/tdvf.c +1 more+252 -00 replies
28/58i386/tdx: Parse TDVF metadata for TDX VMhw/i386/pc_sysfw.c hw/i386/x86.c target/i386/kvm/tdx-stub.c +2 more+23 -10 replies
29/58i386/tdx: Skip BIOS shadowing setuphw/i386/x86.c+14 -110 replies
30/58i386/tdx: Don't initialize pc.rom for TDX VMshw/i386/pc.c+12 -90 replies
31/58i386/tdx: Track mem_ptr for each firmware entry of TDVFhw/i386/tdvf.c include/hw/i386/tdvf.h target/i386/kvm/tdx.c+39 -00 replies
32/58i386/tdx: Track RAM entries for TDX VMtarget/i386/kvm/tdx.c target/i386/kvm/tdx.h+124 -04 replies
33/58headers: Add definitions from UEFI spec for volumes, resources, etc...include/standard-headers/uefi/uefi.h+198 -03 replies
34/58i386/tdx: Setup the TD HOB listhw/i386/meson.build hw/i386/tdvf-hob.c hw/i386/tdvf-hob.h +1 more+188 -10 replies
35/58i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGIONtarget/i386/kvm/tdx.c+24 -00 replies
36/58memory: Introduce memory_region_init_ram_gmem()include/exec/memory.h softmmu/memory.c+58 -03 replies
37/58i386/tdx: register TDVF as private memoryhw/i386/x86.c target/i386/kvm/tdx.c target/i386/kvm/tdx.h+27 -10 replies
38/58i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcputarget/i386/kvm/tdx.c+18 -00 replies
39/58i386/tdx: Finalize TDX VMtarget/i386/kvm/tdx.c+7 -00 replies
40/58i386/tdx: handle TDG.VP.VMCALL<SetupEventNotifyInterrupt>target/i386/kvm/kvm.c target/i386/kvm/tdx-stub.c target/i386/kvm/tdx.c +1 more+80 -00 replies
41/58i386/tdx: handle TDG.VP.VMCALL<GetQuote>qapi/qom.json target/i386/kvm/tdx.c target/i386/kvm/tdx.h+391 -19 replies
42/58i386/tdx: register the fd read callback with the main loop to read the quote datatarget/i386/kvm/tdx.c+96 -511 reply
43/58i386/tdx: setup a timer for the qio channeltarget/i386/kvm/tdx.c+85 -662 replies
44/58i386/tdx: handle TDG.VP.VMCALL<MapGPA> hypercallaccel/kvm/kvm-all.c include/sysemu/kvm.h target/i386/kvm/tdx.c+40 -10 replies
45/58i386/tdx: Limit the range size for MapGPAtarget/i386/kvm/tdx.c+18 -11 reply
46/58i386/tdx: Handle TDG.VP.VMCALL<REPORT_FATAL_ERROR>target/i386/kvm/tdx.c+40 -00 replies
47/58i386/tdx: Wire REPORT_FATAL_ERROR with GuestPanic facilityqapi/run-state.json softmmu/runstate.c target/i386/kvm/tdx.c+87 -34 replies
48/58i386/tdx: Disable SMM for TDX VMstarget/i386/kvm/tdx.c+8 -00 replies
49/58i386/tdx: Disable PIC for TDX VMstarget/i386/kvm/tdx.c+7 -00 replies
50/58i386/tdx: Don't allow system reset for TDX VMstarget/i386/kvm/kvm.c+1 -10 replies
51/58i386/tdx: LMCE is not supported for TDXtarget/i386/kvm/kvm-cpu.c+5 -00 replies
52/58hw/i386: add eoi_intercept_unsupported member to X86MachineStatehw/i386/x86.c include/hw/i386/x86.h target/i386/kvm/tdx.c+4 -00 replies
53/58hw/i386: add option to forcibly report edge trigger in acpi tableshw/i386/acpi-build.c hw/i386/acpi-common.c+104 -450 replies
54/58i386/tdx: Don't synchronize guest tsc for TDstarget/i386/kvm/kvm.c+1 -10 replies
55/58i386/tdx: Only configure MSR_IA32_UCODE_REV in kvm_init_msrs() for TDstarget/i386/kvm/kvm.c+23 -210 replies
56/58i386/tdx: Skip kvm_put_apicbase() for TDstarget/i386/kvm/kvm.c+5 -00 replies
57/58i386/tdx: Don't get/put guest state for TDX VMstarget/i386/kvm/kvm.c+11 -00 replies
58/58docs: Add TDX documentationdocs/system/confidential-guest-support.rst docs/system/i386/tdx.rst docs/system/target-i386.rst+116 -00 replies

Reviews trailers per patch

30 of 58 patches have a Reviewed-by or Acked-by.

PatchGerd HoffmannConnor KuehlMarkus ArmbrusterPhilippe Mathieu-Daudé
1/58
2/58A-b A-b
3/58
4/58A-b R-b
5/58A-b
6/58
7/58A-b
8/58
9/58
10/58
11/58
12/58
13/58A-b
14/58A-b
15/58A-b
16/58
17/58A-b
18/58A-b
19/58
20/58
21/58A-b
22/58A-b
23/58
24/58
25/58
26/58
27/58A-b
28/58A-b
29/58A-b
30/58
31/58A-b
32/58A-b
33/58A-b
34/58A-b
35/58A-b
36/58
37/58
38/58A-b
39/58A-b
40/58
41/58
42/58
43/58
44/58
45/58
46/58
47/58
48/58A-b
49/58A-b
50/58A-b
51/58
52/58A-b
53/58A-b
54/58A-b R-b
55/58A-b
56/58A-b
57/58A-b
58/58

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.

Read the v2 thread

Cover letter [PATCH v2 00/58] TDX QEMU support

This is v2 series of adding TDX suppot in QEMU.

This patch series aims to enable TDX support to allow creating and booting a TD (TDX VM) with QEMU. It needs to work with corresponding KVM v15 patch [1]. TDX related documents can be found in [2].

This series is based on QEMU gmem implemntation, which is posted at [3]. And This series is also available in github:
https://github.com/intel/qemu-tdx/tree/tdx-qemu-upstream-v2

This version aims to update the TDX QEMU side to match with latest TDX KVM side implementation, which expose gmem for private memory. This version is not targeted as the final version because how to support KVM gmem in QEMU is not finalized yet. Though, any review comment is welcomed.

[1] KVM TDX basic feature support v15
https://lore.kernel.org/kvm/[email protected]/

[2] https://www.intel.com/content/www/us/en/developer/articles/technical/intel-trust-domain-extensions.html

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

== Limitation and future work ==
- Readonly memslot

TDX only support readonly (write protection) memslot for shared memory, but not for private memory. For simplicity, just mark readonly memslot not supported entirely for TDX.

- CPU model

We cannot create a TD with arbitrary CPU model like what for non-TDX VMs, because only a subset of features can be configured for TD.

- It's recommended to use '-cpu host' to create TD;
- '+feature/-feature' might not work as expected;

future work: To introduce specific CPU model for TDs and enhance +/-features
for TDs.

- gdb suppport

gdb support to debug a TD of off-debug mode is future work.

== Change history ==
Changes from v1:
[v1] https://lore.kernel.org/qemu-devel/[email protected]/

- Switch to KVM gmem interface for private memory;
- Add TDVMCALL and its sub leaves support;
- mark LMCE as unsupported for TD VM;
- bing back the support of mrconfigid/mrowner/mrownerconfig;
- update documentation;

Changes from RFC v4:
[RFC v4] https://lore.kernel.org/qemu-devel/[email protected]/

- Add 3 more patches(9, 10, 11) to improve the tdx_get_supported_cpuid();
- make attributes of object tdx-guest not settable by user;
- improve get_tdx_capabilities() by using a known starting value and limiting the loop with a known size;
- clarify why isa.bios needs to be skipped;
- remove the MMIO hob setup since OVMF sets them up itself;

Changes from RFC v3:
[RFC v3] https://lore.kernel.org/qemu-devel/[email protected]/

- Load TDVF with -bios interface;
- Adapt to KVM API changes;
- KVM_TDX_CAPABILITIES changes back to KVM-scope;
- struct kvm_tdx_init_vm changes;
- Define TDX_SUPPORTED_KVM_FEATURES;
- Drop the patch of introducing property sept-ve-disable since it's not public yet;
- some misc cleanups

Changes from RFC v2:
[RFC v2] https://lore.kernel.org/qemu-devel/[email protected]/

- Get vm-type from confidential-guest-support object type;
- Drop machine_init_done_late_notifiers;
- Refactor tdx_ioctl implementation;
- re-use existing pflash interface to load TDVF (i.e., OVMF binaries);
- introduce new date structure to track memory type instead of changing e820 table;
- Force smm to off for TDX VM;
- Drop the patches that suppress level-trigger/SMI/INIT/SIPI since KVM will ingore them;
- Add documentation;

Changes from RFC v1:
[RFC v1] https://lore.kernel.org/qemu-devel/[email protected]/

- suppress level trigger/SMI/INIT/SIPI related to IOAPIC.
- add VM attribute sha384 to TD measurement.
- guest TSC Hz specification

Chao Peng (1):
i386/tdx: register TDVF as private memory

Chenyi Qiang (2):
i386/tdx: register the fd read callback with the main loop to read the
quote data
i386/tdx: setup a timer for the qio channel

Isaku Yamahata (14):
i386/tdx: Make sept_ve_disable set by default
qom: implement property helper for sha384
i386/tdx: Allows mrconfigid/mrowner/mrownerconfig for TDX_INIT_VM i386/tdx: Create kvm gmem for TD
kvm/tdx: Don't complain when converting vMMIO region to shared kvm/tdx: Ignore memory conversion to shared of unassigned region i386/tdvf: Introduce function to parse TDVF metadata i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION i386/tdx: handle TDG.VP.VMCALL<SetupEventNotifyInterrupt> i386/tdx: handle TDG.VP.VMCALL<GetQuote>
i386/tdx: handle TDG.VP.VMCALL<MapGPA> hypercall i386/tdx: Limit the range size for MapGPA
hw/i386: add option to forcibly report edge trigger in acpi tables i386/tdx: Don't synchronize guest tsc for TDs

Sean Christopherson (2):
i386/kvm: Move architectural CPUID leaf generation to separate helper i386/tdx: Don't get/put guest state for TDX VMs

Xiaoyao Li (39):
*** HACK *** linux-headers: Update headers to pull in TDX API changes
i386: Introduce tdx-guest object
target/i386: Parse TDX vm type
target/i386: Introduce kvm_confidential_guest_init() i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object i386/tdx: Adjust the supported CPUID based on TDX restrictions i386/tdx: Update tdx_cpuid_lookup[].tdx_fixed0/1 by

    tdx_caps.cpuid_config[]

i386/tdx: Integrate tdx_caps->xfam_fixed0/1 into tdx_cpuid_lookup i386/tdx: Integrate tdx_caps->attrs_fixed0/1 to tdx_cpuid_lookup
kvm: Introduce kvm_arch_pre_create_vcpu()
i386/tdx: Initialize TDX before creating TD vcpus i386/tdx: Add property sept-ve-disable for tdx-guest object i386/tdx: Wire CPU features up with attributes of TD guest i386/tdx: Validate TD attributes
i386/tdx: Implement user specified tsc frequency
i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM i386/tdx: Make memory type private by default
i386/tdx: Parse TDVF metadata for TDX VM
i386/tdx: Skip BIOS shadowing setup
i386/tdx: Don't initialize pc.rom for TDX VMs
i386/tdx: Track mem_ptr for each firmware entry of TDVF i386/tdx: Track RAM entries for TDX VM
headers: Add definitions from UEFI spec for volumes, resources, etc... i386/tdx: Setup the TD HOB list
memory: Introduce memory_region_init_ram_gmem()
i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu i386/tdx: Finalize TDX VM
i386/tdx: Handle TDG.VP.VMCALL<REPORT_FATAL_ERROR> i386/tdx: Wire REPORT_FATAL_ERROR with GuestPanic facility i386/tdx: Disable SMM for TDX VMs
i386/tdx: Disable PIC for TDX VMs
i386/tdx: Don't allow system reset for TDX VMs
i386/tdx: LMCE is not supported for TDX
hw/i386: add eoi_intercept_unsupported member to X86MachineState i386/tdx: Only configure MSR_IA32_UCODE_REV in kvm_init_msrs() for TDs i386/tdx: Skip kvm_put_apicbase() for TDs
docs: Add TDX documentation

 accel/kvm/kvm-all.c                        |   55 +-
 configs/devices/i386-softmmu/default.mak   |    1 +
 docs/system/confidential-guest-support.rst |    1 +
 docs/system/i386/tdx.rst                   |  114 ++
 docs/system/target-i386.rst                |    1 +
 hw/i386/Kconfig                            |    6 +
 hw/i386/acpi-build.c                       |   99 +-
 hw/i386/acpi-common.c                      |   50 +-
 hw/i386/meson.build                        |    1 +
 hw/i386/pc.c                               |   21 +-
 hw/i386/pc_sysfw.c                         |    7 +
 hw/i386/tdvf-hob.c                         |  147 ++
 hw/i386/tdvf-hob.h                         |   24 +
 hw/i386/tdvf.c                             |  200 +++
 hw/i386/x86.c                              |   38 +-
 include/exec/memory.h                      |    6 +
 include/hw/i386/tdvf.h                     |   58 +
 include/hw/i386/x86.h                      |    1 +
 include/qom/object.h                       |   17 +
 include/standard-headers/uefi/uefi.h       |  198 +++
 include/sysemu/kvm.h                       |    3 +
 linux-headers/asm-x86/kvm.h                |   90 ++
 linux-headers/linux/kvm.h                  |   87 ++
 qapi/qom.json                              |   26 +
 qapi/run-state.json                        |   17 +-
 qom/object.c                               |   76 +
 softmmu/memory.c                           |   52 +
 softmmu/runstate.c                         |   49 +
 target/i386/cpu-internal.h                 |    9 +
 target/i386/cpu.c                          |   12 -
 target/i386/cpu.h                          |   21 +
 target/i386/kvm/kvm-cpu.c                  |    5 +
 target/i386/kvm/kvm.c                      |  586 ++++----
 target/i386/kvm/kvm_i386.h                 |    5 +
 target/i386/kvm/meson.build                |    2 +
 target/i386/kvm/tdx-stub.c                 |   22 +
 target/i386/kvm/tdx.c                      | 1543 ++++++++++++++++++++
 target/i386/kvm/tdx.h                      |   73 +
 target/i386/sev.c                          |    1 -
 target/i386/sev.h                          |    2 +
 40 files changed, 3382 insertions(+), 344 deletions(-)
 create mode 100644 docs/system/i386/tdx.rst
 create mode 100644 hw/i386/tdvf-hob.c
 create mode 100644 hw/i386/tdvf-hob.h
 create mode 100644 hw/i386/tdvf.c
 create mode 100644 include/hw/i386/tdvf.h
 create mode 100644 include/standard-headers/uefi/uefi.h
 create mode 100644 target/i386/kvm/tdx-stub.c
 create mode 100644 target/i386/kvm/tdx.c
 create mode 100644 target/i386/kvm/tdx.h
Signature · 1 line
2.34.1