summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/interrupt.c
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2022-10-14 13:07:29 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2022-10-18 22:46:19 +1100
commita073672eb09670540e95a2a4aa1c46f5da74159f (patch)
tree411299c6b96893732dc0edacd16a00a19fb37d2f /arch/powerpc/kernel/interrupt.c
parente59b3399fde5e173b026d4952b215043e77b4521 (diff)
downloadlinux-a073672eb09670540e95a2a4aa1c46f5da74159f.tar.gz
linux-a073672eb09670540e95a2a4aa1c46f5da74159f.tar.bz2
linux-a073672eb09670540e95a2a4aa1c46f5da74159f.zip
powerpc/64/interrupt: Prevent NMI PMI causing a dangerous warning
NMI PMIs really should not return using the normal interrupt_return function. If such a PMI hits in code returning to user with the context switched to user mode, this warning can fire. This was enough to cause crashes when reproducing on 64s, because another perf interrupt would hit while reporting bug, and that would cause another bug, and so on until smashing the stack. Work around that particular crash for now by just disabling that context warning for PMIs. This is a hack and not a complete fix, there could be other such problems lurking in corners. But it does fix the known crash. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20221014030729.2077151-3-npiggin@gmail.com
Diffstat (limited to 'arch/powerpc/kernel/interrupt.c')
-rw-r--r--arch/powerpc/kernel/interrupt.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index f9db0a172401..7bc93367de68 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -374,10 +374,16 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
if (regs_is_unrecoverable(regs))
unrecoverable_exception(regs);
/*
- * CT_WARN_ON comes here via program_check_exception,
- * so avoid recursion.
+ * CT_WARN_ON comes here via program_check_exception, so avoid
+ * recursion.
+ *
+ * Skip the assertion on PMIs to work around a problem caused by NMI
+ * PMIs incorrectly taking this interrupt return path, it's possible
+ * for this to hit after interrupt exit to user switches context to
+ * user. See also the comment in the performance monitor handler in
+ * exceptions-64e/s.S
*/
- if (TRAP(regs) != INTERRUPT_PROGRAM)
+ if (TRAP(regs) != INTERRUPT_PROGRAM && TRAP(regs) != INTERRUPT_PERFMON)
CT_WARN_ON(ct_state() == CONTEXT_USER);
kuap = kuap_get_and_assert_locked();