Message ID | 20240709125704.61312-10-schlameuss@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | selftests: kvm: s390: Add s390x ucontrol selftests | expand |
On Tue, 9 Jul 2024 14:57:04 +0200 Christoph Schlameuss <schlameuss@linux.ibm.com> wrote: > Add a test case verifying KVM_SET_USER_MEMORY_REGION and > KVM_SET_USER_MEMORY_REGION2 cannot be executed on ucontrol VMs. > > Executing this test case on not patched kernels will cause a null > pointer dereference in the host kernel. please add a reference to the patch that fixes the bug > > Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com> > --- > .../selftests/kvm/s390x/ucontrol_test.c | 22 +++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c > index 64ad31f667e3..a6f8a51519f8 100644 > --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c > +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c > @@ -587,4 +587,26 @@ TEST_F(uc_kvm, uc_gprs) > ASSERT_EQ(1, sync_regs->gprs[0]); > } > > +TEST_F(uc_kvm, uc_no_user_region) > +{ > + struct kvm_userspace_memory_region region = { > + .slot = 1, > + .guest_phys_addr = self->code_gpa, > + .memory_size = VM_MEM_EXT_SIZE, > + .userspace_addr = (uintptr_t)self->code_hva, > + }; > + struct kvm_userspace_memory_region2 region2 = { > + .slot = 1, > + .guest_phys_addr = self->code_gpa, > + .memory_size = VM_MEM_EXT_SIZE, > + .userspace_addr = (uintptr_t)self->code_hva, > + }; > + > + ASSERT_EQ(-1, ioctl(self->vm_fd, KVM_SET_USER_MEMORY_REGION, ®ion)); > + ASSERT_EQ(EINVAL, errno); > + > + ASSERT_EQ(-1, ioctl(self->vm_fd, KVM_SET_USER_MEMORY_REGION2, ®ion2)); > + ASSERT_EQ(EINVAL, errno); > +} > + > TEST_HARNESS_MAIN
diff --git a/tools/testing/selftests/kvm/s390x/ucontrol_test.c b/tools/testing/selftests/kvm/s390x/ucontrol_test.c index 64ad31f667e3..a6f8a51519f8 100644 --- a/tools/testing/selftests/kvm/s390x/ucontrol_test.c +++ b/tools/testing/selftests/kvm/s390x/ucontrol_test.c @@ -587,4 +587,26 @@ TEST_F(uc_kvm, uc_gprs) ASSERT_EQ(1, sync_regs->gprs[0]); } +TEST_F(uc_kvm, uc_no_user_region) +{ + struct kvm_userspace_memory_region region = { + .slot = 1, + .guest_phys_addr = self->code_gpa, + .memory_size = VM_MEM_EXT_SIZE, + .userspace_addr = (uintptr_t)self->code_hva, + }; + struct kvm_userspace_memory_region2 region2 = { + .slot = 1, + .guest_phys_addr = self->code_gpa, + .memory_size = VM_MEM_EXT_SIZE, + .userspace_addr = (uintptr_t)self->code_hva, + }; + + ASSERT_EQ(-1, ioctl(self->vm_fd, KVM_SET_USER_MEMORY_REGION, ®ion)); + ASSERT_EQ(EINVAL, errno); + + ASSERT_EQ(-1, ioctl(self->vm_fd, KVM_SET_USER_MEMORY_REGION2, ®ion2)); + ASSERT_EQ(EINVAL, errno); +} + TEST_HARNESS_MAIN
Add a test case verifying KVM_SET_USER_MEMORY_REGION and KVM_SET_USER_MEMORY_REGION2 cannot be executed on ucontrol VMs. Executing this test case on not patched kernels will cause a null pointer dereference in the host kernel. Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com> --- .../selftests/kvm/s390x/ucontrol_test.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+)