diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2014-12-27 15:08:16 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-12-28 04:01:25 -0500 |
commit | dbaff30940d6ef9bfa5f1f0c819cf3344ed3129f (patch) | |
tree | 16bea1eb47bf7e59fc917e03390fc3d263614ccc /virt | |
parent | efbeec7098eee2b3d2359d0cc24bbba0436e7f21 (diff) |
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')
-rw-r--r-- | virt/kvm/kvm_main.c | 4 |
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, | |||
671 | 671 | ||
672 | WARN_ON(mslots[i].id != id); | 672 | WARN_ON(mslots[i].id != id); |
673 | if (!new->npages) { | 673 | if (!new->npages) { |
674 | WARN_ON(!mslots[i].npages); | ||
674 | new->base_gfn = 0; | 675 | new->base_gfn = 0; |
675 | if (mslots[i].npages) | 676 | if (mslots[i].npages) |
676 | slots->used_slots--; | 677 | slots->used_slots--; |
@@ -704,7 +705,8 @@ static void update_memslots(struct kvm_memslots *slots, | |||
704 | slots->id_to_index[mslots[i].id] = i; | 705 | slots->id_to_index[mslots[i].id] = i; |
705 | i--; | 706 | i--; |
706 | } | 707 | } |
707 | } | 708 | } else |
709 | WARN_ON_ONCE(i != slots->used_slots); | ||
708 | 710 | ||
709 | mslots[i] = *new; | 711 | mslots[i] = *new; |
710 | slots->id_to_index[mslots[i].id] = i; | 712 | slots->id_to_index[mslots[i].id] = i; |