This patch address a couple of long-standing issues revolving around kernel panics and use of rdb. Previously, rdb simply did not work on mp systems, as it assumed a splhi was sufficient to lock system resources. On an mp system, unless the uart ISR happened to be wired to the same CPU that has dropped into rdb, I/O will be stolen from the getc poll rdb relies on to communicate with the remote debugger. To fix this behavior, rdb must lock out other machs to avoid sharing resources. panic is similarly afflicted. A splhi is issued which is typically not enough, often resulting in corrupted dumpstack output from prints on other machs. Another interesting side-effect is that procs will continue to run on machs not participating in the panic. These changes made panic a first class citizen rather than a variant of shutdown. To handle both cases, panic (and each arch) have been updated to stall out other machs on the next clock interrupt. This is somewhat similiar to the exiting mechanism. The difference is that this allows the system to pre-emptively shutdown machs apart from exit, which happens too late. A nice side-effect of this change is that not only does this correct rdb behavior, but it also handles the corrupted dumpstack and racing procs issues nicely. A final change introduced a new plan9.ini conf variable, consdebug which enables ^T^Td at boot, which permits use of rdb early in the boot process. --- /n/sourcesdump/2012/0915/plan9/sys/src/9/kw/dat.h Wed Sep 28 04:10:11 2011 +++ /sys/src/9/kw/dat.h Sat Sep 15 00:00:00 2012 @@ -195,7 +195,7 @@ Lock; int machs; /* bitmap of active CPUs */ int exiting; /* shutdown */ - int ispanic; /* shutdown in response to a panic */ + int panicking; /* panic */ }active; enum { --- /n/sourcesdump/2012/0915/plan9/sys/src/9/kw/main.c Tue Jul 26 16:46:45 2011 +++ /sys/src/9/kw/main.c Sat Sep 15 00:00:00 2012 @@ -361,20 +361,17 @@ active.machs = 1; active.exiting = 0; + active.panicking = 0; up = nil; } static void -shutdown(int ispanic) +shutdown(void) { int ms, once; lock(&active); - if(ispanic) - active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) - active.ispanic = 0; once = active.machs & (1<machno); active.machs &= ~(1<machno); active.exiting = 1; @@ -382,11 +379,14 @@ if(once) iprint("cpu%d: exiting\n", m->machno); - spllo(); - for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ - delay(TK2MS(2)); - if(active.machs == 0 && consactive() == 0) - break; + + if(!active.panicking){ + spllo(); + for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ + delay(TK2MS(2)); + if(active.machs == 0 && consactive() == 0) + break; + } } delay(1000); } @@ -395,9 +395,9 @@ * exit kernel either on a panic or user request */ void -exit(int code) +exit(void) { - shutdown(code); + shutdown(); splhi(); archreboot(); } @@ -414,7 +414,7 @@ iprint("starting reboot..."); writeconf(); - shutdown(0); + shutdown(); /* * should be the only processor running now @@ -644,7 +644,7 @@ */ if(nelem(sheevamem) > nelem(conf.mem)){ iprint("memory configuration botch\n"); - exit(1); + exit(); } if((p = getconf("*maxmem")) != nil) { memsize = strtoul(p, 0, 0) - PHYSDRAM; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/mtx/dat.h Wed Sep 28 04:10:30 2011 +++ /sys/src/9/mtx/dat.h Sat Sep 15 00:00:00 2012 @@ -186,7 +186,7 @@ Lock; short machs; short exiting; - short ispanic; + short panicking; }active; /* --- /n/sourcesdump/2012/0915/plan9/sys/src/9/mtx/kbd.c Sat Apr 13 18:08:06 2002 +++ /sys/src/9/mtx/kbd.c Sat Sep 15 00:00:00 2012 @@ -322,7 +322,7 @@ if(!(c & (Spec|KF))){ if(ctl){ if(alt && c == Del) - exit(0); + exit(); c &= 0x1f; } if(!collecting){ --- /n/sourcesdump/2012/0915/plan9/sys/src/9/mtx/main.c Sun Nov 6 15:10:14 2005 +++ /sys/src/9/mtx/main.c Sat Sep 15 00:00:00 2012 @@ -62,6 +62,7 @@ active.machs = 1; active.exiting = 0; + active.panicking = 0; } void @@ -212,19 +213,15 @@ void reboot(void*, void*, ulong) { - exit(0); + exit(); } void -exit(int ispanic) +exit(void) { int ms, once; lock(&active); - if(ispanic) - active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) - active.ispanic = 0; once = active.machs & (1<machno); active.machs &= ~(1<machno); active.exiting = 1; @@ -232,21 +229,21 @@ if(once) print("cpu%d: exiting\n", m->machno); - spllo(); - for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ - delay(TK2MS(2)); - if(active.machs == 0 && consactive() == 0) - break; - } - if(active.ispanic && m->machno == 0){ + if(active.panicking){ if(cpuserver) delay(10000); else if(conf.monitor) for(;;); - } - else + }else{ + spllo(); + for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ + delay(TK2MS(2)); + if(active.machs == 0 && consactive() == 0) + break; + } delay(1000); + } watchreset(); } --- /n/sourcesdump/2012/0915/plan9/sys/src/9/omap/dat.h Wed Sep 28 04:11:18 2011 +++ /sys/src/9/omap/dat.h Sat Sep 15 00:00:00 2012 @@ -217,7 +217,7 @@ Lock; int machs; /* bitmap of active CPUs */ int exiting; /* shutdown */ - int ispanic; /* shutdown in response to a panic */ + int panicking; /* panic */ }active; extern register Mach* m; /* R10 */ --- /n/sourcesdump/2012/0915/plan9/sys/src/9/omap/devcons.c Thu Apr 19 19:05:34 2012 +++ /sys/src/9/omap/devcons.c Sat Sep 15 00:00:00 2012 @@ -17,8 +17,6 @@ ulong kprintinuse; /* test and set whether /dev/kprint is open */ int iprintscreenputs = 1; -int panicking; - static struct { QLock; @@ -281,18 +279,18 @@ void panic(char *fmt, ...) { - int n, s; + int n; va_list arg; char buf[PRINTSIZE]; kprintoq = nil; /* don't try to write to /dev/kprint */ - if(panicking) + splhi(); + if(active.panicking) for(;;); - panicking = 1; + active.panicking = 1; delay(20); - s = splhi(); strcpy(buf, "panic: "); va_start(arg, fmt); n = vseprint(buf+strlen(buf), buf+sizeof(buf), fmt, arg) - buf; @@ -300,13 +298,12 @@ iprint("%s\n", buf); if(consdebug) (*consdebug)(); - splx(s); prflush(); buf[n] = '\n'; // putstrn(buf, n+1); // dumpstack(); - exit(1); + exit(); } /* libmp at least contains a few calls to sysfatal; simulate with panic */ @@ -472,7 +469,7 @@ case 'D': if(consdebug == nil) consdebug = rdb; - consdebug(); + panic("consdebug"); return; case 'p': x = spllo(); @@ -486,7 +483,7 @@ killbig("^t ^t k"); return; case 'r': - exit(0); + exit(); return; } } @@ -668,6 +665,10 @@ static void consinit(void) { + char *s; + + if((s = getconf("consdebug")) != nil && strcmp(s, "0") != 0) + consdebug = rdb; todinit(); randominit(); /* --- /n/sourcesdump/2012/0915/plan9/sys/src/9/omap/kbd.c Thu Apr 26 02:56:30 2012 +++ /sys/src/9/omap/kbd.c Sat Sep 15 00:00:00 2012 @@ -268,7 +268,7 @@ if(!(c & (Spec|KF))){ if(kbscan->ctl) if(kbscan->alt && c == Del) - exit(0); + exit(); if(!kbscan->collecting){ kbdputc(kbdq, c); return; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/omap/main.c Mon Jan 17 23:58:06 2011 +++ /sys/src/9/omap/main.c Sat Sep 15 00:00:00 2012 @@ -297,20 +297,17 @@ active.machs = 1; active.exiting = 0; + active.panicking = 0; up = nil; } static void -shutdown(int ispanic) +shutdown(void) { int ms, once; lock(&active); - if(ispanic) - active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) - active.ispanic = 0; once = active.machs & (1<machno); active.machs &= ~(1<machno); active.exiting = 1; @@ -318,11 +315,14 @@ if(once) iprint("cpu%d: exiting\n", m->machno); - spllo(); - for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ - delay(TK2MS(2)); - if(active.machs == 0 && consactive() == 0) - break; + + if(!active.panicking){ + spllo(); + for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ + delay(TK2MS(2)); + if(active.machs == 0 && consactive() == 0) + break; + } } delay(1000); } @@ -331,9 +331,9 @@ * exit kernel either on a panic or user request */ void -exit(int code) +exit(void) { - shutdown(code); + shutdown(); splhi(); archreboot(); } @@ -382,7 +382,7 @@ print("starting reboot..."); writeconf(); - shutdown(0); + shutdown(); /* * should be the only processor running now @@ -613,7 +613,7 @@ */ if(nelem(omapmem) > nelem(conf.mem)){ iprint("memory configuration botch\n"); - exit(1); + exit(); } if((p = getconf("*maxmem")) != nil) { memsize = strtoul(p, 0, 0) - PHYSDRAM; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/pc/dat.h Wed Aug 15 19:06:06 2012 +++ /sys/src/9/pc/dat.h Sat Sep 15 00:00:00 2012 @@ -277,7 +277,7 @@ Lock; int machs; /* bitmap of active CPUs */ int exiting; /* shutdown */ - int ispanic; /* shutdown in response to a panic */ + int panicking; /* panic */ int thunderbirdsarego; /* lets the added processors continue to schedinit */ int rebooting; /* just idle cpus > 0 */ }active; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/pc/kbd.c Thu Mar 29 22:50:12 2012 +++ /sys/src/9/pc/kbd.c Sat Sep 15 00:00:00 2012 @@ -469,7 +469,7 @@ if(!(c & (Spec|KF))){ if(kbscan->ctl) if(kbscan->alt && c == Del) - exit(0); + exit(); if(!kbscan->collecting){ kbdputc(kbdq, c); return; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/pc/main.c Wed Aug 15 18:33:47 2012 +++ /sys/src/9/pc/main.c Sat Sep 15 00:00:00 2012 @@ -144,6 +144,7 @@ active.machs = 1; active.exiting = 0; + active.panicking = 0; } void @@ -712,22 +713,18 @@ } static void -shutdown(int ispanic) +shutdown(void) { int ms, once; lock(&active); - if(ispanic) - active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) - active.ispanic = 0; once = active.machs & (1<machno); /* - * setting exiting will make hzclock() on each processor call exit(0), - * which calls shutdown(0) and arch->reset(), which on mp systems is + * setting exiting will make hzclock() on each processor call exit(), + * which calls shutdown() and arch->reset(), which on mp systems is * mpshutdown, which idles non-bootstrap cpus and returns on bootstrap * processors (to permit a reboot). clearing our bit in machs avoids - * calling exit(0) from hzclock() on this processor. + * calling exit() from hzclock() on this processor. */ active.machs &= ~(1<machno); active.exiting = 1; @@ -736,15 +733,7 @@ if(once) iprint("cpu%d: exiting\n", m->machno); - /* wait for any other processors to shutdown */ - spllo(); - for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ - delay(TK2MS(2)); - if(active.machs == 0 && consactive() == 0) - break; - } - - if(active.ispanic){ + if(active.panicking){ if(!cpuserver) for(;;) halt(); @@ -752,8 +741,16 @@ delay(5*60*1000); else delay(10000); - }else + }else{ + /* wait for any other processors to shutdown */ + spllo(); + for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ + delay(TK2MS(2)); + if(active.machs == 0 && consactive() == 0) + break; + } delay(1000); + } } void @@ -784,7 +781,7 @@ lock(&active); active.rebooting = 1; unlock(&active); - shutdown(0); + shutdown(); if(arch->resetothers) arch->resetothers(); delay(20); @@ -830,9 +827,9 @@ void -exit(int ispanic) +exit(void) { - shutdown(ispanic); + shutdown(); arch->reset(); } --- /n/sourcesdump/2012/0915/plan9/sys/src/9/pcboot/dat.h Fri Aug 17 20:11:39 2012 +++ /sys/src/9/pcboot/dat.h Sat Sep 15 00:00:00 2012 @@ -279,7 +279,7 @@ Lock; int machs; /* bitmap of active CPUs */ int exiting; /* shutdown */ - int ispanic; /* shutdown in response to a panic */ + int panicking; /* panic */ int thunderbirdsarego; /* lets the added processors continue to schedinit */ int rebooting; /* just idle cpus > 0 */ }active; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/pcboot/main.c Thu May 31 18:22:47 2012 +++ /sys/src/9/pcboot/main.c Sat Sep 15 00:00:00 2012 @@ -227,6 +227,7 @@ active.machs = 1; active.exiting = 0; + active.panicking = 0; } void @@ -498,22 +499,18 @@ } static void -shutdown(int ispanic) +shutdown(void) { int ms, once; lock(&active); - if(ispanic) - active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) - active.ispanic = 0; once = active.machs & (1<machno); /* - * setting exiting will make hzclock() on each processor call exit(0), - * which calls shutdown(0) and arch->reset(), which on mp systems is + * setting exiting will make hzclock() on each processor call exit(), + * which calls shutdown() and arch->reset(), which on mp systems is * mpshutdown, which idles non-bootstrap cpus and returns on bootstrap * processors (to permit a reboot). clearing our bit in machs avoids - * calling exit(0) from hzclock() on this processor. + * calling exit() from hzclock() on this processor. */ active.machs &= ~(1<machno); active.exiting = 1; @@ -522,15 +519,7 @@ if(once) iprint("cpu%d: exiting\n", m->machno); - /* wait for any other processors to shutdown */ - spllo(); - for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ - delay(TK2MS(2)); - if(active.machs == 0 && consactive() == 0) - break; - } - - if(active.ispanic){ + if(active.panicking){ if(!cpuserver) for(;;) halt(); @@ -538,8 +527,16 @@ delay(5*60*1000); else delay(10000); - }else + }else{ + /* wait for any other processors to shutdown */ + spllo(); + for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ + delay(TK2MS(2)); + if(active.machs == 0 && consactive() == 0) + break; + } delay(1000); + } } void @@ -572,7 +569,7 @@ lock(&active); active.rebooting = 1; unlock(&active); - shutdown(0); + shutdown(); if(arch->resetothers) arch->resetothers(); delay(20); @@ -619,10 +616,9 @@ void -exit(int ispanic) +exit(void) { - shutdown(ispanic); - spllo(); + shutdown(); arch->reset(); } --- /n/sourcesdump/2012/0915/plan9/sys/src/9/pcboot/warp64.c Thu May 24 17:48:46 2012 +++ /sys/src/9/pcboot/warp64.c Sat Sep 15 00:00:00 2012 @@ -49,7 +49,7 @@ if(!havelongmode()) { print("can't run 64-bit kernel on 32-bit cpu\n"); delay(5000); - exit(0); + exit(); } if(v_flag) print("mkmultiboot\n"); --- /n/sourcesdump/2012/0915/plan9/sys/src/9/port/allocb.c Mon Oct 19 04:35:54 2009 +++ /sys/src/9/port/allocb.c Sat Sep 15 00:00:00 2012 @@ -84,7 +84,7 @@ if((m1++%10000)==0){ if(mp++ > 1000){ active.exiting = 1; - exit(0); + exit(); } iprint("iallocb: limited %lud/%lud\n", ialloc.bytes, conf.ialloc); @@ -96,7 +96,7 @@ if((m2++%10000)==0){ if(mp++ > 1000){ active.exiting = 1; - exit(0); + exit(); } iprint("iallocb: no memory %lud/%lud\n", ialloc.bytes, conf.ialloc); --- /n/sourcesdump/2012/0915/plan9/sys/src/9/port/devcons.c Mon Aug 8 20:47:55 2011 +++ /sys/src/9/port/devcons.c Sat Sep 15 00:00:00 2012 @@ -18,8 +18,6 @@ ulong kprintinuse; /* test and set whether /dev/kprint is open */ int iprintscreenputs = 1; -int panicking; - static struct { QLock; @@ -272,17 +270,17 @@ void panic(char *fmt, ...) { - int n, s; + int n; va_list arg; char buf[PRINTSIZE]; kprintoq = nil; /* don't try to write to /dev/kprint */ - if(panicking) + splhi(); + if(active.panicking) for(;;); - panicking = 1; + active.panicking = 1; - s = splhi(); strcpy(buf, "panic: "); va_start(arg, fmt); n = vseprint(buf+strlen(buf), buf+sizeof(buf), fmt, arg) - buf; @@ -290,13 +288,12 @@ iprint("%s\n", buf); if(consdebug) (*consdebug)(); - splx(s); prflush(); buf[n] = '\n'; putstrn(buf, n+1); dumpstack(); - exit(1); + exit(); } /* libmp at least contains a few calls to sysfatal; simulate with panic */ @@ -462,7 +459,7 @@ case 'D': if(consdebug == nil) consdebug = rdb; - consdebug(); + panic("consdebug"); return; case 'p': x = spllo(); @@ -476,7 +473,7 @@ killbig("^t ^t k"); return; case 'r': - exit(0); + exit(); return; } } @@ -660,6 +657,10 @@ static void consinit(void) { + char *s; + + if((s = getconf("consdebug")) != nil && strcmp(s, "0") != 0) + consdebug = rdb; todinit(); randominit(); /* --- /n/sourcesdump/2012/0915/plan9/sys/src/9/port/edf.c Sun Aug 10 04:18:34 2008 +++ /sys/src/9/port/edf.c Sat Sep 15 00:00:00 2012 @@ -134,11 +134,10 @@ deadlineintr(Ureg*, Timer *t) { /* Proc reached deadline */ - extern int panicking; Proc *p; void (*pt)(Proc*, int, vlong); - if(panicking || active.exiting) + if(active.exiting || active.panicking) return; p = t->ta; @@ -210,10 +209,9 @@ releaseintr(Ureg*, Timer *t) { Proc *p; - extern int panicking; Schedq *rq; - if(panicking || active.exiting) + if(active.exiting || active.panicking) return; p = t->ta; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/port/portclock.c Sat Apr 28 03:46:42 2012 +++ /sys/src/9/port/portclock.c Sat Sep 15 00:00:00 2012 @@ -156,8 +156,10 @@ if(active.exiting) { print("someone's exiting\n"); - exit(0); + exit(); } + if(active.panicking) + for(;;); checkalarms(); --- /n/sourcesdump/2012/0915/plan9/sys/src/9/port/portfns.h Wed Jun 16 19:27:30 2010 +++ /sys/src/9/port/portfns.h Sat Sep 15 00:00:00 2012 @@ -100,7 +100,7 @@ void error(char*); long execregs(ulong, ulong, ulong); void exhausted(char*); -void exit(int); +void exit(void); uvlong fastticks(uvlong*); uvlong fastticks2ns(uvlong); uvlong fastticks2us(uvlong); --- /n/sourcesdump/2012/0915/plan9/sys/src/9/port/rebootcmd.c Mon Mar 4 21:45:40 2002 +++ /sys/src/9/port/rebootcmd.c Sat Sep 15 00:00:00 2012 @@ -59,7 +59,7 @@ uchar *p; if(argc == 0) - exit(0); + exit(); c = namec(argv[0], Aopen, OEXEC, 0); if(waserror()){ --- /n/sourcesdump/2012/0915/plan9/sys/src/9/port/ucallocb.c Sat Feb 4 20:46:48 2012 +++ /sys/src/9/port/ucallocb.c Sat Sep 15 00:00:00 2012 @@ -84,7 +84,7 @@ if((m1++%10000)==0){ if(mp++ > 1000){ active.exiting = 1; - exit(0); + exit(); } iprint("uciallocb: limited %lud/%lud\n", ucialloc.bytes, conf.ialloc); @@ -96,7 +96,7 @@ if(0 && (m2++%10000)==0){ if(mp++ > 1000){ active.exiting = 1; - exit(0); + exit(); } iprint("uciallocb: no memory %lud/%lud\n", ucialloc.bytes, conf.ialloc); --- /n/sourcesdump/2012/0915/plan9/sys/src/9/ppc/dat.h Wed Sep 21 03:41:40 2005 +++ /sys/src/9/ppc/dat.h Sat Sep 15 00:00:00 2012 @@ -191,7 +191,7 @@ Lock; short machs; short exiting; - short ispanic; + short panicking; }active; /* --- /n/sourcesdump/2012/0915/plan9/sys/src/9/ppc/main.c Sun Nov 6 15:15:17 2005 +++ /sys/src/9/ppc/main.c Sat Sep 15 00:00:00 2012 @@ -243,15 +243,11 @@ } void -exit(int ispanic) +exit(void) { int ms, once; lock(&active); - if(ispanic) - active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) - active.ispanic = 0; once = active.machs & (1<machno); active.machs &= ~(1<machno); active.exiting = 1; @@ -259,22 +255,21 @@ if(once) print("cpu%d: exiting\n", m->machno); - spllo(); - for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ - delay(TK2MS(2)); - if(active.machs == 0 && consactive() == 0) - break; - } - if(active.ispanic && m->machno == 0){ + if(active.panicking){ if(cpuserver) delay(10000); else if(conf.monitor) for(;;); - } - else + }else{ + spllo(); + for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){ + delay(TK2MS(2)); + if(active.machs == 0 && consactive() == 0) + break; + } delay(1000); - + } } /* --- /n/sourcesdump/2012/0915/plan9/sys/src/9/ppc/msaturn.c Mon Dec 29 13:44:42 2003 +++ /sys/src/9/ppc/msaturn.c Sat Sep 15 00:00:00 2012 @@ -142,6 +142,7 @@ active.machs = 1; active.exiting = 0; + active.panicking = 0; putmsr(getmsr() | MSR_ME); --- /n/sourcesdump/2012/0915/plan9/sys/src/9/teg2/dat.h Thu Jul 5 20:40:02 2012 +++ /sys/src/9/teg2/dat.h Sat Sep 15 00:00:00 2012 @@ -249,7 +249,7 @@ int wfi; /* bitmap of CPUs in WFI state */ int stopped; /* bitmap of CPUs stopped */ int exiting; /* shutdown */ - int ispanic; /* shutdown in response to a panic */ + int panicking; /* panic */ int thunderbirdsarego; /* lets the added processors continue to schedinit */ }active; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/teg2/devcons.c Sat Feb 25 06:22:19 2012 +++ /sys/src/9/teg2/devcons.c Sat Sep 15 00:00:00 2012 @@ -18,8 +18,6 @@ ulong kprintinuse; /* test and set whether /dev/kprint is open */ int iprintscreenputs = 1; -int panicking; - static struct { QLock; @@ -282,17 +280,17 @@ void panic(char *fmt, ...) { - int n, s; + int n; va_list arg; char buf[PRINTSIZE]; kprintoq = nil; /* don't try to write to /dev/kprint */ - if(panicking) + splhi(); + if(active.panicking) for(;;); - panicking = 1; + active.panicking = 1; - s = splhi(); delay(2000); strcpy(buf, "\npanic: "); va_start(arg, fmt); @@ -301,7 +299,6 @@ iprint("%s\n", buf); if(consdebug) (*consdebug)(); - splx(s); prflush(); USED(n); // buf[n] = '\n'; @@ -309,7 +306,7 @@ // dumpstack(); delay(2000); - exit(1); + exit(); } /* libmp at least contains a few calls to sysfatal; simulate with panic */ @@ -475,7 +472,7 @@ case 'D': if(consdebug == nil) consdebug = rdb; - consdebug(); + panic("consdebug"); return; case 'p': x = spllo(); @@ -489,7 +486,7 @@ killbig("^t ^t k"); return; case 'r': - exit(0); + exit(); return; } } @@ -673,6 +670,10 @@ static void consinit(void) { + char *s; + + if((s = getconf("consdebug")) != nil && strcmp(s, "0") != 0) + consdebug = rdb; todinit(); randominit(); /* --- /n/sourcesdump/2012/0915/plan9/sys/src/9/teg2/kbd.c Sun Mar 11 23:12:08 2012 +++ /sys/src/9/teg2/kbd.c Sat Sep 15 00:00:00 2012 @@ -268,7 +268,7 @@ if(!(c & (Spec|KF))){ if(kbscan->ctl) if(kbscan->alt && c == Del) - exit(0); + exit(); if(!kbscan->collecting){ kbdputc(kbdq, c); return; --- /n/sourcesdump/2012/0915/plan9/sys/src/9/teg2/main.c Tue May 1 20:57:57 2012 +++ /sys/src/9/teg2/main.c Sat Sep 15 00:00:00 2012 @@ -291,6 +291,7 @@ machinit(); active.exiting = 0; + active.panicking = 0; l1cache->wbse(&active, sizeof active); up = nil; } @@ -482,21 +483,17 @@ } static void -shutdown(int ispanic) +shutdown(void) { int ms, once; lock(&active); - if(ispanic) - active.ispanic = ispanic; - else if(m->machno == 0 && (active.machs & (1<machno)) == 0) - active.ispanic = 0; once = active.machs & (1<machno); /* - * setting exiting will make hzclock() on each processor call exit(0), - * which calls shutdown(0) and idles non-bootstrap cpus and returns + * setting exiting will make hzclock() on each processor call exit(), + * which calls shutdown() and idles non-bootstrap cpus and returns * on bootstrap processors (to permit a reboot). clearing our bit - * in machs avoids calling exit(0) from hzclock() on this processor. + * in machs avoids calling exit() from hzclock() on this processor. */ active.machs &= ~(1<machno); active.exiting = 1; @@ -506,15 +503,18 @@ delay(m->machno*1000); /* stagger them */ iprint("cpu%d: exiting\n", m->machno); } - spllo(); - if (m->machno == 0) - ms = 5*1000; - else - ms = 2*1000; - for(; ms > 0; ms -= TK2MS(2)){ - delay(TK2MS(2)); - if(active.machs == 0 && consactive() == 0) - break; + + if(!active.panicking){ + spllo(); + if (m->machno == 0) + ms = 5*1000; + else + ms = 2*1000; + for(; ms > 0; ms -= TK2MS(2)){ + delay(TK2MS(2)); + if(active.machs == 0 && consactive() == 0) + break; + } } delay(500); } @@ -523,9 +523,9 @@ * exit kernel either on a panic or user request */ void -exit(int code) +exit(void) { - shutdown(code); + shutdown(); splhi(); if (m->machno == 0) archreboot(); @@ -602,7 +602,7 @@ for (want = 0, cpu = 1; cpu < navailcpus; cpu++) want |= 1 << cpu; active.stopped = 0; - shutdown(0); + shutdown(); for (ms = 15*1000; ms > 0 && active.stopped != want; ms -= 10) delay(10); delay(20); @@ -842,7 +842,7 @@ */ if(nelem(tsmem) > nelem(conf.mem)){ iprint("memory configuration botch\n"); - exit(1); + exit(); } if(0 && (p = getconf("*maxmem")) != nil) { memsize = strtoul(p, 0, 0) - PHYSDRAM;