From nobody Sat Feb 17 21:32:29 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Tchpk3rHBz59lBV; Sat, 17 Feb 2024 21:32:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tchpk0jBnz4gbJ; Sat, 17 Feb 2024 21:32:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=j017KCGGDo4vwnu8dq7CQyvDGK5glM6tvoASvTqTUkI=; b=pc+MzzRh9LIs6gV3bRQnebMqYb0Kr76jLfmZg2abqJcE05QfMKtU5svrv+LrEg6lUExj1i sX1wU2N9TrER+Fvr61Z5+cEF64CbHP3av8LCtYIkbHO511JQykvnjkQoJk7UaeLc6QcC2y QLWiLZNqrhp4XyG/1dRemrFBDVzHGRNrEyVOJO7ZPYqVch+U4234yY1obdH4yKlu+vU3NF 3e68XpT85nm5JGqXcouPsH/jQI3wta1XWTb7k6qR3YRq/y2aWQEmuxUubNH0Ue07TzbRpf +8AUaQWvEnruEY44Q69YmQQFxZYhMdbiQD9/lw1U1aIXvtp7/JXIv1soSs6avQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=j017KCGGDo4vwnu8dq7CQyvDGK5glM6tvoASvTqTUkI=; b=b9yfxqSgdMK6wjZrJ9QtlXOeqRlZkdxaoboMiBOKTwRQkUYQvFWBluX0BQz80JMKCZ2N0j PhZMijIx3CxjqcaGYSiNIKGHBYjnCww5cpUETaw0Ie7IBAcnlvS540qyPzoDru+Ka8iD/z dL9R44bquZ7WIMkcEL2LGe2miDse+SQguPQf7AtNU4O6Ml9e3WUY/skaY+moifkSR3hoH9 xK7deDOMz+kq0KlX3P7vw/a+ApRo2STuT5FJdq75ti+Ya3xkX81hfqk515PiS0UVAxbzbQ udJltS47ww3ANzq8buwbfW7Zu/9bjbG/9lxen7/+SF5h4GQ5Ur/1MLe7wbfkyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708205550; a=rsa-sha256; cv=none; b=inLHQJQ5BS3S+Ks1Sby5t3QhmgONGc4MzNMoGgEk5ZOD/iZTdMAT4jwaWhg78eyHXltCdj sy9WSORahyxDRIPc+9ziDdDTJHfL5kz3CqggHdJoykcrIhbvBkb20Q9PVqax6C6R7gvWfg Q5T7voSQAF5xYC8xbNI12Jv0KSGaZxvs+LCjiyRg9nGZ6U6Lleqn46alCrPkzuE3XtWtnA jxMtDnk976zSUku5fa4gK939v3fGIrJWXzVzsszQaT4Q6haAOKKv3F7O6gRGfUK05jlzNr /o40Slc/2Rc2tGkOCUKS7nFqUJ3586LV8L6QBXXQVXvHUUIPHHXOXr0kSWaz+g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Tchpj6sVTzPb9; Sat, 17 Feb 2024 21:32:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41HLWTZp019533; Sat, 17 Feb 2024 21:32:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41HLWTNY019530; Sat, 17 Feb 2024 21:32:29 GMT (envelope-from git) Date: Sat, 17 Feb 2024 21:32:29 GMT Message-Id: <202402172132.41HLWTNY019530@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 95007bfd64c6 - stable/14 - vt(4): Skip vt_window_switch() for nested panics List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 95007bfd64c63f217c97210cd4cdf2d729f2f696 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=95007bfd64c63f217c97210cd4cdf2d729f2f696 commit 95007bfd64c63f217c97210cd4cdf2d729f2f696 Author: Jean-Sébastien Pédron AuthorDate: 2023-11-24 17:30:33 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-02-17 20:58:34 +0000 vt(4): Skip vt_window_switch() for nested panics [Why] The same protection was added to vt_flush() in the previous commit. We want the same one in vt_window_switch(): if e.g. the DRM driver panics while handling a call to vt_window_switch(), we don't want to recursively call vt_window_switch() again and trigger another panic. Reviewed by: imp, manu Approved by: imp, manu Differential Revision: https://reviews.freebsd.org/D42750 (cherry picked from commit 24d6f256f825e5d7f8ca6b5d16499f13614f9cdd) --- sys/dev/vt/vt_core.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 406472a8fbf6..6d44c81181a3 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -275,6 +275,7 @@ SYSINIT(vt_early_cons, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_ANY, vt_upgrade, &vt_consdev); static bool inside_vt_flush = false; +static bool inside_vt_window_switch = false; /* Initialize locks/mem depended members. */ static void @@ -564,6 +565,11 @@ vt_window_switch(struct vt_window *vw) struct vt_window *curvw = vd->vd_curwindow; keyboard_t *kbd; + if (inside_vt_window_switch && KERNEL_PANICKED()) + return (0); + + inside_vt_window_switch = true; + if (kdb_active) { /* * When grabbing the console for the debugger, avoid @@ -575,13 +581,16 @@ vt_window_switch(struct vt_window *vw) */ if (curvw == vw) return (0); - if (!(vw->vw_flags & (VWF_OPENED|VWF_CONSOLE))) + if (!(vw->vw_flags & (VWF_OPENED|VWF_CONSOLE))) { + inside_vt_window_switch = false; return (EINVAL); + } vd->vd_curwindow = vw; vd->vd_flags |= VDF_INVALID; if (vd->vd_driver->vd_postswitch) vd->vd_driver->vd_postswitch(vd); + inside_vt_window_switch = false; return (0); } @@ -595,10 +604,12 @@ vt_window_switch(struct vt_window *vw) if ((kdb_active || KERNEL_PANICKED()) && vd->vd_driver->vd_postswitch) vd->vd_driver->vd_postswitch(vd); + inside_vt_window_switch = false; VT_UNLOCK(vd); return (0); } if (!(vw->vw_flags & (VWF_OPENED|VWF_CONSOLE))) { + inside_vt_window_switch = false; VT_UNLOCK(vd); return (EINVAL); } @@ -627,6 +638,7 @@ vt_window_switch(struct vt_window *vw) mtx_unlock(&Giant); DPRINTF(10, "%s(ttyv%d) done\n", __func__, vw->vw_number); + inside_vt_window_switch = false; return (0); }