aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2011-11-10 07:57:28 -0500
committerAvi Kivity <avi@redhat.com>2011-12-27 04:24:40 -0500
commita6c06ed1a60aff77b27ba558c315c3fed4e35565 (patch)
tree1b2ad5c195928a5408b0fb5c02aaea5c1e975675 /arch
parentfee84b079d5ddee2247b5c1f53162c330c622902 (diff)
KVM: Expose the architectural performance monitoring CPUID leaf
Provide a CPUID leaf that describes the emulated PMU. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/cpuid.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index e70be46f50fc..89b02bfaaca5 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -327,6 +327,35 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
327 } 327 }
328 case 9: 328 case 9:
329 break; 329 break;
330 case 0xa: { /* Architectural Performance Monitoring */
331 struct x86_pmu_capability cap;
332 union cpuid10_eax eax;
333 union cpuid10_edx edx;
334
335 perf_get_x86_pmu_capability(&cap);
336
337 /*
338 * Only support guest architectural pmu on a host
339 * with architectural pmu.
340 */
341 if (!cap.version)
342 memset(&cap, 0, sizeof(cap));
343
344 eax.split.version_id = min(cap.version, 2);
345 eax.split.num_counters = cap.num_counters_gp;
346 eax.split.bit_width = cap.bit_width_gp;
347 eax.split.mask_length = cap.events_mask_len;
348
349 edx.split.num_counters_fixed = cap.num_counters_fixed;
350 edx.split.bit_width_fixed = cap.bit_width_fixed;
351 edx.split.reserved = 0;
352
353 entry->eax = eax.full;
354 entry->ebx = cap.events_mask;
355 entry->ecx = 0;
356 entry->edx = edx.full;
357 break;
358 }
330 /* function 0xb has additional index. */ 359 /* function 0xb has additional index. */
331 case 0xb: { 360 case 0xb: {
332 int i, level_type; 361 int i, level_type;
@@ -427,7 +456,6 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
427 case 3: /* Processor serial number */ 456 case 3: /* Processor serial number */
428 case 5: /* MONITOR/MWAIT */ 457 case 5: /* MONITOR/MWAIT */
429 case 6: /* Thermal management */ 458 case 6: /* Thermal management */
430 case 0xA: /* Architectural Performance Monitoring */
431 case 0x80000007: /* Advanced power management */ 459 case 0x80000007: /* Advanced power management */
432 case 0xC0000002: 460 case 0xC0000002:
433 case 0xC0000003: 461 case 0xC0000003: