mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 07:38:10 +00:00
kvm: selftests: Fix region overlap check in kvm_util
Fix a call to userspace_mem_region_find to conform to its spec of taking an inclusive, inclusive range. It was previously being called with an inclusive, exclusive range. Also remove a redundant region bounds check in vm_userspace_mem_region_add. Region overlap checking is already performed by the call to userspace_mem_region_find. Tested: Compiled tools/testing/selftests/kvm with -static Ran all resulting test binaries on an Intel Haswell test machine All tests passed Signed-off-by: Ben Gardon <bgardon@google.com> Reviewed-by: Jim Mattson <jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
8997f65700
commit
94a980c39c
1 changed files with 2 additions and 7 deletions
|
@ -571,7 +571,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
|
||||||
* already exist.
|
* already exist.
|
||||||
*/
|
*/
|
||||||
region = (struct userspace_mem_region *) userspace_mem_region_find(
|
region = (struct userspace_mem_region *) userspace_mem_region_find(
|
||||||
vm, guest_paddr, guest_paddr + npages * vm->page_size);
|
vm, guest_paddr, (guest_paddr + npages * vm->page_size) - 1);
|
||||||
if (region != NULL)
|
if (region != NULL)
|
||||||
TEST_ASSERT(false, "overlapping userspace_mem_region already "
|
TEST_ASSERT(false, "overlapping userspace_mem_region already "
|
||||||
"exists\n"
|
"exists\n"
|
||||||
|
@ -587,15 +587,10 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
|
||||||
region = region->next) {
|
region = region->next) {
|
||||||
if (region->region.slot == slot)
|
if (region->region.slot == slot)
|
||||||
break;
|
break;
|
||||||
if ((guest_paddr <= (region->region.guest_phys_addr
|
|
||||||
+ region->region.memory_size))
|
|
||||||
&& ((guest_paddr + npages * vm->page_size)
|
|
||||||
>= region->region.guest_phys_addr))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (region != NULL)
|
if (region != NULL)
|
||||||
TEST_ASSERT(false, "A mem region with the requested slot "
|
TEST_ASSERT(false, "A mem region with the requested slot "
|
||||||
"or overlapping physical memory range already exists.\n"
|
"already exists.\n"
|
||||||
" requested slot: %u paddr: 0x%lx npages: 0x%lx\n"
|
" requested slot: %u paddr: 0x%lx npages: 0x%lx\n"
|
||||||
" existing slot: %u paddr: 0x%lx size: 0x%lx",
|
" existing slot: %u paddr: 0x%lx size: 0x%lx",
|
||||||
slot, guest_paddr, npages,
|
slot, guest_paddr, npages,
|
||||||
|
|
Loading…
Reference in a new issue