]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Harden and comment XSS / KVM_SET_MSRS interaction
authorSean Christopherson <seanjc@google.com>
Thu, 2 Jun 2022 21:12:22 +0000 (14:12 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 11 Jun 2022 15:46:27 +0000 (11:46 -0400)
Assert that KVM_SET_MSRS returns '0' or '1' when setting XSS to a
non-zero value.  The ioctl() itself should "succeed", its only the
setting of the XSS MSR that should fail/fault.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/x86_64/xss_msr_test.c

index 7bd15f8a805cd7dad131a4de785d0b7bbeff9db5..a6abcb559e7c4e84c0149aa7877e38d273239d3e 100644 (file)
@@ -53,7 +53,12 @@ int main(int argc, char *argv[])
        for (i = 0; i < MSR_BITS; ++i) {
                r = _vcpu_set_msr(vm, VCPU_ID, MSR_IA32_XSS, 1ull << i);
 
-               TEST_ASSERT(r == 0 || xss_in_msr_list,
+               /*
+                * Setting a list of MSRs returns the entry that "faulted", or
+                * the last entry +1 if all MSRs were successfully written.
+                */
+               TEST_ASSERT(!r || r == 1, KVM_IOCTL_ERROR(KVM_SET_MSRS, r));
+               TEST_ASSERT(r != 1 || xss_in_msr_list,
                            "IA32_XSS was able to be set, but was not in save/restore list");
        }