perf/x86: Correctly use FEATURE_PDCM
authorPeter Zijlstra <peterz@infradead.org>
Mon, 3 Feb 2014 13:29:03 +0000 (14:29 +0100)
committerJiri Slaby <jslaby@suse.cz>
Sat, 10 Jan 2015 11:40:17 +0000 (12:40 +0100)
commit c9b08884c9c98929ec2d8abafd78e89062d01ee7 upstream.

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>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
arch/x86/kernel/cpu/perf_event_intel.c

index 02554ddf84812eebb02548b36f7ab9ac0741b585..b400d0be5b03eb9b6c40586a9bbee550b63000cd 100644 (file)
@@ -2288,10 +2288,7 @@ __init int intel_pmu_init(void)
        if (version > 1)
                x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
 
-       /*
-        * v2 and above have a perf capabilities MSR
-        */
-       if (version > 1) {
+       if (boot_cpu_has(X86_FEATURE_PDCM)) {
                u64 capabilities;
 
                rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);