summaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-12-27 21:08:16 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2014-12-28 10:01:25 +0100
commitdbaff30940d6ef9bfa5f1f0c819cf3344ed3129f (patch)
tree16bea1eb47bf7e59fc917e03390fc3d263614ccc /virt/kvm/kvm_main.c
parentefbeec7098eee2b3d2359d0cc24bbba0436e7f21 (diff)
downloadblackbird-op-linux-dbaff30940d6ef9bfa5f1f0c819cf3344ed3129f.tar.gz
blackbird-op-linux-dbaff30940d6ef9bfa5f1f0c819cf3344ed3129f.zip
kvm: warn on more invariant breakage
Modifying a non-existent slot is not allowed. Also check that the first loop doesn't move a deleted slot beyond the used part of the mslots array. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 050974c051b5..1cc6e2e19982 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -671,6 +671,7 @@ static void update_memslots(struct kvm_memslots *slots,
WARN_ON(mslots[i].id != id);
if (!new->npages) {
+ WARN_ON(!mslots[i].npages);
new->base_gfn = 0;
if (mslots[i].npages)
slots->used_slots--;
@@ -704,7 +705,8 @@ static void update_memslots(struct kvm_memslots *slots,
slots->id_to_index[mslots[i].id] = i;
i--;
}
- }
+ } else
+ WARN_ON_ONCE(i != slots->used_slots);
mslots[i] = *new;
slots->id_to_index[mslots[i].id] = i;
OpenPOWER on IntegriCloud