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 55084Sjohnlev * Common Development and Distribution License (the "License"). 65084Sjohnlev * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 225084Sjohnlev * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * When the operating system detects that it is in an invalid state, a panic 300Sstevel@tonic-gate * is initiated in order to minimize potential damage to user data and to 310Sstevel@tonic-gate * facilitate debugging. There are three major tasks to be performed in 320Sstevel@tonic-gate * a system panic: recording information about the panic in memory (and thus 330Sstevel@tonic-gate * making it part of the crash dump), synchronizing the file systems to 340Sstevel@tonic-gate * preserve user file data, and generating the crash dump. We define the 350Sstevel@tonic-gate * system to be in one of four states with respect to the panic code: 360Sstevel@tonic-gate * 370Sstevel@tonic-gate * CALM - the state of the system prior to any thread initiating a panic 380Sstevel@tonic-gate * 390Sstevel@tonic-gate * QUIESCE - the state of the system when the first thread to initiate 400Sstevel@tonic-gate * a system panic records information about the cause of the panic 410Sstevel@tonic-gate * and renders the system quiescent by stopping other processors 420Sstevel@tonic-gate * 430Sstevel@tonic-gate * SYNC - the state of the system when we synchronize the file systems 440Sstevel@tonic-gate * DUMP - the state when we generate the crash dump. 450Sstevel@tonic-gate * 460Sstevel@tonic-gate * The transitions between these states are irreversible: once we begin 470Sstevel@tonic-gate * panicking, we only make one attempt to perform the actions associated with 480Sstevel@tonic-gate * each state. 490Sstevel@tonic-gate * 500Sstevel@tonic-gate * The panic code itself must be re-entrant because actions taken during any 510Sstevel@tonic-gate * state may lead to another system panic. Additionally, any Solaris 520Sstevel@tonic-gate * thread may initiate a panic at any time, and so we must have synchronization 530Sstevel@tonic-gate * between threads which attempt to initiate a state transition simultaneously. 540Sstevel@tonic-gate * The panic code makes use of a special locking primitive, a trigger, to 550Sstevel@tonic-gate * perform this synchronization. A trigger is simply a word which is set 560Sstevel@tonic-gate * atomically and can only be set once. We declare three triggers, one for 570Sstevel@tonic-gate * each transition between the four states. When a thread enters the panic 580Sstevel@tonic-gate * code it attempts to set each trigger; if it fails it moves on to the 590Sstevel@tonic-gate * next trigger. A special case is the first trigger: if two threads race 600Sstevel@tonic-gate * to perform the transition to QUIESCE, the losing thread may execute before 610Sstevel@tonic-gate * the winner has a chance to stop its CPU. To solve this problem, we have 620Sstevel@tonic-gate * the loser look ahead to see if any other triggers are set; if not, it 630Sstevel@tonic-gate * presumes a panic is underway and simply spins. Unfortunately, since we 640Sstevel@tonic-gate * are panicking, it is not possible to know this with absolute certainty. 650Sstevel@tonic-gate * 660Sstevel@tonic-gate * There are two common reasons for re-entering the panic code once a panic 670Sstevel@tonic-gate * has been initiated: (1) after we debug_enter() at the end of QUIESCE, 680Sstevel@tonic-gate * the operator may type "sync" instead of "go", and the PROM's sync callback 690Sstevel@tonic-gate * routine will invoke panic(); (2) if the clock routine decides that sync 700Sstevel@tonic-gate * or dump is not making progress, it will invoke panic() to force a timeout. 710Sstevel@tonic-gate * The design assumes that a third possibility, another thread causing an 720Sstevel@tonic-gate * unrelated panic while sync or dump is still underway, is extremely unlikely. 730Sstevel@tonic-gate * If this situation occurs, we may end up triggering dump while sync is 740Sstevel@tonic-gate * still in progress. This third case is considered extremely unlikely because 750Sstevel@tonic-gate * all other CPUs are stopped and low-level interrupts have been blocked. 760Sstevel@tonic-gate * 770Sstevel@tonic-gate * The panic code is entered via a call directly to the vpanic() function, 780Sstevel@tonic-gate * or its varargs wrappers panic() and cmn_err(9F). The vpanic routine 790Sstevel@tonic-gate * is implemented in assembly language to record the current machine 800Sstevel@tonic-gate * registers, attempt to set the trigger for the QUIESCE state, and 810Sstevel@tonic-gate * if successful, switch stacks on to the panic_stack before calling into 820Sstevel@tonic-gate * the common panicsys() routine. The first thread to initiate a panic 830Sstevel@tonic-gate * is allowed to make use of the reserved panic_stack so that executing 840Sstevel@tonic-gate * the panic code itself does not overwrite valuable data on that thread's 850Sstevel@tonic-gate * stack *ahead* of the current stack pointer. This data will be preserved 860Sstevel@tonic-gate * in the crash dump and may prove invaluable in determining what this 870Sstevel@tonic-gate * thread has previously been doing. The first thread, saved in panic_thread, 880Sstevel@tonic-gate * is also responsible for stopping the other CPUs as quickly as possible, 890Sstevel@tonic-gate * and then setting the various panic_* variables. Most important among 900Sstevel@tonic-gate * these is panicstr, which allows threads to subsequently bypass held 910Sstevel@tonic-gate * locks so that we can proceed without ever blocking. We must stop the 920Sstevel@tonic-gate * other CPUs *prior* to setting panicstr in case threads running there are 930Sstevel@tonic-gate * currently spinning to acquire a lock; we want that state to be preserved. 940Sstevel@tonic-gate * Every thread which initiates a panic has its T_PANIC flag set so we can 950Sstevel@tonic-gate * identify all such threads in the crash dump. 960Sstevel@tonic-gate * 970Sstevel@tonic-gate * The panic_thread is also allowed to make use of the special memory buffer 980Sstevel@tonic-gate * panicbuf, which on machines with appropriate hardware is preserved across 990Sstevel@tonic-gate * reboots. We allow the panic_thread to store its register set and panic 1000Sstevel@tonic-gate * message in this buffer, so even if we fail to obtain a crash dump we will 1010Sstevel@tonic-gate * be able to examine the machine after reboot and determine some of the 1020Sstevel@tonic-gate * state at the time of the panic. If we do get a dump, the panic buffer 1030Sstevel@tonic-gate * data is structured so that a debugger can easily consume the information 1040Sstevel@tonic-gate * therein (see <sys/panic.h>). 1050Sstevel@tonic-gate * 1060Sstevel@tonic-gate * Each platform or architecture is required to implement the functions 1070Sstevel@tonic-gate * panic_savetrap() to record trap-specific information to panicbuf, 1080Sstevel@tonic-gate * panic_saveregs() to record a register set to panicbuf, panic_stopcpus() 1090Sstevel@tonic-gate * to halt all CPUs but the panicking CPU, panic_quiesce_hw() to perform 1100Sstevel@tonic-gate * miscellaneous platform-specific tasks *after* panicstr is set, 1110Sstevel@tonic-gate * panic_showtrap() to print trap-specific information to the console, 1120Sstevel@tonic-gate * and panic_dump_hw() to perform platform tasks prior to calling dumpsys(). 1130Sstevel@tonic-gate * 1140Sstevel@tonic-gate * A Note on Word Formation, courtesy of the Oxford Guide to English Usage: 1150Sstevel@tonic-gate * 1160Sstevel@tonic-gate * Words ending in -c interpose k before suffixes which otherwise would 1170Sstevel@tonic-gate * indicate a soft c, and thus the verb and adjective forms of 'panic' are 1180Sstevel@tonic-gate * spelled "panicked", "panicking", and "panicky" respectively. Use of 1190Sstevel@tonic-gate * the ill-conceived "panicing" and "panic'd" is discouraged. 1200Sstevel@tonic-gate */ 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate #include <sys/types.h> 1230Sstevel@tonic-gate #include <sys/varargs.h> 1240Sstevel@tonic-gate #include <sys/sysmacros.h> 1250Sstevel@tonic-gate #include <sys/cmn_err.h> 1260Sstevel@tonic-gate #include <sys/cpuvar.h> 1270Sstevel@tonic-gate #include <sys/thread.h> 1280Sstevel@tonic-gate #include <sys/t_lock.h> 1290Sstevel@tonic-gate #include <sys/cred.h> 1300Sstevel@tonic-gate #include <sys/systm.h> 1315084Sjohnlev #include <sys/archsystm.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> 1461414Scindi #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 303*5630Sjbeck if (log_intrq != NULL) 304*5630Sjbeck log_flushq(log_intrq); 305*5630Sjbeck 306*5630Sjbeck /* 307*5630Sjbeck * If log_consq has been initialized and syslogd has started, 308*5630Sjbeck * print any messages in log_consq that haven't been consumed. 309*5630Sjbeck */ 310*5630Sjbeck if (log_consq != NULL && log_consq != log_backlogq) 311*5630Sjbeck log_printq(log_consq); 312*5630Sjbeck 3130Sstevel@tonic-gate fm_banner(); 3140Sstevel@tonic-gate 3155084Sjohnlev #if defined(__x86) 3165084Sjohnlev /* 3175084Sjohnlev * A hypervisor panic originates outside of Solaris, so we 3185084Sjohnlev * don't want to prepend the panic message with misleading 3195084Sjohnlev * pointers from within Solaris. 3205084Sjohnlev */ 3215084Sjohnlev if (!IN_XPV_PANIC()) 3225084Sjohnlev #endif 3235084Sjohnlev printf("\n\rpanic[cpu%d]/thread=%p: ", cp->cpu_id, 3245084Sjohnlev (void *)t); 3250Sstevel@tonic-gate vprintf(format, alist); 3260Sstevel@tonic-gate printf("\n\n"); 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate if (t->t_panic_trap != NULL) { 3290Sstevel@tonic-gate panic_showtrap(t->t_panic_trap); 3300Sstevel@tonic-gate printf("\n"); 3310Sstevel@tonic-gate } 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate traceregs(rp); 3340Sstevel@tonic-gate printf("\n"); 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate if (((boothowto & RB_DEBUG) || obpdebug) && 3370Sstevel@tonic-gate !nopanicdebug && !panic_forced) { 3380Sstevel@tonic-gate if (dumpvp != NULL) { 3390Sstevel@tonic-gate debug_enter("panic: entering debugger " 3400Sstevel@tonic-gate "(continue to save dump)"); 3410Sstevel@tonic-gate } else { 3420Sstevel@tonic-gate debug_enter("panic: entering debugger " 3430Sstevel@tonic-gate "(no dump device, continue to reboot)"); 3440Sstevel@tonic-gate } 3450Sstevel@tonic-gate } 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate } else if (panic_dump != 0 || panic_sync != 0 || panicstr != NULL) { 3480Sstevel@tonic-gate printf("\n\rpanic[cpu%d]/thread=%p: ", cp->cpu_id, (void *)t); 3490Sstevel@tonic-gate vprintf(format, alist); 3500Sstevel@tonic-gate printf("\n"); 3510Sstevel@tonic-gate } else 3520Sstevel@tonic-gate goto spin; 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate /* 3550Sstevel@tonic-gate * Prior to performing sync or dump, we make sure that do_polled_io is 3560Sstevel@tonic-gate * set, but we'll leave ipl at 10; deadman(), a CY_HIGH_LEVEL cyclic, 3570Sstevel@tonic-gate * will re-enter panic if we are not making progress with sync or dump. 3580Sstevel@tonic-gate */ 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate /* 3610Sstevel@tonic-gate * Sync the filesystems. Reset t_cred if not set because much of 3620Sstevel@tonic-gate * the filesystem code depends on CRED() being valid. 3630Sstevel@tonic-gate */ 3640Sstevel@tonic-gate if (!in_sync && panic_trigger(&panic_sync)) { 3650Sstevel@tonic-gate if (t->t_cred == NULL) 3660Sstevel@tonic-gate t->t_cred = kcred; 3670Sstevel@tonic-gate splx(ipltospl(CLOCK_LEVEL)); 3680Sstevel@tonic-gate do_polled_io = 1; 3690Sstevel@tonic-gate vfs_syncall(); 3700Sstevel@tonic-gate } 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate /* 3730Sstevel@tonic-gate * Take the crash dump. If the dump trigger is already set, try to 3740Sstevel@tonic-gate * enter the debugger again before rebooting the system. 3750Sstevel@tonic-gate */ 3760Sstevel@tonic-gate if (panic_trigger(&panic_dump)) { 3770Sstevel@tonic-gate panic_dump_hw(s); 3780Sstevel@tonic-gate splx(ipltospl(CLOCK_LEVEL)); 3795197Sstephh errorq_panic(); 3800Sstevel@tonic-gate do_polled_io = 1; 3810Sstevel@tonic-gate dumpsys(); 3820Sstevel@tonic-gate } else if (((boothowto & RB_DEBUG) || obpdebug) && !nopanicdebug) { 3830Sstevel@tonic-gate debug_enter("panic: entering debugger (continue to reboot)"); 3840Sstevel@tonic-gate } else 3850Sstevel@tonic-gate printf("dump aborted: please record the above information!\n"); 3860Sstevel@tonic-gate 3870Sstevel@tonic-gate if (halt_on_panic) 388136Sachartre mdboot(A_REBOOT, AD_HALT, NULL, B_FALSE); 3890Sstevel@tonic-gate else 390136Sachartre mdboot(A_REBOOT, panic_bootfcn, panic_bootstr, B_FALSE); 3910Sstevel@tonic-gate spin: 3920Sstevel@tonic-gate /* 3930Sstevel@tonic-gate * Restore ipl to at most CLOCK_LEVEL so we don't end up spinning 3940Sstevel@tonic-gate * and unable to jump into the debugger. 3950Sstevel@tonic-gate */ 3960Sstevel@tonic-gate splx(MIN(s, ipltospl(CLOCK_LEVEL))); 3975084Sjohnlev for (;;) 3985084Sjohnlev ; 3990Sstevel@tonic-gate } 4000Sstevel@tonic-gate 4010Sstevel@tonic-gate void 4020Sstevel@tonic-gate panic(const char *format, ...) 4030Sstevel@tonic-gate { 4040Sstevel@tonic-gate va_list alist; 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate va_start(alist, format); 4070Sstevel@tonic-gate vpanic(format, alist); 4080Sstevel@tonic-gate va_end(alist); 4090Sstevel@tonic-gate } 410