Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/kvm: fix compilation on non-x86_64 platforms

MEM_REGION_SLOT and MEM_REGION_GPA are not really needed in
test_invalid_memory_region_flags; the VM never runs and there are no
other slots, so it is okay to use slot 0 and place it at address
zero. This fixes compilation on architectures that do not
define them.

Fixes: 5d74316466f4 ("KVM: selftests: Add a memory region subtest to validate invalid flags")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

+6 -8
-2
tools/testing/selftests/kvm/guest_memfd_test.c
··· 137 137 } 138 138 139 139 for (flag = 0; flag; flag <<= 1) { 140 - uint64_t bit; 141 - 142 140 fd = __vm_create_guest_memfd(vm, page_size, flag); 143 141 TEST_ASSERT(fd == -1 && errno == EINVAL, 144 142 "guest_memfd() with flag '0x%lx' should fail with EINVAL",
+6 -6
tools/testing/selftests/kvm/set_memory_region_test.c
··· 349 349 if ((supported_flags & BIT(i)) && !(v2_only_flags & BIT(i))) 350 350 continue; 351 351 352 - r = __vm_set_user_memory_region(vm, MEM_REGION_SLOT, BIT(i), 353 - MEM_REGION_GPA, MEM_REGION_SIZE, NULL); 352 + r = __vm_set_user_memory_region(vm, 0, BIT(i), 353 + 0, MEM_REGION_SIZE, NULL); 354 354 355 355 TEST_ASSERT(r && errno == EINVAL, 356 356 "KVM_SET_USER_MEMORY_REGION should have failed on v2 only flag 0x%lx", BIT(i)); ··· 358 358 if (supported_flags & BIT(i)) 359 359 continue; 360 360 361 - r = __vm_set_user_memory_region2(vm, MEM_REGION_SLOT, BIT(i), 362 - MEM_REGION_GPA, MEM_REGION_SIZE, NULL, 0, 0); 361 + r = __vm_set_user_memory_region2(vm, 0, BIT(i), 362 + 0, MEM_REGION_SIZE, NULL, 0, 0); 363 363 TEST_ASSERT(r && errno == EINVAL, 364 364 "KVM_SET_USER_MEMORY_REGION2 should have failed on unsupported flag 0x%lx", BIT(i)); 365 365 } 366 366 367 367 if (supported_flags & KVM_MEM_GUEST_MEMFD) { 368 - r = __vm_set_user_memory_region2(vm, MEM_REGION_SLOT, 368 + r = __vm_set_user_memory_region2(vm, 0, 369 369 KVM_MEM_LOG_DIRTY_PAGES | KVM_MEM_GUEST_MEMFD, 370 - MEM_REGION_GPA, MEM_REGION_SIZE, NULL, 0, 0); 370 + 0, MEM_REGION_SIZE, NULL, 0, 0); 371 371 TEST_ASSERT(r && errno == EINVAL, 372 372 "KVM_SET_USER_MEMORY_REGION2 should have failed, dirty logging private memory is unsupported"); 373 373 }