git: 627ca221c311 - main - kern_reboot: unconditionally call shutdown_reset()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Jan 2023 19:11:25 UTC
The branch main has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=627ca221c311b5d9c4132e03664a96f390ff5c0d
commit 627ca221c311b5d9c4132e03664a96f390ff5c0d
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-01-23 18:47:11 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-01-23 19:10:24 +0000
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
---
sys/kern/kern_shutdown.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index ab37b54667f9..6f912369268a 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -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 */
}