KVM: selftests: fix unintentional noop test in guest_memfd_test.c
authorPatrick Roy <roypat@amazon.co.uk>
Thu, 24 Oct 2024 09:59:53 +0000 (10:59 +0100)
committerSean Christopherson <seanjc@google.com>
Tue, 5 Nov 2024 05:10:28 +0000 (21:10 -0800)
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()")
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Reviewed-by: James Gowans <jgowans@amazon.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Link: https://lore.kernel.org/r/20241024095956.3668818-1-roypat@amazon.co.uk
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/guest_memfd_test.c

index ba0c8e996035848821adc5d2b87cfbbca6c7e39c..ce687f8d248fcf9fe4523e77d597b44004448ace 100644 (file)
@@ -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",