xref: /linux/arch/powerpc/platforms/pseries/ras.c (revision a43c1590426c44a5c6bbaf51b70a36a5c6d86914)
1 /*
2  * Copyright (C) 2001 Dave Engebretsen IBM Corporation
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17  */
18 
19 #include <linux/sched.h>
20 #include <linux/interrupt.h>
21 #include <linux/irq.h>
22 #include <linux/of.h>
23 #include <linux/fs.h>
24 #include <linux/reboot.h>
25 #include <linux/irq_work.h>
26 
27 #include <asm/machdep.h>
28 #include <asm/rtas.h>
29 #include <asm/firmware.h>
30 #include <asm/mce.h>
31 
32 #include "pseries.h"
33 
34 static unsigned char ras_log_buf[RTAS_ERROR_LOG_MAX];
35 static DEFINE_SPINLOCK(ras_log_buf_lock);
36 
37 static int ras_check_exception_token;
38 
39 static void mce_process_errlog_event(struct irq_work *work);
40 static struct irq_work mce_errlog_process_work = {
41 	.func = mce_process_errlog_event,
42 };
43 
44 #define EPOW_SENSOR_TOKEN	9
45 #define EPOW_SENSOR_INDEX	0
46 
47 /* EPOW events counter variable */
48 static int num_epow_events;
49 
50 static irqreturn_t ras_hotplug_interrupt(int irq, void *dev_id);
51 static irqreturn_t ras_epow_interrupt(int irq, void *dev_id);
52 static irqreturn_t ras_error_interrupt(int irq, void *dev_id);
53 
54 /* RTAS pseries MCE errorlog section. */
55 struct pseries_mc_errorlog {
56 	__be32	fru_id;
57 	__be32	proc_id;
58 	u8	error_type;
59 	/*
60 	 * sub_err_type (1 byte). Bit fields depends on error_type
61 	 *
62 	 *   MSB0
63 	 *   |
64 	 *   V
65 	 *   01234567
66 	 *   XXXXXXXX
67 	 *
68 	 * For error_type == MC_ERROR_TYPE_UE
69 	 *   XXXXXXXX
70 	 *   X		1: Permanent or Transient UE.
71 	 *    X		1: Effective address provided.
72 	 *     X	1: Logical address provided.
73 	 *      XX	2: Reserved.
74 	 *        XXX	3: Type of UE error.
75 	 *
76 	 * For error_type != MC_ERROR_TYPE_UE
77 	 *   XXXXXXXX
78 	 *   X		1: Effective address provided.
79 	 *    XXXXX	5: Reserved.
80 	 *         XX	2: Type of SLB/ERAT/TLB error.
81 	 */
82 	u8	sub_err_type;
83 	u8	reserved_1[6];
84 	__be64	effective_address;
85 	__be64	logical_address;
86 } __packed;
87 
88 /* RTAS pseries MCE error types */
89 #define MC_ERROR_TYPE_UE		0x00
90 #define MC_ERROR_TYPE_SLB		0x01
91 #define MC_ERROR_TYPE_ERAT		0x02
92 #define MC_ERROR_TYPE_TLB		0x04
93 #define MC_ERROR_TYPE_D_CACHE		0x05
94 #define MC_ERROR_TYPE_I_CACHE		0x07
95 
96 /* RTAS pseries MCE error sub types */
97 #define MC_ERROR_UE_INDETERMINATE		0
98 #define MC_ERROR_UE_IFETCH			1
99 #define MC_ERROR_UE_PAGE_TABLE_WALK_IFETCH	2
100 #define MC_ERROR_UE_LOAD_STORE			3
101 #define MC_ERROR_UE_PAGE_TABLE_WALK_LOAD_STORE	4
102 
103 #define MC_ERROR_SLB_PARITY		0
104 #define MC_ERROR_SLB_MULTIHIT		1
105 #define MC_ERROR_SLB_INDETERMINATE	2
106 
107 #define MC_ERROR_ERAT_PARITY		1
108 #define MC_ERROR_ERAT_MULTIHIT		2
109 #define MC_ERROR_ERAT_INDETERMINATE	3
110 
111 #define MC_ERROR_TLB_PARITY		1
112 #define MC_ERROR_TLB_MULTIHIT		2
113 #define MC_ERROR_TLB_INDETERMINATE	3
114 
115 static inline u8 rtas_mc_error_sub_type(const struct pseries_mc_errorlog *mlog)
116 {
117 	switch (mlog->error_type) {
118 	case	MC_ERROR_TYPE_UE:
119 		return (mlog->sub_err_type & 0x07);
120 	case	MC_ERROR_TYPE_SLB:
121 	case	MC_ERROR_TYPE_ERAT:
122 	case	MC_ERROR_TYPE_TLB:
123 		return (mlog->sub_err_type & 0x03);
124 	default:
125 		return 0;
126 	}
127 }
128 
129 static
130 inline u64 rtas_mc_get_effective_addr(const struct pseries_mc_errorlog *mlog)
131 {
132 	__be64 addr = 0;
133 
134 	switch (mlog->error_type) {
135 	case	MC_ERROR_TYPE_UE:
136 		if (mlog->sub_err_type & 0x40)
137 			addr = mlog->effective_address;
138 		break;
139 	case	MC_ERROR_TYPE_SLB:
140 	case	MC_ERROR_TYPE_ERAT:
141 	case	MC_ERROR_TYPE_TLB:
142 		if (mlog->sub_err_type & 0x80)
143 			addr = mlog->effective_address;
144 	default:
145 		break;
146 	}
147 	return be64_to_cpu(addr);
148 }
149 
150 /*
151  * Enable the hotplug interrupt late because processing them may touch other
152  * devices or systems (e.g. hugepages) that have not been initialized at the
153  * subsys stage.
154  */
155 int __init init_ras_hotplug_IRQ(void)
156 {
157 	struct device_node *np;
158 
159 	/* Hotplug Events */
160 	np = of_find_node_by_path("/event-sources/hot-plug-events");
161 	if (np != NULL) {
162 		if (dlpar_workqueue_init() == 0)
163 			request_event_sources_irqs(np, ras_hotplug_interrupt,
164 						   "RAS_HOTPLUG");
165 		of_node_put(np);
166 	}
167 
168 	return 0;
169 }
170 machine_late_initcall(pseries, init_ras_hotplug_IRQ);
171 
172 /*
173  * Initialize handlers for the set of interrupts caused by hardware errors
174  * and power system events.
175  */
176 static int __init init_ras_IRQ(void)
177 {
178 	struct device_node *np;
179 
180 	ras_check_exception_token = rtas_token("check-exception");
181 
182 	/* Internal Errors */
183 	np = of_find_node_by_path("/event-sources/internal-errors");
184 	if (np != NULL) {
185 		request_event_sources_irqs(np, ras_error_interrupt,
186 					   "RAS_ERROR");
187 		of_node_put(np);
188 	}
189 
190 	/* EPOW Events */
191 	np = of_find_node_by_path("/event-sources/epow-events");
192 	if (np != NULL) {
193 		request_event_sources_irqs(np, ras_epow_interrupt, "RAS_EPOW");
194 		of_node_put(np);
195 	}
196 
197 	return 0;
198 }
199 machine_subsys_initcall(pseries, init_ras_IRQ);
200 
201 #define EPOW_SHUTDOWN_NORMAL				1
202 #define EPOW_SHUTDOWN_ON_UPS				2
203 #define EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS	3
204 #define EPOW_SHUTDOWN_AMBIENT_TEMPERATURE_TOO_HIGH	4
205 
206 static void handle_system_shutdown(char event_modifier)
207 {
208 	switch (event_modifier) {
209 	case EPOW_SHUTDOWN_NORMAL:
210 		pr_emerg("Power off requested\n");
211 		orderly_poweroff(true);
212 		break;
213 
214 	case EPOW_SHUTDOWN_ON_UPS:
215 		pr_emerg("Loss of system power detected. System is running on"
216 			 " UPS/battery. Check RTAS error log for details\n");
217 		orderly_poweroff(true);
218 		break;
219 
220 	case EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS:
221 		pr_emerg("Loss of system critical functions detected. Check"
222 			 " RTAS error log for details\n");
223 		orderly_poweroff(true);
224 		break;
225 
226 	case EPOW_SHUTDOWN_AMBIENT_TEMPERATURE_TOO_HIGH:
227 		pr_emerg("High ambient temperature detected. Check RTAS"
228 			 " error log for details\n");
229 		orderly_poweroff(true);
230 		break;
231 
232 	default:
233 		pr_err("Unknown power/cooling shutdown event (modifier = %d)\n",
234 			event_modifier);
235 	}
236 }
237 
238 struct epow_errorlog {
239 	unsigned char sensor_value;
240 	unsigned char event_modifier;
241 	unsigned char extended_modifier;
242 	unsigned char reserved;
243 	unsigned char platform_reason;
244 };
245 
246 #define EPOW_RESET			0
247 #define EPOW_WARN_COOLING		1
248 #define EPOW_WARN_POWER			2
249 #define EPOW_SYSTEM_SHUTDOWN		3
250 #define EPOW_SYSTEM_HALT		4
251 #define EPOW_MAIN_ENCLOSURE		5
252 #define EPOW_POWER_OFF			7
253 
254 static void rtas_parse_epow_errlog(struct rtas_error_log *log)
255 {
256 	struct pseries_errorlog *pseries_log;
257 	struct epow_errorlog *epow_log;
258 	char action_code;
259 	char modifier;
260 
261 	pseries_log = get_pseries_errorlog(log, PSERIES_ELOG_SECT_ID_EPOW);
262 	if (pseries_log == NULL)
263 		return;
264 
265 	epow_log = (struct epow_errorlog *)pseries_log->data;
266 	action_code = epow_log->sensor_value & 0xF;	/* bottom 4 bits */
267 	modifier = epow_log->event_modifier & 0xF;	/* bottom 4 bits */
268 
269 	switch (action_code) {
270 	case EPOW_RESET:
271 		if (num_epow_events) {
272 			pr_info("Non critical power/cooling issue cleared\n");
273 			num_epow_events--;
274 		}
275 		break;
276 
277 	case EPOW_WARN_COOLING:
278 		pr_info("Non-critical cooling issue detected. Check RTAS error"
279 			" log for details\n");
280 		break;
281 
282 	case EPOW_WARN_POWER:
283 		pr_info("Non-critical power issue detected. Check RTAS error"
284 			" log for details\n");
285 		break;
286 
287 	case EPOW_SYSTEM_SHUTDOWN:
288 		handle_system_shutdown(epow_log->event_modifier);
289 		break;
290 
291 	case EPOW_SYSTEM_HALT:
292 		pr_emerg("Critical power/cooling issue detected. Check RTAS"
293 			 " error log for details. Powering off.\n");
294 		orderly_poweroff(true);
295 		break;
296 
297 	case EPOW_MAIN_ENCLOSURE:
298 	case EPOW_POWER_OFF:
299 		pr_emerg("System about to lose power. Check RTAS error log "
300 			 " for details. Powering off immediately.\n");
301 		emergency_sync();
302 		kernel_power_off();
303 		break;
304 
305 	default:
306 		pr_err("Unknown power/cooling event (action code  = %d)\n",
307 			action_code);
308 	}
309 
310 	/* Increment epow events counter variable */
311 	if (action_code != EPOW_RESET)
312 		num_epow_events++;
313 }
314 
315 static irqreturn_t ras_hotplug_interrupt(int irq, void *dev_id)
316 {
317 	struct pseries_errorlog *pseries_log;
318 	struct pseries_hp_errorlog *hp_elog;
319 
320 	spin_lock(&ras_log_buf_lock);
321 
322 	rtas_call(ras_check_exception_token, 6, 1, NULL,
323 		  RTAS_VECTOR_EXTERNAL_INTERRUPT, virq_to_hw(irq),
324 		  RTAS_HOTPLUG_EVENTS, 0, __pa(&ras_log_buf),
325 		  rtas_get_error_log_max());
326 
327 	pseries_log = get_pseries_errorlog((struct rtas_error_log *)ras_log_buf,
328 					   PSERIES_ELOG_SECT_ID_HOTPLUG);
329 	hp_elog = (struct pseries_hp_errorlog *)pseries_log->data;
330 
331 	/*
332 	 * Since PCI hotplug is not currently supported on pseries, put PCI
333 	 * hotplug events on the ras_log_buf to be handled by rtas_errd.
334 	 */
335 	if (hp_elog->resource == PSERIES_HP_ELOG_RESOURCE_MEM ||
336 	    hp_elog->resource == PSERIES_HP_ELOG_RESOURCE_CPU)
337 		queue_hotplug_event(hp_elog, NULL, NULL);
338 	else
339 		log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, 0);
340 
341 	spin_unlock(&ras_log_buf_lock);
342 	return IRQ_HANDLED;
343 }
344 
345 /* Handle environmental and power warning (EPOW) interrupts. */
346 static irqreturn_t ras_epow_interrupt(int irq, void *dev_id)
347 {
348 	int status;
349 	int state;
350 	int critical;
351 
352 	status = rtas_get_sensor_fast(EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX,
353 				      &state);
354 
355 	if (state > 3)
356 		critical = 1;		/* Time Critical */
357 	else
358 		critical = 0;
359 
360 	spin_lock(&ras_log_buf_lock);
361 
362 	status = rtas_call(ras_check_exception_token, 6, 1, NULL,
363 			   RTAS_VECTOR_EXTERNAL_INTERRUPT,
364 			   virq_to_hw(irq),
365 			   RTAS_EPOW_WARNING,
366 			   critical, __pa(&ras_log_buf),
367 				rtas_get_error_log_max());
368 
369 	log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, 0);
370 
371 	rtas_parse_epow_errlog((struct rtas_error_log *)ras_log_buf);
372 
373 	spin_unlock(&ras_log_buf_lock);
374 	return IRQ_HANDLED;
375 }
376 
377 /*
378  * Handle hardware error interrupts.
379  *
380  * RTAS check-exception is called to collect data on the exception.  If
381  * the error is deemed recoverable, we log a warning and return.
382  * For nonrecoverable errors, an error is logged and we stop all processing
383  * as quickly as possible in order to prevent propagation of the failure.
384  */
385 static irqreturn_t ras_error_interrupt(int irq, void *dev_id)
386 {
387 	struct rtas_error_log *rtas_elog;
388 	int status;
389 	int fatal;
390 
391 	spin_lock(&ras_log_buf_lock);
392 
393 	status = rtas_call(ras_check_exception_token, 6, 1, NULL,
394 			   RTAS_VECTOR_EXTERNAL_INTERRUPT,
395 			   virq_to_hw(irq),
396 			   RTAS_INTERNAL_ERROR, 1 /* Time Critical */,
397 			   __pa(&ras_log_buf),
398 				rtas_get_error_log_max());
399 
400 	rtas_elog = (struct rtas_error_log *)ras_log_buf;
401 
402 	if (status == 0 &&
403 	    rtas_error_severity(rtas_elog) >= RTAS_SEVERITY_ERROR_SYNC)
404 		fatal = 1;
405 	else
406 		fatal = 0;
407 
408 	/* format and print the extended information */
409 	log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, fatal);
410 
411 	if (fatal) {
412 		pr_emerg("Fatal hardware error detected. Check RTAS error"
413 			 " log for details. Powering off immediately\n");
414 		emergency_sync();
415 		kernel_power_off();
416 	} else {
417 		pr_err("Recoverable hardware error detected\n");
418 	}
419 
420 	spin_unlock(&ras_log_buf_lock);
421 	return IRQ_HANDLED;
422 }
423 
424 /*
425  * Some versions of FWNMI place the buffer inside the 4kB page starting at
426  * 0x7000. Other versions place it inside the rtas buffer. We check both.
427  */
428 #define VALID_FWNMI_BUFFER(A) \
429 	((((A) >= 0x7000) && ((A) < 0x7ff0)) || \
430 	(((A) >= rtas.base) && ((A) < (rtas.base + rtas.size - 16))))
431 
432 static inline struct rtas_error_log *fwnmi_get_errlog(void)
433 {
434 	return (struct rtas_error_log *)local_paca->mce_data_buf;
435 }
436 
437 /*
438  * Get the error information for errors coming through the
439  * FWNMI vectors.  The pt_regs' r3 will be updated to reflect
440  * the actual r3 if possible, and a ptr to the error log entry
441  * will be returned if found.
442  *
443  * Use one buffer mce_data_buf per cpu to store RTAS error.
444  *
445  * The mce_data_buf does not have any locks or protection around it,
446  * if a second machine check comes in, or a system reset is done
447  * before we have logged the error, then we will get corruption in the
448  * error log.  This is preferable over holding off on calling
449  * ibm,nmi-interlock which would result in us checkstopping if a
450  * second machine check did come in.
451  */
452 static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs)
453 {
454 	unsigned long *savep;
455 	struct rtas_error_log *h;
456 
457 	/* Mask top two bits */
458 	regs->gpr[3] &= ~(0x3UL << 62);
459 
460 	if (!VALID_FWNMI_BUFFER(regs->gpr[3])) {
461 		printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]);
462 		return NULL;
463 	}
464 
465 	savep = __va(regs->gpr[3]);
466 	regs->gpr[3] = be64_to_cpu(savep[0]);	/* restore original r3 */
467 
468 	h = (struct rtas_error_log *)&savep[1];
469 	/* Use the per cpu buffer from paca to store rtas error log */
470 	memset(local_paca->mce_data_buf, 0, RTAS_ERROR_LOG_MAX);
471 	if (!rtas_error_extended(h)) {
472 		memcpy(local_paca->mce_data_buf, h, sizeof(__u64));
473 	} else {
474 		int len, error_log_length;
475 
476 		error_log_length = 8 + rtas_error_extended_log_length(h);
477 		len = min_t(int, error_log_length, RTAS_ERROR_LOG_MAX);
478 		memcpy(local_paca->mce_data_buf, h, len);
479 	}
480 
481 	return (struct rtas_error_log *)local_paca->mce_data_buf;
482 }
483 
484 /* Call this when done with the data returned by FWNMI_get_errinfo.
485  * It will release the saved data area for other CPUs in the
486  * partition to receive FWNMI errors.
487  */
488 static void fwnmi_release_errinfo(void)
489 {
490 	int ret = rtas_call(rtas_token("ibm,nmi-interlock"), 0, 1, NULL);
491 	if (ret != 0)
492 		printk(KERN_ERR "FWNMI: nmi-interlock failed: %d\n", ret);
493 }
494 
495 int pSeries_system_reset_exception(struct pt_regs *regs)
496 {
497 #ifdef __LITTLE_ENDIAN__
498 	/*
499 	 * Some firmware byteswaps SRR registers and gives incorrect SRR1. Try
500 	 * to detect the bad SRR1 pattern here. Flip the NIP back to correct
501 	 * endian for reporting purposes. Unfortunately the MSR can't be fixed,
502 	 * so clear it. It will be missing MSR_RI so we won't try to recover.
503 	 */
504 	if ((be64_to_cpu(regs->msr) &
505 			(MSR_LE|MSR_RI|MSR_DR|MSR_IR|MSR_ME|MSR_PR|
506 			 MSR_ILE|MSR_HV|MSR_SF)) == (MSR_DR|MSR_SF)) {
507 		regs->nip = be64_to_cpu((__be64)regs->nip);
508 		regs->msr = 0;
509 	}
510 #endif
511 
512 	if (fwnmi_active) {
513 		struct rtas_error_log *errhdr = fwnmi_get_errinfo(regs);
514 		if (errhdr) {
515 			/* XXX Should look at FWNMI information */
516 		}
517 		fwnmi_release_errinfo();
518 	}
519 
520 	if (smp_handle_nmi_ipi(regs))
521 		return 1;
522 
523 	return 0; /* need to perform reset */
524 }
525 
526 static int mce_handle_error(struct rtas_error_log *errp)
527 {
528 	struct pseries_errorlog *pseries_log;
529 	struct pseries_mc_errorlog *mce_log;
530 	int disposition = rtas_error_disposition(errp);
531 	u8 error_type;
532 
533 	if (!rtas_error_extended(errp))
534 		goto out;
535 
536 	pseries_log = get_pseries_errorlog(errp, PSERIES_ELOG_SECT_ID_MCE);
537 	if (pseries_log == NULL)
538 		goto out;
539 
540 	mce_log = (struct pseries_mc_errorlog *)pseries_log->data;
541 	error_type = mce_log->error_type;
542 
543 #ifdef CONFIG_PPC_BOOK3S_64
544 	if (disposition == RTAS_DISP_NOT_RECOVERED) {
545 		switch (error_type) {
546 		case	MC_ERROR_TYPE_SLB:
547 		case	MC_ERROR_TYPE_ERAT:
548 			/* Store the old slb content someplace. */
549 			flush_and_reload_slb();
550 			disposition = RTAS_DISP_FULLY_RECOVERED;
551 			rtas_set_disposition_recovered(errp);
552 			break;
553 		default:
554 			break;
555 		}
556 	}
557 #endif
558 
559 out:
560 	return disposition;
561 }
562 
563 /*
564  * Process MCE rtas errlog event.
565  */
566 static void mce_process_errlog_event(struct irq_work *work)
567 {
568 	struct rtas_error_log *err;
569 
570 	err = fwnmi_get_errlog();
571 	log_error((char *)err, ERR_TYPE_RTAS_LOG, 0);
572 }
573 
574 /*
575  * See if we can recover from a machine check exception.
576  * This is only called on power4 (or above) and only via
577  * the Firmware Non-Maskable Interrupts (fwnmi) handler
578  * which provides the error analysis for us.
579  *
580  * Return 1 if corrected (or delivered a signal).
581  * Return 0 if there is nothing we can do.
582  */
583 static int recover_mce(struct pt_regs *regs, struct rtas_error_log *err)
584 {
585 	int recovered = 0;
586 	int disposition = rtas_error_disposition(err);
587 
588 	if (!(regs->msr & MSR_RI)) {
589 		/* If MSR_RI isn't set, we cannot recover */
590 		recovered = 0;
591 
592 	} else if (disposition == RTAS_DISP_FULLY_RECOVERED) {
593 		/* Platform corrected itself */
594 		recovered = 1;
595 
596 	} else if (disposition == RTAS_DISP_LIMITED_RECOVERY) {
597 		/* Platform corrected itself but could be degraded */
598 		printk(KERN_ERR "MCE: limited recovery, system may "
599 		       "be degraded\n");
600 		recovered = 1;
601 
602 	} else if (user_mode(regs) && !is_global_init(current) &&
603 		   rtas_error_severity(err) == RTAS_SEVERITY_ERROR_SYNC) {
604 
605 		/*
606 		 * If we received a synchronous error when in userspace
607 		 * kill the task. Firmware may report details of the fail
608 		 * asynchronously, so we can't rely on the target and type
609 		 * fields being valid here.
610 		 */
611 		printk(KERN_ERR "MCE: uncorrectable error, killing task "
612 		       "%s:%d\n", current->comm, current->pid);
613 
614 		_exception(SIGBUS, regs, BUS_MCEERR_AR, regs->nip);
615 		recovered = 1;
616 	}
617 
618 	/* Queue irq work to log this rtas event later. */
619 	irq_work_queue(&mce_errlog_process_work);
620 
621 	return recovered;
622 }
623 
624 /*
625  * Handle a machine check.
626  *
627  * Note that on Power 4 and beyond Firmware Non-Maskable Interrupts (fwnmi)
628  * should be present.  If so the handler which called us tells us if the
629  * error was recovered (never true if RI=0).
630  *
631  * On hardware prior to Power 4 these exceptions were asynchronous which
632  * means we can't tell exactly where it occurred and so we can't recover.
633  */
634 int pSeries_machine_check_exception(struct pt_regs *regs)
635 {
636 	struct rtas_error_log *errp;
637 
638 	if (fwnmi_active) {
639 		fwnmi_release_errinfo();
640 		errp = fwnmi_get_errlog();
641 		if (errp && recover_mce(regs, errp))
642 			return 1;
643 	}
644 
645 	return 0;
646 }
647 
648 long pseries_machine_check_realmode(struct pt_regs *regs)
649 {
650 	struct rtas_error_log *errp;
651 	int disposition;
652 
653 	if (fwnmi_active) {
654 		errp = fwnmi_get_errinfo(regs);
655 		/*
656 		 * Call to fwnmi_release_errinfo() in real mode causes kernel
657 		 * to panic. Hence we will call it as soon as we go into
658 		 * virtual mode.
659 		 */
660 		disposition = mce_handle_error(errp);
661 		if (disposition == RTAS_DISP_FULLY_RECOVERED)
662 			return 1;
663 	}
664 
665 	return 0;
666 }
667