Re: db> reset -> panic: acquiring blockable sleep lock with spinlock or critical section held ...

From: Mark Johnston <markj_at_freebsd.org>
Date: Mon, 20 Nov 2023 15:47:04 UTC
On Thu, Nov 16, 2023 at 10:21:38PM +0000, Bjoern A. Zeeb wrote:
> Hi,
> 
> I seem to remember changes related to that a while ago but my cache
> is miss for the actual change.  Are we suppoed to handle this case?
> 
> It would be nice if "reset" would reset again the first time ...

We should perhaps make SCHEDULER_STOPPED() true when resetting from the
debugger, since we can't make any assumptions about the state of the
system (since we don't know how we got into DDB in the first place).
Then the reset path here would behave as it does after a panic.

> KDB: enter: Break to debugger
> [ thread pid 11 tid 100005 ]
> Stopped at      kdb_alt_break_internal+0x180:   str     xzr, [x19, #896]
> db> reset
> panic: acquiring blockable sleep lock with spinlock or critical section held (sleep mutex) eventhandler @ /usr/src/sys/kern/subr_eventhandler.c:269
> cpuid = 2
> time = 307
> KDB: stack backtrace:
> db_trace_self() at db_trace_self
> db_trace_self_wrapper() at db_trace_self_wrapper+0x38
> vpanic() at vpanic+0x1a0
> panic() at panic+0x48
> witness_checkorder() at witness_checkorder+0xb4c
> __mtx_lock_flags() at __mtx_lock_flags+0xac
> eventhandler_find_list() at eventhandler_find_list+0x44
> kern_reboot() at kern_reboot+0x284
> db_reset() at db_reset+0xd8
> db_command() at db_command+0x2e4
> db_command_loop() at db_command_loop+0x58
> db_trap() at db_trap+0x100
> kdb_trap() at kdb_trap+0x364
> handle_el1h_sync() at handle_el1h_sync+0x18
> --- exception, esr 0xf2000000
> kdb_alt_break_internal() at kdb_alt_break_internal+0x180
> kdb_alt_break() at kdb_alt_break+0x10
> uart_intr_rxready() at uart_intr_rxready+0x8c
> uart_intr() at uart_intr+0x120
> intr_event_handle() at intr_event_handle+0xf4
> intr_isrc_dispatch() at intr_isrc_dispatch+0x78
> arm_gic_v3_intr() at arm_gic_v3_intr+0x120
> intr_irq_handler() at intr_irq_handler+0x88
> handle_el1h_irq() at handle_el1h_irq+0x14
> --- interrupt
> cpu_idle() at cpu_idle+0x78
> sched_idletd() at sched_idletd+0x4a0
> fork_exit() at fork_exit+0x78
> fork_trampoline() at fork_trampoline+0x18
> KDB: enter: panic
> [ thread pid 11 tid 100005 ]
> Stopped at      kdb_enter+0x48: str     xzr, [x19, #896]
> db> reset
> Uptime: 5m7s
> INFO:    PSCI Power Domain Map:
> 
> 
> -- 
> Bjoern A. Zeeb                                                     r15:7
>