[PATCH] powerpc/xive: Discard disabled interrupts in get_irqchip_state()

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE1777d LANDED

Landed in mainline as 6f779e1d359b on 2021-10-13.

4 messages, 3 authors, 2021-10-17 · open the first message on its own page

[PATCH] powerpc/xive: Discard disabled interrupts in get_irqchip_state()

From: Cédric Le Goater <clg@kaod.org>
Date: 2021-10-11 07:10:43

When an interrupt is passed through, the KVM XIVE device calls the
set_vcpu_affinity() handler which raises the P bit to mask the
interrupt and to catch any in-flight interrupts while routing the
interrupt to the guest.

On the guest side, drivers (like some Intels) can request at probe
time some MSIs and call synchronize_irq() to check that there are no
in flight interrupts. This will call the XIVE get_irqchip_state()
handler which will always return true as the interrupt P bit has been
set on the host side and lock the CPU in an infinite loop.

Fix that by discarding disabled interrupts in get_irqchip_state().

Fixes: da15c03b047d ("powerpc/xive: Implement get_irqchip_state method for XIVE to fix shutdown race")
Cc: stable@vger.kernel.org#v5.4+
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 arch/powerpc/sysdev/xive/common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index c732ce5a3e1a..c5d75c02ad8b 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -945,7 +945,8 @@ static int xive_get_irqchip_state(struct irq_data *data,
 		 * interrupt to be inactive in that case.
 		 */
 		*state = (pq != XIVE_ESB_INVALID) && !xd->stale_p &&
-			(xd->saved_p || !!(pq & XIVE_ESB_VAL_P));
+			(xd->saved_p || (!!(pq & XIVE_ESB_VAL_P) &&
+			 !irqd_irq_disabled(data)));
 		return 0;
 	default:
 		return -EINVAL;
-- 
2.31.1

Re: [PATCH] powerpc/xive: Discard disabled interrupts in get_irqchip_state()

From: seeteena <hidden>
Date: 2021-10-11 11:36:12

Tested-by: seeteena<redacted>

I have used a KVM guest with a passthrough ethernet adapter and the 
lspci output to identify the adapter.

Re: [PATCH] powerpc/xive: Discard disabled interrupts in get_irqchip_state()

From: seeteena <hidden>
Date: 2021-10-11 11:36:52

Tested-by: seeteena<redacted>

I have used a KVM guest with a passthrough ethernet adapter and the 
lspci output to identify the adapter.

Re: [PATCH] powerpc/xive: Discard disabled interrupts in get_irqchip_state()

From: Michael Ellerman <hidden>
Date: 2021-10-17 12:28:57

On Mon, 11 Oct 2021 09:02:03 +0200, Cédric Le Goater wrote:
When an interrupt is passed through, the KVM XIVE device calls the
set_vcpu_affinity() handler which raises the P bit to mask the
interrupt and to catch any in-flight interrupts while routing the
interrupt to the guest.

On the guest side, drivers (like some Intels) can request at probe
time some MSIs and call synchronize_irq() to check that there are no
in flight interrupts. This will call the XIVE get_irqchip_state()
handler which will always return true as the interrupt P bit has been
set on the host side and lock the CPU in an infinite loop.

[...]
Applied to powerpc/fixes.

[1/1] powerpc/xive: Discard disabled interrupts in get_irqchip_state()
      https://git.kernel.org/powerpc/c/6f779e1d359b8d5801f677c1d49dcfa10bf95674

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help