[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 11/13] kvm: register private memory slots
From: |
Chao Peng |
Subject: |
[RFC PATCH 11/13] kvm: register private memory slots |
Date: |
Thu, 11 Nov 2021 22:13:50 +0800 |
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
---
accel/kvm/kvm-all.c | 9 +++++++++
include/sysemu/kvm_int.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 0125c17edb..d336458e9e 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -138,6 +138,7 @@ struct KVMState
QTAILQ_HEAD(, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
#endif
KVMMemoryListener memory_listener;
+ KVMMemoryListener private_memory_listener;
QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus;
/* For "info mtree -f" to tell if an MR is registered in KVM */
@@ -359,6 +360,7 @@ static int kvm_set_user_memory_region(KVMMemoryListener
*kml, KVMSlot *slot, boo
mem.guest_phys_addr = slot->start_addr;
mem.userspace_addr = (unsigned long)slot->ram;
mem.flags = slot->flags;
+ mem.fd = slot->fd;
if (slot->memory_size && !new && (mem.flags ^ slot->old_flags) &
KVM_MEM_READONLY) {
/* Set the slot size to 0 before setting the slot to the desired
@@ -1423,6 +1425,9 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
mem->ram_start_offset = ram_start_offset;
mem->ram = ram;
mem->flags = kvm_mem_flags(mr);
+ if (mr->ram_block) {
+ mem->fd = mr->ram_block->fd;
+ }
kvm_slot_init_dirty_bitmap(mem);
err = kvm_set_user_memory_region(kml, mem, true);
if (err) {
@@ -2580,6 +2585,9 @@ static int kvm_init(MachineState *ms)
kvm_memory_listener_register(s, &s->memory_listener,
&address_space_memory, 0);
+ kvm_memory_listener_register(s, &s->private_memory_listener,
+ &address_space_private_memory, 2);
+
if (kvm_eventfds_allowed) {
memory_listener_register(&kvm_io_listener,
&address_space_io);
@@ -2613,6 +2621,7 @@ err:
close(s->fd);
}
g_free(s->memory_listener.slots);
+ g_free(s->private_memory_listener.slots);
return ret;
}
diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h
index c788452cd9..0c11c63263 100644
--- a/include/sysemu/kvm_int.h
+++ b/include/sysemu/kvm_int.h
@@ -28,6 +28,7 @@ typedef struct KVMSlot
int as_id;
/* Cache of the offset in ram address space */
ram_addr_t ram_start_offset;
+ int fd;
} KVMSlot;
typedef struct KVMMemoryListener {
--
2.17.1
- [RFC PATCH 3/6] kvm: x86: add private_ops to memslot, (continued)
- [RFC PATCH 3/6] kvm: x86: add private_ops to memslot, Chao Peng, 2021/11/11
- [RFC PATCH 4/6] kvm: x86: implement private_ops for memfd backing store, Chao Peng, 2021/11/11
- [RFC PATCH 5/6] kvm: x86: add KVM_EXIT_MEMORY_ERROR exit, Chao Peng, 2021/11/11
- [RFC PATCH 6/6] KVM: add KVM_SPLIT_MEMORY_REGION, Chao Peng, 2021/11/11
- [RFC PATCH 07/13] linux-headers: Update, Chao Peng, 2021/11/11
- [RFC PATCH 08/13] hostmem: Add guest private memory to memory backend, Chao Peng, 2021/11/11
- [RFC PATCH 09/13] qmp: Include "guest-private" property for memory backends, Chao Peng, 2021/11/11
- [RFC PATCH 10/13] softmmu/physmem: Add private memory address space, Chao Peng, 2021/11/11
- [RFC PATCH 11/13] kvm: register private memory slots,
Chao Peng <=
- [RFC PATCH 12/13] kvm: handle private to shared memory conversion, Chao Peng, 2021/11/11
- [RFC PATCH 13/13] machine: Add 'private-memory-backend' property, Chao Peng, 2021/11/11