git: 2f12145a37be - stable/13 - kern_reboot: unconditionally call shutdown_reset()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Feb 2023 19:36:57 UTC
The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=2f12145a37befc2bae3db859699d394611e96e2d commit 2f12145a37befc2bae3db859699d394611e96e2d Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2023-01-23 18:47:11 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2023-02-06 19:34:36 +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 (cherry picked from commit 627ca221c311b5d9c4132e03664a96f390ff5c0d) --- 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 aaa5c5a0243f..ee6faa222206 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -265,8 +265,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); @@ -499,6 +497,12 @@ kern_reboot(int howto) /* Now that we're going to really halt the system... */ 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 */ }