Skip to contentSkip to conversation

kvm: selftest: fix noop test in guest_memfd_test.c

PATCH Applied Patrick Roy 4 participants 5 messages Oct 24, 2024 – Nov 5, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: selftest: fix noop test in guest_memfd_test.c

The loop in test_create_guest_memfd_invalid that is supposed to test that nothing is accepted as a valid flag to KVM_CREATE_GUEST_MEMFD was initializing flag as 0 instead of BIT(0). This caused the loop to immediately exit instead of iterating over BIT(0), BIT(1), ... .

Fixes 8a89efd43423 ("KVM: selftests: Add basic selftest for guest_memfd()")
---
 tools/testing/selftests/kvm/guest_memfd_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/guest_memfd_test.c +1 -1
index ba0c8e9960358..ce687f8d248fc 100644
@@ -134,7 +134,7 @@ static void test_create_guest_memfd_invalid(struct kvm_vm *vm)
 			    size);
 	}
 
-	for (flag = 0; flag; flag <<= 1) {
+	for (flag = BIT(0); flag; flag <<= 1) {
 		fd = __vm_create_guest_memfd(vm, page_size, flag);
 		TEST_ASSERT(fd == -1 && errno == EINVAL,
 			    "guest_memfd() with flag '0x%lx' should fail with EINVAL",
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Patrick Roy

The loop in test_create_guest_memfd_invalid that is supposed to test that nothing is accepted as a valid flag to KVM_CREATE_GUEST_MEMFD was initializing flag as 0 instead of BIT(0). This caused the loop to immediately exit instead of iterating over BIT(0), BIT(1), ... .

Fixes 8a89efd43423 ("KVM: selftests: Add basic selftest for guest_memfd()")
---
 tools/testing/selftests/kvm/guest_memfd_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/guest_memfd_test.c +0 -0
index ba0c8e9960358..ce687f8d248fc 100644

tools/testing/selftests/kvm/guest_memfd_test.c static void test_create_guest_memfd_invalid(struct kvm_vm *vm) · line 140

Quoted 8 lines
tools/testing/selftests/kvm/guest_memfd_test.c +1 -1
@@ -134,7 +134,7 @@ static void test_create_guest_memfd_invalid(struct kvm_vm *vm)
 			    size);
 	}
 
-	for (flag = 0; flag; flag <<= 1) {
+	for (flag = BIT(0); flag; flag <<= 1) {
 		fd = __vm_create_guest_memfd(vm, page_size, flag);
 		TEST_ASSERT(fd == -1 && errno == EINVAL,
 			    "guest_memfd() with flag '0x%lx' should fail with EINVAL",
Reviewed-by on v1 1/1
#2 lore raw
In reply to Patrick Roy
Quoted 16 lines · Patrick Roy

The loop in test_create_guest_memfd_invalid that is supposed to test that nothing is accepted as a valid flag to KVM_CREATE_GUEST_MEMFD was initializing flag as 0 instead of BIT(0). This caused the loop to immediately exit instead of iterating over BIT(0), BIT(1), ... .

Fixes 8a89efd43423 ("KVM: selftests: Add basic selftest for guest_memfd()")
---
 tools/testing/selftests/kvm/guest_memfd_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/guest_memfd_test.c +0 -0
index ba0c8e9960358..ce687f8d248fc 100644

tools/testing/selftests/kvm/guest_memfd_test.c static void test_create_guest_memfd_invalid(struct kvm_vm *vm) · line 140

Quoted 8 lines
tools/testing/selftests/kvm/guest_memfd_test.c +1 -1
@@ -134,7 +134,7 @@ static void test_create_guest_memfd_invalid(struct kvm_vm *vm)
 			    size);
 	}
 
-	for (flag = 0; flag; flag <<= 1) {
+	for (flag = BIT(0); flag; flag <<= 1) {
 		fd = __vm_create_guest_memfd(vm, page_size, flag);
 		TEST_ASSERT(fd == -1 && errno == EINVAL,
 			    "guest_memfd() with flag '0x%lx' should fail with EINVAL",
Signature · 2 lines
BR,
Muhammad Usama Anjum
reviewer Applied
#3 lore raw
In reply to Patrick Roy
Quoted 4 lines · Patrick Roy

The loop in test_create_guest_memfd_invalid that is supposed to test that nothing is accepted as a valid flag to KVM_CREATE_GUEST_MEMFD was initializing flag as 0 instead of BIT(0). This caused the loop to immediately exit instead of iterating over BIT(0), BIT(1), ... .

Applied to kvm-x86 fixes, thanks!

[1/1] kvm: selftest: fix noop test in guest_memfd_test.c

      https://github.com/kvm-x86/linux/commit/fd5b88cc7fbf

--
https://github.com/kvm-x86/linux/tree/next

#4 lore raw
Quoted 10 lines · Sean Christopherson
Quoted 4 lines · Patrick Roy

The loop in test_create_guest_memfd_invalid that is supposed to test that nothing is accepted as a valid flag to KVM_CREATE_GUEST_MEMFD was initializing flag as 0 instead of BIT(0). This caused the loop to immediately exit instead of iterating over BIT(0), BIT(1), ... .

Applied to kvm-x86 fixes, thanks!

[1/1] kvm: selftest: fix noop test in guest_memfd_test.c

      https://github.com/kvm-x86/linux/commit/fd5b88cc7fbf

FYI, I rebased "fixes" onto 6.12-rc5 to avoid several pointless conflicts in other patches. New hash:

[1/1] KVM: selftests: fix unintentional noop test in guest_memfd_test.c

      https://github.com/kvm-x86/linux/commit/945bdae20be5