]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Use vcpu_clear_cpuid_feature() to clear x2APIC
authorSean Christopherson <seanjc@google.com>
Tue, 14 Jun 2022 20:06:54 +0000 (20:06 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 14 Jul 2022 01:14:20 +0000 (18:14 -0700)
Add X86_FEATURE_X2APIC and use vcpu_clear_cpuid_feature() to clear x2APIC
support in the xAPIC state test.

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

index 7c0396788f7633fe7a5a675f022a62683ca02f89..db90a80dd09a4685a1b930a8f0db736a03858221 100644 (file)
@@ -83,6 +83,7 @@ struct kvm_x86_cpu_feature {
 #define        X86_FEATURE_SMX                 KVM_X86_CPU_FEATURE(0x1, 0, ECX, 6)
 #define        X86_FEATURE_PDCM                KVM_X86_CPU_FEATURE(0x1, 0, ECX, 15)
 #define        X86_FEATURE_PCID                KVM_X86_CPU_FEATURE(0x1, 0, ECX, 17)
+#define X86_FEATURE_X2APIC             KVM_X86_CPU_FEATURE(0x1, 0, ECX, 21)
 #define        X86_FEATURE_MOVBE               KVM_X86_CPU_FEATURE(0x1, 0, ECX, 22)
 #define        X86_FEATURE_TSC_DEADLINE_TIMER  KVM_X86_CPU_FEATURE(0x1, 0, ECX, 24)
 #define        X86_FEATURE_XSAVE               KVM_X86_CPU_FEATURE(0x1, 0, ECX, 26)
index 52133bb4d85a4725cf6098132423761974de4e25..6f7a5ef667186326d358ca301a90815d12bdf373 100644 (file)
@@ -136,9 +136,7 @@ int main(int argc, char *argv[])
                .vcpu = NULL,
                .is_x2apic = true,
        };
-       struct kvm_cpuid2 *cpuid;
        struct kvm_vm *vm;
-       int i;
 
        vm = vm_create_with_one_vcpu(&x.vcpu, x2apic_guest_code);
        test_icr(&x);
@@ -152,13 +150,7 @@ int main(int argc, char *argv[])
        vm = vm_create_with_one_vcpu(&x.vcpu, xapic_guest_code);
        x.is_x2apic = false;
 
-       cpuid = x.vcpu->cpuid;
-       for (i = 0; i < cpuid->nent; i++) {
-               if (cpuid->entries[i].function == 1)
-                       break;
-       }
-       cpuid->entries[i].ecx &= ~BIT(21);
-       vcpu_set_cpuid(x.vcpu);
+       vcpu_clear_cpuid_feature(x.vcpu, X86_FEATURE_X2APIC);
 
        virt_pg_map(vm, APIC_DEFAULT_GPA, APIC_DEFAULT_GPA);
        test_icr(&x);