[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 13/21] i386/kvm: Set memory to default private for KVM_X86
From: |
Xiaoyao Li |
Subject: |
[RFC PATCH v2 13/21] i386/kvm: Set memory to default private for KVM_X86_SW_PROTECTED_VM |
Date: |
Wed, 13 Sep 2023 23:51:09 -0400 |
Register a memory listener for KVM_X86_SW_PROVTED_VM. It set RAM to
private by default.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
include/exec/memory.h | 1 +
target/i386/kvm/sw-protected-vm.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 2c738b5dc420..a2602b783a38 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -820,6 +820,7 @@ struct IOMMUMemoryRegion {
#define MEMORY_LISTENER_PRIORITY_MIN 0
#define MEMORY_LISTENER_PRIORITY_ACCEL 10
#define MEMORY_LISTENER_PRIORITY_DEV_BACKEND 10
+#define MEMORY_LISTENER_PRIORITY_ACCEL_HIGH 20
/**
* struct MemoryListener: callbacks structure for updates to the physical
memory map
diff --git a/target/i386/kvm/sw-protected-vm.c
b/target/i386/kvm/sw-protected-vm.c
index 3cfcc89202a6..f47ac383e1dd 100644
--- a/target/i386/kvm/sw-protected-vm.c
+++ b/target/i386/kvm/sw-protected-vm.c
@@ -12,14 +12,32 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qom/object_interfaces.h"
+#include "exec/address-spaces.h"
+#include "sysemu/kvm.h"
#include "hw/i386/x86.h"
#include "sw-protected-vm.h"
+static void kvm_x86_sw_protected_vm_region_add(MemoryListener *listenr,
+ MemoryRegionSection *section)
+{
+ memory_region_set_default_private(section->mr);
+}
+
+static MemoryListener kvm_x86_sw_protected_vm_memory_listener = {
+ .name = "kvm_x86_sw_protected_vm_memory_listener",
+ .region_add = kvm_x86_sw_protected_vm_region_add,
+ /* Higher than KVM memory listener = 10. */
+ .priority = MEMORY_LISTENER_PRIORITY_ACCEL_HIGH,
+};
+
int sw_protected_vm_kvm_init(MachineState *ms, Error **errp)
{
SwProtectedVm *spvm = SW_PROTECTED_VM(OBJECT(ms->cgs));
+ memory_listener_register(&kvm_x86_sw_protected_vm_memory_listener,
+ &address_space_memory);
+
spvm->parent_obj.ready = true;
return 0;
}
--
2.34.1
- [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, (continued)
- [RFC PATCH v2 03/21] HostMem: Add private property and associate it with RAM_KVM_GMEM, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 04/21] memory: Introduce memory_region_has_gmem_fd(), Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 05/21] kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 06/21] i386: Add support for sw-protected-vm object, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 07/21] i386/pc: Drop pc_machine_kvm_type(), Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 08/21] target/i386: Implement mc->kvm_type() to get VM type, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 09/21] target/i386: Introduce kvm_confidential_guest_init(), Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 10/21] i386/kvm: Implement kvm_sw_protected_vm_init() for sw-protcted-vm specific functions, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 11/21] kvm: Introduce support for memory_attributes, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 12/21] kvm/memory: Introduce the infrastructure to set the default shared/private value, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 13/21] i386/kvm: Set memory to default private for KVM_X86_SW_PROTECTED_VM,
Xiaoyao Li <=
- [RFC PATCH v2 14/21] physmem: replace function name with __func__ in ram_block_discard_range(), Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 15/21] physmem: extract ram_block_discard_range_fd() from ram_block_discard_range(), Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 17/21] kvm: handle KVM_EXIT_MEMORY_FAULT, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 16/21] physmem: Introduce ram_block_convert_range(), Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 18/21] trace/kvm: Add trace for page convertion between shared and private, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 19/21] pci-host/q35: Move PAM initialization above SMRAM initialization, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 20/21] q35: Introduce smm_ranges property for q35-pci-host, Xiaoyao Li, 2023/09/13
- [RFC PATCH v2 21/21] i386: Disable SMM mode for X86_SW_PROTECTED_VM, Xiaoyao Li, 2023/09/13
- Re: [RFC PATCH v2 00/21] QEMU gmem implemention, David Hildenbrand, 2023/09/14