Skip to content

Commit e9e60c8

Browse files
committed
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: 5d74316 ("KVM: selftests: Add a memory region subtest to validate invalid flags") Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 6c370dc commit e9e60c8

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

tools/testing/selftests/kvm/guest_memfd_test.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ static void test_create_guest_memfd_invalid(struct kvm_vm *vm)
137137
}
138138

139139
for (flag = 0; flag; flag <<= 1) {
140-
uint64_t bit;
141-
142140
fd = __vm_create_guest_memfd(vm, page_size, flag);
143141
TEST_ASSERT(fd == -1 && errno == EINVAL,
144142
"guest_memfd() with flag '0x%lx' should fail with EINVAL",

tools/testing/selftests/kvm/set_memory_region_test.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,25 +349,25 @@ static void test_invalid_memory_region_flags(void)
349349
if ((supported_flags & BIT(i)) && !(v2_only_flags & BIT(i)))
350350
continue;
351351

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);
354354

355355
TEST_ASSERT(r && errno == EINVAL,
356356
"KVM_SET_USER_MEMORY_REGION should have failed on v2 only flag 0x%lx", BIT(i));
357357

358358
if (supported_flags & BIT(i))
359359
continue;
360360

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);
363363
TEST_ASSERT(r && errno == EINVAL,
364364
"KVM_SET_USER_MEMORY_REGION2 should have failed on unsupported flag 0x%lx", BIT(i));
365365
}
366366

367367
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,
369369
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);
371371
TEST_ASSERT(r && errno == EINVAL,
372372
"KVM_SET_USER_MEMORY_REGION2 should have failed, dirty logging private memory is unsupported");
373373
}

0 commit comments

Comments
 (0)