Skip to contentSkip to conversation

powerpc/xive: Prevent page fault issues in the machine crash handler

PATCH Applied Cédric Le Goater 4 participants 5 messages Oct 31, 2019 – Nov 14, 2019 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/xive: Prevent page fault issues in the machine crash handler

When the machine crash handler is invoked, all interrupts are masked but interrupts which have not been started yet do not have an ESB page mapped in the Linux address space. This crashes the 'crash kexec' sequence on sPAPR guests.

To fix, force the mapping of the ESB page when an interrupt is being mapped in the Linux IRQ number space. This is done by setting the initial state of the interrupt to OFF which is not necessarily the case on PowerNV.

---
 arch/powerpc/sysdev/xive/common.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/powerpc/sysdev/xive/common.c +9 -0
index df832b09e3e9..f5fadbd2533a 100644
@@ -1035,6 +1035,15 @@ static int xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
 	xd->target = XIVE_INVALID_TARGET;
 	irq_set_handler_data(virq, xd);
 
+	/*
+	 * Turn OFF by default the interrupt being mapped. A side
+	 * effect of this check is the mapping the ESB page of the
+	 * interrupt in the Linux address space. This prevents page
+	 * fault issues in the crash handler which masks all
+	 * interrupts.
+	 */
+	xive_esb_read(xd, XIVE_ESB_SET_PQ_01);
+
 	return 0;
 }
 
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Thu, 31 Oct 2019 07:31:00 +0100 Cédric Le Goater <[email protected]> wrote:

When the machine crash handler is invoked, all interrupts are masked but interrupts which have not been started yet do not have an ESB page mapped in the Linux address space. This crashes the 'crash kexec' sequence on sPAPR guests.

Quoted 7 lines

To fix, force the mapping of the ESB page when an interrupt is being mapped in the Linux IRQ number space. This is done by setting the initial state of the interrupt to OFF which is not necessarily the case on PowerNV.

---

Quoted 23 lines
 arch/powerpc/sysdev/xive/common.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/powerpc/sysdev/xive/common.c +9 -0
index df832b09e3e9..f5fadbd2533a 100644
@@ -1035,6 +1035,15 @@ static int xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
 	xd->target = XIVE_INVALID_TARGET;
 	irq_set_handler_data(virq, xd);
 
+	/*
+	 * Turn OFF by default the interrupt being mapped. A side
+	 * effect of this check is the mapping the ESB page of the
+	 * interrupt in the Linux address space. This prevents page
+	 * fault issues in the crash handler which masks all
+	 * interrupts.
+	 */
+	xive_esb_read(xd, XIVE_ESB_SET_PQ_01);
+
 	return 0;
 }
 
#2 lore raw
In reply to Cédric Le Goater
Quoted 4 lines · Cédric Le Goater

When the machine crash handler is invoked, all interrupts are masked but interrupts which have not been started yet do not have an ESB page mapped in the Linux address space. This crashes the 'crash kexec' sequence on sPAPR guests.

This sounds like it needs a Fixes/stable tag?

I used these:

Fixes 243e25112d06 ("powerpc/xive: Native exploitation of the XIVE interrupt controller")
Cc [email protected] # v4.12+

Please tell me if you think that's wrong.

cheers

Quoted 22 lines
arch/powerpc/sysdev/xive/common.c +9 -0
index df832b09e3e9..f5fadbd2533a 100644
@@ -1035,6 +1035,15 @@ static int xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
 	xd->target = XIVE_INVALID_TARGET;
 	irq_set_handler_data(virq, xd);
 
+	/*
+	 * Turn OFF by default the interrupt being mapped. A side
+	 * effect of this check is the mapping the ESB page of the
+	 * interrupt in the Linux address space. This prevents page
+	 * fault issues in the crash handler which masks all
+	 * interrupts.
+	 */
+	xive_esb_read(xd, XIVE_ESB_SET_PQ_01);
+
 	return 0;
 }
 
Signature · 1 line
2.21.0
#3 lore raw
Quoted 7 lines · Michael Ellerman
Quoted 4 lines · Cédric Le Goater

When the machine crash handler is invoked, all interrupts are masked but interrupts which have not been started yet do not have an ESB page mapped in the Linux address space. This crashes the 'crash kexec' sequence on sPAPR guests.

This sounds like it needs a Fixes/stable tag?

yes.

Quoted 6 lines

I used these:

Fixes 243e25112d06 ("powerpc/xive: Native exploitation of the XIVE interrupt controller")
Cc [email protected] # v4.12+

Please tell me if you think that's wrong.

Looks OK to me.

Thanks,

C.

Quoted 25 lines

cheers

Quoted 22 lines
arch/powerpc/sysdev/xive/common.c +9 -0
index df832b09e3e9..f5fadbd2533a 100644
@@ -1035,6 +1035,15 @@ static int xive_irq_alloc_data(unsigned int virq, irq_hw_number_t hw)
 	xd->target = XIVE_INVALID_TARGET;
 	irq_set_handler_data(virq, xd);
 
+	/*
+	 * Turn OFF by default the interrupt being mapped. A side
+	 * effect of this check is the mapping the ESB page of the
+	 * interrupt in the Linux address space. This prevents page
+	 * fault issues in the crash handler which masks all
+	 * interrupts.
+	 */
+	xive_esb_read(xd, XIVE_ESB_SET_PQ_01);
+
 	return 0;
 }
 
Signature · 1 line
2.21.0
#4 lore raw
In reply to Cédric Le Goater
Quoted 11 lines · On Thu, 2019-10-31 at 06:31:00 UTC, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= wrote:

When the machine crash handler is invoked, all interrupts are masked but interrupts which have not been started yet do not have an ESB page mapped in the Linux address space. This crashes the 'crash kexec' sequence on sPAPR guests.

To fix, force the mapping of the ESB page when an interrupt is being mapped in the Linux IRQ number space. This is done by setting the initial state of the interrupt to OFF which is not necessarily the case on PowerNV.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/1ca3dec2b2dff9d286ce6cd64108bda0e98f9710

cheers