Skip to content

Commit

Permalink
powerpc/perf: Fix MMCR2 handling for EBB
Browse files Browse the repository at this point in the history
In the recent commit b50a6c5 "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: b50a6c5 ("powerpc/perf: Clear MMCR2 when enabling PMU")
Cc: stable@vger.kernel.org
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Michael Ellerman authored and Benjamin Herrenschmidt committed Jul 23, 2014
1 parent 6f5405b commit 8903461
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/powerpc/perf/core-book3s.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,9 @@ static void power_pmu_enable(struct pmu *pmu)
out_enable:
pmao_restore_workaround(ebb);

if (ppmu->flags & PPMU_ARCH_207S)
mtspr(SPRN_MMCR2, 0);

mmcr0 = ebb_switch_in(ebb, cpuhw->mmcr[0]);

mb();
Expand All @@ -1315,9 +1318,6 @@ static void power_pmu_enable(struct pmu *pmu)

write_mmcr0(cpuhw, mmcr0);

if (ppmu->flags & PPMU_ARCH_207S)
mtspr(SPRN_MMCR2, 0);

/*
* Enable instruction sampling if necessary
*/
Expand Down

0 comments on commit 8903461

Please sign in to comment.