Message ID | 20220909104506.738478-9-eesposit@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | kvm: implement atomic memslot updates | expand |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 31e46f9a06fa..ecd43560281c 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1948,7 +1948,7 @@ static int kvm_prepare_batch(struct kvm *kvm, as_id = mem->slot >> 16; id = (u16)mem->slot; - slots = __kvm_memslots(kvm, as_id); + slots = kvm_get_inactive_memslots(kvm, as_id); /* * Note, the old memslot (and the pointer itself!) may be invalidated
Instead of looking at the active list, look at the inactive. This causes no harm to the current code, as active and inactive lists are identical at this point. In addition, provide flexibility for atomic memslot updates, because in that case we want to perform multiple updates in the inactive list first, and then perform a single swap only. If we were to use the active list, previous updates that were not yet swapped won't be seen, and the following logic in kvm_prepare_batch() could for example find an old memslot that was deleted in the inactive but not in the active, thus wrongly assuming that the coming request is a MOVE and not a CREATE. Note that this also causes no harm to the invalidate memslot, since we are already inserting it as replacement in both active and inactive list. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)