Created
April 12, 2023 19:40
-
-
Save dumbbell/88d77789bfeb38869268c84c40575f49 to your computer and use it in GitHub Desktop.
Handle recursive panic inside vt(4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c | |
index 267dd7bf2489..1a7a752d9a07 100644 | |
--- a/sys/dev/vt/vt_core.c | |
+++ b/sys/dev/vt/vt_core.c | |
@@ -276,6 +276,8 @@ SYSINIT(vt_update_static, SI_SUB_KMEM, SI_ORDER_ANY, vt_update_static, | |
SYSINIT(vt_early_cons, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_ANY, vt_upgrade, | |
&vt_consdev); | |
+static bool inside_vtterm_done_in_panic = false; | |
+ | |
/* Initialize locks/mem depended members. */ | |
static void | |
vt_update_static(void *dummy) | |
@@ -1464,7 +1466,13 @@ vtterm_done(struct terminal *tm) | |
struct vt_window *vw = tm->tm_softc; | |
struct vt_device *vd = vw->vw_device; | |
+ if (inside_vtterm_done_in_panic) { | |
+ return; | |
+ } | |
+ | |
if (kdb_active || KERNEL_PANICKED()) { | |
+ inside_vtterm_done_in_panic = true; | |
+ | |
/* Switch to the debugger. */ | |
if (vd->vd_curwindow != vw) { | |
vd->vd_curwindow = vw; | |
@@ -1473,7 +1481,12 @@ vtterm_done(struct terminal *tm) | |
vd->vd_driver->vd_postswitch(vd); | |
} | |
vd->vd_flags &= ~VDF_SPLASH; | |
+ | |
+ panic("vt"); | |
+ | |
vt_flush(vd); | |
+ | |
+ inside_vtterm_done_in_panic = false; | |
} else if (!(vd->vd_flags & VDF_ASYNC)) { | |
vt_flush(vd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment