]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
KVM: x86: Add Intel CPUID.1F cpuid emulation support
authorLike Xu <like.xu@linux.intel.com>
Thu, 6 Jun 2019 01:18:45 +0000 (09:18 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 18 Jun 2019 09:43:44 +0000 (11:43 +0200)
Add support to expose Intel V2 Extended Topology Enumeration Leaf for
some new systems with multiple software-visible die within each package.

Because unimplemented and unexposed leaves should be explicitly reported
as zero, there is no need to limit cpuid.0.eax to the maximum value of
feature configuration but limit it to the highest leaf implemented in
the current code. A single clamping seems sufficient and cheaper.

Co-developed-by: Xiaoyao Li <xiaoyao.li@linux.intel.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@linux.intel.com>
Signed-off-by: Like Xu <like.xu@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/cpuid.c

index 60f87ba2ccca785b67b0e0edbc45e5d9b341ad56..9872f86fdbe9b5e08843db78434d404d1520418e 100644 (file)
@@ -436,7 +436,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 
        switch (function) {
        case 0:
-               entry->eax = min(entry->eax, (u32)(f_intel_pt ? 0x14 : 0xd));
+               /* Limited to the highest leaf implemented in KVM. */
+               entry->eax = min(entry->eax, 0x1fU);
                break;
        case 1:
                entry->edx &= kvm_cpuid_1_edx_x86_features;
@@ -556,7 +557,11 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
                entry->edx = edx.full;
                break;
        }
-       /* function 0xb has additional index. */
+       /*
+        * Per Intel's SDM, the 0x1f is a superset of 0xb,
+        * thus they can be handled by common code.
+        */
+       case 0x1f:
        case 0xb: {
                int i, level_type;