KVM: selftests: Use kvm_cpu_has() for nSVM soft INT injection test
authorSean Christopherson <seanjc@google.com>
Tue, 14 Jun 2022 20:06:40 +0000 (20:06 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 14 Jul 2022 01:14:13 +0000 (18:14 -0700)
Use kvm_cpu_has() to query for NRIPS support instead of open coding
equivalent functionality using kvm_get_supported_cpuid_entry().

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20220614200707.3315957-16-seanjc@google.com
tools/testing/selftests/kvm/include/x86_64/processor.h
tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c

index 15bccdd..a66d625 100644 (file)
@@ -164,9 +164,6 @@ struct kvm_x86_cpu_feature {
 #define CPUID_XSAVE            (1ul << 26)
 #define CPUID_OSXSAVE          (1ul << 27)
 
-/* CPUID.0x8000_000A.EDX */
-#define CPUID_NRIPS            BIT(3)
-
 /* Page table bitfield declarations */
 #define PTE_PRESENT_MASK        BIT_ULL(0)
 #define PTE_WRITABLE_MASK       BIT_ULL(1)
index 2cc09ab..e637d77 100644 (file)
@@ -194,16 +194,13 @@ done:
 
 int main(int argc, char *argv[])
 {
-       struct kvm_cpuid_entry2 *cpuid;
-
        /* Tell stdout not to buffer its content */
        setbuf(stdout, NULL);
 
        TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM));
 
-       cpuid = kvm_get_supported_cpuid_entry(0x8000000a);
-       TEST_ASSERT(cpuid->edx & CPUID_NRIPS,
-                   "KVM with nSVM is supposed to unconditionally advertise nRIP Save\n");
+       TEST_ASSERT(kvm_cpu_has(X86_FEATURE_NRIPS),
+                   "KVM with nSVM is supposed to unconditionally advertise nRIP Save");
 
        atomic_init(&nmi_stage, 0);