From nobody Sun Nov 03 14:56:31 2024 X-Original-To: freebsd-drivers@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 4XhHk04MVDz5cGXt for ; Sun, 03 Nov 2024 14:56:40 +0000 (UTC) (envelope-from robin.haberkorn@googlemail.com) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XhHjz0dwyz49h1 for ; Sun, 3 Nov 2024 14:56:39 +0000 (UTC) (envelope-from robin.haberkorn@googlemail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=googlemail.com header.s=20230601 header.b="jojmB4/f"; spf=pass (mx1.freebsd.org: domain of robin.haberkorn@googlemail.com designates 2a00:1450:4864:20::631 as permitted sender) smtp.mailfrom=robin.haberkorn@googlemail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a9a5f555cfbso263768466b.1 for ; Sun, 03 Nov 2024 06:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1730645796; x=1731250596; darn=freebsd.org; h=mime-version:user-agent:message-id:subject:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=gQY3ox/bApu9IcspQKCrsPe/0UyRFrOR9I61LUp1kyo=; b=jojmB4/f38T7I3hFbGf2yL87LQvtwROs0zKC4D7cx4VuuXXQaMzExonqA6u1j4MgAq EZXbBhn+XLlJP9a74VXtdvcWPDStAMBHipSdsnTgw0gH3B3tiz8kEhSY/vLzjWl/3fhK ePVlQW14xvKpv8SITTPEBjmCrGoEyGl0p8eAlpOw11Nvqt8aj1d1NeCUpYAOV4h0VaX7 OXtEjSMz+x/S3EcJWzqCN++TNSeyEGb1B9SeCsoa1tZQL4iW8yT31jEJY7J2/UamfCb/ w/MjScQX6ncIH8Wd20NXtznUiZ7ixA+p4VISyt1w4eigS/mRLh4GBON10ouDY3zBJD+2 2SDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730645796; x=1731250596; h=mime-version:user-agent:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gQY3ox/bApu9IcspQKCrsPe/0UyRFrOR9I61LUp1kyo=; b=jwM3wfHKWJ2uF76dOBgu1p2ta5ALJjyNAPnwKqwiaJuR7eCu0sFekyvM1oVecqgt1C luVhPm4oevKOkxK2Crq+oqCXEBV5/OVaLFwHNDCk3wV49CVhLauzRtnMgnvEKsCvd8vr oy4wI6yROZDJ8Mr7R6hgEOmjy4uVtaZX8g5DIWvPm86JxtRDTsA+woasrhnhM/Du4ybA YB+OClXhzHJbTQAoYa8pnqEgWh1iSRQurrwwmIvN4nnassLENgMJKCDa/aX3vElYJnyS Mu09NXnOpWugmVDm+ocYURnz9/QXAElm0tQYpQuiyPSw3NlYUJYHp4DX8ntDOR+yotOd Y6YQ== X-Gm-Message-State: AOJu0YxmL6lcZMdtWyJJitDiH+cvKC88aVkFp7AqPczs6bmPk6ce1OUo bSC9/UOATvaxNBFm1CKdxwT4RYf5cXrdy5tVB/HFZeUBVtj4nD4= X-Google-Smtp-Source: AGHT+IHfSV5mvmWQHHd3pXhrrjTuJjftU7D0m1ZZjo0H1NLk5+M4pYNFpBybQxqyD7OMgpychfAxxw== X-Received: by 2002:a05:6402:524b:b0:5ce:afba:f48a with SMTP id 4fb4d7f45d1cf-5ceb935bbc3mr13108411a12.27.1730645796214; Sun, 03 Nov 2024 06:56:36 -0800 (PST) Received: from [10.60.20.28] ([185.103.110.235]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ceac770eccsm3337036a12.40.2024.11.03.06.56.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 06:56:34 -0800 (PST) Date: Sun, 3 Nov 2024 17:56:31 +0300 (MSK) From: Robin Haberkorn To: freebsd-drivers@freebsd.org Subject: double fault during log(LOG_DEBUG) Message-ID: <7634a3ed-18cd-46c2-ffff-3cabd55ed0f5@googlemail.com> User-Agent: Alpine 2.26 (BSF 649 2022-06-02) List-Id: Writing device drivers for FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-drivers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-drivers@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spamd-Result: default: False [-4.00 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.997]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; R_DKIM_ALLOW(-0.20)[googlemail.com:s=20230601]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_FROM(0.00)[googlemail.com]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_NONE(0.00)[googlemail.com:dkim]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[googlemail.com:+]; PREVIOUSLY_DELIVERED(0.00)[freebsd-drivers@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; MLMMJ_DEST(0.00)[freebsd-drivers@freebsd.org]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::631:from] X-Rspamd-Queue-Id: 4XhHjz0dwyz49h1 X-Spamd-Bar: --- Hello, while I am waiting for my reviews.freebsd.org account to be approved, I would like understand a particular crash that I observed while hacking a kernel driver: #33 0xffffffff810346be in panic (fmt=0xffffffff81a69212 "double fault") at /usr/src/sys/kern/kern_shutdown.c:891 #34 0xffffffff81819ae2 in dblfault_handler (frame=0xfffffe001ea4ff30) at /usr/src/sys/amd64/amd64/trap.c:1012 #35 #36 0xffffffff810bb574 in kvprintf (fmt=0xffffffff8197a48b ">", func=0x0, arg=0xfffffe00f8029440, radix=10, ap=0xfffffe00f8029370) at /usr/src/sys/kern/subr_prf.c:907 #37 0xffffffff810bc728 in sprintf (buf=0xfffffe00f8029440 "<", cfmt=0xffffffff8197a488 "<%d>") at /usr/src/sys/kern/subr_prf.c:526 #38 0xffffffff810b4409 in msgbuf_addstr (mbp=0xfffff804417fffb8, pri=7, str=0xfffffe00f8029a00 "Unhandled devclass: drm\n", filter_cr=1) at /usr/src/sys/kern/subr_msgbuf.c:205 #39 0xffffffff810bc65b in msglogstr ( str=0xfffffe00f8029a00 "Unhandled devclass: drm\n", pri=7, filter_cr=1) at /usr/src/sys/kern/subr_prf.c:1029 #40 0xffffffff810bd152 in prf_putbuf ( bufr=0xfffffe00f8029a00 "Unhandled devclass: drm\n", flags=5, pri=7) at /usr/src/sys/kern/subr_prf.c:442 #41 0xffffffff810bd300 in putbuf (c=10, ap=0xfffffe00f80299b8) at /usr/src/sys/kern/subr_prf.c:470 #42 0xffffffff810bbe7d in putchar (c=10, arg=0xfffffe00f80299b8) at /usr/src/sys/kern/subr_prf.c:513 #43 0xffffffff810b9cf6 in kvprintf (fmt=0xffffffff8492e0ac "", func=0xffffffff810bbdd0 , arg=0xfffffe00f80299b8, radix=10, ap=0xfffffe00f8029b00) at /usr/src/sys/kern/subr_prf.c:688 #44 0xffffffff810bc405 in _vprintf (level=7, flags=5, fmt=0xffffffff8492e095 "Unhandled devclass: %s\n", ap=0xfffffe00f8029b00) at /usr/src/sys/kern/subr_prf.c:295 #45 0xffffffff810bc331 in vlog (level=7, fmt=0xffffffff8492e095 "Unhandled devclass: %s\n", ap=0xfffffe00f8029b00) at /usr/src/sys/kern/subr_prf.c:326 #46 0xffffffff810b953d in log (level=7, fmt=0xffffffff8492e095 "Unhandled devclass: %s\n") at /usr/src/sys/kern/subr_prf.c:318 #47 0xffffffff8492a5ca in linsysfs_run_bus (dev=0xfffff8001542cc00, dir=0xfffff800159f6900, scsi=0xfffff8000d289b00, chardev=0xfffff8000d27d800, drm=0xfffff8000d289800, path=0xfffff80015a05000 "/pci0000:00/0000:00:02.0", prefix=0xffffffff8492e31a "0000") at /usr/src/sys/compat/linsysfs/linsysfs.c:540 The "double fault" is reliably caused by the log(LOG_DEBUG) call (frame #46). Once I commented it out, it was gone. Interestingly, I couldn't provoke this bug in my VirtualBox, but only when I tried to test it on my main installation. I don't have a "drm" device in VirtualBox, though. The string "drm", it tries to log, comes from devclass_get_name(). I suppose this string has static lifetime - it shouldn't be possible to become invalid. And in fact, the double fault is obviously caused long after the string has been read. Best regards, Robin