NetBSD Problem Report #55906

From  Sun Jan  3 10:44:56 2021
Return-Path: <>
Received: from ( [])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 7202F1A9217
	for <>; Sun,  3 Jan 2021 10:44:56 +0000 (UTC)
Message-Id: <20210103103530.2B4E11B983@kwarx.station.defora>
Date: Sun,  3 Jan 2021 11:35:30 +0100 (CET)
From: Pierre Pronchery <>
Subject: Kernel panic while loading firmware when booting netbsd-9
X-Send-Pr-Version: 3.95

>Number:         55906
>Category:       kern
>Synopsis:       Call to workqueue_enqueue() for aiodoned performed before initialisation
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          needs-pullups
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 03 10:45:00 +0000 2021
>Last-Modified:  Sun Jan 03 23:37:19 +0000 2021
>Originator:     Pierre Pronchery
>Release:        NetBSD 9.1_STABLE
The DeforaOS Project
The NetBSD Foundation
System: NetBSD localhost 9.1_STABLE NetBSD 9.1_STABLE (GENERIC_KASLR) #14: Mon Dec 28 05:45:36 CET 2020 khorben@localhost:/sys/arch/amd64/compile/GENERIC_KASLR amd64
Architecture: x86_64
Machine: amd64
On a system booting GENERIC_KASLR together with root on cgd(4), and
loading firmware for the graphics card for the console, the kernel
panics with:

> kernel: page fault trap, code=0
> Stopped in pid 0.100 (system) at netbsd:workqueue_enqueue+0x16: testb $0x2,10(%rdi)
> workqueue_enqueue() at netbsd:workqueue_enqueue+0x16
> biodone2() at netbsd:biodone2+0xd8

The graphics card in this case is an ATI Radeon HD4870 (RV770) using

After debugging I figured the culprit was not in the DRM2 code as
initially suspected, but with the workqueue for aiodoned, in the
kernel's main() routine.

Boot NetBSD 9 on a system loading multiple or relatively big (?)
firmware files before running init(8).
The patch I sent on the tech-kern@ mailing-list does fix this issue and
seems to be correct, as confirmed by Chuck Silvers (chs@). I have
reproduced it here below.

I believe it is only relevant for the netbsd-9 branch, as it was fixed
differently in -current. It should therefore be applied there, but there
cannot be a corresponding commit in -current anymore to be pulled up.

I have not looked at the netbsd-8 branch.

The patch initialises the aiodoned queue before mounting the root file
system, as follows:

diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index bbf418df55ce..0b07c9164ade 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -668,6 +668,11 @@ main(void)

+	/* Create the aiodone daemon kernel thread. */
+	if (workqueue_create(&uvm.aiodone_queue, "aiodoned",
+	    uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE))
+		panic("fork aiodoned");
 	/* Mount the root file system. */
 	do {
@@ -736,11 +741,6 @@ main(void)
 	    NULL, NULL, "ioflush"))
 		panic("fork syncer");

-	/* Create the aiodone daemon kernel thread. */
-	if (workqueue_create(&uvm.aiodone_queue, "aiodoned",
-	    uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE))
-		panic("fork aiodoned");
 	/* Wait for final configure threads to complete. */



State-Changed-From-To: open->pending-pullups
State-Changed-When: Sun, 03 Jan 2021 11:18:32 +0000
pullup-9 #1177

From: "Martin Husemann" <>
Subject: PR/55906 CVS commit: [netbsd-9] src/sys/kern
Date: Sun, 3 Jan 2021 12:51:33 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Jan  3 12:51:33 UTC 2021

 Modified Files:
 	src/sys/kern [netbsd-9]: init_main.c

 Log Message:
 Apply patch, requested by khorben in ticket #1177 (issue solved differently
 in -current):

 	sys/kern/init_main.c			(apply patch)

 PR kern/55906: create the aiodone workqueue before running mountroothooks.

 To generate a diff of this commit:
 cvs rdiff -u -r1.504.2.1 -r1.504.2.2 src/sys/kern/init_main.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->needs-pullups
State-Changed-When: Sun, 03 Jan 2021 23:37:19 +0000
Pull-up to netbsd-9 done (thanks!)
It looks like a pull-up to netbsd-8 is also necessary, but it should be tested first.

 Up to and including "Ticket #1160".

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.