qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/19] QEMU gmem implemention
@ 2023-07-31 16:21 Xiaoyao Li
  2023-07-31 16:21 ` [RFC PATCH 01/19] trace/kvm: Split address space and slot id in trace_kvm_set_user_memory() Xiaoyao Li
                   ` (20 more replies)
  0 siblings, 21 replies; 53+ messages in thread
From: Xiaoyao Li @ 2023-07-31 16:21 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, David Hildenbrand,
	Igor Mammedov, Michael S. Tsirkin, Marcel Apfelbaum,
	Richard Henderson, Marcelo Tosatti
  Cc: Markus Armbruster, Eric Blake, Daniel P. Berrangé,
	Philippe Mathieu-Daudé,
	Peter Xu, Chao Peng, Michael Roth, isaku.yamahata, xiaoyao.li,
	qemu-devel, kvm

This is the first RFC version of enabling KVM gmem[1] as the backend for
private memory of KVM_X86_PROTECTED_VM.

It adds the support to create a specific KVM_X86_PROTECTED_VM type VM,
and introduces 'private' property for memory backend. When the vm type
is KVM_X86_PROTECTED_VM and memory backend has private enabled as below,
it will call KVM gmem ioctl to allocate private memory for the backend.

    $qemu -object memory-backend-ram,id=mem0,size=1G,private=on \
          -machine q35,kvm-type=sw-protected-vm,memory-backend=mem0 \
	  ...

Unfortunately this patch series fails the boot of OVMF at very early
stage due to triple fault because KVM doesn't support emulate string IO
to private memory. We leave it as an open to be discussed.

There are following design opens that need to be discussed:

1. how to determine the vm type?

   a. like this series, specify the vm type via machine property
      'kvm-type'
   b. check the memory backend, if any backend has 'private' property
      set, the vm-type is set to KVM_X86_PROTECTED_VM.

2. whether 'private' property is needed if we choose 1.b as design 

   with 1.b, QEMU can decide whether the memory region needs to be
   private (allocates gmem fd for it) or not, on its own.

3. What is KVM_X86_SW_PROTECTED_VM going to look like? What's the
   purose of it and what's the requirement on it. I think it's the
   questions for KVM folks than QEMU folks.

Any other idea/open/question is welcomed.


Beside, TDX QEMU implemetation is based on this series to provide
private gmem for TD private memory, which can be found at [2].
And it can work corresponding KVM [3] to boot TDX guest. 

[1] https://lore.kernel.org/all/20230718234512.1690985-1-seanjc@google.com/
[2] https://github.com/intel/qemu-tdx/tree/tdx-upstream-wip
[3] https://github.com/intel/tdx/tree/kvm-upstream-2023.07.27-v6.5-rc2-workaround

Chao Peng (4):
  RAMBlock: Support KVM gmemory
  kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot
  physmem: Add ram_block_convert_range
  kvm: handle KVM_EXIT_MEMORY_FAULT

Isaku Yamahata (4):
  HostMem: Add private property to indicate to use kvm gmem
  trace/kvm: Add trace for page convertion between shared and private
  pci-host/q35: Move PAM initialization above SMRAM initialization
  q35: Introduce smm_ranges property for q35-pci-host

Xiaoyao Li (11):
  trace/kvm: Split address space and slot id in
    trace_kvm_set_user_memory()
  *** HACK *** linux-headers: Update headers to pull in gmem APIs
  memory: Introduce memory_region_can_be_private()
  i386/pc: Drop pc_machine_kvm_type()
  target/i386: Implement mc->kvm_type() to get VM type
  i386/kvm: Create gmem fd for KVM_X86_SW_PROTECTED_VM
  kvm: Introduce support for memory_attributes
  kvm/memory: Introduce the infrastructure to set the default
    shared/private value
  i386/kvm: Set memory to default private for KVM_X86_SW_PROTECTED_VM
  physmem: replace function name with __func__ in
    ram_block_discard_range()
  i386: Disable SMM mode for X86_SW_PROTECTED_VM

 accel/kvm/kvm-all.c         | 166 +++++++++++++++++++++++++++++++++---
 accel/kvm/trace-events      |   4 +-
 backends/hostmem.c          |  18 ++++
 hw/i386/pc.c                |   5 --
 hw/i386/pc_q35.c            |   3 +-
 hw/i386/x86.c               |  27 ++++++
 hw/pci-host/q35.c           |  61 ++++++++-----
 include/exec/cpu-common.h   |   2 +
 include/exec/memory.h       |  24 ++++++
 include/exec/ramblock.h     |   1 +
 include/hw/i386/pc.h        |   4 +-
 include/hw/i386/x86.h       |   4 +
 include/hw/pci-host/q35.h   |   1 +
 include/sysemu/hostmem.h    |   2 +-
 include/sysemu/kvm.h        |   3 +
 include/sysemu/kvm_int.h    |   2 +
 linux-headers/asm-x86/kvm.h |   3 +
 linux-headers/linux/kvm.h   |  50 +++++++++++
 qapi/qom.json               |   4 +
 softmmu/memory.c            |  27 ++++++
 softmmu/physmem.c           |  97 ++++++++++++++-------
 target/i386/kvm/kvm.c       |  84 ++++++++++++++++++
 target/i386/kvm/kvm_i386.h  |   1 +
 23 files changed, 517 insertions(+), 76 deletions(-)

