提交 8903461c 编写于 作者: M Michael Ellerman 提交者: Benjamin Herrenschmidt

powerpc/perf: Fix MMCR2 handling for EBB

In the recent commit b50a6c58 "Clear MMCR2 when enabling PMU", I
screwed up the handling of MMCR2 for tasks using EBB.

We must make sure we set MMCR2 *before* ebb_switch_in(), otherwise we
overwrite the value of MMCR2 that userspace may have written. That
potentially breaks a task that uses EBB and manually uses MMCR2 for
event freezing.

Fixes: b50a6c58 ("powerpc/perf: Clear MMCR2 when enabling PMU")
Cc: stable@vger.kernel.org
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
上级 6f5405bc
...@@ -1307,6 +1307,9 @@ static void power_pmu_enable(struct pmu *pmu) ...@@ -1307,6 +1307,9 @@ static void power_pmu_enable(struct pmu *pmu)
out_enable: out_enable:
pmao_restore_workaround(ebb); pmao_restore_workaround(ebb);
if (ppmu->flags & PPMU_ARCH_207S)
mtspr(SPRN_MMCR2, 0);
mmcr0 = ebb_switch_in(ebb, cpuhw->mmcr[0]); mmcr0 = ebb_switch_in(ebb, cpuhw->mmcr[0]);
mb(); mb();
...@@ -1315,9 +1318,6 @@ static void power_pmu_enable(struct pmu *pmu) ...@@ -1315,9 +1318,6 @@ static void power_pmu_enable(struct pmu *pmu)
write_mmcr0(cpuhw, mmcr0); write_mmcr0(cpuhw, mmcr0);
if (ppmu->flags & PPMU_ARCH_207S)
mtspr(SPRN_MMCR2, 0);
/* /*
* Enable instruction sampling if necessary * Enable instruction sampling if necessary
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册