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