WITNESS is fun. However it can lead you to DDB while trying to grab
the KERNEL_LOCK(). In such case 'bo reboot' won't work because you'll
certainly hit a KERNEL_ASSERT_LOCKED().
Here's an example:
ddb{0}> c
syncing disks... done
panic: kernel diagnostic assertion "_kernel_lock_held()" failed: file
"/sys/net/rtsock.c", line 371
Stopped at db_enter+0x5: popq %rbp
db_enter() at db_enter+0x5
panic() at panic+0x140
__assert(ffffffff817c7604,ffff800003715c58,0,ffffff00063d1800) at
__assert+0x24
route_input(ffff800003715d58,ffff800003715cd0,ffffffff81c16588) at
route_input+0x29c
if_down(ffff800000056000) at if_down+0x90
if_downall() at if_downall+0x51
boot(100) at boot+0x76
reboot(ffffffff81a8faa5) at reboot+0x4b
panic() at panic+0x148
witness_checkorder(ffffffff8196abd9,212,a,0,ffffffff81c16380) at
witness_checkorder+0xb18
___mp_lock(ffffffff81aac1b0,ffff800003715ec8,c) at ___mp_lock+0x5f
intr_handler(ffffffff818c2978,ffff80000002be80) at intr_handler+0x41
Xintr_legacy0() at Xintr_legacy0+0xe0
--- interrupt ---
So here's a diff to close our eyes and try harder. It works for
me(tm).
ok?
Index: kern/kern_lock.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_lock.c,v
retrieving revision 1.49
diff -u -p -r1.49 kern_lock.c
--- kern/kern_lock.c 20 Apr 2017 15:06:47 -0000 1.49
+++ kern/kern_lock.c 3 Oct 2017 14:35:03 -0000
@@ -85,6 +85,8 @@ _kernel_unlock(void)
int
_kernel_lock_held(void)
{
+ if (panicstr)
+ return 1;
return (__mp_lock_held(&kernel_lock));
}