1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2001 Dave Engebretsen IBM Corporation
6 #include <linux/sched.h>
7 #include <linux/interrupt.h>
11 #include <linux/reboot.h>
12 #include <linux/irq_work.h>
14 #include <asm/machdep.h>
16 #include <asm/firmware.h>
21 static unsigned char ras_log_buf
[RTAS_ERROR_LOG_MAX
];
22 static DEFINE_SPINLOCK(ras_log_buf_lock
);
24 static int ras_check_exception_token
;
26 static void mce_process_errlog_event(struct irq_work
*work
);
27 static struct irq_work mce_errlog_process_work
= {
28 .func
= mce_process_errlog_event
,
31 #define EPOW_SENSOR_TOKEN 9
32 #define EPOW_SENSOR_INDEX 0
34 /* EPOW events counter variable */
35 static int num_epow_events
;
37 static irqreturn_t
ras_hotplug_interrupt(int irq
, void *dev_id
);
38 static irqreturn_t
ras_epow_interrupt(int irq
, void *dev_id
);
39 static irqreturn_t
ras_error_interrupt(int irq
, void *dev_id
);
41 /* RTAS pseries MCE errorlog section. */
42 struct pseries_mc_errorlog
{
47 * sub_err_type (1 byte). Bit fields depends on error_type
55 * For error_type == MC_ERROR_TYPE_UE
57 * X 1: Permanent or Transient UE.
58 * X 1: Effective address provided.
59 * X 1: Logical address provided.
61 * XXX 3: Type of UE error.
63 * For error_type != MC_ERROR_TYPE_UE
65 * X 1: Effective address provided.
67 * XX 2: Type of SLB/ERAT/TLB error.
71 __be64 effective_address
;
72 __be64 logical_address
;
75 /* RTAS pseries MCE error types */
76 #define MC_ERROR_TYPE_UE 0x00
77 #define MC_ERROR_TYPE_SLB 0x01
78 #define MC_ERROR_TYPE_ERAT 0x02
79 #define MC_ERROR_TYPE_TLB 0x04
80 #define MC_ERROR_TYPE_D_CACHE 0x05
81 #define MC_ERROR_TYPE_I_CACHE 0x07
83 /* RTAS pseries MCE error sub types */
84 #define MC_ERROR_UE_INDETERMINATE 0
85 #define MC_ERROR_UE_IFETCH 1
86 #define MC_ERROR_UE_PAGE_TABLE_WALK_IFETCH 2
87 #define MC_ERROR_UE_LOAD_STORE 3
88 #define MC_ERROR_UE_PAGE_TABLE_WALK_LOAD_STORE 4
90 #define MC_ERROR_SLB_PARITY 0
91 #define MC_ERROR_SLB_MULTIHIT 1
92 #define MC_ERROR_SLB_INDETERMINATE 2
94 #define MC_ERROR_ERAT_PARITY 1
95 #define MC_ERROR_ERAT_MULTIHIT 2
96 #define MC_ERROR_ERAT_INDETERMINATE 3
98 #define MC_ERROR_TLB_PARITY 1
99 #define MC_ERROR_TLB_MULTIHIT 2
100 #define MC_ERROR_TLB_INDETERMINATE 3
102 static inline u8
rtas_mc_error_sub_type(const struct pseries_mc_errorlog
*mlog
)
104 switch (mlog
->error_type
) {
105 case MC_ERROR_TYPE_UE
:
106 return (mlog
->sub_err_type
& 0x07);
107 case MC_ERROR_TYPE_SLB
:
108 case MC_ERROR_TYPE_ERAT
:
109 case MC_ERROR_TYPE_TLB
:
110 return (mlog
->sub_err_type
& 0x03);
117 inline u64
rtas_mc_get_effective_addr(const struct pseries_mc_errorlog
*mlog
)
121 switch (mlog
->error_type
) {
122 case MC_ERROR_TYPE_UE
:
123 if (mlog
->sub_err_type
& 0x40)
124 addr
= mlog
->effective_address
;
126 case MC_ERROR_TYPE_SLB
:
127 case MC_ERROR_TYPE_ERAT
:
128 case MC_ERROR_TYPE_TLB
:
129 if (mlog
->sub_err_type
& 0x80)
130 addr
= mlog
->effective_address
;
134 return be64_to_cpu(addr
);
138 * Enable the hotplug interrupt late because processing them may touch other
139 * devices or systems (e.g. hugepages) that have not been initialized at the
142 int __init
init_ras_hotplug_IRQ(void)
144 struct device_node
*np
;
147 np
= of_find_node_by_path("/event-sources/hot-plug-events");
149 if (dlpar_workqueue_init() == 0)
150 request_event_sources_irqs(np
, ras_hotplug_interrupt
,
157 machine_late_initcall(pseries
, init_ras_hotplug_IRQ
);
160 * Initialize handlers for the set of interrupts caused by hardware errors
161 * and power system events.
163 static int __init
init_ras_IRQ(void)
165 struct device_node
*np
;
167 ras_check_exception_token
= rtas_token("check-exception");
169 /* Internal Errors */
170 np
= of_find_node_by_path("/event-sources/internal-errors");
172 request_event_sources_irqs(np
, ras_error_interrupt
,
178 np
= of_find_node_by_path("/event-sources/epow-events");
180 request_event_sources_irqs(np
, ras_epow_interrupt
, "RAS_EPOW");
186 machine_subsys_initcall(pseries
, init_ras_IRQ
);
188 #define EPOW_SHUTDOWN_NORMAL 1
189 #define EPOW_SHUTDOWN_ON_UPS 2
190 #define EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS 3
191 #define EPOW_SHUTDOWN_AMBIENT_TEMPERATURE_TOO_HIGH 4
193 static void handle_system_shutdown(char event_modifier
)
195 switch (event_modifier
) {
196 case EPOW_SHUTDOWN_NORMAL
:
197 pr_emerg("Power off requested\n");
198 orderly_poweroff(true);
201 case EPOW_SHUTDOWN_ON_UPS
:
202 pr_emerg("Loss of system power detected. System is running on"
203 " UPS/battery. Check RTAS error log for details\n");
204 orderly_poweroff(true);
207 case EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS
:
208 pr_emerg("Loss of system critical functions detected. Check"
209 " RTAS error log for details\n");
210 orderly_poweroff(true);
213 case EPOW_SHUTDOWN_AMBIENT_TEMPERATURE_TOO_HIGH
:
214 pr_emerg("High ambient temperature detected. Check RTAS"
215 " error log for details\n");
216 orderly_poweroff(true);
220 pr_err("Unknown power/cooling shutdown event (modifier = %d)\n",
225 struct epow_errorlog
{
226 unsigned char sensor_value
;
227 unsigned char event_modifier
;
228 unsigned char extended_modifier
;
229 unsigned char reserved
;
230 unsigned char platform_reason
;
234 #define EPOW_WARN_COOLING 1
235 #define EPOW_WARN_POWER 2
236 #define EPOW_SYSTEM_SHUTDOWN 3
237 #define EPOW_SYSTEM_HALT 4
238 #define EPOW_MAIN_ENCLOSURE 5
239 #define EPOW_POWER_OFF 7
241 static void rtas_parse_epow_errlog(struct rtas_error_log
*log
)
243 struct pseries_errorlog
*pseries_log
;
244 struct epow_errorlog
*epow_log
;
248 pseries_log
= get_pseries_errorlog(log
, PSERIES_ELOG_SECT_ID_EPOW
);
249 if (pseries_log
== NULL
)
252 epow_log
= (struct epow_errorlog
*)pseries_log
->data
;
253 action_code
= epow_log
->sensor_value
& 0xF; /* bottom 4 bits */
254 modifier
= epow_log
->event_modifier
& 0xF; /* bottom 4 bits */
256 switch (action_code
) {
258 if (num_epow_events
) {
259 pr_info("Non critical power/cooling issue cleared\n");
264 case EPOW_WARN_COOLING
:
265 pr_info("Non-critical cooling issue detected. Check RTAS error"
266 " log for details\n");
269 case EPOW_WARN_POWER
:
270 pr_info("Non-critical power issue detected. Check RTAS error"
271 " log for details\n");
274 case EPOW_SYSTEM_SHUTDOWN
:
275 handle_system_shutdown(epow_log
->event_modifier
);
278 case EPOW_SYSTEM_HALT
:
279 pr_emerg("Critical power/cooling issue detected. Check RTAS"
280 " error log for details. Powering off.\n");
281 orderly_poweroff(true);
284 case EPOW_MAIN_ENCLOSURE
:
286 pr_emerg("System about to lose power. Check RTAS error log "
287 " for details. Powering off immediately.\n");
293 pr_err("Unknown power/cooling event (action code = %d)\n",
297 /* Increment epow events counter variable */
298 if (action_code
!= EPOW_RESET
)
302 static irqreturn_t
ras_hotplug_interrupt(int irq
, void *dev_id
)
304 struct pseries_errorlog
*pseries_log
;
305 struct pseries_hp_errorlog
*hp_elog
;
307 spin_lock(&ras_log_buf_lock
);
309 rtas_call(ras_check_exception_token
, 6, 1, NULL
,
310 RTAS_VECTOR_EXTERNAL_INTERRUPT
, virq_to_hw(irq
),
311 RTAS_HOTPLUG_EVENTS
, 0, __pa(&ras_log_buf
),
312 rtas_get_error_log_max());
314 pseries_log
= get_pseries_errorlog((struct rtas_error_log
*)ras_log_buf
,
315 PSERIES_ELOG_SECT_ID_HOTPLUG
);
316 hp_elog
= (struct pseries_hp_errorlog
*)pseries_log
->data
;
319 * Since PCI hotplug is not currently supported on pseries, put PCI
320 * hotplug events on the ras_log_buf to be handled by rtas_errd.
322 if (hp_elog
->resource
== PSERIES_HP_ELOG_RESOURCE_MEM
||
323 hp_elog
->resource
== PSERIES_HP_ELOG_RESOURCE_CPU
||
324 hp_elog
->resource
== PSERIES_HP_ELOG_RESOURCE_PMEM
)
325 queue_hotplug_event(hp_elog
);
327 log_error(ras_log_buf
, ERR_TYPE_RTAS_LOG
, 0);
329 spin_unlock(&ras_log_buf_lock
);
333 /* Handle environmental and power warning (EPOW) interrupts. */
334 static irqreturn_t
ras_epow_interrupt(int irq
, void *dev_id
)
340 status
= rtas_get_sensor_fast(EPOW_SENSOR_TOKEN
, EPOW_SENSOR_INDEX
,
344 critical
= 1; /* Time Critical */
348 spin_lock(&ras_log_buf_lock
);
350 status
= rtas_call(ras_check_exception_token
, 6, 1, NULL
,
351 RTAS_VECTOR_EXTERNAL_INTERRUPT
,
354 critical
, __pa(&ras_log_buf
),
355 rtas_get_error_log_max());
357 log_error(ras_log_buf
, ERR_TYPE_RTAS_LOG
, 0);
359 rtas_parse_epow_errlog((struct rtas_error_log
*)ras_log_buf
);
361 spin_unlock(&ras_log_buf_lock
);
366 * Handle hardware error interrupts.
368 * RTAS check-exception is called to collect data on the exception. If
369 * the error is deemed recoverable, we log a warning and return.
370 * For nonrecoverable errors, an error is logged and we stop all processing
371 * as quickly as possible in order to prevent propagation of the failure.
373 static irqreturn_t
ras_error_interrupt(int irq
, void *dev_id
)
375 struct rtas_error_log
*rtas_elog
;
379 spin_lock(&ras_log_buf_lock
);
381 status
= rtas_call(ras_check_exception_token
, 6, 1, NULL
,
382 RTAS_VECTOR_EXTERNAL_INTERRUPT
,
384 RTAS_INTERNAL_ERROR
, 1 /* Time Critical */,
386 rtas_get_error_log_max());
388 rtas_elog
= (struct rtas_error_log
*)ras_log_buf
;
391 rtas_error_severity(rtas_elog
) >= RTAS_SEVERITY_ERROR_SYNC
)
396 /* format and print the extended information */
397 log_error(ras_log_buf
, ERR_TYPE_RTAS_LOG
, fatal
);
400 pr_emerg("Fatal hardware error detected. Check RTAS error"
401 " log for details. Powering off immediately\n");
405 pr_err("Recoverable hardware error detected\n");
408 spin_unlock(&ras_log_buf_lock
);
413 * Some versions of FWNMI place the buffer inside the 4kB page starting at
414 * 0x7000. Other versions place it inside the rtas buffer. We check both.
416 #define VALID_FWNMI_BUFFER(A) \
417 ((((A) >= 0x7000) && ((A) < 0x7ff0)) || \
418 (((A) >= rtas.base) && ((A) < (rtas.base + rtas.size - 16))))
420 static inline struct rtas_error_log
*fwnmi_get_errlog(void)
422 return (struct rtas_error_log
*)local_paca
->mce_data_buf
;
426 * Get the error information for errors coming through the
427 * FWNMI vectors. The pt_regs' r3 will be updated to reflect
428 * the actual r3 if possible, and a ptr to the error log entry
429 * will be returned if found.
431 * Use one buffer mce_data_buf per cpu to store RTAS error.
433 * The mce_data_buf does not have any locks or protection around it,
434 * if a second machine check comes in, or a system reset is done
435 * before we have logged the error, then we will get corruption in the
436 * error log. This is preferable over holding off on calling
437 * ibm,nmi-interlock which would result in us checkstopping if a
438 * second machine check did come in.
440 static struct rtas_error_log
*fwnmi_get_errinfo(struct pt_regs
*regs
)
442 unsigned long *savep
;
443 struct rtas_error_log
*h
;
445 /* Mask top two bits */
446 regs
->gpr
[3] &= ~(0x3UL
<< 62);
448 if (!VALID_FWNMI_BUFFER(regs
->gpr
[3])) {
449 printk(KERN_ERR
"FWNMI: corrupt r3 0x%016lx\n", regs
->gpr
[3]);
453 savep
= __va(regs
->gpr
[3]);
454 regs
->gpr
[3] = be64_to_cpu(savep
[0]); /* restore original r3 */
456 h
= (struct rtas_error_log
*)&savep
[1];
457 /* Use the per cpu buffer from paca to store rtas error log */
458 memset(local_paca
->mce_data_buf
, 0, RTAS_ERROR_LOG_MAX
);
459 if (!rtas_error_extended(h
)) {
460 memcpy(local_paca
->mce_data_buf
, h
, sizeof(__u64
));
462 int len
, error_log_length
;
464 error_log_length
= 8 + rtas_error_extended_log_length(h
);
465 len
= min_t(int, error_log_length
, RTAS_ERROR_LOG_MAX
);
466 memcpy(local_paca
->mce_data_buf
, h
, len
);
469 return (struct rtas_error_log
*)local_paca
->mce_data_buf
;
472 /* Call this when done with the data returned by FWNMI_get_errinfo.
473 * It will release the saved data area for other CPUs in the
474 * partition to receive FWNMI errors.
476 static void fwnmi_release_errinfo(void)
478 int ret
= rtas_call(rtas_token("ibm,nmi-interlock"), 0, 1, NULL
);
480 printk(KERN_ERR
"FWNMI: nmi-interlock failed: %d\n", ret
);
483 int pSeries_system_reset_exception(struct pt_regs
*regs
)
485 #ifdef __LITTLE_ENDIAN__
487 * Some firmware byteswaps SRR registers and gives incorrect SRR1. Try
488 * to detect the bad SRR1 pattern here. Flip the NIP back to correct
489 * endian for reporting purposes. Unfortunately the MSR can't be fixed,
490 * so clear it. It will be missing MSR_RI so we won't try to recover.
492 if ((be64_to_cpu(regs
->msr
) &
493 (MSR_LE
|MSR_RI
|MSR_DR
|MSR_IR
|MSR_ME
|MSR_PR
|
494 MSR_ILE
|MSR_HV
|MSR_SF
)) == (MSR_DR
|MSR_SF
)) {
495 regs
->nip
= be64_to_cpu((__be64
)regs
->nip
);
501 struct rtas_error_log
*errhdr
= fwnmi_get_errinfo(regs
);
503 /* XXX Should look at FWNMI information */
505 fwnmi_release_errinfo();
508 if (smp_handle_nmi_ipi(regs
))
511 return 0; /* need to perform reset */
514 #define VAL_TO_STRING(ar, val) \
515 (((val) < ARRAY_SIZE(ar)) ? ar[(val)] : "Unknown")
517 static void pseries_print_mce_info(struct pt_regs
*regs
,
518 struct rtas_error_log
*errp
)
520 const char *level
, *sevstr
;
521 struct pseries_errorlog
*pseries_log
;
522 struct pseries_mc_errorlog
*mce_log
;
523 u8 error_type
, err_sub_type
;
525 u8 initiator
= rtas_error_initiator(errp
);
526 int disposition
= rtas_error_disposition(errp
);
528 static const char * const initiators
[] = {
536 static const char * const mc_err_types
[] = {
546 static const char * const mc_ue_types
[] = {
547 [0] = "Indeterminate",
548 [1] = "Instruction fetch",
549 [2] = "Page table walk ifetch",
551 [4] = "Page table walk Load/Store",
554 /* SLB sub errors valid values are 0x0, 0x1, 0x2 */
555 static const char * const mc_slb_types
[] = {
558 [2] = "Indeterminate",
561 /* TLB and ERAT sub errors valid values are 0x1, 0x2, 0x3 */
562 static const char * const mc_soft_types
[] = {
566 [3] = "Indeterminate",
569 if (!rtas_error_extended(errp
)) {
570 pr_err("Machine check interrupt: Missing extended error log\n");
574 pseries_log
= get_pseries_errorlog(errp
, PSERIES_ELOG_SECT_ID_MCE
);
575 if (pseries_log
== NULL
)
578 mce_log
= (struct pseries_mc_errorlog
*)pseries_log
->data
;
580 error_type
= mce_log
->error_type
;
581 err_sub_type
= rtas_mc_error_sub_type(mce_log
);
583 switch (rtas_error_severity(errp
)) {
584 case RTAS_SEVERITY_NO_ERROR
:
588 case RTAS_SEVERITY_WARNING
:
589 level
= KERN_WARNING
;
592 case RTAS_SEVERITY_ERROR
:
593 case RTAS_SEVERITY_ERROR_SYNC
:
597 case RTAS_SEVERITY_FATAL
:
604 #ifdef CONFIG_PPC_BOOK3S_64
605 /* Display faulty slb contents for SLB errors. */
606 if (error_type
== MC_ERROR_TYPE_SLB
)
607 slb_dump_contents(local_paca
->mce_faulty_slbs
);
610 printk("%s%s Machine check interrupt [%s]\n", level
, sevstr
,
611 disposition
== RTAS_DISP_FULLY_RECOVERED
?
612 "Recovered" : "Not recovered");
613 if (user_mode(regs
)) {
614 printk("%s NIP: [%016lx] PID: %d Comm: %s\n", level
,
615 regs
->nip
, current
->pid
, current
->comm
);
617 printk("%s NIP [%016lx]: %pS\n", level
, regs
->nip
,
620 printk("%s Initiator: %s\n", level
,
621 VAL_TO_STRING(initiators
, initiator
));
623 switch (error_type
) {
624 case MC_ERROR_TYPE_UE
:
625 printk("%s Error type: %s [%s]\n", level
,
626 VAL_TO_STRING(mc_err_types
, error_type
),
627 VAL_TO_STRING(mc_ue_types
, err_sub_type
));
629 case MC_ERROR_TYPE_SLB
:
630 printk("%s Error type: %s [%s]\n", level
,
631 VAL_TO_STRING(mc_err_types
, error_type
),
632 VAL_TO_STRING(mc_slb_types
, err_sub_type
));
634 case MC_ERROR_TYPE_ERAT
:
635 case MC_ERROR_TYPE_TLB
:
636 printk("%s Error type: %s [%s]\n", level
,
637 VAL_TO_STRING(mc_err_types
, error_type
),
638 VAL_TO_STRING(mc_soft_types
, err_sub_type
));
641 printk("%s Error type: %s\n", level
,
642 VAL_TO_STRING(mc_err_types
, error_type
));
646 addr
= rtas_mc_get_effective_addr(mce_log
);
648 printk("%s Effective address: %016llx\n", level
, addr
);
651 static int mce_handle_error(struct rtas_error_log
*errp
)
653 struct pseries_errorlog
*pseries_log
;
654 struct pseries_mc_errorlog
*mce_log
;
655 int disposition
= rtas_error_disposition(errp
);
658 if (!rtas_error_extended(errp
))
661 pseries_log
= get_pseries_errorlog(errp
, PSERIES_ELOG_SECT_ID_MCE
);
662 if (pseries_log
== NULL
)
665 mce_log
= (struct pseries_mc_errorlog
*)pseries_log
->data
;
666 error_type
= mce_log
->error_type
;
668 #ifdef CONFIG_PPC_BOOK3S_64
669 if (disposition
== RTAS_DISP_NOT_RECOVERED
) {
670 switch (error_type
) {
671 case MC_ERROR_TYPE_SLB
:
672 case MC_ERROR_TYPE_ERAT
:
674 * Store the old slb content in paca before flushing.
675 * Print this when we go to virtual mode.
676 * There are chances that we may hit MCE again if there
677 * is a parity error on the SLB entry we trying to read
678 * for saving. Hence limit the slb saving to single
679 * level of recursion.
681 if (local_paca
->in_mce
== 1)
682 slb_save_contents(local_paca
->mce_faulty_slbs
);
683 flush_and_reload_slb();
684 disposition
= RTAS_DISP_FULLY_RECOVERED
;
685 rtas_set_disposition_recovered(errp
);
697 #ifdef CONFIG_MEMORY_FAILURE
699 static DEFINE_PER_CPU(int, rtas_ue_count
);
700 static DEFINE_PER_CPU(unsigned long, rtas_ue_paddr
[MAX_MC_EVT
]);
702 #define UE_EFFECTIVE_ADDR_PROVIDED 0x40
703 #define UE_LOGICAL_ADDR_PROVIDED 0x20
706 static void pseries_hwpoison_work_fn(struct work_struct
*work
)
711 while (__this_cpu_read(rtas_ue_count
) > 0) {
712 index
= __this_cpu_read(rtas_ue_count
) - 1;
713 paddr
= __this_cpu_read(rtas_ue_paddr
[index
]);
714 memory_failure(paddr
>> PAGE_SHIFT
, 0);
715 __this_cpu_dec(rtas_ue_count
);
719 static DECLARE_WORK(hwpoison_work
, pseries_hwpoison_work_fn
);
721 static void queue_ue_paddr(unsigned long paddr
)
725 index
= __this_cpu_inc_return(rtas_ue_count
) - 1;
726 if (index
>= MAX_MC_EVT
) {
727 __this_cpu_dec(rtas_ue_count
);
730 this_cpu_write(rtas_ue_paddr
[index
], paddr
);
731 schedule_work(&hwpoison_work
);
734 static void pseries_do_memory_failure(struct pt_regs
*regs
,
735 struct pseries_mc_errorlog
*mce_log
)
739 if (mce_log
->sub_err_type
& UE_LOGICAL_ADDR_PROVIDED
) {
740 paddr
= be64_to_cpu(mce_log
->logical_address
);
741 } else if (mce_log
->sub_err_type
& UE_EFFECTIVE_ADDR_PROVIDED
) {
744 pfn
= addr_to_pfn(regs
,
745 be64_to_cpu(mce_log
->effective_address
));
746 if (pfn
== ULONG_MAX
)
748 paddr
= pfn
<< PAGE_SHIFT
;
752 queue_ue_paddr(paddr
);
755 static void pseries_process_ue(struct pt_regs
*regs
,
756 struct rtas_error_log
*errp
)
758 struct pseries_errorlog
*pseries_log
;
759 struct pseries_mc_errorlog
*mce_log
;
761 if (!rtas_error_extended(errp
))
764 pseries_log
= get_pseries_errorlog(errp
, PSERIES_ELOG_SECT_ID_MCE
);
768 mce_log
= (struct pseries_mc_errorlog
*)pseries_log
->data
;
770 if (mce_log
->error_type
== MC_ERROR_TYPE_UE
)
771 pseries_do_memory_failure(regs
, mce_log
);
774 static inline void pseries_process_ue(struct pt_regs
*regs
,
775 struct rtas_error_log
*errp
) { }
776 #endif /*CONFIG_MEMORY_FAILURE */
779 * Process MCE rtas errlog event.
781 static void mce_process_errlog_event(struct irq_work
*work
)
783 struct rtas_error_log
*err
;
785 err
= fwnmi_get_errlog();
786 log_error((char *)err
, ERR_TYPE_RTAS_LOG
, 0);
790 * See if we can recover from a machine check exception.
791 * This is only called on power4 (or above) and only via
792 * the Firmware Non-Maskable Interrupts (fwnmi) handler
793 * which provides the error analysis for us.
795 * Return 1 if corrected (or delivered a signal).
796 * Return 0 if there is nothing we can do.
798 static int recover_mce(struct pt_regs
*regs
, struct rtas_error_log
*err
)
801 int disposition
= rtas_error_disposition(err
);
803 pseries_print_mce_info(regs
, err
);
805 if (!(regs
->msr
& MSR_RI
)) {
806 /* If MSR_RI isn't set, we cannot recover */
807 pr_err("Machine check interrupt unrecoverable: MSR(RI=0)\n");
810 } else if (disposition
== RTAS_DISP_FULLY_RECOVERED
) {
811 /* Platform corrected itself */
814 } else if (disposition
== RTAS_DISP_LIMITED_RECOVERY
) {
815 /* Platform corrected itself but could be degraded */
816 printk(KERN_ERR
"MCE: limited recovery, system may "
820 } else if (user_mode(regs
) && !is_global_init(current
) &&
821 rtas_error_severity(err
) == RTAS_SEVERITY_ERROR_SYNC
) {
824 * If we received a synchronous error when in userspace
825 * kill the task. Firmware may report details of the fail
826 * asynchronously, so we can't rely on the target and type
827 * fields being valid here.
829 printk(KERN_ERR
"MCE: uncorrectable error, killing task "
830 "%s:%d\n", current
->comm
, current
->pid
);
832 _exception(SIGBUS
, regs
, BUS_MCEERR_AR
, regs
->nip
);
836 pseries_process_ue(regs
, err
);
838 /* Queue irq work to log this rtas event later. */
839 irq_work_queue(&mce_errlog_process_work
);
845 * Handle a machine check.
847 * Note that on Power 4 and beyond Firmware Non-Maskable Interrupts (fwnmi)
848 * should be present. If so the handler which called us tells us if the
849 * error was recovered (never true if RI=0).
851 * On hardware prior to Power 4 these exceptions were asynchronous which
852 * means we can't tell exactly where it occurred and so we can't recover.
854 int pSeries_machine_check_exception(struct pt_regs
*regs
)
856 struct rtas_error_log
*errp
;
859 fwnmi_release_errinfo();
860 errp
= fwnmi_get_errlog();
861 if (errp
&& recover_mce(regs
, errp
))
868 long pseries_machine_check_realmode(struct pt_regs
*regs
)
870 struct rtas_error_log
*errp
;
874 errp
= fwnmi_get_errinfo(regs
);
876 * Call to fwnmi_release_errinfo() in real mode causes kernel
877 * to panic. Hence we will call it as soon as we go into
880 disposition
= mce_handle_error(errp
);
881 if (disposition
== RTAS_DISP_FULLY_RECOVERED
)