[PATCH] powerpc: Send SIGBUS from machine_check

Joakim Tjernlund joakim.tjernlund at infinera.com
Fri Oct 2 03:05:57 AEST 2020


Embedded PPC CPU should send SIGBUS to user space when applicable.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund at infinera.com>
---
 arch/powerpc/kernel/traps.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 0381242920d9..12715d24141c 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -621,6 +621,11 @@ int machine_check_e500mc(struct pt_regs *regs)
 		       reason & MCSR_MEA ? "Effective" : "Physical", addr);
 	}
 
+	if ((user_mode(regs))) {
+		_exception(SIGBUS, regs, reason, regs->nip);
+		recoverable = 1;
+	}
+
 silent_out:
 	mtspr(SPRN_MCSR, mcsr);
 	return mfspr(SPRN_MCSR) == 0 && recoverable;
@@ -665,6 +670,10 @@ int machine_check_e500(struct pt_regs *regs)
 	if (reason & MCSR_BUS_RPERR)
 		printk("Bus - Read Parity Error\n");
 
+	if ((user_mode(regs))) {
+		_exception(SIGBUS, regs, reason, regs->nip);
+		return 1;
+	}
 	return 0;
 }
 
@@ -695,6 +704,10 @@ int machine_check_e200(struct pt_regs *regs)
 	if (reason & MCSR_BUS_WRERR)
 		printk("Bus - Write Bus Error on buffered store or cache line push\n");
 
+	if ((user_mode(regs))) {
+		_exception(SIGBUS, regs, reason, regs->nip);
+		return 1;
+	}
 	return 0;
 }
 #elif defined(CONFIG_PPC32)
@@ -731,6 +744,10 @@ int machine_check_generic(struct pt_regs *regs)
 	default:
 		printk("Unknown values in msr\n");
 	}
+	if ((user_mode(regs))) {
+		_exception(SIGBUS, regs, reason, regs->nip);
+		return 1;
+	}
 	return 0;
 }
 #endif /* everything else */
-- 
2.26.2



More information about the Linuxppc-dev mailing list