All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix 4 "[v3, 28/32] powerpc/64s: interrupt implement exit logic in C"
@ 2020-03-26 19:10 Nicholas Piggin
  0 siblings, 0 replies; only message in thread
From: Nicholas Piggin @ 2020-03-26 19:10 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

The return-to-kernel path has to replay any soft-pending interrupts if it is
returning to a context that had interrupts soft-enabled. It has to do this
carefully and avoid plain enabling interrupts if this is an irq context,
which can cause multiple nesting of interrupts on the stack, and other
unexpected issues.

The code which avoided this case got the soft-mask state wrong, and
marked interrupts as enabled before going around again to retry. This
seems to be mostly harmless except when PREEMPT=y, this calls
preempt_schedule_irq with irqs apparently enabled and runs into a BUG
in kernel/sched/core.c

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/syscall_64.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/syscall_64.c b/arch/powerpc/kernel/syscall_64.c
index 049608d811c7..cf06eb443a80 100644
--- a/arch/powerpc/kernel/syscall_64.c
+++ b/arch/powerpc/kernel/syscall_64.c
@@ -342,11 +342,15 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs, unsign
 			trace_hardirqs_off();
 			local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
 			/*
-			 * Can't local_irq_enable in case we are in interrupt
-			 * context. Must replay directly.
+			 * Can't local_irq_restore to replay if we were in
+			 * interrupt context. Must replay directly.
 			 */
-			replay_soft_interrupts();
-			irq_soft_mask_set(flags);
+			if (irqs_disabled_flags(flags)) {
+				replay_soft_interrupts();
+			} else {
+				local_irq_restore(flags);
+				local_irq_save(flags);
+			}
 			/* Took an interrupt, may have more exit work to do. */
 			goto again;
 		}
-- 
2.23.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-26 19:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 19:10 [PATCH] Fix 4 "[v3, 28/32] powerpc/64s: interrupt implement exit logic in C" Nicholas Piggin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.