xref: /titanic_41/usr/src/uts/sun4v/os/error.c (revision 28cdc3d776761766afeb198769d1b70ed7e0f2e1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <sys/types.h>
29 #include <sys/machsystm.h>
30 #include <sys/cpuvar.h>
31 #include <sys/async.h>
32 #include <sys/ontrap.h>
33 #include <sys/ddifm.h>
34 #include <sys/hypervisor_api.h>
35 #include <sys/errorq.h>
36 #include <sys/promif.h>
37 #include <sys/prom_plat.h>
38 #include <sys/x_call.h>
39 #include <sys/error.h>
40 #include <sys/fm/util.h>
41 #include <sys/ivintr.h>
42 
43 #define	MAX_CE_FLTS		10
44 #define	MAX_ASYNC_FLTS		6
45 
46 errorq_t *ue_queue;			/* queue of uncorrectable errors */
47 errorq_t *ce_queue;			/* queue of correctable errors */
48 
49 /*
50  * Being used by memory test driver.
51  * ce_verbose_memory - covers CEs in DIMMs
52  * ce_verbose_other - covers "others" (ecache, IO, etc.)
53  *
54  * If the value is 0, nothing is logged.
55  * If the value is 1, the error is logged to the log file, but not console.
56  * If the value is 2, the error is logged to the log file and console.
57  */
58 int	ce_verbose_memory = 1;
59 int	ce_verbose_other = 1;
60 
61 int	ce_show_data = 0;
62 int	ce_debug = 0;
63 int	ue_debug = 0;
64 int	reset_debug = 0;
65 
66 /*
67  * Tunables for controlling the handling of asynchronous faults (AFTs). Setting
68  * these to non-default values on a non-DEBUG kernel is NOT supported.
69  */
70 int	aft_verbose = 0;	/* log AFT messages > 1 to log only */
71 int	aft_panic = 0;		/* panic (not reboot) on fatal usermode AFLT */
72 int	aft_testfatal = 0;	/* force all AFTs to panic immediately */
73 
74 /*
75  * Used for vbsc hostshutdown (power-off buton)
76  */
77 int	err_shutdown_triggered = 0;	/* only once */
78 uint_t	err_shutdown_inum = 0;		/* used to pull the trigger */
79 
80 /*
81  * Defined in bus_func.c but initialised in error_init
82  */
83 extern kmutex_t bfd_lock;
84 
85 static uint32_t rq_overflow_count = 0;		/* counter for rq overflow */
86 
87 static void cpu_queue_one_event(errh_async_flt_t *);
88 static uint32_t count_entries_on_queue(uint64_t, uint64_t, uint32_t);
89 static void errh_page_retire(errh_async_flt_t *, uchar_t);
90 static int errh_error_protected(struct regs *, struct async_flt *, int *);
91 static void errh_rq_full(struct async_flt *);
92 static void ue_drain(void *, struct async_flt *, errorq_elem_t *);
93 static void ce_drain(void *, struct async_flt *, errorq_elem_t *);
94 
95 /*ARGSUSED*/
96 void
97 process_resumable_error(struct regs *rp, uint32_t head_offset,
98     uint32_t tail_offset)
99 {
100 	struct machcpu *mcpup;
101 	struct async_flt *aflt;
102 	errh_async_flt_t errh_flt;
103 	errh_er_t *head_va;
104 
105 	mcpup = &(CPU->cpu_m);
106 
107 	while (head_offset != tail_offset) {
108 		/* kernel buffer starts right after the resumable queue */
109 		head_va = (errh_er_t *)(mcpup->cpu_rq_va + head_offset +
110 		    CPU_RQ_SIZE);
111 		/* Copy the error report to local buffer */
112 		bzero(&errh_flt, sizeof (errh_async_flt_t));
113 		bcopy((char *)head_va, &(errh_flt.errh_er),
114 		    sizeof (errh_er_t));
115 
116 		/* Increment the queue head */
117 		head_offset += Q_ENTRY_SIZE;
118 		/* Wrap around */
119 		head_offset &= (CPU_RQ_SIZE - 1);
120 
121 		/* set error handle to zero so it can hold new error report */
122 		head_va->ehdl = 0;
123 
124 		switch (errh_flt.errh_er.desc) {
125 		case ERRH_DESC_UCOR_RE:
126 			break;
127 
128 		case ERRH_DESC_WARN_RE:
129 			/*
130 			 * Power-off requested, but handle it one time only.
131 			 */
132 			if (!err_shutdown_triggered) {
133 				setsoftint(err_shutdown_inum);
134 				++err_shutdown_triggered;
135 			}
136 			continue;
137 
138 		default:
139 			cmn_err(CE_WARN, "Error Descriptor 0x%llx "
140 			    " invalid in resumable error handler",
141 			    (long long) errh_flt.errh_er.desc);
142 			continue;
143 		}
144 
145 		aflt = (struct async_flt *)&(errh_flt.cmn_asyncflt);
146 		aflt->flt_id = gethrtime();
147 		aflt->flt_bus_id = getprocessorid();
148 		aflt->flt_class = CPU_FAULT;
149 		aflt->flt_prot = AFLT_PROT_NONE;
150 		aflt->flt_priv = (((errh_flt.errh_er.attr & ERRH_MODE_MASK)
151 		    >> ERRH_MODE_SHIFT) == ERRH_MODE_PRIV);
152 
153 		if (errh_flt.errh_er.attr & ERRH_ATTR_CPU)
154 			/* If it is an error on other cpu */
155 			aflt->flt_panic = 1;
156 		else
157 			aflt->flt_panic = 0;
158 
159 		/*
160 		 * Handle resumable queue full case.
161 		 */
162 		if (errh_flt.errh_er.attr & ERRH_ATTR_RQF) {
163 			(void) errh_rq_full(aflt);
164 		}
165 
166 		/*
167 		 * Queue the error on ce or ue queue depend on flt_panic.
168 		 * Even if flt_panic is set, the code still keep processing
169 		 * the rest element on rq until the panic starts.
170 		 */
171 		(void) cpu_queue_one_event(&errh_flt);
172 
173 		/*
174 		 * Panic here if aflt->flt_panic has been set.
175 		 * Enqueued errors will be logged as part of the panic flow.
176 		 */
177 		if (aflt->flt_panic) {
178 			fm_panic("Unrecoverable error on another CPU");
179 		}
180 	}
181 }
182 
183 void
184 process_nonresumable_error(struct regs *rp, uint64_t flags,
185     uint32_t head_offset, uint32_t tail_offset)
186 {
187 	struct machcpu *mcpup;
188 	struct async_flt *aflt;
189 	errh_async_flt_t errh_flt;
190 	errh_er_t *head_va;
191 	int trampolined = 0;
192 	int expected = DDI_FM_ERR_UNEXPECTED;
193 	uint64_t exec_mode;
194 	uint8_t u_spill_fill;
195 
196 	mcpup = &(CPU->cpu_m);
197 
198 	while (head_offset != tail_offset) {
199 		/* kernel buffer starts right after the nonresumable queue */
200 		head_va = (errh_er_t *)(mcpup->cpu_nrq_va + head_offset +
201 		    CPU_NRQ_SIZE);
202 
203 		/* Copy the error report to local buffer */
204 		bzero(&errh_flt, sizeof (errh_async_flt_t));
205 
206 		bcopy((char *)head_va, &(errh_flt.errh_er),
207 		    sizeof (errh_er_t));
208 
209 		/* Increment the queue head */
210 		head_offset += Q_ENTRY_SIZE;
211 		/* Wrap around */
212 		head_offset &= (CPU_NRQ_SIZE - 1);
213 
214 		/* set error handle to zero so it can hold new error report */
215 		head_va->ehdl = 0;
216 
217 		aflt = (struct async_flt *)&(errh_flt.cmn_asyncflt);
218 
219 		trampolined = 0;
220 
221 		if (errh_flt.errh_er.attr & ERRH_ATTR_PIO)
222 			aflt->flt_class = BUS_FAULT;
223 		else
224 			aflt->flt_class = CPU_FAULT;
225 
226 		aflt->flt_id = gethrtime();
227 		aflt->flt_bus_id = getprocessorid();
228 		aflt->flt_pc = (caddr_t)rp->r_pc;
229 		exec_mode = (errh_flt.errh_er.attr & ERRH_MODE_MASK)
230 		    >> ERRH_MODE_SHIFT;
231 		aflt->flt_priv = (exec_mode == ERRH_MODE_PRIV ||
232 		    exec_mode == ERRH_MODE_UNKNOWN);
233 		aflt->flt_prot = AFLT_PROT_NONE;
234 		aflt->flt_tl = (uchar_t)(flags & ERRH_TL_MASK);
235 		aflt->flt_panic = ((aflt->flt_tl != 0) ||
236 		    (aft_testfatal != 0));
237 
238 		/*
239 		 * For the first error packet on the queue, check if it
240 		 * happened in user fill/spill trap.
241 		 */
242 		if (flags & ERRH_U_SPILL_FILL) {
243 			u_spill_fill = 1;
244 			/* clear the user fill/spill flag in flags */
245 			flags = (uint64_t)aflt->flt_tl;
246 		} else
247 			u_spill_fill = 0;
248 
249 		switch (errh_flt.errh_er.desc) {
250 		case ERRH_DESC_PR_NRE:
251 			if (u_spill_fill) {
252 				aflt->flt_panic = 0;
253 				break;
254 			}
255 			/*
256 			 * Fall through, precise fault also need to check
257 			 * to see if it was protected.
258 			 */
259 			/*FALLTHRU*/
260 
261 		case ERRH_DESC_DEF_NRE:
262 			/*
263 			 * If the trap occurred in privileged mode at TL=0,
264 			 * we need to check to see if we were executing
265 			 * in kernel under on_trap() or t_lofault
266 			 * protection. If so, and if it was a PIO or MEM
267 			 * error, then modify the saved registers so that
268 			 * we return from the trap to the appropriate
269 			 * trampoline routine.
270 			 */
271 			if (aflt->flt_priv == 1 && aflt->flt_tl == 0 &&
272 			    ((errh_flt.errh_er.attr & ERRH_ATTR_PIO) ||
273 			    (errh_flt.errh_er.attr & ERRH_ATTR_MEM))) {
274 				trampolined =
275 				    errh_error_protected(rp, aflt, &expected);
276 			}
277 
278 			if (!aflt->flt_priv || aflt->flt_prot ==
279 			    AFLT_PROT_COPY) {
280 				aflt->flt_panic |= aft_panic;
281 			} else if (!trampolined &&
282 			    (errh_flt.errh_er.attr & ERRH_ATTR_MEM)) {
283 				aflt->flt_panic = 1;
284 			}
285 
286 			/*
287 			 * If PIO error, we need to query the bus nexus
288 			 * for fatal errors.
289 			 */
290 			if (aflt->flt_class == BUS_FAULT) {
291 				aflt->flt_addr = errh_flt.errh_er.ra;
292 				errh_cpu_run_bus_error_handlers(aflt,
293 				    expected);
294 			}
295 
296 			break;
297 
298 		default:
299 			cmn_err(CE_WARN, "Error Descriptor 0x%llx "
300 			    " invalid in nonresumable error handler",
301 			    (long long) errh_flt.errh_er.desc);
302 			continue;
303 		}
304 
305 		/*
306 		 * Queue the error report for further processing. If
307 		 * flt_panic is set, code still process other errors
308 		 * in the queue until the panic routine stops the
309 		 * kernel.
310 		 */
311 		(void) cpu_queue_one_event(&errh_flt);
312 
313 		/*
314 		 * Panic here if aflt->flt_panic has been set.
315 		 * Enqueued errors will be logged as part of the panic flow.
316 		 */
317 		if (aflt->flt_panic) {
318 			fm_panic("Unrecoverable hardware error");
319 		}
320 
321 		/*
322 		 * Call page_retire() to handle memory errors.
323 		 */
324 		if (errh_flt.errh_er.attr & ERRH_ATTR_MEM)
325 			errh_page_retire(&errh_flt, PR_UE);
326 
327 		/*
328 		 * If we queued an error and the it was in user mode, or
329 		 * protected by t_lofault, or user_spill_fill is set, we
330 		 * set AST flag so the queue will be drained before
331 		 * returning to user mode.
332 		 */
333 		if (!aflt->flt_priv || aflt->flt_prot == AFLT_PROT_COPY ||
334 		    u_spill_fill) {
335 			int pcb_flag = 0;
336 
337 			if (aflt->flt_class == CPU_FAULT)
338 				pcb_flag |= ASYNC_HWERR;
339 			else if (aflt->flt_class == BUS_FAULT)
340 				pcb_flag |= ASYNC_BERR;
341 
342 			ttolwp(curthread)->lwp_pcb.pcb_flags |= pcb_flag;
343 			aston(curthread);
344 		}
345 	}
346 }
347 
348 /*
349  * For PIO errors, this routine calls nexus driver's error
350  * callback routines. If the callback routine returns fatal, and
351  * we are in kernel or unknow mode without any error protection,
352  * we need to turn on the panic flag.
353  */
354 void
355 errh_cpu_run_bus_error_handlers(struct async_flt *aflt, int expected)
356 {
357 	int status;
358 	ddi_fm_error_t de;
359 
360 	bzero(&de, sizeof (ddi_fm_error_t));
361 
362 	de.fme_version = DDI_FME_VERSION;
363 	de.fme_ena = fm_ena_generate(aflt->flt_id, FM_ENA_FMT1);
364 	de.fme_flag = expected;
365 	de.fme_bus_specific = (void *)aflt->flt_addr;
366 	status = ndi_fm_handler_dispatch(ddi_root_node(), NULL, &de);
367 
368 	/*
369 	 * If error is protected, it will jump to proper routine
370 	 * to handle the handle; if it is in user level, we just
371 	 * kill the user process; if the driver thinks the error is
372 	 * not fatal, we can drive on. If none of above are true,
373 	 * we panic
374 	 */
375 	if ((aflt->flt_prot == AFLT_PROT_NONE) && (aflt->flt_priv == 1) &&
376 	    (status == DDI_FM_FATAL))
377 		aflt->flt_panic = 1;
378 }
379 
380 /*
381  * This routine checks to see if we are under any error protection when
382  * the error happens. If we are under error protection, we unwind to
383  * the protection and indicate fault.
384  */
385 static int
386 errh_error_protected(struct regs *rp, struct async_flt *aflt, int *expected)
387 {
388 	int trampolined = 0;
389 	ddi_acc_hdl_t *hp;
390 
391 	if (curthread->t_ontrap != NULL) {
392 		on_trap_data_t *otp = curthread->t_ontrap;
393 
394 		if (otp->ot_prot & OT_DATA_EC) {
395 			aflt->flt_prot = AFLT_PROT_EC;
396 			otp->ot_trap |= OT_DATA_EC;
397 			rp->r_pc = otp->ot_trampoline;
398 			rp->r_npc = rp->r_pc +4;
399 			trampolined = 1;
400 		}
401 
402 		if (otp->ot_prot & OT_DATA_ACCESS) {
403 			aflt->flt_prot = AFLT_PROT_ACCESS;
404 			otp->ot_trap |= OT_DATA_ACCESS;
405 			rp->r_pc = otp->ot_trampoline;
406 			rp->r_npc = rp->r_pc + 4;
407 			trampolined = 1;
408 			/*
409 			 * for peek and caut_gets
410 			 * errors are expected
411 			 */
412 			hp = (ddi_acc_hdl_t *)otp->ot_handle;
413 			if (!hp)
414 				*expected = DDI_FM_ERR_PEEK;
415 			else if (hp->ah_acc.devacc_attr_access ==
416 			    DDI_CAUTIOUS_ACC)
417 				*expected = DDI_FM_ERR_EXPECTED;
418 		}
419 	} else if (curthread->t_lofault) {
420 		aflt->flt_prot = AFLT_PROT_COPY;
421 		rp->r_g1 = EFAULT;
422 		rp->r_pc = curthread->t_lofault;
423 		rp->r_npc = rp->r_pc + 4;
424 		trampolined = 1;
425 	}
426 
427 	return (trampolined);
428 }
429 
430 /*
431  * Queue one event.
432  */
433 static void
434 cpu_queue_one_event(errh_async_flt_t *errh_fltp)
435 {
436 	struct async_flt *aflt = (struct async_flt *)errh_fltp;
437 	errorq_t *eqp;
438 
439 	if (aflt->flt_panic)
440 		eqp = ue_queue;
441 	else
442 		eqp = ce_queue;
443 
444 	errorq_dispatch(eqp, errh_fltp, sizeof (errh_async_flt_t),
445 	    aflt->flt_panic);
446 }
447 
448 /*
449  * The cpu_async_log_err() function is called by the ce/ue_drain() function to
450  * handle logging for CPU events that are dequeued.  As such, it can be invoked
451  * from softint context, from AST processing in the trap() flow, or from the
452  * panic flow.  We decode the CPU-specific data, and log appropriate messages.
453  */
454 void
455 cpu_async_log_err(void *flt)
456 {
457 	errh_async_flt_t *errh_fltp = (errh_async_flt_t *)flt;
458 	errh_er_t *errh_erp = (errh_er_t *)&errh_fltp->errh_er;
459 
460 	switch (errh_erp->desc) {
461 	case ERRH_DESC_UCOR_RE:
462 		if (errh_erp->attr & ERRH_ATTR_MEM) {
463 			/*
464 			 * Turn on the PR_UE flag. The page will be
465 			 * scrubbed when it is freed.
466 			 */
467 			errh_page_retire(errh_fltp, PR_UE);
468 		}
469 
470 		break;
471 
472 	case ERRH_DESC_PR_NRE:
473 	case ERRH_DESC_DEF_NRE:
474 		if (errh_erp->attr & ERRH_ATTR_MEM) {
475 			/*
476 			 * For non-resumable memory error, retire
477 			 * the page here.
478 			 */
479 			errh_page_retire(errh_fltp, PR_UE);
480 
481 			/*
482 			 * If we are going to panic, scrub the page first
483 			 */
484 			if (errh_fltp->cmn_asyncflt.flt_panic)
485 				mem_scrub(errh_fltp->errh_er.ra,
486 				    errh_fltp->errh_er.sz);
487 		}
488 		break;
489 
490 	default:
491 		break;
492 	}
493 }
494 
495 /*
496  * Called from ce_drain().
497  */
498 void
499 cpu_ce_log_err(struct async_flt *aflt)
500 {
501 	switch (aflt->flt_class) {
502 	case CPU_FAULT:
503 		cpu_async_log_err(aflt);
504 		break;
505 
506 	case BUS_FAULT:
507 		cpu_async_log_err(aflt);
508 		break;
509 
510 	default:
511 		break;
512 	}
513 }
514 
515 /*
516  * Called from ue_drain().
517  */
518 void
519 cpu_ue_log_err(struct async_flt *aflt)
520 {
521 	switch (aflt->flt_class) {
522 	case CPU_FAULT:
523 		cpu_async_log_err(aflt);
524 		break;
525 
526 	case BUS_FAULT:
527 		cpu_async_log_err(aflt);
528 		break;
529 
530 	default:
531 		break;
532 	}
533 }
534 
535 /*
536  * Turn on flag on the error memory region.
537  */
538 static void
539 errh_page_retire(errh_async_flt_t *errh_fltp, uchar_t flag)
540 {
541 	uint64_t flt_real_addr_start = errh_fltp->errh_er.ra;
542 	uint64_t flt_real_addr_end = flt_real_addr_start +
543 	    errh_fltp->errh_er.sz - 1;
544 	int64_t current_addr;
545 
546 	if (errh_fltp->errh_er.sz == 0)
547 		return;
548 
549 	for (current_addr = flt_real_addr_start;
550 	    current_addr < flt_real_addr_end; current_addr += MMU_PAGESIZE) {
551 		(void) page_retire(current_addr, flag);
552 	}
553 }
554 
555 void
556 mem_scrub(uint64_t paddr, uint64_t len)
557 {
558 	uint64_t pa, length, scrubbed_len;
559 
560 	pa = paddr;
561 	length = len;
562 	scrubbed_len = 0;
563 
564 	while (length > 0) {
565 		if (hv_mem_scrub(pa, length, &scrubbed_len) != H_EOK)
566 			break;
567 
568 		pa += scrubbed_len;
569 		length -= scrubbed_len;
570 	}
571 }
572 
573 /*
574  * Call hypervisor to flush the memory region. The memory region
575  * must be within the same page frame.
576  */
577 void
578 mem_sync(caddr_t va, size_t len)
579 {
580 	uint64_t pa, length, flushed;
581 
582 	pa = va_to_pa((caddr_t)va);
583 
584 	if (pa == (uint64_t)-1)
585 		return;
586 
587 	ASSERT((pa >> MMU_PAGESHIFT) == ((pa + len - 1) >> MMU_PAGESHIFT));
588 
589 	length = len;
590 	flushed = 0;
591 
592 	while (length > 0) {
593 		if (hv_mem_sync(pa, length, &flushed) != H_EOK)
594 			break;
595 
596 		pa += flushed;
597 		length -= flushed;
598 	}
599 }
600 
601 /*
602  * If resumable queue is full, we need to check if any cpu is in
603  * error state. If not, we drive on. If yes, we need to panic. The
604  * hypervisor call hv_cpu_state() is being used for checking the
605  * cpu state.
606  */
607 static void
608 errh_rq_full(struct async_flt *afltp)
609 {
610 	processorid_t who;
611 	uint64_t cpu_state;
612 	uint64_t retval;
613 
614 	for (who = 0; who < NCPU; who++)
615 		if (CPU_IN_SET(cpu_ready_set, who)) {
616 			retval = hv_cpu_state(who, &cpu_state);
617 			if (retval != H_EOK || cpu_state == CPU_STATE_ERROR) {
618 				afltp->flt_panic = 1;
619 				break;
620 			}
621 		}
622 }
623 
624 /*
625  * Return processor specific async error structure
626  * size used.
627  */
628 int
629 cpu_aflt_size(void)
630 {
631 	return (sizeof (errh_async_flt_t));
632 }
633 
634 #define	SZ_TO_ETRS_SHIFT	6
635 
636 /*
637  * Message print out when resumable queue is overflown
638  */
639 /*ARGSUSED*/
640 void
641 rq_overflow(struct regs *rp, uint64_t head_offset,
642     uint64_t tail_offset)
643 {
644 	rq_overflow_count++;
645 }
646 
647 /*
648  * Handler to process a fatal error.  This routine can be called from a
649  * softint, called from trap()'s AST handling, or called from the panic flow.
650  */
651 /*ARGSUSED*/
652 static void
653 ue_drain(void *ignored, struct async_flt *aflt, errorq_elem_t *eqep)
654 {
655 	cpu_ue_log_err(aflt);
656 }
657 
658 /*
659  * Handler to process a correctable error.  This routine can be called from a
660  * softint.  We just call the CPU module's logging routine.
661  */
662 /*ARGSUSED*/
663 static void
664 ce_drain(void *ignored, struct async_flt *aflt, errorq_elem_t *eqep)
665 {
666 	cpu_ce_log_err(aflt);
667 }
668 
669 /*
670  * Handler to process vbsc hostshutdown (power-off button).
671  */
672 static int
673 err_shutdown_softintr()
674 {
675 	cmn_err(CE_WARN, "Power-off requested, system will now shutdown.");
676 	do_shutdown();
677 
678 	/*
679 	 * just in case do_shutdown() fails
680 	 */
681 	(void) timeout((void(*)(void *))power_down, NULL, 100 * hz);
682 	return (DDI_INTR_CLAIMED);
683 }
684 
685 /*
686  * Allocate error queue sizes based on max_ncpus.  max_ncpus is set just
687  * after ncpunode has been determined.  ncpus is set in start_other_cpus
688  * which is called after error_init() but may change dynamically.
689  */
690 void
691 error_init(void)
692 {
693 	char tmp_name[MAXSYSNAME];
694 	pnode_t node;
695 	size_t size = cpu_aflt_size();
696 
697 	/*
698 	 * Initialize the correctable and uncorrectable error queues.
699 	 */
700 	ue_queue = errorq_create("ue_queue", (errorq_func_t)ue_drain, NULL,
701 	    MAX_ASYNC_FLTS * (max_ncpus + 1), size, PIL_2, ERRORQ_VITAL);
702 
703 	ce_queue = errorq_create("ce_queue", (errorq_func_t)ce_drain, NULL,
704 	    MAX_CE_FLTS * (max_ncpus + 1), size, PIL_1, 0);
705 
706 	if (ue_queue == NULL || ce_queue == NULL)
707 		panic("failed to create required system error queue");
708 
709 	/*
710 	 * Setup interrupt handler for power-off button.
711 	 */
712 	err_shutdown_inum = add_softintr(PIL_9,
713 	    (softintrfunc)err_shutdown_softintr, NULL);
714 
715 	/*
716 	 * Initialize the busfunc list mutex.  This must be a PIL_15 spin lock
717 	 * because we will need to acquire it from cpu_async_error().
718 	 */
719 	mutex_init(&bfd_lock, NULL, MUTEX_SPIN, (void *)PIL_15);
720 
721 	node = prom_rootnode();
722 	if ((node == OBP_NONODE) || (node == OBP_BADNODE)) {
723 		cmn_err(CE_CONT, "error_init: node 0x%x\n", (uint_t)node);
724 		return;
725 	}
726 
727 	if (((size = prom_getproplen(node, "reset-reason")) != -1) &&
728 	    (size <= MAXSYSNAME) &&
729 	    (prom_getprop(node, "reset-reason", tmp_name) != -1)) {
730 		if (reset_debug) {
731 			cmn_err(CE_CONT, "System booting after %s\n", tmp_name);
732 		} else if (strncmp(tmp_name, "FATAL", 5) == 0) {
733 			cmn_err(CE_CONT,
734 			    "System booting after fatal error %s\n", tmp_name);
735 		}
736 	}
737 }
738 
739 /*
740  * Nonresumable queue is full, panic here
741  */
742 /*ARGSUSED*/
743 void
744 nrq_overflow(struct regs *rp)
745 {
746 	fm_panic("Nonresumable queue full");
747 }
748