OSDN Git Service

selftests: kvm: Check whether SIDA memop fails for normal guests
authorThomas Huth <thuth@redhat.com>
Tue, 15 Feb 2022 07:48:24 +0000 (08:48 +0100)
committerChristian Borntraeger <borntraeger@linux.ibm.com>
Tue, 15 Feb 2022 15:38:12 +0000 (16:38 +0100)
Commit 2c212e1baedc ("KVM: s390: Return error on SIDA memop on normal
guest") fixed the behavior of the SIDA memops for normal guests. It
would be nice to have a way to test whether the current kernel has
the fix applied or not. Thus add a check to the KVM selftests for
these two memops.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20220215074824.188440-1-thuth@redhat.com
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
tools/testing/selftests/kvm/s390x/memop.c

index 9f49ead..d19c3ff 100644 (file)
@@ -160,6 +160,21 @@ int main(int argc, char *argv[])
        run->psw_mask &= ~(3UL << (63 - 17));   /* Disable AR mode */
        vcpu_run(vm, VCPU_ID);                  /* Run to sync new state */
 
+       /* Check that the SIDA calls are rejected for non-protected guests */
+       ksmo.gaddr = 0;
+       ksmo.flags = 0;
+       ksmo.size = 8;
+       ksmo.op = KVM_S390_MEMOP_SIDA_READ;
+       ksmo.buf = (uintptr_t)mem1;
+       ksmo.sida_offset = 0x1c0;
+       rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
+       TEST_ASSERT(rv == -1 && errno == EINVAL,
+                   "ioctl does not reject SIDA_READ in non-protected mode");
+       ksmo.op = KVM_S390_MEMOP_SIDA_WRITE;
+       rv = _vcpu_ioctl(vm, VCPU_ID, KVM_S390_MEM_OP, &ksmo);
+       TEST_ASSERT(rv == -1 && errno == EINVAL,
+                   "ioctl does not reject SIDA_WRITE in non-protected mode");
+
        kvm_vm_free(vm);
 
        return 0;