[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 47/70] memory: Introduce memory_region_init_ram_guest_memfd()
|
From: |
Xiaoyao Li |
|
Subject: |
[PATCH v3 47/70] memory: Introduce memory_region_init_ram_guest_memfd() |
|
Date: |
Wed, 15 Nov 2023 02:14:56 -0500 |
Introduce memory_region_init_ram_guest_memfd() to allocate private
guset memfd on the MemoryRegion initialization. It's for the use case of
TDVF, which must be private on TDX case.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
include/exec/memory.h | 6 ++++++
system/memory.c | 27 +++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index c8b0385b19ad..ca23a1a6b336 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1590,6 +1590,12 @@ void memory_region_init_ram(MemoryRegion *mr,
uint64_t size,
Error **errp);
+void memory_region_init_ram_guest_memfd(MemoryRegion *mr,
+ Object *owner,
+ const char *name,
+ uint64_t size,
+ Error **errp);
+
/**
* memory_region_init_rom: Initialize a ROM memory region.
*
diff --git a/system/memory.c b/system/memory.c
index b0c58232b6f7..166eb9fd6f7d 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -3632,6 +3632,33 @@ void memory_region_init_ram(MemoryRegion *mr,
vmstate_register_ram(mr, owner_dev);
}
+void memory_region_init_ram_guest_memfd(MemoryRegion *mr,
+ Object *owner,
+ const char *name,
+ uint64_t size,
+ Error **errp)
+{
+ DeviceState *owner_dev;
+ Error *err = NULL;
+
+ memory_region_init_ram_flags_nomigrate(mr, owner, name, size,
+ RAM_GUEST_MEMFD, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
+ memory_region_set_default_private(mr);
+
+ /* This will assert if owner is neither NULL nor a DeviceState.
+ * We only want the owner here for the purposes of defining a
+ * unique name for migration. TODO: Ideally we should implement
+ * a naming scheme for Objects which are not DeviceStates, in
+ * which case we can relax this restriction.
+ */
+ owner_dev = DEVICE(owner);
+ vmstate_register_ram(mr, owner_dev);
+}
+
void memory_region_init_rom(MemoryRegion *mr,
Object *owner,
const char *name,
--
2.34.1
- [PATCH v3 36/70] kvm/tdx: Don't complain when converting vMMIO region to shared, (continued)
- [PATCH v3 36/70] kvm/tdx: Don't complain when converting vMMIO region to shared, Xiaoyao Li, 2023/11/15
- [PATCH v3 37/70] kvm/tdx: Ignore memory conversion to shared of unassigned region, Xiaoyao Li, 2023/11/15
- [PATCH v3 38/70] i386/tdvf: Introduce function to parse TDVF metadata, Xiaoyao Li, 2023/11/15
- [PATCH v3 39/70] i386/tdx: Parse TDVF metadata for TDX VM, Xiaoyao Li, 2023/11/15
- [PATCH v3 40/70] i386/tdx: Skip BIOS shadowing setup, Xiaoyao Li, 2023/11/15
- [PATCH v3 41/70] i386/tdx: Don't initialize pc.rom for TDX VMs, Xiaoyao Li, 2023/11/15
- [PATCH v3 42/70] i386/tdx: Track mem_ptr for each firmware entry of TDVF, Xiaoyao Li, 2023/11/15
- [PATCH v3 43/70] i386/tdx: Track RAM entries for TDX VM, Xiaoyao Li, 2023/11/15
- [PATCH v3 44/70] headers: Add definitions from UEFI spec for volumes, resources, etc..., Xiaoyao Li, 2023/11/15
- [PATCH v3 45/70] i386/tdx: Setup the TD HOB list, Xiaoyao Li, 2023/11/15
- [PATCH v3 47/70] memory: Introduce memory_region_init_ram_guest_memfd(),
Xiaoyao Li <=
- [PATCH v3 46/70] i386/tdx: Add TDVF memory via KVM_TDX_INIT_MEM_REGION, Xiaoyao Li, 2023/11/15
- [PATCH v3 48/70] i386/tdx: register TDVF as private memory, Xiaoyao Li, 2023/11/15
- [PATCH v3 49/70] i386/tdx: Call KVM_TDX_INIT_VCPU to initialize TDX vcpu, Xiaoyao Li, 2023/11/15
- [PATCH v3 50/70] i386/tdx: Finalize TDX VM, Xiaoyao Li, 2023/11/15
- [PATCH v3 51/70] i386/tdx: handle TDG.VP.VMCALL<SetupEventNotifyInterrupt>, Xiaoyao Li, 2023/11/15
- [PATCH v3 54/70] i386/tdx: handle TDG.VP.VMCALL<MapGPA> hypercall, Xiaoyao Li, 2023/11/15
- [PATCH v3 55/70] i386/tdx: Limit the range size for MapGPA, Xiaoyao Li, 2023/11/15
- [PATCH v3 53/70] i386/tdx: setup a timer for the qio channel, Xiaoyao Li, 2023/11/15
- [PATCH v3 52/70] i386/tdx: handle TDG.VP.VMCALL<GetQuote>, Xiaoyao Li, 2023/11/15