Skip to content

Commit d9864e7

Browse files
committed
Merge tag 'perf-urgent-2025-06-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 perf fix from Thomas Gleixner: "A single fix for the x86 performance counters on Intel CPUs: The MSR offset calculations for fixed performance counters are stored at the wrong index in the configuration array causing the general purpose counter MSR offset to be overwritten, so both the general purpose and the fixed counters offsets are incorrect. Correct the array index calculation to fix that" * tag 'perf-urgent-2025-06-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel: Fix incorrect MSR index calculations in intel_pmu_config_acr()
2 parents 70b7d65 + 86aa94c commit d9864e7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/x86/events/intel/core.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,26 +2900,28 @@ static void intel_pmu_config_acr(int idx, u64 mask, u32 reload)
29002900
{
29012901
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
29022902
int msr_b, msr_c;
2903+
int msr_offset;
29032904

29042905
if (!mask && !cpuc->acr_cfg_b[idx])
29052906
return;
29062907

29072908
if (idx < INTEL_PMC_IDX_FIXED) {
29082909
msr_b = MSR_IA32_PMC_V6_GP0_CFG_B;
29092910
msr_c = MSR_IA32_PMC_V6_GP0_CFG_C;
2911+
msr_offset = x86_pmu.addr_offset(idx, false);
29102912
} else {
29112913
msr_b = MSR_IA32_PMC_V6_FX0_CFG_B;
29122914
msr_c = MSR_IA32_PMC_V6_FX0_CFG_C;
2913-
idx -= INTEL_PMC_IDX_FIXED;
2915+
msr_offset = x86_pmu.addr_offset(idx - INTEL_PMC_IDX_FIXED, false);
29142916
}
29152917

29162918
if (cpuc->acr_cfg_b[idx] != mask) {
2917-
wrmsrl(msr_b + x86_pmu.addr_offset(idx, false), mask);
2919+
wrmsrl(msr_b + msr_offset, mask);
29182920
cpuc->acr_cfg_b[idx] = mask;
29192921
}
29202922
/* Only need to update the reload value when there is a valid config value. */
29212923
if (mask && cpuc->acr_cfg_c[idx] != reload) {
2922-
wrmsrl(msr_c + x86_pmu.addr_offset(idx, false), reload);
2924+
wrmsrl(msr_c + msr_offset, reload);
29232925
cpuc->acr_cfg_c[idx] = reload;
29242926
}
29252927
}

0 commit comments

Comments
 (0)