skiboot machine check handler
RFC PATCH 1/1 skiboot machine check handler
Provide facilities to decode machine checks into human readable strings, with only sufficient information required to deal with them sanely.
The old machine check stuff was over engineered. The philosophy here is that OPAL should correct anything it possibly can, what it can't handle but the OS might be able to do something with (e.g., uncorrected memory error or SLB multi-hit), it passes back to Linux. Anything else, the OS doesn't care. It doesn't want a huge struct of severities and levels and originators etc that it can't do anything with -- just provide human readable strings for what happened and what was done with it.
A Linux driver for this will be able to cope with new processors.
This also uses the same facility to decode machine checks in OPAL boot.
The code is a bit in flux because it's sitting on top of a few other RFC patches and not quite complete, just wanted opinions about it.
--- core/Makefile.inc | 2 +- core/exceptions.c | 28 ++++- core/mce.c | 306 +++++++++++++++++++++++++++++++++++++++++++++ include/opal-api.h | 41 +++++- include/skiboot.h | 6 + 5 files changed, 379 insertions(+), 4 deletions(-) create mode 100644 core/mce.c
core/Makefile.inc +1 -1
@@ -7,7 +7,7 @@ CORE_OBJS = relocate.o console.o stack.o init.o chip.o mem_region.o vm.o CORE_OBJS += malloc.o lock.o cpu.o utils.o fdt.o opal.o interrupts.o timebase.o CORE_OBJS += opal-msg.o pci.o pci-virt.o pci-slot.o pcie-slot.o CORE_OBJS += pci-opal.o fast-reboot.o device.o exceptions.o trace.o affinity.o -CORE_OBJS += vpd.o platform.o nvram.o nvram-format.o hmi.o +CORE_OBJS += vpd.o platform.o nvram.o nvram-format.o hmi.o mce.o CORE_OBJS += console-log.o ipmi.o time-utils.o pel.o pool.o errorlog.o CORE_OBJS += timer.o i2c.o rtc.o flash.o sensor.o ipmi-opal.o CORE_OBJS += flash-subpartition.o bitmap.o buddy.o pci-quirk.o powercap.o psr.o
core/exceptions.c +26 -2
@@ -32,6 +32,7 @@ static void dump_regs(struct stack_frame *stack)#define EXCEPTION_MAX_STR 320 +#if 0 static void print_recoverable_mce_vm (struct stack_frame *stack,uint64_t nip,uint64_t msr) {char buf[EXCEPTION_MAX_STR ];
@@ -46,6 +47,7 @@ static void print_recoverable_mce_vm(struct stack_frame *stack, uint64_t nip, uidump_regs (stack); prerror("Continuing with VM off\n"); } +#endif void exception_entry (struct stack_frame *stack) {
@@ -103,7 +105,11 @@ void exception_entry(struct stack_frame *stack) }break ; -case 0x200 : +case 0x200 : { +uint64_t mce_flags, mce_addr; +const char *mce_err; + +#if 0 if (this_cpu ()->vm_local_map_inuse) fatal = true;/* local map is non-linear */
@@ -114,12 +120,29 @@ void exception_entry(struct stack_frame *stack) stack->srr1 &= ~(MSR_IR |MSR_DR ); goto out; } +#endif fatal = true;prerror ("***********************************************\n" ); l +=snprintf (buf + l,EXCEPTION_MAX_STR - l,"Fatal MCE at " REG " " , nip); -break ; + l +=snprintf_symbol (buf + l,EXCEPTION_MAX_STR - l, nip); + l +=snprintf (buf + l,EXCEPTION_MAX_STR - l," MSR " REG , msr); +prerror ("%s\n" , buf); + +decode_mce (stack->srr0, stack->srr1, stack->dsisr, stack->dar, + &mce_flags, &mce_err, &mce_addr); + l =0 ; + l +=snprintf (buf + l,EXCEPTION_MAX_STR - l, +"Cause: %s" , mce_err); +prerror ("%s\n" , buf); +if (mce_flags &MCE_INVOLVED_EA ) { + l +=snprintf (buf + l,EXCEPTION_MAX_STR - l, +"Effective address: 0x%016llx" , mce_addr); +prerror ("%s\n" , buf); + } + goto no_symbol; + }case 0x300 :if (vm_dsi (nip, stack->dar, !!(stack->dsisr &DSISR_ISSTORE )))
@@ -195,6 +218,7 @@ void exception_entry(struct stack_frame *stack) l +=snprintf_symbol (buf + l,EXCEPTION_MAX_STR - l, nip); l +=snprintf (buf + l,EXCEPTION_MAX_STR - l," MSR " REG , msr);prerror ("%s\n" , buf); +no_symbol:dump_regs (stack);backtrace_r1 ((uint64_t )stack);if (fatal) {
core/mce.c new file +306 -0
306 lines not on this page · raw message
include/opal-api.h +40 -1
53 lines not on this page · raw message
include/skiboot.h +6 -0
@@ -181,6 +181,12 @@ extern char __sym_map_start[];extern char __sym_map_end[];extern size_t snprintf_symbol (char *buf,size_t len,uint64_t addr); +/* RAS */ +void decode_mce (uint64_t srr0,uint64_t srr1, +uint32_t dsisr,uint64_t dar, +uint64_t *flags,const char **error_str, +uint64_t *address); +/* Direct controls */ extern void direct_controls_init (void );extern int64_t opal_signal_system_reset (int cpu_nr);
Signature · 1 line
2.23.0
Quoted 13 lines · Nicholas Piggin
Provide facilities to decode machine checks into human readable strings, with only sufficient information required to deal with them sanely.
The old machine check stuff was over engineered. The philosophy here is that OPAL should correct anything it possibly can, what it can't handle but the OS might be able to do something with (e.g., uncorrected memory error or SLB multi-hit), it passes back to Linux. Anything else, the OS doesn't care. It doesn't want a huge struct of severities and levels and originators etc that it can't do anything with -- just provide human readable strings for what happened and what was done with it.
Quoted 8 lines
A Linux driver for this will be able to cope with new processors.
This also uses the same facility to decode machine checks in OPAL boot.
The code is a bit in flux because it's sitting on top of a few other RFC patches and not quite complete, just wanted opinions about it.
opal_handle_mce() may have to be treated as special opal call. For MCE that occurs in OPAL context, Linux making opal call will clobber original opal call stack which hit MCE. Same is true with nested MCE in OPAL. Should it just continue using same r1 to avoid clobbering or have a separate stack for mce opal call ?
Thanks,
-Mahesh.
Mahesh J Salgaonkar's on January 16, 2020 5:03 pm:
Quoted 23 lines · Nicholas Piggin
Quoted 13 lines
Provide facilities to decode machine checks into human readable strings, with only sufficient information required to deal with them sanely.
The old machine check stuff was over engineered. The philosophy here is that OPAL should correct anything it possibly can, what it can't handle but the OS might be able to do something with (e.g., uncorrected memory error or SLB multi-hit), it passes back to Linux. Anything else, the OS doesn't care. It doesn't want a huge struct of severities and levels and originators etc that it can't do anything with -- just provide human readable strings for what happened and what was done with it.
Quoted 8 lines
A Linux driver for this will be able to cope with new processors.
This also uses the same facility to decode machine checks in OPAL boot.
The code is a bit in flux because it's sitting on top of a few other RFC patches and not quite complete, just wanted opinions about it.
Quoted 5 lines
opal_handle_mce()may have to be treated as special opal call. For MCE that occurs in OPAL context, Linux making opal call will clobber original opal call stack which hit MCE. Same is true with nested MCE in OPAL. Should it just continue using same r1 to avoid clobbering or have a separate stack for mce opal call ?
Ah, it wasn't clear in my message, sorry: this would only be made available to kernels which use the new calling convention where the kernel provides its own stack for OPAL to use.
That may be controversial itself, that's another RFC but if we went ahead with that approach, then handling re-entrant interrupts like this becomes easy because Linux does all the hard work with NMI/MCE stacks etc.
Thanks,
Nick