Skip to content
Commit efbeec70 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

kvm: fix sorting of memslots with base_gfn == 0



Before commit 0e60b079 (kvm: change memslot sorting rule from size
to GFN, 2014-12-01), the memslots' sorting key was npages, meaning
that a valid memslot couldn't have its sorting key equal to zero.
On the other hand, a valid memslot can have base_gfn == 0, and invalid
memslots are identified by base_gfn == npages == 0.

Because of this, commit 0e60b079 broke the invariant that invalid
memslots are at the end of the mslots array.  When a memslot with
base_gfn == 0 was created, any invalid memslot before it were left
in place.

This can be fixed by changing the insertion to use a ">=" comparison
instead of "<=", but some care is needed to avoid breaking the case
of deleting a memslot; see the comment in update_memslots.

Thanks to Tiejun Chen for posting an initial patch for this bug.

Reported-by: default avatarJamie Heilman <jamie@audible.transient.net>
Reported-by: default avatarAndy Lutomirski <luto@amacapital.net>
Tested-by: default avatarJamie Heilman <jamie@audible.transient.net>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent a629df7e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment