kern_reboot: unconditionally call shutdown_reset()

Currently shutdown_reset() is registered as the final entry of the
shutdown_final event handler. However, if a panic occurs early in boot
before the event is registered (SI_SUB_INTRINSIC), we may end up
spinning in the subsequent infinite for loop and failing to reset
altogether. Instead we can simply call this function unconditionally.

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D37981
This commit is contained in:
Mitchell Horne 2023-01-23 14:47:11 -04:00
parent dec7db4960
commit 627ca221c3

View File

@ -270,8 +270,6 @@ shutdown_conf(void *unused)
SHUTDOWN_PRI_LAST + 100);
EVENTHANDLER_REGISTER(shutdown_final, shutdown_panic, NULL,
SHUTDOWN_PRI_LAST + 100);
EVENTHANDLER_REGISTER(shutdown_final, shutdown_reset, NULL,
SHUTDOWN_PRI_LAST + 200);
}
SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL);
@ -548,6 +546,12 @@ kern_reboot(int howto)
EVENTHANDLER_INVOKE(shutdown_final, howto);
/*
* Call this directly so that reset is attempted even if shutdown
* handlers are not yet registered.
*/
shutdown_reset(NULL, howto);
for(;;) ; /* safety against shutdown_reset not working */
/* NOTREACHED */
}