All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v3 00/36] TDX QEMU support
@ 2022-03-17 13:58 ` Xiaoyao Li
  0 siblings, 0 replies; 154+ messages in thread
From: Xiaoyao Li @ 2022-03-17 13:58 UTC (permalink / raw)
  To: Paolo Bonzini, Philippe Mathieu-Daudé,
	Richard Henderson, Michael S. Tsirkin, Marcel Apfelbaum,
	Cornelia Huck, Daniel P. Berrangé,
	Marcelo Tosatti, Laszlo Ersek, Gerd Hoffmann, Eric Blake
  Cc: Connor Kuehl, isaku.yamahata, xiaoyao.li, erdemaktas, kvm,
	qemu-devel, seanjc

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 patch
for TDX [1]. You can find TDX related documents in [2].

You can also find this series in below repo in github:

https://github.com/intel/qemu-tdx.git

and it's based on two cleanup patches

https://lore.kernel.org/qemu-devel/20220310122811.807794-1-xiaoyao.li@intel.com/


To boot a TDX VM, it requires several changes/additional steps in the flow:

 1. specify the vm type KVM_X86_TDX_VM when creating VM with
    IOCTL(KVM_CREATE_VM);
 2. initialize VM scope configuration before creating any VCPU;
 3. initialize VCPU scope configuration;
 4. initialize virtual firmware in guest private memory before vcpu running;

Besides, TDX VM needs to boot with TDVF (TDX virtual firmware, and come out
as OVMF). This series adds the support of parsing TDVF, loading TDVF into
guest's private memory and preparing TD HOB info for TDVF.

[1] KVM TDX basic feature support
https://lore.kernel.org/all/cover.1646422845.git.isaku.yamahata@intel.com/

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

== 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 arbitrarily CPU model like what for normal 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.

== Patch organization ==
1           Manually fetch Linux UAPI changes for TDX;
2-15,24,26  Basic TDX support that parses vm-type and invoke TDX
            specific IOCTLs
16-25       Load, parse and initialize TDVF for TDX VM;
27-31       Disable unsupported functions for TDX VM;
32-35       Avoid errors due to KVM's requirement on TDX;
36          Add documentation of TDX;

== Change history ==

Changes from v2:
- 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;

[v2] https://lore.kernel.org/qemu-devel/cover.1625704980.git.isaku.yamahata@intel.com/

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

[v1] https://lore.kernel.org/qemu-devel/cover.1613188118.git.isaku.yamahata@intel.com/

---
Isaku Yamahata (4):
  i386/tdvf: Introduce function to parse TDVF metadata
  i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION
  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 (30):
  *** HACK *** linux-headers: Update headers to pull in TDX API changes
  i386: Introduce tdx-guest object
  target/i386: Implement mc->kvm_type() to get 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 get_supported_cpuid() for TDX VM
  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
  pflash_cfi01/tdx: Introduce ram_mode of pflash for TDVF
  i386/tdx: Parse TDVF metadata for TDX VM
  i386/tdx: Get and store the mem_ptr of TDVF firmware
  i386/tdx: Track mem_ptr for each firmware entry of TDVF
  i386/tdx: Track RAM entries for TDX VM
  i386/tdx: Create the TD HOB list upon machine init done
  i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu
  i386/tdx: Finalize TDX VM
  i386/tdx: Disable SMM for TDX VMs
  i386/tdx: Disable PIC for TDX VMs
  i386/tdx: Don't allow system reset for TDX VMs
  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                        |  16 +-
 configs/devices/i386-softmmu/default.mak   |   1 +
 docs/system/confidential-guest-support.rst |   1 +
 docs/system/i386/tdx.rst                   | 103 ++++
 docs/system/target-i386.rst                |   1 +
 hw/block/pflash_cfi01.c                    |  25 +-
 hw/i386/Kconfig                            |   6 +
 hw/i386/acpi-build.c                       |  99 ++--
 hw/i386/acpi-common.c                      |  50 +-
 hw/i386/meson.build                        |   1 +
 hw/i386/pc_sysfw.c                         |  49 +-
 hw/i386/tdvf-hob.c                         | 212 ++++++++
 hw/i386/tdvf-hob.h                         |  25 +
 hw/i386/tdvf.c                             | 196 ++++++++
 hw/i386/uefi.h                             | 198 ++++++++
 hw/i386/x86.c                              |   7 +
 include/hw/i386/tdvf.h                     |  60 +++
 include/hw/i386/x86.h                      |   1 +
 include/sysemu/kvm.h                       |   1 +
 linux-headers/asm-x86/kvm.h                |  60 +++
 linux-headers/linux/kvm.h                  |   2 +
 qapi/qom.json                              |  17 +
 target/arm/kvm64.c                         |   5 +
 target/i386/cpu.h                          |   5 +
 target/i386/kvm/kvm.c                      | 362 ++++++++------
 target/i386/kvm/kvm_i386.h                 |   5 +
 target/i386/kvm/meson.build                |   2 +
 target/i386/kvm/tdx-stub.c                 |  24 +
 target/i386/kvm/tdx.c                      | 541 +++++++++++++++++++++
 target/i386/kvm/tdx.h                      |  56 +++
 target/i386/sev.c                          |   1 -
 target/i386/sev.h                          |   2 +
 target/mips/kvm.c                          |   5 +
 target/ppc/kvm.c                           |   5 +
 target/s390x/kvm/kvm.c                     |   5 +
 35 files changed, 1940 insertions(+), 209 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 hw/i386/uefi.h
 create mode 100644 include/hw/i386/tdvf.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

-- 
2.27.0


^ permalink raw reply	[flat|nested] 154+ messages in thread

end of thread, other threads:[~2022-03-31 14:53 UTC | newest]

Thread overview: 154+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17 13:58 [RFC PATCH v3 00/36] TDX QEMU support Xiaoyao Li
2022-03-17 13:58 ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 01/36] *** HACK *** linux-headers: Update headers to pull in TDX API changes Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 02/36] i386: Introduce tdx-guest object Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 03/36] target/i386: Implement mc->kvm_type() to get VM type Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 04/36] target/i386: Introduce kvm_confidential_guest_init() Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 05/36] i386/tdx: Implement tdx_kvm_init() to initialize TDX VM context Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-18  2:07   ` Isaku Yamahata
2022-03-18  2:07     ` Isaku Yamahata
2022-03-21  5:35     ` Xiaoyao Li
2022-03-21  5:35       ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 06/36] i386/tdx: Get tdx_capabilities via KVM_TDX_CAPABILITIES Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-18  2:08   ` Isaku Yamahata
2022-03-18  2:08     ` Isaku Yamahata
2022-03-21  6:56     ` Xiaoyao Li
2022-03-21  6:56       ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 07/36] i386/tdx: Introduce is_tdx_vm() helper and cache tdx_guest object Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 08/36] i386/tdx: Adjust get_supported_cpuid() for TDX VM Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-18 16:55   ` Isaku Yamahata
2022-03-18 16:55     ` Isaku Yamahata
2022-03-21  5:37     ` Xiaoyao Li
2022-03-21  5:37       ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 09/36] KVM: Introduce kvm_arch_pre_create_vcpu() Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-18 16:56   ` Isaku Yamahata
2022-03-18 16:56     ` Isaku Yamahata
2022-03-21  7:02     ` Xiaoyao Li
2022-03-21  7:02       ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 10/36] i386/kvm: Move architectural CPUID leaf generation to separate helper Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 11/36] i386/tdx: Initialize TDX before creating TD vcpus Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 12/36] i386/tdx: Add property sept-ve-disable for tdx-guest object Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-22  9:02   ` Gerd Hoffmann
2022-03-22  9:02     ` Gerd Hoffmann
2022-03-24  6:52     ` Xiaoyao Li
2022-03-24  6:52       ` Xiaoyao Li
2022-03-24  7:57       ` Gerd Hoffmann
2022-03-24  7:57         ` Gerd Hoffmann
2022-03-24  8:08         ` Xiaoyao Li
2022-03-24  8:08           ` Xiaoyao Li
2022-03-24  9:37           ` Gerd Hoffmann
2022-03-24  9:37             ` Gerd Hoffmann
2022-03-24 14:36             ` Xiaoyao Li
2022-03-24 14:36               ` Xiaoyao Li
2022-03-25  1:35             ` Isaku Yamahata
2022-03-25  1:35               ` Isaku Yamahata
2022-03-17 13:58 ` [RFC PATCH v3 13/36] i386/tdx: Wire CPU features up with attributes of TD guest Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 14/36] i386/tdx: Validate TD attributes Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 15/36] i386/tdx: Implement user specified tsc frequency Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 16/36] i386/tdx: Set kvm_readonly_mem_enabled to false for TDX VM Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-18 17:11   ` Isaku Yamahata
2022-03-18 17:11     ` Isaku Yamahata
2022-03-21  8:15     ` Xiaoyao Li
2022-03-21  8:15       ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 17/36] pflash_cfi01/tdx: Introduce ram_mode of pflash for TDVF Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-18 14:07   ` Philippe Mathieu-Daudé
2022-03-18 14:07     ` Philippe Mathieu-Daudé
2022-03-21  8:54     ` Xiaoyao Li
2022-03-21  8:54       ` Xiaoyao Li
2022-03-21 22:06       ` Isaku Yamahata
2022-03-21 22:06         ` Isaku Yamahata
2022-03-22  9:21       ` Gerd Hoffmann
2022-03-22  9:21         ` Gerd Hoffmann
2022-03-22  9:29         ` Daniel P. Berrangé
2022-03-22  9:29           ` Daniel P. Berrangé
2022-03-22 10:35           ` Gerd Hoffmann
2022-03-22 10:35             ` Gerd Hoffmann
2022-03-22 10:51             ` Daniel P. Berrangé
2022-03-22 10:51               ` Daniel P. Berrangé
2022-03-22 12:20               ` Gerd Hoffmann
2022-03-22 12:20                 ` Gerd Hoffmann
2022-03-24  8:35                 ` Gerd Hoffmann
2022-03-24  8:35                   ` Gerd Hoffmann
2022-03-31  6:57                   ` Xiaoyao Li
2022-03-31  6:57                     ` Xiaoyao Li
2022-03-24  6:13           ` Xiaoyao Li
2022-03-24  6:13             ` Xiaoyao Li
2022-03-24  7:58             ` Gerd Hoffmann
2022-03-24  7:58               ` Gerd Hoffmann
2022-03-24  8:18               ` Xiaoyao Li
2022-03-24  8:18                 ` Xiaoyao Li
2022-03-24  8:52             ` Daniel P. Berrangé
2022-03-24  8:52               ` Daniel P. Berrangé
2022-03-22  9:27       ` Daniel P. Berrangé
2022-03-22  9:27         ` Daniel P. Berrangé
2022-03-31  8:51         ` Xiaoyao Li
2022-03-31  8:51           ` Xiaoyao Li
2022-03-31  9:00           ` Daniel P. Berrangé
2022-03-31  9:00             ` Daniel P. Berrangé
2022-03-31 14:50             ` Xiaoyao Li
2022-03-31 14:50               ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 18/36] i386/tdvf: Introduce function to parse TDVF metadata Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-18 17:19   ` Isaku Yamahata
2022-03-18 17:19     ` Isaku Yamahata
2022-03-21  6:11     ` Xiaoyao Li
2022-03-21  6:11       ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 19/36] i386/tdx: Parse TDVF metadata for TDX VM Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 20/36] i386/tdx: Get and store the mem_ptr of TDVF firmware Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 21/36] i386/tdx: Track mem_ptr for each firmware entry of TDVF Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:58 ` [RFC PATCH v3 22/36] i386/tdx: Track RAM entries for TDX VM Xiaoyao Li
2022-03-17 13:58   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 23/36] i386/tdx: Create the TD HOB list upon machine init done Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 24/36] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 25/36] i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 26/36] i386/tdx: Finalize TDX VM Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 27/36] i386/tdx: Disable SMM for TDX VMs Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-21  6:51   ` Xiaoyao Li
2022-03-21  6:51     ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 28/36] i386/tdx: Disable PIC " Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 29/36] i386/tdx: Don't allow system reset " Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 30/36] hw/i386: add eoi_intercept_unsupported member to X86MachineState Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 31/36] hw/i386: add option to forcibly report edge trigger in acpi tables Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 32/36] i386/tdx: Don't synchronize guest tsc for TDs Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 33/36] i386/tdx: Only configure MSR_IA32_UCODE_REV in kvm_init_msrs() " Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-18 17:31   ` Isaku Yamahata
2022-03-18 17:31     ` Isaku Yamahata
2022-03-21  6:08     ` Xiaoyao Li
2022-03-21  6:08       ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 34/36] i386/tdx: Skip kvm_put_apicbase() " Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 35/36] i386/tdx: Don't get/put guest state for TDX VMs Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li
2022-03-17 13:59 ` [RFC PATCH v3 36/36] docs: Add TDX documentation Xiaoyao Li
2022-03-17 13:59   ` Xiaoyao Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.