All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/64: Fix __check_irq_replay missing decrementer interrupt
@ 2017-08-01 13:59 Nicholas Piggin
  2017-08-03 10:19 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Piggin @ 2017-08-01 13:59 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

If the decrementer wraps and de-asserts the decrementer exception while
hard-disabled, __check_irq_replay has a test to notice the wrap when
interrupts are re-enabled.

The decrementer check must be done when clearing the PACA_IRQ_HARD_DIS
flag, not when the PACA_IRQ_DEC flag is tested. Previously this worked
because the decrementer interrupt was always the first one checked after
clearing the hard disable flag, but HMI check was moved ahead of that,
which introduced this bug.

This can cause a missed decrementer interrupt if we soft-disable
interrupts then take an HMI which is recorded in irq_happened, then
hard-disable interrupts for > 4s to wrap the decrementer.

Fixes: e0e0d6b739 ("powerpc/64: Replay hypervisor maintenance interrupt first")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/irq.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 0bcec745a672..f291f7826abc 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -145,6 +145,19 @@ notrace unsigned int __check_irq_replay(void)
 
 	/* Clear bit 0 which we wouldn't clear otherwise */
 	local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
+	if (happened & PACA_IRQ_HARD_DIS) {
+		/*
+		 * We may have missed a decrementer interrupt if hard disabled.
+		 * Check the decrementer register in case we had a rollover
+		 * while hard disabled.
+		 */
+		if (!(happened & PACA_IRQ_DEC)) {
+			if (decrementer_check_overflow()) {
+				local_paca->irq_happened |= PACA_IRQ_DEC;
+				happened |= PACA_IRQ_DEC;
+			}
+		}
+	}
 
 	/*
 	 * Force the delivery of pending soft-disabled interrupts on PS3.
@@ -170,7 +183,7 @@ notrace unsigned int __check_irq_replay(void)
 	 * in case we also had a rollover while hard disabled
 	 */
 	local_paca->irq_happened &= ~PACA_IRQ_DEC;
-	if ((happened & PACA_IRQ_DEC) || decrementer_check_overflow())
+	if (happened & PACA_IRQ_DEC)
 		return 0x900;
 
 	/* Finally check if an external interrupt happened */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: powerpc/64: Fix __check_irq_replay missing decrementer interrupt
  2017-08-01 13:59 [PATCH] powerpc/64: Fix __check_irq_replay missing decrementer interrupt Nicholas Piggin
@ 2017-08-03 10:19 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2017-08-03 10:19 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin

On Tue, 2017-08-01 at 13:59:28 UTC, Nicholas Piggin wrote:
> If the decrementer wraps and de-asserts the decrementer exception while
> hard-disabled, __check_irq_replay has a test to notice the wrap when
> interrupts are re-enabled.
> 
> The decrementer check must be done when clearing the PACA_IRQ_HARD_DIS
> flag, not when the PACA_IRQ_DEC flag is tested. Previously this worked
> because the decrementer interrupt was always the first one checked after
> clearing the hard disable flag, but HMI check was moved ahead of that,
> which introduced this bug.
> 
> This can cause a missed decrementer interrupt if we soft-disable
> interrupts then take an HMI which is recorded in irq_happened, then
> hard-disable interrupts for > 4s to wrap the decrementer.
> 
> Fixes: e0e0d6b739 ("powerpc/64: Replay hypervisor maintenance interrupt first")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/f283f06014c36acd1ce7f71985b8a3

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-03 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-01 13:59 [PATCH] powerpc/64: Fix __check_irq_replay missing decrementer interrupt Nicholas Piggin
2017-08-03 10:19 ` Michael Ellerman

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.