Subject: [PATCH][RFC] opal: allow some opal calls to re-enter OPAL in case we take a NMI

From: Nicholas Piggin <[email-masked]>
Date: Wed, 17 Jan 2018 22:08:31 +1000

I'm not sure if I like this, as said in the other mail. Seems a bit
arbitrary. I wouldn't mind making a single special opal call,
OPAL_MAYDAY, which is allowed through the reentrancy check, stops
all other CPUs, prints some opal backtraces, then allows the remaining
CPU to issue more OPAL calls, so we can print the Linux console out,
reboot, etc.

That would require kernel change, so maybe we can do something like
this for older kernels.
---
 core/opal.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/opal.c b/core/opal.c
index fd69359c4..d0dd5b3b3 100644
--- a/core/opal.c
+++ b/core/opal.c
@@ -145,7 +145,8 @@ int64_t opal_entry_check(struct stack_frame *eframe)
 	if (!opal_quiesce_state && cpu->in_opal_call) {
 		printf("CPU ATTEMPT TO RE-ENTER FIRMWARE! PIR=%04lx cpu @%p -> pir=%04x token=%llu\n",
 		       mfspr(SPR_PIR), cpu, cpu->pir, token);
-		if (token != OPAL_CEC_REBOOT &&
+		if (token != OPAL_QUIESCE &&
+				token != OPAL_CEC_REBOOT &&
 				token != OPAL_CEC_POWER_DOWN &&
 				token != OPAL_CEC_REBOOT2 &&
 				token != OPAL_SIGNAL_SYSTEM_RESET)
-- 
2.15.1