lkml.org 
[lkml]   [2022]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 7/9] kvm_main.c: duplicate invalid memslot also in inactive list
Date
In preparation for atomic memslot updates, make sure the
invalid memslot is also replacing the old one in the inactive list.

This implies that once we want to insert the new slot for a MOVE,
or simply delete the existing one for a DELETE,
we need to remove the "invalid" slot, not the "old" one.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
virt/kvm/kvm_main.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 6b73615891f0..31e46f9a06fa 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1830,6 +1830,7 @@ static int kvm_prepare_memslot(struct kvm *kvm,
}
batch->invalid = invalid_slot;
kvm_invalidate_memslot(kvm, old, invalid_slot);
+ kvm_replace_memslot(kvm, old, invalid_slot);
}

r = kvm_prepare_memory_region(kvm, batch);
@@ -1900,10 +1901,14 @@ static int kvm_set_memslot(struct kvm *kvm,
return r;

/*
- * if change is DELETE or MOVE, invalid is in active memslots
- * and old in inactive, so replace old with new.
+ * if change is DELETE or MOVE, invalid is in both active and inactive
+ * memslot list. This means that we don't need old anymore, and
+ * we should replace invalid with new.
*/
- kvm_replace_memslot(kvm, batch->old, batch->new);
+ if (batch->change == KVM_MR_DELETE || batch->change == KVM_MR_MOVE)
+ kvm_replace_memslot(kvm, batch->invalid, batch->new);
+ else
+ kvm_replace_memslot(kvm, batch->old, batch->new);

/* either old or invalid is the same, since invalid is old's copy */
as_id = kvm_memslots_get_as_id(batch->old, batch->new);
--
2.31.1
\
 
 \ /
  Last update: 2022-09-09 12:46    [W:0.189 / U:2.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site