HostMem: Add mechanism to opt in kvm guest memfd via MachineState
authorXiaoyao Li <xiaoyao.li@intel.com>
Wed, 20 Mar 2024 08:39:03 +0000 (03:39 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 23 Apr 2024 15:35:25 +0000 (17:35 +0200)
commit37662d85b0b7dded0ebdf6747bef6c3bb7ed6a0c
treeb5d8be3492b7aa7e3df4d1ec71a44180255077fb
parentbd3bcf6962b664ca3bf9c60fdcc4534e8e3d0641
HostMem: Add mechanism to opt in kvm guest memfd via MachineState

Add a new member "guest_memfd" to memory backends. When it's set
to true, it enables RAM_GUEST_MEMFD in ram_flags, thus private kvm
guest_memfd will be allocated during RAMBlock allocation.

Memory backend's @guest_memfd is wired with @require_guest_memfd
field of MachineState. It avoid looking up the machine in phymem.c.

MachineState::require_guest_memfd is supposed to be set by any VMs
that requires KVM guest memfd as private memory, e.g., TDX VM.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-ID: <20240320083945.991426-8-michael.roth@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
backends/hostmem-file.c
backends/hostmem-memfd.c
backends/hostmem-ram.c
backends/hostmem.c
hw/core/machine.c
include/hw/boards.h
include/sysemu/hostmem.h