Commit c9b08884c9c98929ec2d8abafd78e89062d01ee7

Authored by Peter Zijlstra
Committed by Thomas Gleixner
1 parent a3ef2229c9

perf/x86: Correctly use FEATURE_PDCM

The current code simply assumes Intel Arch PerfMon v2+ to have
the IA32_PERF_CAPABILITIES MSR; the SDM specifies that we should check
CPUID[1].ECX[15] (aka, FEATURE_PDCM) instead.

This was found by KVM which implements v2+ but didn't provide the
capabilities MSR. Change the code to DTRT; KVM will also implement the
MSR and return 0.

Cc: pbonzini@redhat.com
Reported-by: "Michael S. Tsirkin" <mst@redhat.com>
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140203132903.GI8874@twins.programming.kicks-ass.net
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Showing 1 changed file with 1 additions and 4 deletions Side-by-side Diff

arch/x86/kernel/cpu/perf_event_intel.c
... ... @@ -2308,10 +2308,7 @@
2308 2308 if (version > 1)
2309 2309 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
2310 2310  
2311   - /*
2312   - * v2 and above have a perf capabilities MSR
2313   - */
2314   - if (version > 1) {
  2311 + if (boot_cpu_has(X86_FEATURE_PDCM)) {
2315 2312 u64 capabilities;
2316 2313  
2317 2314 rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);