KVM: x86: Move nSVM CPUID 0x8000000A handling into common x86 code
authorSean Christopherson <sean.j.christopherson@intel.com>
Mon, 2 Mar 2020 23:57:09 +0000 (15:57 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 16 Mar 2020 16:58:45 +0000 (17:58 +0100)
Handle CPUID 0x8000000A in the main switch in __do_cpuid_func() and drop
->set_supported_cpuid() now that both VMX and SVM implementations are
empty.  Like leaf 0x14 (Intel PT) and leaf 0x8000001F (SEV), leaf
0x8000000A is is (obviously) vendor specific but can be queried in
common code while respecting SVM's wishes by querying kvm_cpu_cap_has().

Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/cpuid.c
arch/x86/kvm/svm.c
arch/x86/kvm/vmx/vmx.c

index 531b5a96df333e4d847e5c0b5658953a8e7d60b6..24c90ea5ddbd1cbe0d1dd1d4e9822aa4bdbe208d 100644 (file)
@@ -1158,8 +1158,6 @@ struct kvm_x86_ops {
 
        void (*set_tdp_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
 
-       void (*set_supported_cpuid)(struct kvm_cpuid_entry2 *entry);
-
        bool (*has_wbinvd_exit)(void);
 
        u64 (*read_l1_tsc_offset)(struct kvm_vcpu *vcpu);
index 5dd67b124a68dce4f35e9473893c8c03c313b81b..cc8b24b4d8f3db9638cbad929a2b8643bfd0a730 100644 (file)
@@ -741,6 +741,17 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
                cpuid_entry_override(entry, CPUID_8000_0008_EBX);
                break;
        }
+       case 0x8000000A:
+               if (!kvm_cpu_cap_has(X86_FEATURE_SVM)) {
+                       entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
+                       break;
+               }
+               entry->eax = 1; /* SVM revision 1 */
+               entry->ebx = 8; /* Lets support 8 ASIDs in case we add proper
+                                  ASID emulation to nested SVM */
+               entry->ecx = 0; /* Reserved */
+               cpuid_entry_override(entry, CPUID_8000_000A_EDX);
+               break;
        case 0x80000019:
                entry->ecx = entry->edx = 0;
                break;
@@ -770,8 +781,6 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
                break;
        }
 
-       kvm_x86_ops->set_supported_cpuid(entry);
-
        r = 0;
 
 out:
index 9b173d5fdc525c2faebbc765ce90735535dfcec8..c6e9910d1149c686695185ef32e7953d4df77693 100644 (file)
@@ -6052,23 +6052,6 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu)
                                         APICV_INHIBIT_REASON_NESTED);
 }
 
-static void svm_set_supported_cpuid(struct kvm_cpuid_entry2 *entry)
-{
-       switch (entry->function) {
-       case 0x8000000A:
-               if (!kvm_cpu_cap_has(X86_FEATURE_SVM)) {
-                       entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
-                       break;
-               }
-               entry->eax = 1; /* SVM revision 1 */
-               entry->ebx = 8; /* Lets support 8 ASIDs in case we add proper
-                                  ASID emulation to nested SVM */
-               entry->ecx = 0; /* Reserved */
-               cpuid_entry_override(entry, CPUID_8000_000A_EDX);
-               break;
-       }
-}
-
 static bool svm_has_wbinvd_exit(void)
 {
        return true;
@@ -7428,8 +7411,6 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
 
        .cpuid_update = svm_cpuid_update,
 
-       .set_supported_cpuid = svm_set_supported_cpuid,
-
        .has_wbinvd_exit = svm_has_wbinvd_exit,
 
        .read_l1_tsc_offset = svm_read_l1_tsc_offset,
index 3ee5f75dd1e1f859f4e19d3a3e5689171202ff34..e91a84bb251c5561b3134a9a87fc542ae91ed07b 100644 (file)
@@ -7102,10 +7102,6 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
        }
 }
 
-static void vmx_set_supported_cpuid(struct kvm_cpuid_entry2 *entry)
-{
-}
-
 static __init void vmx_set_cpu_caps(void)
 {
        kvm_set_cpu_caps();
@@ -7919,7 +7915,6 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
        .get_exit_info = vmx_get_exit_info,
 
        .cpuid_update = vmx_cpuid_update,
-       .set_supported_cpuid = vmx_set_supported_cpuid,
 
        .has_wbinvd_exit = cpu_has_vmx_wbinvd_exit,