From nobody Wed Apr 12 20:45:27 2023 X-Original-To: freebsd-hackers@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 4PxZV33Hwtz44jZd for ; Wed, 12 Apr 2023 20:45:31 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from smtp-190c.mail.infomaniak.ch (smtp-190c.mail.infomaniak.ch [185.125.25.12]) (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 (2048 bits) client-digest SHA256) (Client CN "relay.mail.infomaniak.ch", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PxZV21gQGz3D9p for ; Wed, 12 Apr 2023 20:45:30 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Authentication-Results: mx1.freebsd.org; dkim=none; spf=softfail (mx1.freebsd.org: 185.125.25.12 is neither permitted nor denied by domain of dumbbell@FreeBSD.org) smtp.mailfrom=dumbbell@FreeBSD.org; dmarc=none Received: from smtp-2-0001.mail.infomaniak.ch (unknown [10.5.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4PxZTz4LLYzMqCDm for ; Wed, 12 Apr 2023 22:45:27 +0200 (CEST) Received: from unknown by smtp-2-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4PxZTz2NM1zMpsd1 for ; Wed, 12 Apr 2023 22:45:27 +0200 (CEST) Message-ID: <4ed85151-09e8-db3e-0e0b-d0a8f3bb937c@FreeBSD.org> Date: Wed, 12 Apr 2023 22:45:27 +0200 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 To: freebsd-hackers@freebsd.org Content-Language: fr, en-US From: =?UTF-8?Q?Jean-S=c3=a9bastien_P=c3=a9dron?= Subject: Handling panics inside vt(4) callbacks Organization: The FreeBSD Project Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Infomaniak-Routing: alpha X-Spamd-Result: default: False [-2.08 / 15.00]; R_MIXED_CHARSET(1.11)[subject]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.993]; RCVD_IN_DNSWL_LOW(-0.10)[185.125.25.12:from]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[dumbbell]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; TO_DOM_EQ_FROM_DOM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; HAS_ORG_HEADER(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; TO_DN_NONE(0.00)[]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; RCVD_COUNT_THREE(0.00)[3]; R_DKIM_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:29222, ipnet:185.125.24.0/22, country:CH]; RWL_MAILSPIKE_POSSIBLE(0.00)[185.125.25.12:from] X-Rspamd-Queue-Id: 4PxZV21gQGz3D9p X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N Hi! While working on the DRM drivers, I don't always get a kernel core dump in case of a panic. My hypothesis is that if the DRM driver code called by vt(4) panics, then the panic code might not go through successfully. The reason is because panic(9) prints the reason, a stacktrace and possibly some progress to the console, which calls vt(4) and the DRM driver code again. I played with the following patch: https://gist.github.com/dumbbell/88d77789bfeb38869268c84c40575f49 The idea is that before calling "vt_flush()" in "vtterm_done()", I set a global flag to true to indicate that vt(4) is called as part of kdb or a panic. If another panic occurs inside vt_flush(), typically the underlying DRM driver code, "vtterm_done()" is called recursively and "vt_flush()" might trigger the same panic again. If the flag is set, the entire function is skipped instead. I test the patch by adding a panic(9) just before "vt_flush()" and I trigger the initial panic with debug.kdb.panic=1. I don't even load a DRM driver. My problem is that in this case, the laptop reboots immediately. However, if I replace panic(9) with a simple printf(9), it works as expected and I get a kernel dump. I could not find something in panic(9) code that would reboot the computer in case of a nested panic. Previous versions of the patch called doadump() and rebooted the computer explicitly if the flag was set, but it didn't work either and I thought I could simplify that patch and let panic(9) handle recursion. In other words, I just want to skip most of vt(4) code if vt(4) or DRM crash. Does someone spot something wrong in my hypothesis or methodology? -- Jean-Sébastien Pédron The FreeBSD Project