From nobody Fri Nov 24 17:31:56 2023 X-Original-To: dev-commits-src-main@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 4ScMVP09FSz51dYn; Fri, 24 Nov 2023 17:31:57 +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 4ScMVN6pZHz4LTv; Fri, 24 Nov 2023 17:31:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700847117; 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=MoH+2MSOkNuUkPDacgIINTrZBj+wYgOrtAqpWx2q7Ko=; b=qCJhVeHGafYIbN+VEo7/g7fZ9UZYiJSwSBbZ65thf/zetVoxu5S41Cir5nin8oEYZYPFvF O/nn147vU1XoPryvOYBd8tXcjHpki1kPTVinORkfUEekx1ByWXw4LyrfV311egDQxAMulA giuOBvPxi4ZTYzWdLy9p+UTQH8jmr+pBeMv9c6yHKaPTA7sR3ocqXYUUiTdTB79ep98tjB qa80hmVIZlgTGUzeeAAynK9eRarxknXBM7UcdggovqDpIYJsttv3UlvdNbag9pnU5pr4qS bwWig8lANoOI3V+qDRZBa2z2069SC+VHzbgLEcI3io5gkOftQHpD4RP4t91xOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700847117; 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=MoH+2MSOkNuUkPDacgIINTrZBj+wYgOrtAqpWx2q7Ko=; b=QJ4YQb16qaOqTlnCIvE4xcGOogPE/jJtq9HcN52pafhns3xsXC+ICxPuBFmPlawZUkJm/J Y8ZdNc2jfReddsnL7Y31LwFibXltGZgBV77wUMrk1zrtBwxJk+MBlomX12kwmgpA7317+8 jHe1pdQQdKIp4bpQUA2Id/dU+Vzk+WsNvl0oHLUJPVn71gm3S7gHyGMWrbluPMOS34pdcK tSulS/koMWxzrQGUkHC/3ZQv+80wzqpFkMempr03uS18IoTB6auXzlYsSGmuvK07IR+bD8 yOp3pXchujaAyrimqsJUPfWMiOe+uKJMCt5OLbwD2G+Ia5x/aqjpfCp1g9C7dQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700847117; a=rsa-sha256; cv=none; b=uu+KoNTjgBJb55R571GCkOBVl8Pna5wGzDGkVCqvgBK/O9b1TXUCVqNSNQUHMkSi4G21m0 6kUlmgoN1RhmfwZL4MV3LLeZFnznuePcciBTWRJMP0yv+LNAqovvjyjjkDM4eGafzhXukR GI+oNRGcNHSbGubjdLcpvpfnIve+Tjc6IVEzJBv/d3mAp8TSxOPdOfeGYy00Xw7tGwyTXk s5EDXYu9Xy/unyt3ZbDjehRSKQtq4BcKddwcke4SLtof7n/Y4I8uubsxqieaA2fZGm/0Xz DEbVzRUor8nGgNtujK9Sh7OlNDYFoPXEDhnH7HZXr4xxv3ZRz9IwQghlG4BudQ== 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 4ScMVN5KMGzv8s; Fri, 24 Nov 2023 17:31:56 +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 3AOHVuHC061846; Fri, 24 Nov 2023 17:31:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AOHVuEI061843; Fri, 24 Nov 2023 17:31:56 GMT (envelope-from git) Date: Fri, 24 Nov 2023 17:31:56 GMT Message-Id: <202311241731.3AOHVuEI061843@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien?= =?utf-8?Q?P=C3=A9dron?= Subject: git: 24d6f256f825 - main - vt(4): Skip vt_window_switch() for nested panics List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 24d6f256f825e5d7f8ca6b5d16499f13614f9cdd Auto-Submitted: auto-generated The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=24d6f256f825e5d7f8ca6b5d16499f13614f9cdd commit 24d6f256f825e5d7f8ca6b5d16499f13614f9cdd Author: Jean-Sébastien Pédron AuthorDate: 2023-11-24 17:30:33 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-11-24 17:31:33 +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 --- 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); }