kvm: x86: Use AMD CPUID semantics for AMD vCPUs
authorJim Mattson <jmattson@google.com>
Thu, 26 Sep 2019 00:04:18 +0000 (17:04 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 26 Sep 2019 10:31:32 +0000 (12:31 +0200)
When the guest CPUID information represents an AMD vCPU, return all
zeroes for queries of undefined CPUID leaves, whether or not they are
in range.

Signed-off-by: Jim Mattson <jmattson@google.com>
Fixes: bd22f5cfcfe8f6 ("KVM: move and fix substitue search for missing CPUID entries")
Reviewed-by: Marc Orr <marcorr@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
Reviewed-by: Jacob Xu <jacobhxu@google.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/cpuid.c

index a26a1ae03145a2a3bcad4163cfc9615621c10997..ce4a1b3cc3e8218010aa042cbcff15ab06c15a39 100644 (file)
@@ -998,9 +998,11 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
        /*
         * Intel CPUID semantics treats any query for an out-of-range
         * leaf as if the highest basic leaf (i.e. CPUID.0H:EAX) were
-        * requested.
+        * requested. AMD CPUID semantics returns all zeroes for any
+        * undefined leaf, whether or not the leaf is in range.
         */
-       if (!entry && check_limit && !cpuid_function_in_range(vcpu, function)) {
+       if (!entry && check_limit && !guest_cpuid_is_amd(vcpu) &&
+           !cpuid_function_in_range(vcpu, function)) {
                max = kvm_find_cpuid_entry(vcpu, 0, 0);
                if (max) {
                        function = max->eax;