[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 3/6] KVM: Notify the state change via RamDiscardManager helpe
From: |
Chenyi Qiang |
Subject: |
[RFC PATCH 3/6] KVM: Notify the state change via RamDiscardManager helper during shared/private conversion |
Date: |
Thu, 25 Jul 2024 03:21:12 -0400 |
Once exit to userspace to convert the page from private to shared or
vice versa at runtime, notify the state change via the
guest_memfd_state_change() helper so that other registered subsystems
like VFIO can be notified.
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
---
accel/kvm/kvm-all.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 854cb86b22..94bbbbd2de 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -48,6 +48,7 @@
#include "kvm-cpus.h"
#include "sysemu/dirtylimit.h"
#include "qemu/range.h"
+#include "sysemu/guest-memfd-manager.h"
#include "hw/boards.h"
#include "sysemu/stats.h"
@@ -2852,6 +2853,7 @@ int kvm_convert_memory(hwaddr start, hwaddr size, bool
to_private)
RAMBlock *rb;
void *addr;
int ret = -1;
+ GuestMemfdManager *gmm;
trace_kvm_convert_memory(start, size, to_private ? "shared_to_private" :
"private_to_shared");
@@ -2914,6 +2916,11 @@ int kvm_convert_memory(hwaddr start, hwaddr size, bool
to_private)
addr = memory_region_get_ram_ptr(mr) + section.offset_within_region;
rb = qemu_ram_block_from_host(addr, false, &offset);
+ gmm = GUEST_MEMFD_MANAGER(mr->rdm);
+ if (gmm) {
+ guest_memfd_state_change(gmm, offset, size, to_private);
+ }
+
if (to_private) {
if (rb->page_size != qemu_real_host_page_size()) {
/*
--
2.43.5
- [RFC PATCH 0/6] Enable shared device assignment, Chenyi Qiang, 2024/07/25
- [RFC PATCH 1/6] guest_memfd: Introduce an object to manage the guest-memfd with RamDiscardManager, Chenyi Qiang, 2024/07/25
- [RFC PATCH 2/6] guest_memfd: Introduce a helper to notify the shared/private state change, Chenyi Qiang, 2024/07/25
- [RFC PATCH 3/6] KVM: Notify the state change via RamDiscardManager helper during shared/private conversion,
Chenyi Qiang <=
- [RFC PATCH 4/6] memory: Register the RamDiscardManager instance upon guest_memfd creation, Chenyi Qiang, 2024/07/25
- [RFC PATCH 5/6] guest-memfd: Default to discarded (private) in guest_memfd_manager, Chenyi Qiang, 2024/07/25
- [RFC PATCH 6/6] RAMBlock: make guest_memfd require coordinate discard, Chenyi Qiang, 2024/07/25
- Re: [RFC PATCH 0/6] Enable shared device assignment, David Hildenbrand, 2024/07/25
- Re: [RFC PATCH 0/6] Enable shared device assignment, Chenyi Qiang, 2024/07/26