Change all uses of 'debugger' to kdb_active and remove this variable. This

restores avoidance of doing dangerous things like calling wakeup() and
callouts while in ddb.

Initialization of 'debugger' was broken by removing the cndbctl() console
method that was used mainly in this driver to initialize 'debugger' and
switch to the console screen on entry to ddb.  The screen switch was
restored using the cngrab() method, but cngrab() is more general so it
should not initialize 'debugger' and never did.  'debugger' was just
an over-engineered alias for kdb_active anyway.  It existed because
kdb_active (when it was named ddb_active) was considered as a private
kdb variable, and there are ordering problems initializing the variables
atomically with the state that they represent, but an extra variable and
method to set it increased these problems.

The bug caused LORs, but WITNESS is normally misconfigured with
WITNESS_SKIPSIN so it doesn't check the spinlocks used by wakeup() and
callouts.
This commit is contained in:
Bruce Evans 2016-08-15 14:28:16 +00:00
parent e85c2b0b12
commit abf3a584b6

View File

@ -172,8 +172,6 @@ SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key,
#define VTY_WCHAN(sc, vty) (&SC_DEV(sc, vty))
static int debugger;
/* prototypes */
static int sc_allocate_keyboard(sc_softc_t *sc, int unit);
static int scvidprobe(int unit, int flags, int cons);
@ -1815,7 +1813,7 @@ sccnupdate(scr_stat *scp)
if (suspend_in_progress || scp->sc->font_loading_in_progress)
return;
if (debugger > 0 || panicstr || shutdown_in_progress) {
if (kdb_active || panicstr || shutdown_in_progress) {
sc_touch_scrn_saver();
} else if (scp != scp->sc->cur_scp) {
return;
@ -1884,7 +1882,7 @@ scrn_timer(void *arg)
#endif /* PC98 */
/* should we stop the screen saver? */
if (debugger > 0 || panicstr || shutdown_in_progress)
if (kdb_active || panicstr || shutdown_in_progress)
sc_touch_scrn_saver();
if (run_scrn_saver) {
if (time_uptime > sc->scrn_time_stamp + scrn_blank_time)
@ -2279,7 +2277,7 @@ stop_scrn_saver(sc_softc_t *sc, void (*saver)(sc_softc_t *, int))
mark_all(sc->cur_scp);
if (sc->delayed_next_scr)
sc_switch_scr(sc, sc->delayed_next_scr - 1);
if (debugger == 0)
if (!kdb_active)
wakeup(&scrn_blanked);
}
@ -2474,7 +2472,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
DPRINTF(5, ("error 2, requested vty isn't open!\n"));
return EINVAL;
}
if ((debugger > 0) && (SC_STAT(tp)->smode.mode == VT_PROCESS)) {
if (kdb_active && SC_STAT(tp)->smode.mode == VT_PROCESS) {
splx(s);
DPRINTF(5, ("error 3, requested vty is in the VT_PROCESS mode\n"));
return EINVAL;
@ -2495,7 +2493,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
* is supposed to be locked by splhigh(), but the debugger may
* be invoked at splhigh().
*/
if (debugger == 0)
if (!kdb_active)
wakeup(VTY_WCHAN(sc,next_scr));
splx(s);
DPRINTF(5, ("switch done (new == old)\n"));
@ -2518,7 +2516,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
s = spltty();
/* wake up processes waiting for this vty */
if (debugger == 0)
if (!kdb_active)
wakeup(VTY_WCHAN(sc,next_scr));
/* wait for the controlling process to acknowledge, if necessary */