Subject: [PATCH 3/4] powernv/pseries: machine check use kernel crash path

From: Nicholas Piggin <[email-masked]>
Date: Wed, 5 Jul 2017 14:04:21 +1000

Similarly to the powernv patch, pseries can recover from and/or
print more error details from a recovered machine check if it
goes via the kernel crash path rather than panic()ing in the case
of MCE in kernel mode.

Signed-off-by: Nicholas Piggin <[email-masked]>
---
 arch/powerpc/platforms/pseries/ras.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 4923ffe230cf..eeac00160de0 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -436,19 +436,19 @@ static int recover_mce(struct pt_regs *regs, struct rtas_error_log *err)
 		       "be degraded\n");
 		recovered = 1;
 
-	} else if (user_mode(regs) && !is_global_init(current) &&
-		   rtas_error_severity(err) == RTAS_SEVERITY_ERROR_SYNC) {
-
+	} else if (rtas_error_severity(err) == RTAS_SEVERITY_ERROR_SYNC) {
 		/*
-		 * If we received a synchronous error when in userspace
-		 * kill the task. Firmware may report details of the fail
-		 * asynchronously, so we can't rely on the target and type
-		 * fields being valid here.
+		 * Firmware may report details of the fail asynchronously, so
+		 * we can't rely on the target and type fields being valid
+		 * here.
 		 */
-		printk(KERN_ERR "MCE: uncorrectable error, killing task "
-		       "%s:%d\n", current->comm, current->pid);
-
-		_exception(SIGBUS, regs, BUS_MCEERR_AR, regs->nip);
+		if ((user_mode(regs))) {
+			printk(KERN_ERR "MCE: uncorrectable error, killing task"
+				" %s:%d\n", current->comm, current->pid);
+			_exception(SIGBUS, regs, BUS_MCEERR_AR, regs->nip);
+		} else {
+			die("Machine check", regs, SIGBUS);
+		}
 		recovered = 1;
 	}
 
-- 
2.11.0