-- 
2.34.1



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

end of thread, other threads:[~2023-09-13  7:00 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31 16:21 [RFC PATCH 00/19] QEMU gmem implemention Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 01/19] trace/kvm: Split address space and slot id in trace_kvm_set_user_memory() Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 02/19] *** HACK *** linux-headers: Update headers to pull in gmem APIs Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 03/19] RAMBlock: Support KVM gmemory Xiaoyao Li
2023-08-01 16:33   ` David Hildenbrand
2023-07-31 16:21 ` [RFC PATCH 04/19] memory: Introduce memory_region_can_be_private() Xiaoyao Li
2023-07-31 21:23   ` Peter Xu
2023-07-31 21:33     ` Michael S. Tsirkin
2023-07-31 21:34     ` Sean Christopherson
2023-07-31 21:36       ` Michael S. Tsirkin
2023-08-01  0:21         ` Peter Xu
2023-08-01 16:23           ` Sean Christopherson
2023-08-01 16:48   ` Claudio Fontana
2023-08-01 16:52     ` Claudio Fontana
2023-08-02  8:05       ` Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 05/19] kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot Xiaoyao Li
2023-08-01 17:10   ` Claudio Fontana
2023-08-03  8:43     ` Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 06/19] i386/pc: Drop pc_machine_kvm_type() Xiaoyao Li
2023-08-02 23:00   ` Isaku Yamahata
2023-07-31 16:21 ` [RFC PATCH 07/19] target/i386: Implement mc->kvm_type() to get VM type Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 08/19] HostMem: Add private property to indicate to use kvm gmem Xiaoyao Li
2023-07-31 17:22   ` Markus Armbruster
2023-08-01 14:54     ` Xiaoyao Li
2023-08-01 14:57     ` Daniel P. Berrangé
2023-08-02  8:04       ` Xiaoyao Li
2023-08-01 17:21   ` David Hildenbrand
2023-08-02  8:03     ` Xiaoyao Li
2023-08-02 14:14       ` David Hildenbrand
2023-08-02 22:53         ` Isaku Yamahata
2023-08-03 13:05           ` David Hildenbrand
2023-07-31 16:21 ` [RFC PATCH 09/19] i386/kvm: Create gmem fd for KVM_X86_SW_PROTECTED_VM Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 10/19] kvm: Introduce support for memory_attributes Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 11/19] kvm/memory: Introduce the infrastructure to set the default shared/private value Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 12/19] i386/kvm: Set memory to default private for KVM_X86_SW_PROTECTED_VM Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 13/19] physmem: replace function name with __func__ in ram_block_discard_range() Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 14/19] physmem: Add ram_block_convert_range Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 15/19] kvm: handle KVM_EXIT_MEMORY_FAULT Xiaoyao Li
2023-08-02 22:25   ` Isaku Yamahata
2023-09-13  6:59     ` Xiaoyao Li
2023-08-09 15:02   ` Xu Yilun
2023-09-13  7:00     ` Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 16/19] trace/kvm: Add trace for page convertion between shared and private Xiaoyao Li
2023-07-31 16:21 ` [RFC PATCH 17/19] pci-host/q35: Move PAM initialization above SMRAM initialization Xiaoyao Li
2023-07-31 16:22 ` [RFC PATCH 18/19] q35: Introduce smm_ranges property for q35-pci-host Xiaoyao Li
2023-07-31 16:22 ` [RFC PATCH 19/19] i386: Disable SMM mode for X86_SW_PROTECTED_VM Xiaoyao Li
2023-08-02 22:27   ` Isaku Yamahata
2023-07-31 16:51 ` [RFC PATCH 00/19] QEMU gmem implemention Daniel P. Berrangé
2023-08-01  1:45   ` Xiaoyao Li
2023-08-10 15:58     ` Michael Roth via
2023-08-14 21:45       ` Isaku Yamahata
2023-07-31 17:10 ` Isaku Yamahata
2023-08-01  1:55   ` Xiaoyao Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).