Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

oprofile/fsl emb: Don't set MSR[PMM] until after clearing the interrupt.

On an arch 2.06 hypervisor, a pending perfmon interrupt will be delivered
to the hypervisor at any point the guest is running, regardless of
MSR[EE]. In order to reflect this interrupt, the hypervisor has to mask
the interrupt in PMGC0 -- and set MSRP[PMMP] to intercept futher guest
accesses to the PMRs to detect when to unmask (and prevent the guest from
unmasking early, or seeing inconsistent state).

This has the side effect of ignoring any changes the guest makes to
MSR[PMM], so wait until after the interrupt is clear, and thus the
hypervisor should have cleared MSRP[PMMP], before setting MSR[PMM]. The
counters wil not actually run until PMGC0[FAC] is cleared in
pmc_start_ctrs(), so this will not reduce the effectiveness of PMM.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

authored by

Scott Wood and committed by
Kumar Gala
4267ea72 4f0e3322

+8 -7
+8 -7
arch/powerpc/oprofile/op_model_fsl_emb.c
··· 2 2 * Freescale Embedded oprofile support, based on ppc64 oprofile support 3 3 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM 4 4 * 5 - * Copyright (c) 2004 Freescale Semiconductor, Inc 5 + * Copyright (c) 2004, 2010 Freescale Semiconductor, Inc 6 6 * 7 7 * Author: Andy Fleming 8 8 * Maintainer: Kumar Gala <galak@kernel.crashing.org> ··· 321 321 int val; 322 322 int i; 323 323 324 - /* set the PMM bit (see comment below) */ 325 - mtmsr(mfmsr() | MSR_PMM); 326 - 327 324 pc = regs->nip; 328 325 is_kernel = is_kernel_addr(pc); 329 326 ··· 337 340 } 338 341 339 342 /* The freeze bit was set by the interrupt. */ 340 - /* Clear the freeze bit, and reenable the interrupt. 341 - * The counters won't actually start until the rfi clears 342 - * the PMM bit */ 343 + /* Clear the freeze bit, and reenable the interrupt. The 344 + * counters won't actually start until the rfi clears the PMM 345 + * bit. The PMM bit should not be set until after the interrupt 346 + * is cleared to avoid it getting lost in some hypervisor 347 + * environments. 348 + */ 349 + mtmsr(mfmsr() | MSR_PMM); 343 350 pmc_start_ctrs(1); 344 351 } 345 352