KVM: selftests: Add a testcase to verify GUEST_MEMFD and READONLY are exclusive

Extend set_memory_region_test's invalid flags subtest to verify that
GUEST_MEMFD is incompatible with READONLY. GUEST_MEMFD doesn't currently
support writes from userspace and KVM doesn't support emulated MMIO on
private accesses, and so KVM is supposed to reject the GUEST_MEMFD+READONLY
in order to avoid configuration that KVM can't support.

Link: https://lore.kernel.org/r/20240222190612.2942589-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

Changed files
+6
tools
testing
selftests
+6
tools/testing/selftests/kvm/set_memory_region_test.c
··· 375 375 TEST_ASSERT(r && errno == EINVAL, 376 376 "KVM_SET_USER_MEMORY_REGION2 should have failed, dirty logging private memory is unsupported"); 377 377 378 + r = __vm_set_user_memory_region2(vm, 0, 379 + KVM_MEM_READONLY | KVM_MEM_GUEST_MEMFD, 380 + 0, MEM_REGION_SIZE, NULL, guest_memfd, 0); 381 + TEST_ASSERT(r && errno == EINVAL, 382 + "KVM_SET_USER_MEMORY_REGION2 should have failed, read-only GUEST_MEMFD memslots are unsupported"); 383 + 378 384 close(guest_memfd); 379 385 } 380 386 }