diff options
| author | Doug White <dwhite@FreeBSD.org> | 2005-04-30 20:01:00 +0000 |
|---|---|---|
| committer | Doug White <dwhite@FreeBSD.org> | 2005-04-30 20:01:00 +0000 |
| commit | fdc9713bf7ae15f0c9718cf3a37de6b7142cb23d (patch) | |
| tree | b1d1d16a2806520655c3bf213640cc3b5593de38 /sys/kern/subr_kdb.c | |
| parent | 6964622dd06c583e7242d0cc4d14cbfceb83bbb0 (diff) | |
Notes
Diffstat (limited to 'sys/kern/subr_kdb.c')
| -rw-r--r-- | sys/kern/subr_kdb.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 54274db67c42..5726a845f4d6 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -40,6 +40,18 @@ __FBSDID("$FreeBSD$"); #include <machine/kdb.h> #include <machine/pcb.h> +#ifdef KDB_STOP_NMI +#include <machine/smp.h> +#endif + +/* + * KDB_STOP_NMI requires SMP to pick up the right dependencies + * (And isn't useful on UP anyway) + */ +#if defined(KDB_STOP_NMI) && !defined(SMP) +#error "options KDB_STOP_NMI" requires "options SMP" +#endif + int kdb_active = 0; void *kdb_jmpbufp = NULL; struct kdb_dbbe *kdb_dbbe = NULL; @@ -77,6 +89,19 @@ static int kdb_stop_cpus = 1; SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus, CTLTYPE_INT | CTLFLAG_RW, &kdb_stop_cpus, 0, ""); TUNABLE_INT("debug.kdb.stop_cpus", &kdb_stop_cpus); + +#ifdef KDB_STOP_NMI +/* + * Provide an alternate method of stopping other CPUs. If another CPU has + * disabled interrupts the conventional STOP IPI will be blocked. This + * NMI-based stop should get through in that case. + */ +static int kdb_stop_cpus_with_nmi = 0; +SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus_with_nmi, CTLTYPE_INT | CTLFLAG_RW, + &kdb_stop_cpus_with_nmi, 0, ""); +TUNABLE_INT("debug.kdb.stop_cpus_with_nmi", &kdb_stop_cpus_with_nmi); +#endif /* KDB_STOP_NMI */ + #endif static int @@ -308,9 +333,27 @@ kdb_reenter(void) struct pcb * kdb_thr_ctx(struct thread *thr) +#ifdef KDB_STOP_NMI +{ + u_int cpuid; + struct pcpu *pc; + + if (thr == curthread) + return &kdb_pcb; + + SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + cpuid = pc->pc_cpuid; + if (pc->pc_curthread == thr && (atomic_load_acq_int(&stopped_cpus) & (1 << cpuid))) + return &stoppcbs[cpuid]; + } + + return thr->td_pcb; +} +#else { return ((thr == curthread) ? &kdb_pcb : thr->td_pcb); } +#endif /* KDB_STOP_NMI */ struct thread * kdb_thr_first(void) @@ -407,7 +450,14 @@ kdb_trap(int type, int code, struct trapframe *tf) #ifdef SMP if ((did_stop_cpus = kdb_stop_cpus) != 0) + { +#ifdef KDB_STOP_NMI + if(kdb_stop_cpus_with_nmi) + stop_cpus_nmi(PCPU_GET(other_cpus)); + else +#endif /* KDB_STOP_NMI */ stop_cpus(PCPU_GET(other_cpus)); + } #endif kdb_frame = tf; |
