1d9953105SMichael Ellerman /* 2d9953105SMichael Ellerman * Copyright (C) 2001 Dave Engebretsen IBM Corporation 3d9953105SMichael Ellerman * 4d9953105SMichael Ellerman * This program is free software; you can redistribute it and/or modify 5d9953105SMichael Ellerman * it under the terms of the GNU General Public License as published by 6d9953105SMichael Ellerman * the Free Software Foundation; either version 2 of the License, or 7d9953105SMichael Ellerman * (at your option) any later version. 8d9953105SMichael Ellerman * 9d9953105SMichael Ellerman * This program is distributed in the hope that it will be useful, 10d9953105SMichael Ellerman * but WITHOUT ANY WARRANTY; without even the implied warranty of 11d9953105SMichael Ellerman * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12d9953105SMichael Ellerman * GNU General Public License for more details. 13d9953105SMichael Ellerman * 14d9953105SMichael Ellerman * You should have received a copy of the GNU General Public License 15d9953105SMichael Ellerman * along with this program; if not, write to the Free Software 16d9953105SMichael Ellerman * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17d9953105SMichael Ellerman */ 18d9953105SMichael Ellerman 19d9953105SMichael Ellerman #include <linux/sched.h> 20d9953105SMichael Ellerman #include <linux/interrupt.h> 21d9953105SMichael Ellerman #include <linux/irq.h> 2290128997SAnton Blanchard #include <linux/of.h> 2355fc0c56SAnton Blanchard #include <linux/fs.h> 2455fc0c56SAnton Blanchard #include <linux/reboot.h> 25d9953105SMichael Ellerman 26d9953105SMichael Ellerman #include <asm/machdep.h> 27d9953105SMichael Ellerman #include <asm/rtas.h> 288c4f1f29SMichael Ellerman #include <asm/firmware.h> 29d9953105SMichael Ellerman 30577830b0SMichael Ellerman #include "pseries.h" 31c902be71SArnd Bergmann 32d9953105SMichael Ellerman static unsigned char ras_log_buf[RTAS_ERROR_LOG_MAX]; 33d9953105SMichael Ellerman static DEFINE_SPINLOCK(ras_log_buf_lock); 34d9953105SMichael Ellerman 35d368514cSAnton Blanchard static char global_mce_data_buf[RTAS_ERROR_LOG_MAX]; 36d368514cSAnton Blanchard static DEFINE_PER_CPU(__u64, mce_data_buf); 37d9953105SMichael Ellerman 38d9953105SMichael Ellerman static int ras_check_exception_token; 39d9953105SMichael Ellerman 40d9953105SMichael Ellerman #define EPOW_SENSOR_TOKEN 9 41d9953105SMichael Ellerman #define EPOW_SENSOR_INDEX 0 42d9953105SMichael Ellerman 437d12e780SDavid Howells static irqreturn_t ras_epow_interrupt(int irq, void *dev_id); 447d12e780SDavid Howells static irqreturn_t ras_error_interrupt(int irq, void *dev_id); 45d9953105SMichael Ellerman 460ebfff14SBenjamin Herrenschmidt 47d9953105SMichael Ellerman /* 48d9953105SMichael Ellerman * Initialize handlers for the set of interrupts caused by hardware errors 49d9953105SMichael Ellerman * and power system events. 50d9953105SMichael Ellerman */ 51d9953105SMichael Ellerman static int __init init_ras_IRQ(void) 52d9953105SMichael Ellerman { 53d9953105SMichael Ellerman struct device_node *np; 54d9953105SMichael Ellerman 55d9953105SMichael Ellerman ras_check_exception_token = rtas_token("check-exception"); 56d9953105SMichael Ellerman 57d9953105SMichael Ellerman /* Internal Errors */ 58d9953105SMichael Ellerman np = of_find_node_by_path("/event-sources/internal-errors"); 59d9953105SMichael Ellerman if (np != NULL) { 6032c96f77SMark Nelson request_event_sources_irqs(np, ras_error_interrupt, 6132c96f77SMark Nelson "RAS_ERROR"); 62d9953105SMichael Ellerman of_node_put(np); 63d9953105SMichael Ellerman } 64d9953105SMichael Ellerman 65d9953105SMichael Ellerman /* EPOW Events */ 66d9953105SMichael Ellerman np = of_find_node_by_path("/event-sources/epow-events"); 67d9953105SMichael Ellerman if (np != NULL) { 6832c96f77SMark Nelson request_event_sources_irqs(np, ras_epow_interrupt, "RAS_EPOW"); 69d9953105SMichael Ellerman of_node_put(np); 70d9953105SMichael Ellerman } 71d9953105SMichael Ellerman 7269ed3324SAnton Blanchard return 0; 73d9953105SMichael Ellerman } 748e83e905SMichael Ellerman machine_subsys_initcall(pseries, init_ras_IRQ); 75d9953105SMichael Ellerman 7655fc0c56SAnton Blanchard #define EPOW_SHUTDOWN_NORMAL 1 7755fc0c56SAnton Blanchard #define EPOW_SHUTDOWN_ON_UPS 2 7855fc0c56SAnton Blanchard #define EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS 3 7955fc0c56SAnton Blanchard #define EPOW_SHUTDOWN_AMBIENT_TEMPERATURE_TOO_HIGH 4 8055fc0c56SAnton Blanchard 8155fc0c56SAnton Blanchard static void handle_system_shutdown(char event_modifier) 8255fc0c56SAnton Blanchard { 8355fc0c56SAnton Blanchard switch (event_modifier) { 8455fc0c56SAnton Blanchard case EPOW_SHUTDOWN_NORMAL: 8555fc0c56SAnton Blanchard pr_emerg("Firmware initiated power off"); 861b7e0cbeSliguang orderly_poweroff(true); 8755fc0c56SAnton Blanchard break; 8855fc0c56SAnton Blanchard 8955fc0c56SAnton Blanchard case EPOW_SHUTDOWN_ON_UPS: 9055fc0c56SAnton Blanchard pr_emerg("Loss of power reported by firmware, system is " 9155fc0c56SAnton Blanchard "running on UPS/battery"); 9279872e35SAnshuman Khandual pr_emerg("Check RTAS error log for details"); 9379872e35SAnshuman Khandual orderly_poweroff(true); 9455fc0c56SAnton Blanchard break; 9555fc0c56SAnton Blanchard 9655fc0c56SAnton Blanchard case EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS: 9755fc0c56SAnton Blanchard pr_emerg("Loss of system critical functions reported by " 9855fc0c56SAnton Blanchard "firmware"); 9955fc0c56SAnton Blanchard pr_emerg("Check RTAS error log for details"); 1001b7e0cbeSliguang orderly_poweroff(true); 10155fc0c56SAnton Blanchard break; 10255fc0c56SAnton Blanchard 10355fc0c56SAnton Blanchard case EPOW_SHUTDOWN_AMBIENT_TEMPERATURE_TOO_HIGH: 10455fc0c56SAnton Blanchard pr_emerg("Ambient temperature too high reported by firmware"); 10555fc0c56SAnton Blanchard pr_emerg("Check RTAS error log for details"); 1061b7e0cbeSliguang orderly_poweroff(true); 10755fc0c56SAnton Blanchard break; 10855fc0c56SAnton Blanchard 10955fc0c56SAnton Blanchard default: 11055fc0c56SAnton Blanchard pr_err("Unknown power/cooling shutdown event (modifier %d)", 11155fc0c56SAnton Blanchard event_modifier); 11255fc0c56SAnton Blanchard } 11355fc0c56SAnton Blanchard } 11455fc0c56SAnton Blanchard 11555fc0c56SAnton Blanchard struct epow_errorlog { 11655fc0c56SAnton Blanchard unsigned char sensor_value; 11755fc0c56SAnton Blanchard unsigned char event_modifier; 11855fc0c56SAnton Blanchard unsigned char extended_modifier; 11955fc0c56SAnton Blanchard unsigned char reserved; 12055fc0c56SAnton Blanchard unsigned char platform_reason; 12155fc0c56SAnton Blanchard }; 12255fc0c56SAnton Blanchard 12355fc0c56SAnton Blanchard #define EPOW_RESET 0 12455fc0c56SAnton Blanchard #define EPOW_WARN_COOLING 1 12555fc0c56SAnton Blanchard #define EPOW_WARN_POWER 2 12655fc0c56SAnton Blanchard #define EPOW_SYSTEM_SHUTDOWN 3 12755fc0c56SAnton Blanchard #define EPOW_SYSTEM_HALT 4 12855fc0c56SAnton Blanchard #define EPOW_MAIN_ENCLOSURE 5 12955fc0c56SAnton Blanchard #define EPOW_POWER_OFF 7 13055fc0c56SAnton Blanchard 131e51df2c1SAnton Blanchard static void rtas_parse_epow_errlog(struct rtas_error_log *log) 13255fc0c56SAnton Blanchard { 13355fc0c56SAnton Blanchard struct pseries_errorlog *pseries_log; 13455fc0c56SAnton Blanchard struct epow_errorlog *epow_log; 13555fc0c56SAnton Blanchard char action_code; 13655fc0c56SAnton Blanchard char modifier; 13755fc0c56SAnton Blanchard 13855fc0c56SAnton Blanchard pseries_log = get_pseries_errorlog(log, PSERIES_ELOG_SECT_ID_EPOW); 13955fc0c56SAnton Blanchard if (pseries_log == NULL) 14055fc0c56SAnton Blanchard return; 14155fc0c56SAnton Blanchard 14255fc0c56SAnton Blanchard epow_log = (struct epow_errorlog *)pseries_log->data; 14355fc0c56SAnton Blanchard action_code = epow_log->sensor_value & 0xF; /* bottom 4 bits */ 14455fc0c56SAnton Blanchard modifier = epow_log->event_modifier & 0xF; /* bottom 4 bits */ 14555fc0c56SAnton Blanchard 14655fc0c56SAnton Blanchard switch (action_code) { 14755fc0c56SAnton Blanchard case EPOW_RESET: 14855fc0c56SAnton Blanchard pr_err("Non critical power or cooling issue cleared"); 14955fc0c56SAnton Blanchard break; 15055fc0c56SAnton Blanchard 15155fc0c56SAnton Blanchard case EPOW_WARN_COOLING: 15255fc0c56SAnton Blanchard pr_err("Non critical cooling issue reported by firmware"); 15355fc0c56SAnton Blanchard pr_err("Check RTAS error log for details"); 15455fc0c56SAnton Blanchard break; 15555fc0c56SAnton Blanchard 15655fc0c56SAnton Blanchard case EPOW_WARN_POWER: 15755fc0c56SAnton Blanchard pr_err("Non critical power issue reported by firmware"); 15855fc0c56SAnton Blanchard pr_err("Check RTAS error log for details"); 15955fc0c56SAnton Blanchard break; 16055fc0c56SAnton Blanchard 16155fc0c56SAnton Blanchard case EPOW_SYSTEM_SHUTDOWN: 16255fc0c56SAnton Blanchard handle_system_shutdown(epow_log->event_modifier); 16355fc0c56SAnton Blanchard break; 16455fc0c56SAnton Blanchard 16555fc0c56SAnton Blanchard case EPOW_SYSTEM_HALT: 16655fc0c56SAnton Blanchard pr_emerg("Firmware initiated power off"); 1671b7e0cbeSliguang orderly_poweroff(true); 16855fc0c56SAnton Blanchard break; 16955fc0c56SAnton Blanchard 17055fc0c56SAnton Blanchard case EPOW_MAIN_ENCLOSURE: 17155fc0c56SAnton Blanchard case EPOW_POWER_OFF: 17255fc0c56SAnton Blanchard pr_emerg("Critical power/cooling issue reported by firmware"); 17355fc0c56SAnton Blanchard pr_emerg("Check RTAS error log for details"); 17455fc0c56SAnton Blanchard pr_emerg("Immediate power off"); 17555fc0c56SAnton Blanchard emergency_sync(); 17655fc0c56SAnton Blanchard kernel_power_off(); 17755fc0c56SAnton Blanchard break; 17855fc0c56SAnton Blanchard 17955fc0c56SAnton Blanchard default: 18055fc0c56SAnton Blanchard pr_err("Unknown power/cooling event (action code %d)", 18155fc0c56SAnton Blanchard action_code); 18255fc0c56SAnton Blanchard } 18355fc0c56SAnton Blanchard } 18455fc0c56SAnton Blanchard 18555fc0c56SAnton Blanchard /* Handle environmental and power warning (EPOW) interrupts. */ 1867d12e780SDavid Howells static irqreturn_t ras_epow_interrupt(int irq, void *dev_id) 187d9953105SMichael Ellerman { 18855fc0c56SAnton Blanchard int status; 18955fc0c56SAnton Blanchard int state; 190d9953105SMichael Ellerman int critical; 191d9953105SMichael Ellerman 192*1c2cb594SThomas Huth status = rtas_get_sensor_fast(EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX, 193*1c2cb594SThomas Huth &state); 194d9953105SMichael Ellerman 195d9953105SMichael Ellerman if (state > 3) 196d9953105SMichael Ellerman critical = 1; /* Time Critical */ 197d9953105SMichael Ellerman else 198d9953105SMichael Ellerman critical = 0; 199d9953105SMichael Ellerman 200d9953105SMichael Ellerman spin_lock(&ras_log_buf_lock); 201d9953105SMichael Ellerman 202d9953105SMichael Ellerman status = rtas_call(ras_check_exception_token, 6, 1, NULL, 203b08e281bSMark Nelson RTAS_VECTOR_EXTERNAL_INTERRUPT, 204476eb491SGrant Likely virq_to_hw(irq), 2056f43747fSAnton Blanchard RTAS_EPOW_WARNING, 206d9953105SMichael Ellerman critical, __pa(&ras_log_buf), 207d9953105SMichael Ellerman rtas_get_error_log_max()); 208d9953105SMichael Ellerman 209d9953105SMichael Ellerman log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, 0); 210d9953105SMichael Ellerman 21155fc0c56SAnton Blanchard rtas_parse_epow_errlog((struct rtas_error_log *)ras_log_buf); 21255fc0c56SAnton Blanchard 213d9953105SMichael Ellerman spin_unlock(&ras_log_buf_lock); 214d9953105SMichael Ellerman return IRQ_HANDLED; 215d9953105SMichael Ellerman } 216d9953105SMichael Ellerman 217d9953105SMichael Ellerman /* 218d9953105SMichael Ellerman * Handle hardware error interrupts. 219d9953105SMichael Ellerman * 220d9953105SMichael Ellerman * RTAS check-exception is called to collect data on the exception. If 221d9953105SMichael Ellerman * the error is deemed recoverable, we log a warning and return. 222d9953105SMichael Ellerman * For nonrecoverable errors, an error is logged and we stop all processing 223d9953105SMichael Ellerman * as quickly as possible in order to prevent propagation of the failure. 224d9953105SMichael Ellerman */ 2257d12e780SDavid Howells static irqreturn_t ras_error_interrupt(int irq, void *dev_id) 226d9953105SMichael Ellerman { 227d9953105SMichael Ellerman struct rtas_error_log *rtas_elog; 228cc8b5263SAnton Blanchard int status; 229d9953105SMichael Ellerman int fatal; 230d9953105SMichael Ellerman 231d9953105SMichael Ellerman spin_lock(&ras_log_buf_lock); 232d9953105SMichael Ellerman 233d9953105SMichael Ellerman status = rtas_call(ras_check_exception_token, 6, 1, NULL, 234b08e281bSMark Nelson RTAS_VECTOR_EXTERNAL_INTERRUPT, 235476eb491SGrant Likely virq_to_hw(irq), 236d9953105SMichael Ellerman RTAS_INTERNAL_ERROR, 1 /* Time Critical */, 237d9953105SMichael Ellerman __pa(&ras_log_buf), 238d9953105SMichael Ellerman rtas_get_error_log_max()); 239d9953105SMichael Ellerman 240d9953105SMichael Ellerman rtas_elog = (struct rtas_error_log *)ras_log_buf; 241d9953105SMichael Ellerman 242a08a53eaSGreg Kurz if (status == 0 && 243a08a53eaSGreg Kurz rtas_error_severity(rtas_elog) >= RTAS_SEVERITY_ERROR_SYNC) 244d9953105SMichael Ellerman fatal = 1; 245d9953105SMichael Ellerman else 246d9953105SMichael Ellerman fatal = 0; 247d9953105SMichael Ellerman 248d9953105SMichael Ellerman /* format and print the extended information */ 249d9953105SMichael Ellerman log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, fatal); 250d9953105SMichael Ellerman 251d9953105SMichael Ellerman if (fatal) { 252cc8b5263SAnton Blanchard pr_emerg("Fatal hardware error reported by firmware"); 253cc8b5263SAnton Blanchard pr_emerg("Check RTAS error log for details"); 254cc8b5263SAnton Blanchard pr_emerg("Immediate power off"); 255cc8b5263SAnton Blanchard emergency_sync(); 256cc8b5263SAnton Blanchard kernel_power_off(); 257d9953105SMichael Ellerman } else { 258cc8b5263SAnton Blanchard pr_err("Recoverable hardware error reported by firmware"); 259d9953105SMichael Ellerman } 260d9953105SMichael Ellerman 261d9953105SMichael Ellerman spin_unlock(&ras_log_buf_lock); 262d9953105SMichael Ellerman return IRQ_HANDLED; 263d9953105SMichael Ellerman } 264d9953105SMichael Ellerman 265d368514cSAnton Blanchard /* 266d368514cSAnton Blanchard * Some versions of FWNMI place the buffer inside the 4kB page starting at 267d368514cSAnton Blanchard * 0x7000. Other versions place it inside the rtas buffer. We check both. 268d368514cSAnton Blanchard */ 269d368514cSAnton Blanchard #define VALID_FWNMI_BUFFER(A) \ 270d368514cSAnton Blanchard ((((A) >= 0x7000) && ((A) < 0x7ff0)) || \ 271d368514cSAnton Blanchard (((A) >= rtas.base) && ((A) < (rtas.base + rtas.size - 16)))) 272d368514cSAnton Blanchard 273d368514cSAnton Blanchard /* 274d368514cSAnton Blanchard * Get the error information for errors coming through the 275d9953105SMichael Ellerman * FWNMI vectors. The pt_regs' r3 will be updated to reflect 276d9953105SMichael Ellerman * the actual r3 if possible, and a ptr to the error log entry 277d9953105SMichael Ellerman * will be returned if found. 278d9953105SMichael Ellerman * 279d368514cSAnton Blanchard * If the RTAS error is not of the extended type, then we put it in a per 280d368514cSAnton Blanchard * cpu 64bit buffer. If it is the extended type we use global_mce_data_buf. 281d368514cSAnton Blanchard * 282d368514cSAnton Blanchard * The global_mce_data_buf does not have any locks or protection around it, 283d9953105SMichael Ellerman * if a second machine check comes in, or a system reset is done 284d9953105SMichael Ellerman * before we have logged the error, then we will get corruption in the 285d9953105SMichael Ellerman * error log. This is preferable over holding off on calling 286d9953105SMichael Ellerman * ibm,nmi-interlock which would result in us checkstopping if a 287d9953105SMichael Ellerman * second machine check did come in. 288d9953105SMichael Ellerman */ 289d9953105SMichael Ellerman static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs) 290d9953105SMichael Ellerman { 291d9953105SMichael Ellerman unsigned long *savep; 292d368514cSAnton Blanchard struct rtas_error_log *h, *errhdr = NULL; 293d9953105SMichael Ellerman 294ee1dd1e3SMahesh Salgaonkar /* Mask top two bits */ 295ee1dd1e3SMahesh Salgaonkar regs->gpr[3] &= ~(0x3UL << 62); 296ee1dd1e3SMahesh Salgaonkar 297d368514cSAnton Blanchard if (!VALID_FWNMI_BUFFER(regs->gpr[3])) { 298f0e939aeSAnton Blanchard printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]); 299d368514cSAnton Blanchard return NULL; 300d9953105SMichael Ellerman } 301d368514cSAnton Blanchard 302d368514cSAnton Blanchard savep = __va(regs->gpr[3]); 303d368514cSAnton Blanchard regs->gpr[3] = savep[0]; /* restore original r3 */ 304d368514cSAnton Blanchard 305d368514cSAnton Blanchard /* If it isn't an extended log we can use the per cpu 64bit buffer */ 306d368514cSAnton Blanchard h = (struct rtas_error_log *)&savep[1]; 307a08a53eaSGreg Kurz if (!rtas_error_extended(h)) { 30869111bacSChristoph Lameter memcpy(this_cpu_ptr(&mce_data_buf), h, sizeof(__u64)); 30969111bacSChristoph Lameter errhdr = (struct rtas_error_log *)this_cpu_ptr(&mce_data_buf); 310d368514cSAnton Blanchard } else { 311a08a53eaSGreg Kurz int len, error_log_length; 312d368514cSAnton Blanchard 313a08a53eaSGreg Kurz error_log_length = 8 + rtas_error_extended_log_length(h); 314a08a53eaSGreg Kurz len = max_t(int, error_log_length, RTAS_ERROR_LOG_MAX); 315d368514cSAnton Blanchard memset(global_mce_data_buf, 0, RTAS_ERROR_LOG_MAX); 316d368514cSAnton Blanchard memcpy(global_mce_data_buf, h, len); 317d368514cSAnton Blanchard errhdr = (struct rtas_error_log *)global_mce_data_buf; 318d368514cSAnton Blanchard } 319d368514cSAnton Blanchard 320d9953105SMichael Ellerman return errhdr; 321d9953105SMichael Ellerman } 322d9953105SMichael Ellerman 323d9953105SMichael Ellerman /* Call this when done with the data returned by FWNMI_get_errinfo. 324d9953105SMichael Ellerman * It will release the saved data area for other CPUs in the 325d9953105SMichael Ellerman * partition to receive FWNMI errors. 326d9953105SMichael Ellerman */ 327d9953105SMichael Ellerman static void fwnmi_release_errinfo(void) 328d9953105SMichael Ellerman { 329d9953105SMichael Ellerman int ret = rtas_call(rtas_token("ibm,nmi-interlock"), 0, 1, NULL); 330d9953105SMichael Ellerman if (ret != 0) 331d368514cSAnton Blanchard printk(KERN_ERR "FWNMI: nmi-interlock failed: %d\n", ret); 332d9953105SMichael Ellerman } 333d9953105SMichael Ellerman 334c902be71SArnd Bergmann int pSeries_system_reset_exception(struct pt_regs *regs) 335d9953105SMichael Ellerman { 336d9953105SMichael Ellerman if (fwnmi_active) { 337d9953105SMichael Ellerman struct rtas_error_log *errhdr = fwnmi_get_errinfo(regs); 338d9953105SMichael Ellerman if (errhdr) { 339d9953105SMichael Ellerman /* XXX Should look at FWNMI information */ 340d9953105SMichael Ellerman } 341d9953105SMichael Ellerman fwnmi_release_errinfo(); 342d9953105SMichael Ellerman } 343c902be71SArnd Bergmann return 0; /* need to perform reset */ 344d9953105SMichael Ellerman } 345d9953105SMichael Ellerman 346d9953105SMichael Ellerman /* 347d9953105SMichael Ellerman * See if we can recover from a machine check exception. 348d9953105SMichael Ellerman * This is only called on power4 (or above) and only via 349d9953105SMichael Ellerman * the Firmware Non-Maskable Interrupts (fwnmi) handler 350d9953105SMichael Ellerman * which provides the error analysis for us. 351d9953105SMichael Ellerman * 352d9953105SMichael Ellerman * Return 1 if corrected (or delivered a signal). 353d9953105SMichael Ellerman * Return 0 if there is nothing we can do. 354d9953105SMichael Ellerman */ 355d9953105SMichael Ellerman static int recover_mce(struct pt_regs *regs, struct rtas_error_log *err) 356d9953105SMichael Ellerman { 357d47d1d8aSAnton Blanchard int recovered = 0; 358a08a53eaSGreg Kurz int disposition = rtas_error_disposition(err); 359d9953105SMichael Ellerman 360d47d1d8aSAnton Blanchard if (!(regs->msr & MSR_RI)) { 361d47d1d8aSAnton Blanchard /* If MSR_RI isn't set, we cannot recover */ 362d47d1d8aSAnton Blanchard recovered = 0; 363d47d1d8aSAnton Blanchard 364a08a53eaSGreg Kurz } else if (disposition == RTAS_DISP_FULLY_RECOVERED) { 365d9953105SMichael Ellerman /* Platform corrected itself */ 366d47d1d8aSAnton Blanchard recovered = 1; 367d47d1d8aSAnton Blanchard 368a08a53eaSGreg Kurz } else if (disposition == RTAS_DISP_LIMITED_RECOVERY) { 369d47d1d8aSAnton Blanchard /* Platform corrected itself but could be degraded */ 370d47d1d8aSAnton Blanchard printk(KERN_ERR "MCE: limited recovery, system may " 371d47d1d8aSAnton Blanchard "be degraded\n"); 372d47d1d8aSAnton Blanchard recovered = 1; 373d47d1d8aSAnton Blanchard 374d47d1d8aSAnton Blanchard } else if (user_mode(regs) && !is_global_init(current) && 375a08a53eaSGreg Kurz rtas_error_severity(err) == RTAS_SEVERITY_ERROR_SYNC) { 376d47d1d8aSAnton Blanchard 377d47d1d8aSAnton Blanchard /* 378d47d1d8aSAnton Blanchard * If we received a synchronous error when in userspace 379d47d1d8aSAnton Blanchard * kill the task. Firmware may report details of the fail 380d47d1d8aSAnton Blanchard * asynchronously, so we can't rely on the target and type 381d47d1d8aSAnton Blanchard * fields being valid here. 382d47d1d8aSAnton Blanchard */ 383d47d1d8aSAnton Blanchard printk(KERN_ERR "MCE: uncorrectable error, killing task " 384d47d1d8aSAnton Blanchard "%s:%d\n", current->comm, current->pid); 385d47d1d8aSAnton Blanchard 386d47d1d8aSAnton Blanchard _exception(SIGBUS, regs, BUS_MCEERR_AR, regs->nip); 387d47d1d8aSAnton Blanchard recovered = 1; 388d9953105SMichael Ellerman } 389d9953105SMichael Ellerman 3903f9793e6SAnton Blanchard log_error((char *)err, ERR_TYPE_RTAS_LOG, 0); 391d9953105SMichael Ellerman 392d47d1d8aSAnton Blanchard return recovered; 393d9953105SMichael Ellerman } 394d9953105SMichael Ellerman 395d9953105SMichael Ellerman /* 396d9953105SMichael Ellerman * Handle a machine check. 397d9953105SMichael Ellerman * 398d9953105SMichael Ellerman * Note that on Power 4 and beyond Firmware Non-Maskable Interrupts (fwnmi) 399d9953105SMichael Ellerman * should be present. If so the handler which called us tells us if the 400d9953105SMichael Ellerman * error was recovered (never true if RI=0). 401d9953105SMichael Ellerman * 402d9953105SMichael Ellerman * On hardware prior to Power 4 these exceptions were asynchronous which 403d9953105SMichael Ellerman * means we can't tell exactly where it occurred and so we can't recover. 404d9953105SMichael Ellerman */ 405d9953105SMichael Ellerman int pSeries_machine_check_exception(struct pt_regs *regs) 406d9953105SMichael Ellerman { 407d9953105SMichael Ellerman struct rtas_error_log *errp; 408d9953105SMichael Ellerman 409d9953105SMichael Ellerman if (fwnmi_active) { 410d9953105SMichael Ellerman errp = fwnmi_get_errinfo(regs); 411d9953105SMichael Ellerman fwnmi_release_errinfo(); 412d9953105SMichael Ellerman if (errp && recover_mce(regs, errp)) 413d9953105SMichael Ellerman return 1; 414d9953105SMichael Ellerman } 415d9953105SMichael Ellerman 416d9953105SMichael Ellerman return 0; 417d9953105SMichael Ellerman } 418