[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 1/1] kvm/kvm-all.c: implement KVM_SET_USER_MEMORY_REGION_LIST
From: |
Emanuele Giuseppe Esposito |
Subject: |
[RFC PATCH 1/1] kvm/kvm-all.c: implement KVM_SET_USER_MEMORY_REGION_LIST ioctl |
Date: |
Fri, 9 Sep 2022 07:00:34 -0400 |
Instead of sending memslot updates in each callback, kvm listener
already takes care of sending them in the commit phase, as multiple
ioctls.
Using the new KVM_SET_USER_MEMORY_REGION_LIST, we just need a single
call containing all memory regions to update.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
accel/kvm/kvm-all.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 9780f3d2da..6a7f7b4567 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -1547,30 +1547,25 @@ static void kvm_commit(MemoryListener *listener)
KVMMemoryListener *kml = container_of(listener, KVMMemoryListener,
listener);
KVMState *s = kvm_state;
- int i;
+ int i, ret;
for (i = 0; i < kml->mem_array.list->nent; i++) {
struct kvm_userspace_memory_region_entry *mem;
- int ret;
mem = &kml->mem_array.list->entries[i];
- /*
- * Note that mem is struct kvm_userspace_memory_region_entry, while the
- * kernel expects a kvm_userspace_memory_region, so it will currently
- * ignore mem->invalidate_slot and mem->padding.
- */
- ret = kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, mem);
-
trace_kvm_set_user_memory(mem->slot, mem->flags, mem->guest_phys_addr,
mem->memory_size, mem->userspace_addr, 0);
+ }
- if (ret < 0) {
- error_report("%s: KVM_SET_USER_MEMORY_REGION failed, slot=%d,"
- " start=0x%" PRIx64 ": %s",
- __func__, mem->slot,
- (uint64_t)mem->memory_size, strerror(errno));
- }
+ ret = kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION_LIST,
kml->mem_array.list);
+
+ if (ret < 0) {
+ error_report("%s: KVM_SET_USER_MEMORY_REGION_LIST failed, size=0x%"
+ PRIx64 " flags=0x%" PRIx64 ": %s",
+ __func__, (uint64_t)kml->mem_array.list->nent,
+ (uint64_t)kml->mem_array.list->flags,
+ strerror(errno));
}
kml->mem_array.list->nent = 0;
--
2.31.1