Re: linux 3.13 guest crash with -cpu host

Peter Zijlstra
2014-02-03T13:29:07Z

On Mon, Feb 03, 2014 at 10:58:28AM -0200, Eduardo Habkost wrote:
> Linux seems to be trying to read IA32_PERF_CAPABILITIES without checking the
> PDCM flag (CPUID[1].ECX[15]).
>
> I can't see why this wasn't crashing before, though. That code seems to be old.
>
> * v2 and above have a perf capabilities MSR
> */
> if (version > 1) {
> u64 capabilities;
>
> rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
> x86_pmu.intel_cap.capabilities = capabilities;
> }
>
> Where does the "v2 and above have a perf capabilities MSR" claim in the code
> come from?

Dunno, I'm pretty sure I wrote that code but I've no idea, other than
that's what actual hardware does.

I suppose the below would be correct.

diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 0fa4f242f050..9407f61cdc1c 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -2310,10 +2310,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);