10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*1414Scindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * When the operating system detects that it is in an invalid state, a panic 310Sstevel@tonic-gate * is initiated in order to minimize potential damage to user data and to 320Sstevel@tonic-gate * facilitate debugging. There are three major tasks to be performed in 330Sstevel@tonic-gate * a system panic: recording information about the panic in memory (and thus 340Sstevel@tonic-gate * making it part of the crash dump), synchronizing the file systems to 350Sstevel@tonic-gate * preserve user file data, and generating the crash dump. We define the 360Sstevel@tonic-gate * system to be in one of four states with respect to the panic code: 370Sstevel@tonic-gate * 380Sstevel@tonic-gate * CALM - the state of the system prior to any thread initiating a panic 390Sstevel@tonic-gate * 400Sstevel@tonic-gate * QUIESCE - the state of the system when the first thread to initiate 410Sstevel@tonic-gate * a system panic records information about the cause of the panic 420Sstevel@tonic-gate * and renders the system quiescent by stopping other processors 430Sstevel@tonic-gate * 440Sstevel@tonic-gate * SYNC - the state of the system when we synchronize the file systems 450Sstevel@tonic-gate * DUMP - the state when we generate the crash dump. 460Sstevel@tonic-gate * 470Sstevel@tonic-gate * The transitions between these states are irreversible: once we begin 480Sstevel@tonic-gate * panicking, we only make one attempt to perform the actions associated with 490Sstevel@tonic-gate * each state. 500Sstevel@tonic-gate * 510Sstevel@tonic-gate * The panic code itself must be re-entrant because actions taken during any 520Sstevel@tonic-gate * state may lead to another system panic. Additionally, any Solaris 530Sstevel@tonic-gate * thread may initiate a panic at any time, and so we must have synchronization 540Sstevel@tonic-gate * between threads which attempt to initiate a state transition simultaneously. 550Sstevel@tonic-gate * The panic code makes use of a special locking primitive, a trigger, to 560Sstevel@tonic-gate * perform this synchronization. A trigger is simply a word which is set 570Sstevel@tonic-gate * atomically and can only be set once. We declare three triggers, one for 580Sstevel@tonic-gate * each transition between the four states. When a thread enters the panic 590Sstevel@tonic-gate * code it attempts to set each trigger; if it fails it moves on to the 600Sstevel@tonic-gate * next trigger. A special case is the first trigger: if two threads race 610Sstevel@tonic-gate * to perform the transition to QUIESCE, the losing thread may execute before 620Sstevel@tonic-gate * the winner has a chance to stop its CPU. To solve this problem, we have 630Sstevel@tonic-gate * the loser look ahead to see if any other triggers are set; if not, it 640Sstevel@tonic-gate * presumes a panic is underway and simply spins. Unfortunately, since we 650Sstevel@tonic-gate * are panicking, it is not possible to know this with absolute certainty. 660Sstevel@tonic-gate * 670Sstevel@tonic-gate * There are two common reasons for re-entering the panic code once a panic 680Sstevel@tonic-gate * has been initiated: (1) after we debug_enter() at the end of QUIESCE, 690Sstevel@tonic-gate * the operator may type "sync" instead of "go", and the PROM's sync callback 700Sstevel@tonic-gate * routine will invoke panic(); (2) if the clock routine decides that sync 710Sstevel@tonic-gate * or dump is not making progress, it will invoke panic() to force a timeout. 720Sstevel@tonic-gate * The design assumes that a third possibility, another thread causing an 730Sstevel@tonic-gate * unrelated panic while sync or dump is still underway, is extremely unlikely. 740Sstevel@tonic-gate * If this situation occurs, we may end up triggering dump while sync is 750Sstevel@tonic-gate * still in progress. This third case is considered extremely unlikely because 760Sstevel@tonic-gate * all other CPUs are stopped and low-level interrupts have been blocked. 770Sstevel@tonic-gate * 780Sstevel@tonic-gate * The panic code is entered via a call directly to the vpanic() function, 790Sstevel@tonic-gate * or its varargs wrappers panic() and cmn_err(9F). The vpanic routine 800Sstevel@tonic-gate * is implemented in assembly language to record the current machine 810Sstevel@tonic-gate * registers, attempt to set the trigger for the QUIESCE state, and 820Sstevel@tonic-gate * if successful, switch stacks on to the panic_stack before calling into 830Sstevel@tonic-gate * the common panicsys() routine. The first thread to initiate a panic 840Sstevel@tonic-gate * is allowed to make use of the reserved panic_stack so that executing 850Sstevel@tonic-gate * the panic code itself does not overwrite valuable data on that thread's 860Sstevel@tonic-gate * stack *ahead* of the current stack pointer. This data will be preserved 870Sstevel@tonic-gate * in the crash dump and may prove invaluable in determining what this 880Sstevel@tonic-gate * thread has previously been doing. The first thread, saved in panic_thread, 890Sstevel@tonic-gate * is also responsible for stopping the other CPUs as quickly as possible, 900Sstevel@tonic-gate * and then setting the various panic_* variables. Most important among 910Sstevel@tonic-gate * these is panicstr, which allows threads to subsequently bypass held 920Sstevel@tonic-gate * locks so that we can proceed without ever blocking. We must stop the 930Sstevel@tonic-gate * other CPUs *prior* to setting panicstr in case threads running there are 940Sstevel@tonic-gate * currently spinning to acquire a lock; we want that state to be preserved. 950Sstevel@tonic-gate * Every thread which initiates a panic has its T_PANIC flag set so we can 960Sstevel@tonic-gate * identify all such threads in the crash dump. 970Sstevel@tonic-gate * 980Sstevel@tonic-gate * The panic_thread is also allowed to make use of the special memory buffer 990Sstevel@tonic-gate * panicbuf, which on machines with appropriate hardware is preserved across 1000Sstevel@tonic-gate * reboots. We allow the panic_thread to store its register set and panic 1010Sstevel@tonic-gate * message in this buffer, so even if we fail to obtain a crash dump we will 1020Sstevel@tonic-gate * be able to examine the machine after reboot and determine some of the 1030Sstevel@tonic-gate * state at the time of the panic. If we do get a dump, the panic buffer 1040Sstevel@tonic-gate * data is structured so that a debugger can easily consume the information 1050Sstevel@tonic-gate * therein (see <sys/panic.h>). 1060Sstevel@tonic-gate * 1070Sstevel@tonic-gate * Each platform or architecture is required to implement the functions 1080Sstevel@tonic-gate * panic_savetrap() to record trap-specific information to panicbuf, 1090Sstevel@tonic-gate * panic_saveregs() to record a register set to panicbuf, panic_stopcpus() 1100Sstevel@tonic-gate * to halt all CPUs but the panicking CPU, panic_quiesce_hw() to perform 1110Sstevel@tonic-gate * miscellaneous platform-specific tasks *after* panicstr is set, 1120Sstevel@tonic-gate * panic_showtrap() to print trap-specific information to the console, 1130Sstevel@tonic-gate * and panic_dump_hw() to perform platform tasks prior to calling dumpsys(). 1140Sstevel@tonic-gate * 1150Sstevel@tonic-gate * A Note on Word Formation, courtesy of the Oxford Guide to English Usage: 1160Sstevel@tonic-gate * 1170Sstevel@tonic-gate * Words ending in -c interpose k before suffixes which otherwise would 1180Sstevel@tonic-gate * indicate a soft c, and thus the verb and adjective forms of 'panic' are 1190Sstevel@tonic-gate * spelled "panicked", "panicking", and "panicky" respectively. Use of 1200Sstevel@tonic-gate * the ill-conceived "panicing" and "panic'd" is discouraged. 1210Sstevel@tonic-gate */ 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate #include <sys/types.h> 1240Sstevel@tonic-gate #include <sys/varargs.h> 1250Sstevel@tonic-gate #include <sys/sysmacros.h> 1260Sstevel@tonic-gate #include <sys/cmn_err.h> 1270Sstevel@tonic-gate #include <sys/cpuvar.h> 1280Sstevel@tonic-gate #include <sys/thread.h> 1290Sstevel@tonic-gate #include <sys/t_lock.h> 1300Sstevel@tonic-gate #include <sys/cred.h> 1310Sstevel@tonic-gate #include <sys/systm.h> 1320Sstevel@tonic-gate #include <sys/uadmin.h> 1330Sstevel@tonic-gate #include <sys/callb.h> 1340Sstevel@tonic-gate #include <sys/vfs.h> 1350Sstevel@tonic-gate #include <sys/log.h> 1360Sstevel@tonic-gate #include <sys/disp.h> 1370Sstevel@tonic-gate #include <sys/param.h> 1380Sstevel@tonic-gate #include <sys/dumphdr.h> 1390Sstevel@tonic-gate #include <sys/ftrace.h> 1400Sstevel@tonic-gate #include <sys/reboot.h> 1410Sstevel@tonic-gate #include <sys/debug.h> 1420Sstevel@tonic-gate #include <sys/stack.h> 1430Sstevel@tonic-gate #include <sys/spl.h> 1440Sstevel@tonic-gate #include <sys/errorq.h> 1450Sstevel@tonic-gate #include <sys/panic.h> 146*1414Scindi #include <sys/fm/util.h> 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate /* 1490Sstevel@tonic-gate * Panic variables which are set once during the QUIESCE state by the 1500Sstevel@tonic-gate * first thread to initiate a panic. These are examined by post-mortem 1510Sstevel@tonic-gate * debugging tools; the inconsistent use of 'panic' versus 'panic_' in 1520Sstevel@tonic-gate * the variable naming is historical and allows legacy tools to work. 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate #pragma align STACK_ALIGN(panic_stack) 1550Sstevel@tonic-gate char panic_stack[PANICSTKSIZE]; /* reserved stack for panic_thread */ 1560Sstevel@tonic-gate kthread_t *panic_thread; /* first thread to call panicsys() */ 1570Sstevel@tonic-gate cpu_t panic_cpu; /* cpu from first call to panicsys() */ 1580Sstevel@tonic-gate label_t panic_regs; /* setjmp label from panic_thread */ 1590Sstevel@tonic-gate struct regs *panic_reg; /* regs struct from first panicsys() */ 1600Sstevel@tonic-gate char *volatile panicstr; /* format string to first panicsys() */ 1610Sstevel@tonic-gate va_list panicargs; /* arguments to first panicsys() */ 1620Sstevel@tonic-gate clock_t panic_lbolt; /* lbolt at time of panic */ 1630Sstevel@tonic-gate int64_t panic_lbolt64; /* lbolt64 at time of panic */ 1640Sstevel@tonic-gate hrtime_t panic_hrtime; /* hrtime at time of panic */ 1650Sstevel@tonic-gate timespec_t panic_hrestime; /* hrestime at time of panic */ 1660Sstevel@tonic-gate int panic_ipl; /* ipl on panic_cpu at time of panic */ 1670Sstevel@tonic-gate ushort_t panic_schedflag; /* t_schedflag for panic_thread */ 1680Sstevel@tonic-gate cpu_t *panic_bound_cpu; /* t_bound_cpu for panic_thread */ 1690Sstevel@tonic-gate char panic_preempt; /* t_preempt for panic_thread */ 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate /* 1720Sstevel@tonic-gate * Panic variables which can be set via /etc/system or patched while 1730Sstevel@tonic-gate * the system is in operation. Again, the stupid names are historic. 1740Sstevel@tonic-gate */ 1750Sstevel@tonic-gate char *panic_bootstr = NULL; /* mdboot string to use after panic */ 1760Sstevel@tonic-gate int panic_bootfcn = AD_BOOT; /* mdboot function to use after panic */ 1770Sstevel@tonic-gate int halt_on_panic = 0; /* halt after dump instead of reboot? */ 1780Sstevel@tonic-gate int nopanicdebug = 0; /* reboot instead of call debugger? */ 1790Sstevel@tonic-gate int in_sync = 0; /* skip vfs_syncall() and just dump? */ 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate /* 1820Sstevel@tonic-gate * The do_polled_io flag is set by the panic code to inform the SCSI subsystem 1830Sstevel@tonic-gate * to use polled mode instead of interrupt-driven i/o. 1840Sstevel@tonic-gate */ 1850Sstevel@tonic-gate int do_polled_io = 0; 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * The panic_forced flag is set by the uadmin A_DUMP code to inform the 1890Sstevel@tonic-gate * panic subsystem that it should not attempt an initial debug_enter. 1900Sstevel@tonic-gate */ 1910Sstevel@tonic-gate int panic_forced = 0; 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate /* 1940Sstevel@tonic-gate * Triggers for panic state transitions: 1950Sstevel@tonic-gate */ 1960Sstevel@tonic-gate int panic_quiesce; /* trigger for CALM -> QUIESCE */ 1970Sstevel@tonic-gate int panic_sync; /* trigger for QUIESCE -> SYNC */ 1980Sstevel@tonic-gate int panic_dump; /* trigger for SYNC -> DUMP */ 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate void 2010Sstevel@tonic-gate panicsys(const char *format, va_list alist, struct regs *rp, int on_panic_stack) 2020Sstevel@tonic-gate { 2030Sstevel@tonic-gate int s = spl8(); 2040Sstevel@tonic-gate kthread_t *t = curthread; 2050Sstevel@tonic-gate cpu_t *cp = CPU; 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate caddr_t intr_stack = NULL; 2080Sstevel@tonic-gate uint_t intr_actv; 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate ushort_t schedflag = t->t_schedflag; 2110Sstevel@tonic-gate cpu_t *bound_cpu = t->t_bound_cpu; 2120Sstevel@tonic-gate char preempt = t->t_preempt; 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate (void) setjmp(&t->t_pcb); 2150Sstevel@tonic-gate t->t_flag |= T_PANIC; 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate t->t_schedflag |= TS_DONT_SWAP; 2180Sstevel@tonic-gate t->t_bound_cpu = cp; 2190Sstevel@tonic-gate t->t_preempt++; 2200Sstevel@tonic-gate 2210Sstevel@tonic-gate panic_enter_hw(s); 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate /* 2240Sstevel@tonic-gate * If we're on the interrupt stack and an interrupt thread is available 2250Sstevel@tonic-gate * in this CPU's pool, preserve the interrupt stack by detaching an 2260Sstevel@tonic-gate * interrupt thread and making its stack the intr_stack. 2270Sstevel@tonic-gate */ 2280Sstevel@tonic-gate if (CPU_ON_INTR(cp) && cp->cpu_intr_thread != NULL) { 2290Sstevel@tonic-gate kthread_t *it = cp->cpu_intr_thread; 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate intr_stack = cp->cpu_intr_stack; 2320Sstevel@tonic-gate intr_actv = cp->cpu_intr_actv; 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate cp->cpu_intr_stack = thread_stk_init(it->t_stk); 2350Sstevel@tonic-gate cp->cpu_intr_thread = it->t_link; 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* 2380Sstevel@tonic-gate * Clear only the high level bits of cpu_intr_actv. 2390Sstevel@tonic-gate * We want to indicate that high-level interrupts are 2400Sstevel@tonic-gate * not active without destroying the low-level interrupt 2410Sstevel@tonic-gate * information stored there. 2420Sstevel@tonic-gate */ 2430Sstevel@tonic-gate cp->cpu_intr_actv &= ((1 << (LOCK_LEVEL + 1)) - 1); 2440Sstevel@tonic-gate } 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate /* 2470Sstevel@tonic-gate * Record one-time panic information and quiesce the other CPUs. 2480Sstevel@tonic-gate * Then print out the panic message and stack trace. 2490Sstevel@tonic-gate */ 2500Sstevel@tonic-gate if (on_panic_stack) { 2510Sstevel@tonic-gate panic_data_t *pdp = (panic_data_t *)panicbuf; 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate pdp->pd_version = PANICBUFVERS; 2540Sstevel@tonic-gate pdp->pd_msgoff = sizeof (panic_data_t) - sizeof (panic_nv_t); 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate if (t->t_panic_trap != NULL) 2570Sstevel@tonic-gate panic_savetrap(pdp, t->t_panic_trap); 2580Sstevel@tonic-gate else 2590Sstevel@tonic-gate panic_saveregs(pdp, rp); 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate (void) vsnprintf(&panicbuf[pdp->pd_msgoff], 2620Sstevel@tonic-gate PANICBUFSIZE - pdp->pd_msgoff, format, alist); 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate /* 2650Sstevel@tonic-gate * Call into the platform code to stop the other CPUs. 2660Sstevel@tonic-gate * We currently have all interrupts blocked, and expect that 2670Sstevel@tonic-gate * the platform code will lower ipl only as far as needed to 2680Sstevel@tonic-gate * perform cross-calls, and will acquire as *few* locks as is 2690Sstevel@tonic-gate * possible -- panicstr is not set so we can still deadlock. 2700Sstevel@tonic-gate */ 2710Sstevel@tonic-gate panic_stopcpus(cp, t, s); 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate panicstr = (char *)format; 2740Sstevel@tonic-gate va_copy(panicargs, alist); 2750Sstevel@tonic-gate panic_lbolt = lbolt; 2760Sstevel@tonic-gate panic_lbolt64 = lbolt64; 2770Sstevel@tonic-gate panic_hrestime = hrestime; 2780Sstevel@tonic-gate panic_hrtime = gethrtime_waitfree(); 2790Sstevel@tonic-gate panic_thread = t; 2800Sstevel@tonic-gate panic_regs = t->t_pcb; 2810Sstevel@tonic-gate panic_reg = rp; 2820Sstevel@tonic-gate panic_cpu = *cp; 2830Sstevel@tonic-gate panic_ipl = spltoipl(s); 2840Sstevel@tonic-gate panic_schedflag = schedflag; 2850Sstevel@tonic-gate panic_bound_cpu = bound_cpu; 2860Sstevel@tonic-gate panic_preempt = preempt; 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate if (intr_stack != NULL) { 2890Sstevel@tonic-gate panic_cpu.cpu_intr_stack = intr_stack; 2900Sstevel@tonic-gate panic_cpu.cpu_intr_actv = intr_actv; 2910Sstevel@tonic-gate } 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate /* 2940Sstevel@tonic-gate * Lower ipl to 10 to keep clock() from running, but allow 2950Sstevel@tonic-gate * keyboard interrupts to enter the debugger. These callbacks 2960Sstevel@tonic-gate * are executed with panicstr set so they can bypass locks. 2970Sstevel@tonic-gate */ 2980Sstevel@tonic-gate splx(ipltospl(CLOCK_LEVEL)); 2990Sstevel@tonic-gate panic_quiesce_hw(pdp); 3000Sstevel@tonic-gate (void) FTRACE_STOP(); 3010Sstevel@tonic-gate (void) callb_execute_class(CB_CL_PANIC, NULL); 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate if (log_intrq != NULL) 3040Sstevel@tonic-gate log_flushq(log_intrq); 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate /* 3070Sstevel@tonic-gate * If log_consq has been initialized and syslogd has started, 3080Sstevel@tonic-gate * print any messages in log_consq that haven't been consumed. 3090Sstevel@tonic-gate */ 3100Sstevel@tonic-gate if (log_consq != NULL && log_consq != log_backlogq) 3110Sstevel@tonic-gate log_printq(log_consq); 3120Sstevel@tonic-gate 3130Sstevel@tonic-gate fm_banner(); 3140Sstevel@tonic-gate errorq_panic(); 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate printf("\n\rpanic[cpu%d]/thread=%p: ", cp->cpu_id, (void *)t); 3170Sstevel@tonic-gate vprintf(format, alist); 3180Sstevel@tonic-gate printf("\n\n"); 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate if (t->t_panic_trap != NULL) { 3210Sstevel@tonic-gate panic_showtrap(t->t_panic_trap); 3220Sstevel@tonic-gate printf("\n"); 3230Sstevel@tonic-gate } 3240Sstevel@tonic-gate 3250Sstevel@tonic-gate traceregs(rp); 3260Sstevel@tonic-gate printf("\n"); 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate if (((boothowto & RB_DEBUG) || obpdebug) && 3290Sstevel@tonic-gate !nopanicdebug && !panic_forced) { 3300Sstevel@tonic-gate if (dumpvp != NULL) { 3310Sstevel@tonic-gate debug_enter("panic: entering debugger " 3320Sstevel@tonic-gate "(continue to save dump)"); 3330Sstevel@tonic-gate } else { 3340Sstevel@tonic-gate debug_enter("panic: entering debugger " 3350Sstevel@tonic-gate "(no dump device, continue to reboot)"); 3360Sstevel@tonic-gate } 3370Sstevel@tonic-gate } 3380Sstevel@tonic-gate 3390Sstevel@tonic-gate } else if (panic_dump != 0 || panic_sync != 0 || panicstr != NULL) { 3400Sstevel@tonic-gate printf("\n\rpanic[cpu%d]/thread=%p: ", cp->cpu_id, (void *)t); 3410Sstevel@tonic-gate vprintf(format, alist); 3420Sstevel@tonic-gate printf("\n"); 3430Sstevel@tonic-gate } else 3440Sstevel@tonic-gate goto spin; 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate /* 3470Sstevel@tonic-gate * Prior to performing sync or dump, we make sure that do_polled_io is 3480Sstevel@tonic-gate * set, but we'll leave ipl at 10; deadman(), a CY_HIGH_LEVEL cyclic, 3490Sstevel@tonic-gate * will re-enter panic if we are not making progress with sync or dump. 3500Sstevel@tonic-gate */ 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate /* 3530Sstevel@tonic-gate * Sync the filesystems. Reset t_cred if not set because much of 3540Sstevel@tonic-gate * the filesystem code depends on CRED() being valid. 3550Sstevel@tonic-gate */ 3560Sstevel@tonic-gate if (!in_sync && panic_trigger(&panic_sync)) { 3570Sstevel@tonic-gate if (t->t_cred == NULL) 3580Sstevel@tonic-gate t->t_cred = kcred; 3590Sstevel@tonic-gate splx(ipltospl(CLOCK_LEVEL)); 3600Sstevel@tonic-gate do_polled_io = 1; 3610Sstevel@tonic-gate vfs_syncall(); 3620Sstevel@tonic-gate } 3630Sstevel@tonic-gate 3640Sstevel@tonic-gate /* 3650Sstevel@tonic-gate * Take the crash dump. If the dump trigger is already set, try to 3660Sstevel@tonic-gate * enter the debugger again before rebooting the system. 3670Sstevel@tonic-gate */ 3680Sstevel@tonic-gate if (panic_trigger(&panic_dump)) { 3690Sstevel@tonic-gate panic_dump_hw(s); 3700Sstevel@tonic-gate splx(ipltospl(CLOCK_LEVEL)); 3710Sstevel@tonic-gate do_polled_io = 1; 3720Sstevel@tonic-gate dumpsys(); 3730Sstevel@tonic-gate } else if (((boothowto & RB_DEBUG) || obpdebug) && !nopanicdebug) { 3740Sstevel@tonic-gate debug_enter("panic: entering debugger (continue to reboot)"); 3750Sstevel@tonic-gate } else 3760Sstevel@tonic-gate printf("dump aborted: please record the above information!\n"); 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate if (halt_on_panic) 379136Sachartre mdboot(A_REBOOT, AD_HALT, NULL, B_FALSE); 3800Sstevel@tonic-gate else 381136Sachartre mdboot(A_REBOOT, panic_bootfcn, panic_bootstr, B_FALSE); 3820Sstevel@tonic-gate spin: 3830Sstevel@tonic-gate /* 3840Sstevel@tonic-gate * Restore ipl to at most CLOCK_LEVEL so we don't end up spinning 3850Sstevel@tonic-gate * and unable to jump into the debugger. 3860Sstevel@tonic-gate */ 3870Sstevel@tonic-gate splx(MIN(s, ipltospl(CLOCK_LEVEL))); 3880Sstevel@tonic-gate for (;;); 3890Sstevel@tonic-gate } 3900Sstevel@tonic-gate 3910Sstevel@tonic-gate void 3920Sstevel@tonic-gate panic(const char *format, ...) 3930Sstevel@tonic-gate { 3940Sstevel@tonic-gate va_list alist; 3950Sstevel@tonic-gate 3960Sstevel@tonic-gate va_start(alist, format); 3970Sstevel@tonic-gate vpanic(format, alist); 3980Sstevel@tonic-gate va_end(alist); 3990Sstevel@tonic-gate } 400