Skip to content

Commit 768c470

Browse files
npigginmpe
authored andcommitted
powerpc/64/interrupt: Reconcile soft-mask state in NMI and fix false BUG
If a NMI hits early in an interrupt handler before the irq soft-mask state is reconciled, that can cause a false-positive BUG with a CONFIG_PPC_IRQ_SOFT_MASK_DEBUG assertion. Remove that assertion and instead check the case that if regs->msr has EE clear, then regs->softe should be marked as disabled so the irq state looks correct to NMI handlers, the same as how it's fixed up in the case it was implicit soft-masked. This doesn't fix a known problem -- the change that was fixed by commit 4ec5fee ("powerpc/64s: Make NMI record implicitly soft-masked code as irqs disabled") was the addition of a warning in the soft-nmi watchdog interrupt which can never actually fire when MSR[EE]=0. However it may be important if NMI handlers grow more code, and it's less surprising to anything using 'regs' - (I tripped over this when working in the area). Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ff058a8 commit 768c470

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

arch/powerpc/include/asm/interrupt.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,16 @@ static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct inte
265265
local_paca->irq_soft_mask = IRQS_ALL_DISABLED;
266266
local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
267267

268-
if (is_implicit_soft_masked(regs)) {
269-
// Adjust regs->softe soft implicit soft-mask, so
270-
// arch_irq_disabled_regs(regs) behaves as expected.
268+
if (!(regs->msr & MSR_EE) || is_implicit_soft_masked(regs)) {
269+
/*
270+
* Adjust regs->softe to be soft-masked if it had not been
271+
* reconcied (e.g., interrupt entry with MSR[EE]=0 but softe
272+
* not yet set disabled), or if it was in an implicit soft
273+
* masked state. This makes arch_irq_disabled_regs(regs)
274+
* behave as expected.
275+
*/
271276
regs->softe = IRQS_ALL_DISABLED;
272277
}
273-
if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
274-
BUG_ON(!arch_irq_disabled_regs(regs) && !(regs->msr & MSR_EE));
275278

276279
/* Don't do any per-CPU operations until interrupt state is fixed */
277280

0 commit comments

Comments
 (0)