Provide a CPUID leaf that describes the emulated PMU.

Signed-off-by: Avi Kivity <a...@redhat.com>
---
 arch/x86/kvm/x86.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 7bc5e56..7e1a02b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2442,6 +2442,25 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, 
u32 function,
        }
        case 9:
                break;
+       case 0xA: { /* Architectural Performance Monitoring */
+               unsigned version = entry->eax & 0xff;
+               unsigned gp_nr = (entry->eax >> 8) & 0xff;
+               unsigned gp_width = (entry->eax >> 16) & 0xff;
+
+               if (version < 1) {
+                       gp_nr = 2;
+                       gp_width = 40;
+               }
+
+               entry->eax = 0x01             /* version */
+                       | (gp_nr << 8)
+                       | (gp_width << 16)
+                       | (7 << 24);   /* supported counters bitmask length */
+               entry->ebx &= (1 << 7) - 1;
+               entry->ecx = 0;
+               entry->edx = 0;
+               break;
+       }
        /* function 0xb has additional index. */
        case 0xb: {
                int i, level_type;
@@ -2532,7 +2551,6 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, 
u32 function,
        case 3: /* Processor serial number */
        case 5: /* MONITOR/MWAIT */
        case 6: /* Thermal management */
-       case 0xA: /* Architectural Performance Monitoring */
        case 0x80000007: /* Advanced power management */
        case 0xC0000002:
        case 0xC0000003:
-- 
1.7.5.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to