NetBSD Problem Report #58335

From www@netbsd.org  Mon Jun 10 19:51:33 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 62FAA1A9238
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 10 Jun 2024 19:51:33 +0000 (UTC)
Message-Id: <20240610195130.B2C9E1A923A@mollari.NetBSD.org>
Date: Mon, 10 Jun 2024 19:51:30 +0000 (UTC)
From: roddy.gonzalez.89@gmail.com
Reply-To: roddy.gonzalez.89@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Kernel panic when shutting down a virtual machine with Virtio devices
X-Send-Pr-Version: www-1.0

>Number:         58335
>Category:       kern
>Synopsis:       Kernel panic when shutting down a virtual machine with Virtio devices
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 10 19:55:00 +0000 2024
>Closed-Date:    Sat Oct 12 22:49:12 +0000 2024
>Last-Modified:  Sat Oct 12 22:49:12 +0000 2024
>Originator:     Roddy
>Release:        10.0
>Organization:
>Environment:
NetBSD marte.local 10.0 NetBSD 10.0 (GENERIC) #0: Thu Mar 28 08:33:33 UTC 2024  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
Sometimes, my virtual machines with virtio devices get kernel panics when shutting down.

This is an example of a power cycle when it happens:

```

boot
21288680+782888+1314264 [939258+1396248+1023001]=0x1b34a30
[   1.0000000] cpu_rng: rdrand/rdseed
[   1.0000000] entropy: ready
[   1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
[   1.0000000]     2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
[   1.0000000]     2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023,
[   1.0000000]     2024
[   1.0000000]     The NetBSD Foundation, Inc.  All rights reserved.
[   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[   1.0000000]     The Regents of the University of California.  All rights reserved.

[   1.0000000] NetBSD 10.0 (GENERIC) #0: Thu Mar 28 08:33:33 UTC 2024
[   1.0000000] 	mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC
[   1.0000000] total memory = 4095 MB
[   1.0000000] avail memory = 3935 MB
[   1.0000040] mainbus0 (root)
[   1.0000040] ACPI: RSDP 0x00000000000F5AD0 000014 (v00 BOCHS )
[   1.0000040] ACPI: RSDT 0x00000000BFFE1650 000030 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[   1.0000040] ACPI: FACP 0x00000000BFFE1524 000074 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[   1.0000040] ACPI: DSDT 0x00000000BFFDFDC0 001764 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[   1.0000040] ACPI: FACS 0x00000000BFFDFD80 000040
[   1.0000040] ACPI: APIC 0x00000000BFFE1598 000090 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[   1.0000040] ACPI: WAET 0x00000000BFFE1628 000028 (v01 BOCHS  BXPC     00000001 BXPC 00000001)
[   1.0000040] ACPI: 1 ACPI AML tables successfully acquired and loaded
[   1.0000040] ioapic0 at mainbus0 apid 0
[   1.0000040] cpu0 at mainbus0 apid 0
[   1.0000040] cpu0: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
[   1.0000040] cpu0: node 0, package 0, core 0, smt 0
[   1.0000040] cpu1 at mainbus0 apid 1
[   1.0000040] cpu1: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
[   1.0000040] cpu1: node 0, package 1, core 0, smt 0
[   1.0000040] cpu2 at mainbus0 apid 2
[   1.0000040] cpu2: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
[   1.0000040] cpu2: node 0, package 2, core 0, smt 0
[   1.0000040] cpu3 at mainbus0 apid 3
[   1.0000040] cpu3: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
[   1.0000040] cpu3: node 0, package 3, core 0, smt 0
[   1.0000040] acpi0 at mainbus0: Intel ACPICA 20221020
[   1.0000040] acpi0: fixed power button present
[   1.0513583] com0 at acpi0 (COM1, PNP0501-1): io 0x3f8-0x3ff irq 4
[   1.0513583] com0: ns16550a, 16-byte FIFO
[   1.0513583] com0: console
[   1.0513583] pckbc1 at acpi0 (KBD, PNP0303) (kbd port): io 0x60,0x64 irq 1
[   1.0513583] pckbc2 at acpi0 (MOU, PNP0F13) (aux port): irq 12
[   1.0513583] fdc0 at acpi0 (FDC0, PNP0700): io 0x3f2-0x3f5,0x3f7 irq 6 drq 2
[   1.0513583] qemufwcfg0 at acpi0 (FWCF, QEMU0002): io 0x510-0x51b
[   1.0513583] ACPI: Enabled 2 GPEs in block 00 to 0F
[   1.0513583] pckbd0 at pckbc1 (kbd slot)
[   1.0513583] pckbc1: using irq 1 for kbd slot
[   1.0513583] wskbd0 at pckbd0 mux 1
[   1.0513583] pms0 at pckbc1 (aux slot)
[   1.0513583] pckbc1: using irq 12 for aux slot
[   1.0513583] wsmouse0 at pms0 mux 0
[   1.0513583] pci0 at mainbus0 bus 0: configuration mode 1
[   1.0513583] pchb0 at pci0 dev 0 function 0: Intel 82441FX (PMC) PCI and Memory Controller (rev. 0x02)
[   1.0513583] pcib0 at pci0 dev 1 function 0: Intel 82371SB (PIIX3) PCI-ISA Bridge (rev. 0x00)
[   1.0513583] piixide0 at pci0 dev 1 function 1: Intel 82371SB IDE Interface (PIIX3) (rev. 0x00)
[   1.0513583] piixide0: primary channel interrupting at ioapic0 pin 14
[   1.0513583] atabus0 at piixide0 channel 0
[   1.0513583] piixide0: secondary channel interrupting at ioapic0 pin 15
[   1.0513583] atabus1 at piixide0 channel 1
[   1.0513583] piixpm0 at pci0 dev 1 function 3: Intel 82371AB (PIIX4) Power Management Controller (rev. 0x03)
[   1.0513583] piixpm0: 24-bit timer
[   1.0513583] piixpm0: interrupting at ioapic0 pin 9
[   1.0513583] iic0 at piixpm0 port 0: I2C bus
[   1.0513583] virtio0 at pci0 dev 2 function 0
[   1.0513583] virtio0: Unknown device (id 16, rev. 0x01)
[   1.0513583] virtio0: no matching child driver; not configured
[   1.0513583] wm0 at pci0 dev 3 function 0: Intel i82540EM 1000BASE-T Ethernet (rev. 0x03)
[   1.0513583] wm0: interrupting at ioapic0 pin 11
[   1.0513583] wm0: Ethernet address 52:54:00:0f:0c:bb
[   1.0513583] makphy0 at wm0 phy 1: Marvell 88E1011 Gigabit PHY, rev. 0
[   1.0513583] makphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
[   1.0513583] hdaudio0 at pci0 dev 4 function 0: HD Audio Controller
[   1.0513583] hdaudio0: interrupting at msi0 vec 0
[   1.0513583] hdaudio0: HDA ver. 1.0, OSS 4, ISS 4, BSS 0, SDO 1, 64-bit
[   1.0513583] hdafg0 at hdaudio0: vendor 1af4 product 0022
[   1.0513583] hdafg0: DAC00 2ch: Speaker [Jack]
[   1.0513583] hdafg0: ADC01 2ch: Line In [Jack]
[   1.0513583] hdafg0: 2ch/2ch 16000Hz 22050Hz 32000Hz 44100Hz 48000Hz 88200Hz 96000Hz PCM16
[   1.0513583] audio0 at hdafg0: playback, capture, full duplex, independent
[   1.0513583] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) for playback
[   1.0513583] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) for recording
[   1.0513583] spkr0 at audio0: PC Speaker (synthesized)
[   1.0513583] wsbell at spkr0 not configured
[   1.0513583] uhci0 at pci0 dev 5 function 0: Intel 82801I USB UHCI Controller (rev. 0x03)
[   1.0513583] uhci0: interrupting at ioapic0 pin 10
[   1.0513583] usb0 at uhci0: USB revision 1.0
[   1.0513583] uhci1 at pci0 dev 5 function 1: Intel 82801I USB UHCI Controller (rev. 0x03)
[   1.0513583] uhci1: interrupting at ioapic0 pin 10
[   1.0513583] usb1 at uhci1: USB revision 1.0
[   1.0513583] uhci2 at pci0 dev 5 function 2: Intel 82801I USB UHCI Controller (rev. 0x03)
[   1.0513583] uhci2: interrupting at ioapic0 pin 11
[   1.0513583] usb2 at uhci2: USB revision 1.0
[   1.0513583] ehci0 at pci0 dev 5 function 7: Intel 82801I USB EHCI Controller (rev. 0x03)
[   1.0513583] ehci0: interrupting at ioapic0 pin 11
[   1.0513583] ehci0: 3 companion controllers, 2 ports each: uhci0 uhci1 uhci2
[   1.0513583] ehci0: Using DMA subregion for control data structures
[   1.0513583] usb3 at ehci0: USB revision 2.0
[   1.0513583] virtio1 at pci0 dev 6 function 0
[   1.0513583] virtio1: console device (id 3, rev. 0x00)
[   1.0513583] virtio1: no matching child driver; not configured
[   1.0513583] virtio2 at pci0 dev 7 function 0
[   1.0513583] virtio2: memory balloon device (id 5, rev. 0x00)
[   1.0513583] viomb0 at virtio2: features: 0x10000000<INDIRECT_DESC>
[   1.0513583] virtio2: interrupting at ioapic0 pin 11
[   1.0513583] virtio3 at pci0 dev 8 function 0
[   1.0513583] virtio3: Unknown device (id 19, rev. 0x01)
[   1.0513583] virtio3: no matching child driver; not configured
[   1.0513583] isa0 at pcib0
[   1.0513583] attimer0 at isa0 port 0x40-0x43
[   1.0513583] pcppi0 at isa0 port 0x61
[   1.0513583] spkr1 at pcppi0: PC Speaker
[   1.0513583] wsbell at spkr1 not configured
[   1.0513583] midi0 at pcppi0: PC speaker
[   1.0513583] sysbeep0 at pcppi0
[   1.0513583] attimer0: attached to pcppi0
[   1.0513583] acpicpu0 at cpu0: ACPI CPU
[   1.0513583] acpicpu1 at cpu1: ACPI CPU
[   1.0513583] acpicpu2 at cpu2: ACPI CPU
[   1.0513583] acpicpu3 at cpu3: ACPI CPU
[   1.9604157] atapibus0 at atabus0: 2 targets
[   1.9706785] uhub0 at usb0: NetBSD (0x0000) UHCI root hub (0x0000), class 9/0, rev 1.00/1.00, addr 1
[   1.9808482] uhub1 at usb3: NetBSD (0x0000) EHCI root hub (0x0000), class 9/0, rev 2.00/1.00, addr 1
[   1.9911392] uhub2 at usb1: NetBSD (0x0000) UHCI root hub (0x0000), class 9/0, rev 1.00/1.00, addr 1
[   2.0013475] uhub3 at usb2: NetBSD (0x0000) UHCI root hub (0x0000), class 9/0, rev 1.00/1.00, addr 1
[   2.0149936] cd0 at atapibus0 drive 1: <QEMU DVD-ROM, QM00002, 2.5+> cdrom removable
[   2.0217540] wd0 at atabus0 drive 0
[   2.0217540] wd0: <QEMU HARDDISK>
[   2.0217540] wd0: 24576 MB, 49932 cyl, 16 head, 63 sec, 512 bytes/sect x 50331648 sectors
[   2.0626726] dk0 at wd0: "14278129-a49e-44f0-ba70-53c132d50ce6", 41942912 blocks at 64, type: ffs
[   2.0728158] dk1 at wd0: "b41146b7-841a-4c6a-9614-a7f87f7b4afe", 8388608 blocks at 41942976, type: swap
[   3.1660681] uhidev0 at uhub1 port 1 configuration 1 interface 0
[   3.1779467] uhidev0: QEMU (0x0627) QEMU USB Tablet (0x0001), rev 2.00/0.00, addr 2, iclass 3/0
[   3.1881497] ums0 at uhidev0: 3 buttons and Z dir
[   3.1973598] wsmouse1 at ums0 mux 0
[   3.1973598] swwdog0: software watchdog initialized
[   3.2375185] WARNING: 3 errors while detecting hardware; check system log.
[   3.2539846] boot device: wd0
[   3.2539846] root on dk0 dumps on dk1
[   3.2681747] root file system type: ffs
[   3.2681747] kern.module.path=/stand/amd64/10.0/modules
Mon Jun 10 21:27:21 CEST 2024
Starting root file system check:
/dev/rdk0: file system is clean; not checking
Loading modules.
[   3.8709884] nvmm0: attached, using backend x86-vmx
Setting sysctl variables:
ddb.onpanic: 1 -> 0
swapctl: setting dump device to /dev/dk1
swapctl: adding /dev/dk1 as swap device at priority 0
Starting file system checks:
Loaded entropy from /var/db/entropy-file.
Waiting for entropy...done
Setting tty flags.
Starting network.
Hostname: marte.local
IPv6 mode: host
Configuring network interfaces: wm0.
Adding interface aliases:.
Waiting for duplicate address detection to finish...
Starting dhcpcd.
Building databases: dev, utmp, utmpx.
wsconscfg: Cannot open `/dev/ttyEcfg': Device not configured
wsconscfg: Cannot open `/dev/ttyEcfg': Device not configured
wsconscfg: Cannot open `/dev/ttyEcfg': Device not configured
wsconscfg: Cannot open `/dev/ttyEcfg': Device not configured
Starting syslogd.
Setting date via ntp.
Mounting all file systems...
Clearing temporary files.
Updating fontconfig cache: done.
Checking quotas: done.
swapctl: setting dump device to /dev/dk1
Starting virecover.
Checking for core dump...
savecore: no core dump
Starting local daemons:.
Updating motd.
Starting ntpd.
Starting powerd.
Starting sshd.
Starting dbus.
Starting slim.
Starting postfix.
postfix/postlog: starting the Postfix mail system
Starting libvirtd.
Starting inetd.
Starting cron.
Mon Jun 10 21:27:46 CEST 2024
Jun 10 21:27:46 marte getty[406]: /dev/ttyE1: Device not configured
Jun 10 21:27:46 marte getty[408]: /dev/ttyE3: Device not configured
Jun 10 21:27:46 marte getty[407]: /dev/ttyE2: Device not configured

NetBSD/amd64 (marte.local) (constty)

login: Jun 10 21:28:51 marte shutdown: poweroff by root: power button pressed 
Jun 10 21:28:59 marte syslogd[1019]: Exiting on signal 15
[ 105.8760835] syncing disks... done
[ 106.3358485] cd0: detached
[ 106.3358485] sysbeep0: detached
[ 106.3460615] midi0: detached
[ 106.3460615] uhub3: detached
[ 106.3460615] uhub2: detached
[ 106.3562927] uhub0: detached
[ 106.3562927] atapibus0: detached
[ 106.3562927] usb2: detached
[ 106.3664630] usb1: detached
[ 106.3664630] usb0: detached
[ 106.3664630] iic0: detached
[ 106.3778639] atabus1: detached
[ 106.3778639] virtio3: detached
[ 106.3878898] virtio1: detached
[ 106.3971479] uhci2: detached
[ 106.3971479] uhci1: detached
[ 106.4089229] uhci0: detached
[ 106.4089229] makphy0: detached
[ 106.4278426] wm0: detached
[ 106.4278426] extent `iomem' (0x0 - 0xffffffffffff), flags = 0x3
[ 106.4278426]      0x0 - 0x9fbff
[ 106.4278426]      0x100000 - 0xbffdefff
[ 106.4380481]      0xfe800000 - 0xfe803fff
[ 106.4380481]      0xfebb0000 - 0xfebb3fff
[ 106.4380481]      0xfebb5000 - 0xfebb5fff
[ 106.4482081]      0x100000000 - 0x13fffffff
[ 106.4482081] extent_free: start 0xfe801000, end 0xfe804fff
[ 106.4482081] Skipping crash dump on recursive panic
[ 106.4584259] panic: extent_free: region not found
[ 106.4584259] cpu1: Begin traceback...
[ 106.4687266] vpanic() at netbsd:vpanic+0x183
[ 106.4789207] panic() at netbsd:panic+0x3c
[ 106.4891186] extent_free() at netbsd:extent_free+0x117
[ 106.4891186] bus_space_release() at netbsd:bus_space_release+0x4a
[ 106.4993216] bus_space_unmap() at netbsd:bus_space_unmap+0x57
[ 106.5094972] virtio_pci_detach() at netbsd:virtio_pci_detach+0x67
[ 106.5197460] config_detach() at netbsd:config_detach+0xfc
[ 106.5299093] config_detach_all() at netbsd:config_detach_all+0xc8
[ 106.5401480] cpu_reboot() at netbsd:cpu_reboot+0x1c0
[ 106.5503510] kern_reboot() at netbsd:kern_reboot+0x6c
[ 106.5606009] sys_reboot() at netbsd:sys_reboot+0x63
[ 106.5707902] syscall() at netbsd:syscall+0x1fc
[ 106.5707902] --- syscall (number 208) ---
[ 106.5810476] netbsd:syscall+0x1fc:
[ 106.5810476] cpu1: End traceback...
[ 106.6831523] rebooting...
[ 106.6831523] fatal breakpoint trap in supervisor mode
[ 106.6831523] trap type 1 code 0 rip 0xffffffff80235385 cs 0x8 rflags 0x2 cr2 0x7f45e19d0924 ilevel 0x8 rsp 0xffffb4813869dbc0
[ 106.6831523] curlwp 0xfffffea00e25b640 pid 411.411 lowest kstack 0xffffb481386992c0
Stopped in pid 411.411 (halt) at        netbsd:breakpoint+0x5:  leave
breakpoint() at netbsd:breakpoint+0x5
cpu_reset() at netbsd:cpu_reset+0x68
cpu_reboot() at netbsd:cpu_reboot+0xc3
kern_reboot() at netbsd:kern_reboot+0x6c
vpanic() at netbsd:vpanic+0x18d
panic() at netbsd:panic+0x3c
extent_free() at netbsd:extent_free+0x117
bus_space_release() at netbsd:bus_space_release+0x4a
bus_space_unmap() at netbsd:bus_space_unmap+0x57
virtio_pci_detach() at netbsd:virtio_pci_detach+0x67
config_detach() at netbsd:config_detach+0xfc
config_detach_all() at netbsd:config_detach_all+0xc8
cpu_reboot() at netbsd:cpu_reboot+0x1c0
kern_reboot() at netbsd:kern_reboot+0x6c
sys_reboot() at netbsd:sys_reboot+0x63
syscall() at netbsd:syscall+0x1fc
--- syscall (number 208) ---
netbsd:syscall+0x1fc:
ds          dba0
es          0
fs          0
gs          4758
--db_more--

```

>How-To-Repeat:
This is the libvirt domain I use to run it.
Although other virtual machines with different video/storage suffer the same. I haven't be able to isolate the problematic virtio device.

Also, I assume the problem lies in a virtio device, because of the panic trace, but I'm not really sure.

```
<domain type="kvm">
  <name>marte</name>
  <uuid>58c50088-de9d-4002-897c-54f38f259cba</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://netbsd.org/netbsd/9.0"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit="KiB">4194304</memory>
  <currentMemory unit="KiB">4194304</currentMemory>
  <vcpu placement="static">4</vcpu>
  <os>
    <type arch="x86_64" machine="pc-i440fx-jammy">hvm</type>
  </os>
  <features>
    <acpi/>
    <apic/>
    <vmport state="off"/>
  </features>
  <cpu mode="host-passthrough" check="none" migratable="on"/>
  <clock offset="utc">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2" discard="unmap"/>
      <source file="/var/lib/libvirt/images/marte.qcow2"/>
      <target dev="hda" bus="ide"/>
      <boot order="2"/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <target dev="hdb" bus="ide"/>
      <readonly/>
      <boot order="1"/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    </disk>
    <controller type="usb" index="0" model="ich9-ehci1">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x7"/>
    </controller>
    <controller type="usb" index="0" model="ich9-uhci1">
      <master startport="0"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0" multifunction="on"/>
    </controller>
    <controller type="usb" index="0" model="ich9-uhci2">
      <master startport="2"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x1"/>
    </controller>
    <controller type="usb" index="0" model="ich9-uhci3">
      <master startport="4"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x2"/>
    </controller>
    <controller type="pci" index="0" model="pci-root"/>
    <controller type="ide" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
    </controller>
    <controller type="virtio-serial" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"/>
    </controller>
    <interface type="network">
      <mac address="52:54:00:0f:0c:bb"/>
      <source network="default"/>
      <model type="e1000"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0"/>
    </interface>
    <serial type="pty">
      <target type="isa-serial" port="0">
        <model name="isa-serial"/>
      </target>
    </serial>
    <console type="pty">
      <target type="serial" port="0"/>
    </console>
    <channel type="spicevmc">
      <target type="virtio" name="com.redhat.spice.0"/>
      <address type="virtio-serial" controller="0" bus="0" port="1"/>
    </channel>
    <channel type="unix">
      <target type="virtio" name="org.qemu.guest_agent.0"/>
      <address type="virtio-serial" controller="0" bus="0" port="2"/>
    </channel>
    <input type="tablet" bus="usb">
      <address type="usb" bus="0" port="1"/>
    </input>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <graphics type="spice">
      <listen type="none"/>
      <gl enable="yes"/>
    </graphics>
    <sound model="ich6">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
    </sound>
    <audio id="1" type="spice"/>
    <video>
      <model type="virtio" heads="1" primary="yes">
        <acceleration accel3d="yes"/>
      </model>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0"/>
    </video>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="2"/>
    </redirdev>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="3"/>
    </redirdev>
    <memballoon model="virtio">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"/>
    </memballoon>
    <vsock model="virtio">
      <cid auto="yes" address="3"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x08" function="0x0"/>
    </vsock>
  </devices>
</domain>
```
>Fix:

>Release-Note:

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58335 CVS commit: src/sys/dev/pci
Date: Tue, 25 Jun 2024 14:22:03 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Tue Jun 25 14:22:03 UTC 2024

 Modified Files:
 	src/sys/dev/pci: virtio_pci.c

 Log Message:
 virtio@pci: Unmap the BARs we actually mapped on >=1.0 detach.

 PR kern/58335


 To generate a diff of this commit:
 cvs rdiff -u -r1.45 -r1.46 src/sys/dev/pci/virtio_pci.c

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

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58335 CVS commit: src/sys/dev/pci
Date: Tue, 25 Jun 2024 14:22:16 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Tue Jun 25 14:22:16 UTC 2024

 Modified Files:
 	src/sys/dev/pci: virtio_pci.c

 Log Message:
 virtio@pci: Nix useless sc_mapped_iosize.

 This appears to have been a mistaken attempt to pass the subregion
 length through to bus_space_unmap, which doesn't make any sense --
 bus_space_subregion does not allocate anything and the resulting
 handle must not be passed to bus_space_unmap.

 Once we pass the size that was actually returned by pci_mapreg_map to
 bus_space_unmap, which matches the size passed internally by
 pci_mapreg_map to bus_space_map, sc_mapped_iosize is no longer used
 and can be flushed.

 Prompted by PR kern/58335.


 To generate a diff of this commit:
 cvs rdiff -u -r1.46 -r1.47 src/sys/dev/pci/virtio_pci.c

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

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58335 CVS commit: src/sys/dev/pci
Date: Tue, 25 Jun 2024 14:22:31 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Tue Jun 25 14:22:31 UTC 2024

 Modified Files:
 	src/sys/dev/pci: virtio_pci.c

 Log Message:
 virtio@pci: Don't detach on shutdown.

 The virtio bus does not keep state in memory that needs to flushed to
 persistent storage.  Typically DVF_DETACH_SHUTDOWN is only needed by,
 e.g., disk drivers to flush disk caches (although really, vfs sync
 should do that anyway, so maybe we should just nix the option
 altogether).

 Prompted by PR kern/58335.


 To generate a diff of this commit:
 cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/virtio_pci.c

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

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58335 CVS commit: src/sys/dev/pci
Date: Tue, 25 Jun 2024 14:22:48 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Tue Jun 25 14:22:48 UTC 2024

 Modified Files:
 	src/sys/dev/pci: virtio_pci.c

 Log Message:
 virtio@pci: Zero sc_bars_iosize[i] on unmap.

 No functional change intended, but this makes the code less brittle.

 Prompted by PR kern/58335.


 To generate a diff of this commit:
 cvs rdiff -u -r1.48 -r1.49 src/sys/dev/pci/virtio_pci.c

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

State-Changed-From-To: open->feedback
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Tue, 25 Jun 2024 15:02:39 +0000
State-Changed-Why:
Thanks for the report!  Can you see if you can still reproduce the
symptom?  And, can you also try reproducing the symptom after running
`sysctl -w kern.detachall=1' (each time you boot)?

You can find daily kernel builds for testing here:
https://nycdn.netbsd.org/


From: =?UTF-8?Q?Roddy_Gonz=C3=A1lez?= <roddy.gonzalez.89@gmail.com>
To: gnats-bugs@netbsd.org, kern-bug-people@netbsd.org,
 netbsd-bugs@netbsd.org, gnats-admin@netbsd.org, riastradh@NetBSD.org
Cc: 
Subject: Re: kern/58335 (Kernel panic when shutting down a virtual machine
 with Virtio devices)
Date: Wed, 26 Jun 2024 13:54:33 +0200

 Hi! Thank you!

 I can't reproduce the problem anymore with kern.detachall=0. But with 
 kern.detach=1 I get a different panic.

 This is what I get with with kern.detachall=0.


 ```
   \\-__,------,___.
     \\        __,---`  NetBSD/x86 EFI Boot (x64)
      \\       `---,_.  Revision 1.2 (Tue Jun 25 16:58:24 UTC 2024)
       \\-,_____,.---`
        \\
         \\
          \\

  > boot
 21680896+795008+1302144 [947716+1416552+1038933]=0x1b3f8c0
 Loading /stand/amd64/10.99.10/modules/cd9660/cd9660.kmod
 [   1.0000000] cpu_rng: rdrand/rdseed
 [   1.0000000] entropy: ready
 [   1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
 [   1.0000000]     2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 
 2013,
 [   1.0000000]     2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 
 2023,
 [   1.0000000]     2024
 [   1.0000000]     The NetBSD Foundation, Inc.  All rights reserved.
 [   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
 [   1.0000000]     The Regents of the University of California.  All 
 rights reserved.

 [   1.0000000] NetBSD 10.99.10 (GENERIC) #0: Tue Jun 25 16:58:24 UTC 2024
 [   1.0000000] 
 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC
 [   1.0000000] total memory = 2043 MB
 [   1.0000000] avail memory = 1948 MB
 [   1.0000000] WARNING: module error: module `cd9660' pushed by boot 
 loader already exists
 [   1.0000040] efi: systbl at pa 7f9ed018
 [   1.0000040] mainbus0 (root)
 [   1.0000040] ACPI: RSDP 0x000000007FB7D014 000024 (v02 BOCHS )
 [   1.0000040] ACPI: XSDT 0x000000007FB7C0E8 000044 (v01 BOCHS  BXPC 
 00000001      01000013)
 [   1.0000040] ACPI: FACP 0x000000007FB79000 000074 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: DSDT 0x000000007FB7A000 001792 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: FACS 0x000000007FBDC000 000040
 [   1.0000040] ACPI: APIC 0x000000007FB78000 000090 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: WAET 0x000000007FB77000 000028 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: BGRT 0x000000007FB76000 000038 (v01 INTEL  EDK2 
 00000002      01000013)
 [   1.0000040] ACPI: 1 ACPI AML tables successfully acquired and loaded
 [   1.0000040] ioapic0 at mainbus0 apid 0
 [   1.0000040] cpu0 at mainbus0 apid 0
 [   1.0000040] cpu0: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu0: node 0, package 0, core 0, smt 0
 [   1.0000040] cpu1 at mainbus0 apid 1
 [   1.0000040] cpu1: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu1: node 0, package 1, core 0, smt 0
 [   1.0000040] cpu2 at mainbus0 apid 2
 [   1.0000040] cpu2: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu2: node 0, package 2, core 0, smt 0
 [   1.0000040] cpu3 at mainbus0 apid 3
 [   1.0000040] cpu3: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu3: node 0, package 3, core 0, smt 0
 [   1.0000040] acpi0 at mainbus0: Intel ACPICA 20230628
 [   1.0000040] LNKS: BIOS IRQ 10 for 0.1.INTA is invalid
 [   1.0000040] acpi0: fixed power button present
 [   1.0159697] com0 at acpi0 (COM2, PNP0501-2): io 0x2f8-0x2ff irq 3
 [   1.0159697] com0: ns16550a, 16-byte FIFO
 [   1.0159697] com1 at acpi0 (COM1, PNP0501-1): io 0x3f8-0x3ff irq 4
 [   1.0159697] com1: ns16550a, 16-byte FIFO
 [   1.0159697] com1: console
 [   1.0159697] pckbc1 at acpi0 (KBD, PNP0303) (kbd port): io 0x60,0x64 irq 1
 [   1.0159697] pckbc2 at acpi0 (MOU, PNP0F13) (aux port): irq 12
 [   1.0159697] fdc0 at acpi0 (FDC0, PNP0700): io 0x3f2-0x3f5,0x3f7 irq 6 
 drq 2
 [   1.0159697] qemufwcfg0 at acpi0 (FWCF, QEMU0002): io 0x510-0x51b
 [   1.0159697] ACPI: Enabled 2 GPEs in block 00 to 0F
 [   1.0159697] pckbd0 at pckbc1 (kbd slot)
 [   1.0159697] pckbc1: using irq 1 for kbd slot
 [   1.0159697] wskbd0 at pckbd0 mux 1
 [   1.0159697] pms0 at pckbc1 (aux slot)
 [   1.0159697] pckbc1: using irq 12 for aux slot
 [   1.0159697] wsmouse0 at pms0 mux 0
 [   1.0159697] pci0 at mainbus0 bus 0: configuration mode 1
 [   1.0159697] pchb0 at pci0 dev 0 function 0: Intel 82441FX (PMC) PCI 
 and Memory Controller (rev. 0x02)
 [   1.0159697] pcib0 at pci0 dev 1 function 0: Intel 82371SB (PIIX3) 
 PCI-ISA Bridge (rev. 0x00)
 [   1.0159697] piixide0 at pci0 dev 1 function 1: Intel 82371SB IDE 
 Interface (PIIX3) (rev. 0x00)
 [   1.0159697] piixide0: primary channel interrupting at ioapic0 pin 14
 [   1.0159697] atabus0 at piixide0 channel 0
 [   1.0159697] piixide0: secondary channel ignored (disabled)
 [   1.0159697] piixpm0 at pci0 dev 1 function 3: Intel 82371AB (PIIX4) 
 Power Management Controller (rev. 0x03)
 [   1.0159697] piixpm0: 24-bit timer
 [   1.0159697] piixpm0: interrupting at ioapic0 pin 9
 [   1.0159697] iic0 at piixpm0 port 0: I2C bus
 [   1.0159697] virtio0 at pci0 dev 2 function 0
 [   1.0159697] virtio0: Unknown device (id 16, rev. 0x01)
 [   1.0159697] virtio0: no matching child driver; not configured
 [   1.0159697] wm0 at pci0 dev 3 function 0: Intel i82540EM 1000BASE-T 
 Ethernet (rev. 0x03)
 [   1.0159697] wm0: interrupting at ioapic0 pin 11
 [   1.0159697] wm0: Ethernet address 52:54:00:e7:05:1f
 [   1.0159697] makphy0 at wm0 phy 1: Marvell 88E1011 Gigabit PHY, rev. 0
 [   1.0159697] makphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 
 1000baseT, 1000baseT-FDX, auto
 [   1.0159697] hdaudio0 at pci0 dev 4 function 0: HD Audio Controller
 [   1.0159697] hdaudio0: interrupting at msi0 vec 0
 [   1.0159697] hdaudio0: HDA ver. 1.0, OSS 4, ISS 4, BSS 0, SDO 1, 64-bit
 [   1.0159697] hdafg0 at hdaudio0: vendor 1af4 product 0022
 [   1.0159697] hdafg0: DAC00 2ch: Speaker [Jack]
 [   1.0159697] hdafg0: ADC01 2ch: Line In [Jack]
 [   1.0159697] hdafg0: 2ch/2ch 16000Hz 22050Hz 32000Hz 44100Hz 48000Hz 
 88200Hz 96000Hz PCM16
 [   1.0159697] audio0 at hdafg0: playback, capture, full duplex, independent
 [   1.0159697] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for playback
 [   1.0159697] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for recording
 [   1.0159697] spkr0 at audio0: PC Speaker (synthesized)
 [   1.0159697] wsbell at spkr0 not configured
 [   1.0159697] uhci0 at pci0 dev 5 function 0: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0159697] uhci0: interrupting at ioapic0 pin 10
 [   1.0159697] usb0 at uhci0: USB revision 1.0
 [   1.0159697] uhci1 at pci0 dev 5 function 1: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0159697] uhci1: interrupting at ioapic0 pin 10
 [   1.0159697] usb1 at uhci1: USB revision 1.0
 [   1.0159697] uhci2 at pci0 dev 5 function 2: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0159697] uhci2: interrupting at ioapic0 pin 11
 [   1.0159697] usb2 at uhci2: USB revision 1.0
 [   1.0159697] ehci0 at pci0 dev 5 function 7: Intel 82801I USB EHCI 
 Controller (rev. 0x03)
 [   1.0159697] ehci0: interrupting at ioapic0 pin 11
 [   1.0159697] ehci0: 3 companion controllers, 2 ports each: uhci0 uhci1 
 uhci2
 [   1.0159697] ehci0: Using DMA subregion for control data structures
 [   1.0159697] usb3 at ehci0: USB revision 2.0
 [   1.0159697] virtio1 at pci0 dev 6 function 0
 [   1.0159697] virtio1: console device (id 3, rev. 0x00)
 [   1.0159697] virtio1: no matching child driver; not configured
 [   1.0159697] virtio2 at pci0 dev 7 function 0
 [   1.0159697] virtio2: memory balloon device (id 5, rev. 0x00)
 [   1.0159697] viomb0 at virtio2: features: 0x10000000<INDIRECT_DESC>
 [   1.0159697] virtio2: interrupting at ioapic0 pin 11
 [   1.0159697] isa0 at pcib0
 [   1.0159697] attimer0 at isa0 port 0x40-0x43
 [   1.0159697] pcppi0 at isa0 port 0x61
 [   1.0159697] spkr1 at pcppi0: PC Speaker
 [   1.0159697] wsbell at spkr1 not configured
 [   1.0159697] midi0 at pcppi0: PC speaker
 [   1.0159697] sysbeep0 at pcppi0
 [   1.0159697] attimer0: attached to pcppi0
 [   1.0159697] acpicpu0 at cpu0: ACPI CPU
 [   1.0159697] acpicpu1 at cpu1: ACPI CPU
 [   1.0159697] acpicpu2 at cpu2: ACPI CPU
 [   1.0159697] acpicpu3 at cpu3: ACPI CPU
 [   1.4304028] atapibus0 at atabus0: 2 targets
 [   1.4408849] uhub0 at usb1: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.4514013] uhub1 at usb3: NetBSD (0x0000) EHCI root hub (0x0000), 
 class 9/0, rev 2.00/1.00, addr 1
 [   1.4618859] uhub2 at usb0: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.4763573] uhub3 at usb2: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.4829360] cd0 at atapibus0 drive 1: <QEMU DVD-ROM, QM00002, 2.5+> 
 cdrom removable
 [   1.4934111] wd0 at atabus0 drive 0
 [   1.4934111] wd0: <QEMU HARDDISK>
 [   1.4934111] wd0: 20480 MB, 41610 cyl, 16 head, 63 sec, 512 bytes/sect 
 x 41943040 sectors
 [   1.5249204] dk0 at wd0: "EFI", 262144 blocks at 4096, type: msdos
 [   1.5354609] dk1 at wd0: "NetBSD", 16777216 blocks at 266240, type: ffs
 [   1.5354609] dk2 at wd0: "syscgd", 24895488 blocks at 17043456, type: cgd
 [   2.6375962] uhidev0 at uhub1 port 1 configuration 1 interface 0
 [   2.6375962] uhidev0: QEMU (0x0627) QEMU USB Tablet (0x0001), rev 
 2.00/0.00, addr 2, iclass 3/0
 [   2.6583969] ums0 at uhidev0: 3 buttons and Z dir
 [   2.6583969] wsmouse1 at ums0 mux 0
 [   2.6692279] swwdog0: software watchdog initialized
 [   2.7004994] WARNING: 2 errors while detecting hardware; check system log.
 [   2.7177502] boot device: cd0
 [   2.7423374] root on cd0a dumps on cd0b
 [   2.7738197] root file system type: cd9660
 [   2.7843246] kern.module.path=/stand/amd64/10.99.10/modules
 Created tmpfs /dev (1835008 byte, 3552 inodes)


 You are using a serial console, we do not know your terminal emulation.
 Please select one, typical values are:

          vt100
          ansi
          xterm

 Terminal type (just hit ENTER for 'vt220'): xterm
 # uname -a
 NetBSD  10.99.10 NetBSD 10.99.10 (GENERIC) #0: Tue Jun 25 16:58:24 UTC 
 2024  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC 
 amd64
 # sysctl kern.detachall
 kern.detachall = 0
 # uname -a
 NetBSD  10.99.10 NetBSD 10.99.10 (GENERIC) #0: Tue Jun 25 16:58:24 UTC 
 2024  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC 
 amd64
 # shutdown -p now
 Shutdown NOW!
 shutdown: [pid 506]
 # wall: You have write permission turned off; no reply possible
 wall: Cannot stat `/var/run/utmp': No such file or directory
 shutdown: poweroff by root:

 System shutdown time has arrived

 About to run shutdown hooks...
 cron not running? (check /var/run/cron.pid).
 inetd not running? (check /var/run/inetd.pid).
 Saved entropy to /var/db/entropy-file.
 Forcibly unmounting /tmp
 Forcibly unmounting /var
 Forcibly unmounting /etc
 Removing block-type swap devices
 Wed Jun 26 11:36:44 UTC 2024

 Done running shutdown hooks.
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `console': Bad file descriptor
 [  71.2384052] syncing disks... done
 [  71.3199488] sysbeep0: detached
 [  71.3199488] midi0: detached
 [  71.3199488] dk2 at wd0 (syscgd) deleted
 [  71.3305114] dk1 at wd0 (NetBSD) deleted
 [  71.3305114] dk0 at wd0 (EFI) deleted
 [  71.3409082] wd0: detached
 [  71.3409082] uhub3: detached
 [  71.3409082] uhub2: detached
 [  71.3409082] uhub0: detached
 [  71.3514758] usb2: detached
 [  71.3514758] usb1: detached
 [  71.3514758] usb0: detached
 [  71.3620416] iic0: detached
 [  71.3724619] uhci2: detached
 [  71.3724619] uhci1: detached
 [  71.3829049] uhci0: detached
 [  71.3829049] makphy0: detached
 [  71.3935202] wm0: detached
 [  71.3935202] pchb0: detached
 [  71.4144145] cd0: detached
 [  71.4144145] atapibus0: detached
 [  71.4249750] atabus0: detached
 [  71.4354267] acpi0: entering state S5
 ```


 This is what I get with kern.detachall=1


 ```
    \\-__,------,___.
     \\        __,---`  NetBSD/x86 EFI Boot (x64)
      \\       `---,_.  Revision 1.2 (Tue Jun 25 16:58:24 UTC 2024)
       \\-,_____,.---`
        \\
         \\
          \\

  > boot
 21680896+795008+1302144 [947716+1416552+1038933]=0x1b3f8c0
 Loading /stand/amd64/10.99.10/modules/cd9660/cd9660.kmod
 [   1.0000000] cpu_rng: rdrand/rdseed
 [   1.0000000] entropy: ready
 [   1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
 [   1.0000000]     2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 
 2013,
 [   1.0000000]     2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 
 2023,
 [   1.0000000]     2024
 [   1.0000000]     The NetBSD Foundation, Inc.  All rights reserved.
 [   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
 [   1.0000000]     The Regents of the University of California.  All 
 rights reserved.

 [   1.0000000] NetBSD 10.99.10 (GENERIC) #0: Tue Jun 25 16:58:24 UTC 2024
 [   1.0000000] 
 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC
 [   1.0000000] total memory = 2043 MB
 [   1.0000000] avail memory = 1948 MB
 [   1.0000000] WARNING: module error: module `cd9660' pushed by boot 
 loader already exists
 [   1.0000040] efi: systbl at pa 7f9ed018
 [   1.0000040] mainbus0 (root)
 [   1.0000040] ACPI: RSDP 0x000000007FB7D014 000024 (v02 BOCHS )
 [   1.0000040] ACPI: XSDT 0x000000007FB7C0E8 000044 (v01 BOCHS  BXPC 
 00000001      01000013)
 [   1.0000040] ACPI: FACP 0x000000007FB79000 000074 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: DSDT 0x000000007FB7A000 001792 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: FACS 0x000000007FBDC000 000040
 [   1.0000040] ACPI: APIC 0x000000007FB78000 000090 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: WAET 0x000000007FB77000 000028 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: BGRT 0x000000007FB76000 000038 (v01 INTEL  EDK2 
 00000002      01000013)
 [   1.0000040] ACPI: 1 ACPI AML tables successfully acquired and loaded
 [   1.0000040] ioapic0 at mainbus0 apid 0
 [   1.0000040] cpu0 at mainbus0 apid 0
 [   1.0000040] cpu0: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu0: node 0, package 0, core 0, smt 0
 [   1.0000040] cpu1 at mainbus0 apid 1
 [   1.0000040] cpu1: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu1: node 0, package 1, core 0, smt 0
 [   1.0000040] cpu2 at mainbus0 apid 2
 [   1.0000040] cpu2: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu2: node 0, package 2, core 0, smt 0
 [   1.0000040] cpu3 at mainbus0 apid 3
 [   1.0000040] cpu3: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu3: node 0, package 3, core 0, smt 0
 [   1.0000040] acpi0 at mainbus0: Intel ACPICA 20230628
 [   1.0000040] LNKS: BIOS IRQ 10 for 0.1.INTA is invalid
 [   1.0000040] acpi0: fixed power button present
 [   1.0036891] com0 at acpi0 (COM2, PNP0501-2): io 0x2f8-0x2ff irq 3
 [   1.0036891] com0: ns16550a, 16-byte FIFO
 [   1.0036891] com1 at acpi0 (COM1, PNP0501-1): io 0x3f8-0x3ff irq 4
 [   1.0036891] com1: ns16550a, 16-byte FIFO
 [   1.0036891] com1: console
 [   1.0036891] pckbc1 at acpi0 (KBD, PNP0303) (kbd port): io 0x60,0x64 irq 1
 [   1.0036891] pckbc2 at acpi0 (MOU, PNP0F13) (aux port): irq 12
 [   1.0036891] fdc0 at acpi0 (FDC0, PNP0700): io 0x3f2-0x3f5,0x3f7 irq 6 
 drq 2
 [   1.0036891] qemufwcfg0 at acpi0 (FWCF, QEMU0002): io 0x510-0x51b
 [   1.0036891] ACPI: Enabled 2 GPEs in block 00 to 0F
 [   1.0036891] pckbd0 at pckbc1 (kbd slot)
 [   1.0036891] pckbc1: using irq 1 for kbd slot
 [   1.0036891] wskbd0 at pckbd0 mux 1
 [   1.0036891] pms0 at pckbc1 (aux slot)
 [   1.0036891] pckbc1: using irq 12 for aux slot
 [   1.0036891] wsmouse0 at pms0 mux 0
 [   1.0036891] pci0 at mainbus0 bus 0: configuration mode 1
 [   1.0036891] pchb0 at pci0 dev 0 function 0: Intel 82441FX (PMC) PCI 
 and Memory Controller (rev. 0x02)
 [   1.0036891] pcib0 at pci0 dev 1 function 0: Intel 82371SB (PIIX3) 
 PCI-ISA Bridge (rev. 0x00)
 [   1.0036891] piixide0 at pci0 dev 1 function 1: Intel 82371SB IDE 
 Interface (PIIX3) (rev. 0x00)
 [   1.0036891] piixide0: primary channel interrupting at ioapic0 pin 14
 [   1.0036891] atabus0 at piixide0 channel 0
 [   1.0036891] piixide0: secondary channel ignored (disabled)
 [   1.0036891] piixpm0 at pci0 dev 1 function 3: Intel 82371AB (PIIX4) 
 Power Management Controller (rev. 0x03)
 [   1.0036891] piixpm0: 24-bit timer
 [   1.0036891] piixpm0: interrupting at ioapic0 pin 9
 [   1.0036891] iic0 at piixpm0 port 0: I2C bus
 [   1.0036891] virtio0 at pci0 dev 2 function 0
 [   1.0036891] virtio0: Unknown device (id 16, rev. 0x01)
 [   1.0036891] virtio0: no matching child driver; not configured
 [   1.0036891] wm0 at pci0 dev 3 function 0: Intel i82540EM 1000BASE-T 
 Ethernet (rev. 0x03)
 [   1.0036891] wm0: interrupting at ioapic0 pin 11
 [   1.0036891] wm0: Ethernet address 52:54:00:e7:05:1f
 [   1.0036891] makphy0 at wm0 phy 1: Marvell 88E1011 Gigabit PHY, rev. 0
 [   1.0036891] makphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 
 1000baseT, 1000baseT-FDX, auto
 [   1.0036891] hdaudio0 at pci0 dev 4 function 0: HD Audio Controller
 [   1.0036891] hdaudio0: interrupting at msi0 vec 0
 [   1.0036891] hdaudio0: HDA ver. 1.0, OSS 4, ISS 4, BSS 0, SDO 1, 64-bit
 [   1.0036891] hdafg0 at hdaudio0: vendor 1af4 product 0022
 [   1.0036891] hdafg0: DAC00 2ch: Speaker [Jack]
 [   1.0036891] hdafg0: ADC01 2ch: Line In [Jack]
 [   1.0036891] hdafg0: 2ch/2ch 16000Hz 22050Hz 32000Hz 44100Hz 48000Hz 
 88200Hz 96000Hz PCM16
 [   1.0036891] audio0 at hdafg0: playback, capture, full duplex, independent
 [   1.0036891] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for playback
 [   1.0036891] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for recording
 [   1.0036891] spkr0 at audio0: PC Speaker (synthesized)
 [   1.0036891] wsbell at spkr0 not configured
 [   1.0036891] uhci0 at pci0 dev 5 function 0: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0036891] uhci0: interrupting at ioapic0 pin 10
 [   1.0036891] usb0 at uhci0: USB revision 1.0
 [   1.0036891] uhci1 at pci0 dev 5 function 1: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0036891] uhci1: interrupting at ioapic0 pin 10
 [   1.0036891] usb1 at uhci1: USB revision 1.0
 [   1.0036891] uhci2 at pci0 dev 5 function 2: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0036891] uhci2: interrupting at ioapic0 pin 11
 [   1.0036891] usb2 at uhci2: USB revision 1.0
 [   1.0036891] ehci0 at pci0 dev 5 function 7: Intel 82801I USB EHCI 
 Controller (rev. 0x03)
 [   1.0036891] ehci0: interrupting at ioapic0 pin 11
 [   1.0036891] ehci0: 3 companion controllers, 2 ports each: uhci0 uhci1 
 uhci2
 [   1.0036891] ehci0: Using DMA subregion for control data structures
 [   1.0036891] usb3 at ehci0: USB revision 2.0
 [   1.0036891] virtio1 at pci0 dev 6 function 0
 [   1.0036891] virtio1: console device (id 3, rev. 0x00)
 [   1.0036891] virtio1: no matching child driver; not configured
 [   1.0036891] virtio2 at pci0 dev 7 function 0
 [   1.0036891] virtio2: memory balloon device (id 5, rev. 0x00)
 [   1.0036891] viomb0 at virtio2: features: 0x10000000<INDIRECT_DESC>
 [   1.0036891] virtio2: interrupting at ioapic0 pin 11
 [   1.0036891] isa0 at pcib0
 [   1.0036891] attimer0 at isa0 port 0x40-0x43
 [   1.0036891] pcppi0 at isa0 port 0x61
 [   1.0036891] spkr1 at pcppi0: PC Speaker
 [   1.0036891] wsbell at spkr1 not configured
 [   1.0036891] midi0 at pcppi0: PC speaker
 [   1.0036891] sysbeep0 at pcppi0
 [   1.0036891] attimer0: attached to pcppi0
 [   1.0036891] acpicpu0 at cpu0: ACPI CPU
 [   1.0036891] acpicpu1 at cpu1: ACPI CPU
 [   1.0036891] acpicpu2 at cpu2: ACPI CPU
 [   1.0036891] acpicpu3 at cpu3: ACPI CPU
 [   1.4185731] atapibus0 at atabus0: 2 targets
 [   1.4304302] uhub0 at usb1: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.4422904] uhub1 at usb3: NetBSD (0x0000) EHCI root hub (0x0000), 
 class 9/0, rev 2.00/1.00, addr 1
 [   1.4541542] uhub2 at usb0: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.4660258] uhub3 at usb2: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.4801094] cd0 at atapibus0 drive 1: <QEMU DVD-ROM, QM00002, 2.5+> 
 cdrom removable
 [   1.4902859] wd0 at atabus0 drive 0
 [   1.4902859] wd0: <QEMU HARDDISK>
 [   1.4902859] wd0: 20480 MB, 41610 cyl, 16 head, 63 sec, 512 bytes/sect 
 x 41943040 sectors
 [   1.5137218] dk0 at wd0: "EFI", 262144 blocks at 4096, type: msdos
 [   1.5303644] dk1 at wd0: "NetBSD", 16777216 blocks at 266240, type: ffs
 [   1.5303644] dk2 at wd0: "syscgd", 24895488 blocks at 17043456, type: cgd
 [   2.8062802] uhidev0 at uhub1 port 1 configuration 1 interface 0
 [   2.8062802] uhidev0: QEMU (0x0627) QEMU USB Tablet (0x0001), rev 
 2.00/0.00, addr 2, iclass 3/0
 [   2.8191260] ums0 at uhidev0: 3 buttons and Z dir
 [   2.8306825] wsmouse1 at ums0 mux 0
 [   2.8306825] swwdog0: software watchdog initialized
 [   2.8655213] WARNING: 2 errors while detecting hardware; check system log.
 [   2.8826796] boot device: cd0
 [   2.9129672] root on cd0a dumps on cd0b
 [   2.9485480] root file system type: cd9660
 [   2.9485480] kern.module.path=/stand/amd64/10.99.10/modules
 Created tmpfs /dev (1835008 byte, 3552 inodes)


 You are using a serial console, we do not know your terminal emulation.
 Please select one, typical values are:

          vt100
          ansi
          xterm

 Terminal type (just hit ENTER for 'vt220'): xterm
 # sysctl -w kern.detachall=1
 kern.detachall: 0 -> 1
 # uname -a
 NetBSD  10.99.10 NetBSD 10.99.10 (GENERIC) #0: Tue Jun 25 16:58:24 UTC 
 2024  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC 
 amd64
 # shutdown -p now
 Shutdown NOW!
 shutdown: [pid 507]
 # wall: You have write permission turned off; no reply possible
 wall: Cannot stat `/var/run/utmp': No such file or directory
 shutdown: poweroff by root:

 System shutdown time has arrived

 About to run shutdown hooks...
 cron not running? (check /var/run/cron.pid).
 inetd not running? (check /var/run/inetd.pid).
 Saved entropy to /var/db/entropy-file.
 Forcibly unmounting /tmp
 Forcibly unmounting /var
 Forcibly unmounting /etc
 Removing block-type swap devices
 Wed Jun 26 11:44:34 UTC 2024

 Done running shutdown hooks.
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `console': Bad file descriptor
 [ 151.0339731] syncing disks... done
 [ 151.1047106] wsmouse1: detached
 [ 151.1186892] ums0: detached
 [ 151.1186892] uhidev0: detached
 [ 151.1186892] sysbeep0: detached
 [ 151.1284332] midi0: detached
 [ 151.1284332] spkr1: detached
 [ 151.1284332] spkr0: detached
 [ 151.1284332] dk2 at wd0 (syscgd) deleted
 [ 151.1402925] dk1 at wd0 (NetBSD) deleted
 [ 151.1402925] dk0 at wd0 (EFI) deleted
 [ 151.1521717] wd0: detached
 [ 151.1521717] uhub3: detached
 [ 151.1521717] uhub2: detached
 [ 151.1642215] uhub1: detached
 [ 151.1642215] uhub0: detached
 [ 151.1642215] pcppi0: detached
 [ 151.1642215] attimer0: detached
 [ 151.1768930] audio0: detached
 [ 151.1768930] wsmouse0: detached
 [ 151.1768930] wskbd0: detached
 [ 151.1877675] isa0: detached
 [ 151.1877675] usb3: detached
 [ 151.1877675] usb2: detached
 [ 151.1995984] usb1: detached
 [ 151.1995984] usb0: detached
 [ 151.1995984] hdafg0: detached
 [ 151.2114529] makphy0: detached
 [ 151.2114529] iic0: detached
 [ 151.2114529] acpicpu3: detached
 [ 151.2233436] acpicpu2: detached
 [ 151.2233436] acpicpu1: detached
 [ 151.2233436] acpicpu0: detached
 [ 151.2351655] virtio1: detached
 [ 151.2351655] ehci0: detached
 [ 151.2470231] uhci2: detached
 [ 151.2470231] uhci1: detached
 [ 151.2588757] uhci0: detached
 [ 151.2588757] hdaudio0: detached
 [ 151.2588757] Skipping crash dump on recursive panic
 [ 151.2708496] panic: kernel diagnostic assertion "!dv->dv_detach_done" 
 failed: file "/usr/src/sys/kern/subr_autoconf.c", line 2916 makphy0
 [ 151.2834657] cpu3: Begin traceback...
 [ 151.2834657] vpanic() at netbsd:vpanic+0x171
 [ 151.2944786] kern_assert() at netbsd:kern_assert+0x4b
 [ 151.3063340] config_detach() at netbsd:config_detach+0x67
 [ 151.3182165] mii_detach() at netbsd:mii_detach+0xde
 [ 151.3182165] wm_detach() at netbsd:wm_detach+0x3f9
 [ 151.3301923] config_detach_release() at netbsd:config_detach_release+0x1fc
 [ 151.3419109] config_detach_all() at netbsd:config_detach_all+0xd1
 [ 151.3538233] cpu_reboot() at netbsd:cpu_reboot+0x1b9
 [ 151.3656482] kern_reboot() at netbsd:kern_reboot+0x93
 [ 151.3656482] sys_reboot() at netbsd:sys_reboot+0x63
 [ 151.3775400] syscall() at netbsd:syscall+0x112
 [ 151.3775400] --- syscall (number 208) ---
 [ 151.3894108] netbsd:syscall+0x112:
 [ 151.3894108] cpu3: End traceback...
 [ 151.3894108] fatal breakpoint trap in supervisor mode
 [ 151.4012525] trap type 1 code 0 rip 0xffffffff80235415 cs 0x8 rflags 
 0x202 cr2 0x7573dedce420 ilevel 0 rsp 0xffff9080b4262c60
 [ 151.4131624] curlwp 0xffffbddf0ea6a000 pid 507.507 lowest kstack 
 0xffff9080b425e2c0
 Stopped in pid 507.507 (halt) at        netbsd:breakpoint+0x5:  leave
 breakpoint() at netbsd:breakpoint+0x5
 vpanic() at netbsd:vpanic+0x171
 kern_assert() at netbsd:kern_assert+0x4b
 config_detach() at netbsd:config_detach+0x67
 mii_detach() at netbsd:mii_detach+0xde
 wm_detach() at netbsd:wm_detach+0x3f9
 config_detach_release() at netbsd:config_detach_release+0x1fc
 config_detach_all() at netbsd:config_detach_all+0xd1
 cpu_reboot() at netbsd:cpu_reboot+0x1b9
 kern_reboot() at netbsd:kern_reboot+0x93
 sys_reboot() at netbsd:sys_reboot+0x63
 syscall() at netbsd:syscall+0x112
 --- syscall (number 208) ---
 netbsd:syscall+0x112:
 ds          8
 es          3
 fs          180
 gs          2c10
 rdi         0
 rsi         3f8
 rbp         ffff9080b4262c60
 rbx         ffffffff813f4610    ostype+0x51adf
 rdx         1
 rcx         ffffffffffffff
 rax         800000000000000
 r8          0
 r9          0
 r10         0
 r11         0
 r12         ffff9080b4262ca8
 r13         4
 r14         ffffffff
 r15         ffff908003eab458
 rip         ffffffff80235415    breakpoint+0x5
 cs          8
 rflags      202
 rsp         ffff9080b4262c60
 ss          10
 netbsd:breakpoint+0x5:  leave
 db{3}>

 ```


 On 6/25/24 17:02, riastradh@NetBSD.org wrote:
 > Synopsis: Kernel panic when shutting down a virtual machine with Virtio devices
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: riastradh@NetBSD.org
 > State-Changed-When: Tue, 25 Jun 2024 15:02:39 +0000
 > State-Changed-Why:
 > Thanks for the report!  Can you see if you can still reproduce the
 > symptom?  And, can you also try reproducing the symptom after running
 > `sysctl -w kern.detachall=1' (each time you boot)?
 > 
 > You can find daily kernel builds for testing here:
 > https://nycdn.netbsd.org/
 > 
 > 
 > 

From: Taylor R Campbell <campbell@mumble.net>
To: =?UTF-8?Q?Roddy_Gonz=C3=A1lez?= <roddy.gonzalez.89@gmail.com>
Cc: gnats-bugs@netbsd.org, kern-bug-people@netbsd.org,
	netbsd-bugs@netbsd.org, gnats-admin@netbsd.org
Subject: Re: kern/58335 (Kernel panic when shutting down a virtual machine
	with Virtio devices)
Date: Wed, 26 Jun 2024 14:39:05 +0000

 This is a multi-part message in MIME format.
 --=_ml7q+P8YFLTA7qSAPcDHHBHCSIXmg0yj

 Thanks!  Looks like we have another bug, and that one's a little more
 work to deal with.

 Can you try reverting this change?

 https://mail-index.netbsd.org/source-changes/2024/06/25/msg151955.html

 That change disables access to a code path, but I want to see if I
 fixed that code path too.

 --=_ml7q+P8YFLTA7qSAPcDHHBHCSIXmg0yj
 Content-Type: text/plain; charset="ISO-8859-1"; name="virtio_shutdown"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="virtio_shutdown.patch"

 diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c
 index 5ede6a6c448a..30e30721e23e 100644
 --- a/sys/dev/pci/virtio_pci.c
 +++ b/sys/dev/pci/virtio_pci.c
 @@ -174,7 +174,7 @@ static bool	virtio_pci_msix_enabled(struct virtio_pci_s=
 oftc *);
 =20
  CFATTACH_DECL3_NEW(virtio_pci, sizeof(struct virtio_pci_softc),
      virtio_pci_match, virtio_pci_attach, virtio_pci_detach, NULL,
 -    virtio_pci_rescan, NULL, 0);
 +    virtio_pci_rescan, NULL, DVF_DETACH_SHUTDOWN);
 =20
  static const struct virtio_ops virtio_pci_ops_09 =3D {
  	.kick =3D virtio_pci_kick_09,

 --=_ml7q+P8YFLTA7qSAPcDHHBHCSIXmg0yj--

From: =?UTF-8?Q?Roddy_Gonz=C3=A1lez?= <roddy.gonzalez.89@gmail.com>
To: Taylor R Campbell <campbell@mumble.net>
Cc: gnats-bugs@netbsd.org, kern-bug-people@netbsd.org,
 netbsd-bugs@netbsd.org, gnats-admin@netbsd.org
Subject: Re: kern/58335 (Kernel panic when shutting down a virtual machine
 with Virtio devices)
Date: Fri, 28 Jun 2024 12:26:43 +0200

 Hi! Thanks!

 I applied the patch and rebuilt. Same results.

 This is with kern.detachall = 0


 ```
    \\-__,------,___.
     \\        __,---`  NetBSD/x86 EFI Boot (x64)
      \\       `---,_.  Revision 1.2 (Thu Jun 27 16:24:39 UTC 2024)
       \\-,_____,.---`
        \\
         \\
          \\

  > boot
 21697920+795008+1302144 [967040+1416528+1038924]=0x1b44418
 Loading /stand/amd64/10.99.10/modules/cd9660/cd9660.kmod
 [   1.0000000] cpu_rng: rdrand/rdseed
 [   1.0000000] entropy: ready
 [   1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
 [   1.0000000]     2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 
 2013,
 [   1.0000000]     2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 
 2023,
 [   1.0000000]     2024
 [   1.0000000]     The NetBSD Foundation, Inc.  All rights reserved.
 [   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
 [   1.0000000]     The Regents of the University of California.  All 
 rights reserved.

 [   1.0000000] NetBSD 10.99.10 (GENERIC) #0: Thu Jun 27 20:02:04 CEST 2024
 [   1.0000000] 	roddy@apollo:/home/roddy/obj/sys/arch/amd64/compile/GENERIC
 [   1.0000000] total memory = 2043 MB
 [   1.0000000] avail memory = 1948 MB
 [   1.0000000] WARNING: module error: module `cd9660' pushed by boot 
 loader already exists
 [   1.0000040] efi: systbl at pa 7f9ed018
 [   1.0000040] mainbus0 (root)
 [   1.0000040] ACPI: RSDP 0x000000007FB7D014 000024 (v02 BOCHS )
 [   1.0000040] ACPI: XSDT 0x000000007FB7C0E8 000044 (v01 BOCHS  BXPC 
 00000001      01000013)
 [   1.0000040] ACPI: FACP 0x000000007FB79000 000074 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: DSDT 0x000000007FB7A000 001792 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: FACS 0x000000007FBDC000 000040
 [   1.0000040] ACPI: APIC 0x000000007FB78000 000090 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: WAET 0x000000007FB77000 000028 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: BGRT 0x000000007FB76000 000038 (v01 INTEL  EDK2 
 00000002      01000013)
 [   1.0000040] ACPI: 1 ACPI AML tables successfully acquired and loaded
 [   1.0000040] ioapic0 at mainbus0 apid 0
 [   1.0000040] cpu0 at mainbus0 apid 0
 [   1.0000040] cpu0: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu0: node 0, package 0, core 0, smt 0
 [   1.0000040] cpu1 at mainbus0 apid 1
 [   1.0000040] cpu1: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu1: node 0, package 1, core 0, smt 0
 [   1.0000040] cpu2 at mainbus0 apid 2
 [   1.0000040] cpu2: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu2: node 0, package 2, core 0, smt 0
 [   1.0000040] cpu3 at mainbus0 apid 3
 [   1.0000040] cpu3: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu3: node 0, package 3, core 0, smt 0
 [   1.0000040] acpi0 at mainbus0: Intel ACPICA 20230628
 [   1.0000040] LNKS: BIOS IRQ 10 for 0.1.INTA is invalid
 [   1.0000040] acpi0: fixed power button present
 [   1.0168883] com0 at acpi0 (COM2, PNP0501-2): io 0x2f8-0x2ff irq 3
 [   1.0168883] com0: ns16550a, 16-byte FIFO
 [   1.0168883] com1 at acpi0 (COM1, PNP0501-1): io 0x3f8-0x3ff irq 4
 [   1.0168883] com1: ns16550a, 16-byte FIFO
 [   1.0168883] com1: console
 [   1.0168883] pckbc1 at acpi0 (KBD, PNP0303) (kbd port): io 0x60,0x64 irq 1
 [   1.0168883] pckbc2 at acpi0 (MOU, PNP0F13) (aux port): irq 12
 [   1.0168883] fdc0 at acpi0 (FDC0, PNP0700): io 0x3f2-0x3f5,0x3f7 irq 6 
 drq 2
 [   1.0168883] qemufwcfg0 at acpi0 (FWCF, QEMU0002): io 0x510-0x51b
 [   1.0168883] ACPI: Enabled 2 GPEs in block 00 to 0F
 [   1.0168883] pckbd0 at pckbc1 (kbd slot)
 [   1.0168883] pckbc1: using irq 1 for kbd slot
 [   1.0168883] wskbd0 at pckbd0 mux 1
 [   1.0168883] pms0 at pckbc1 (aux slot)
 [   1.0168883] pckbc1: using irq 12 for aux slot
 [   1.0168883] wsmouse0 at pms0 mux 0
 [   1.0168883] pci0 at mainbus0 bus 0: configuration mode 1
 [   1.0168883] pchb0 at pci0 dev 0 function 0: Intel 82441FX (PMC) PCI 
 and Memory Controller (rev. 0x02)
 [   1.0168883] pcib0 at pci0 dev 1 function 0: Intel 82371SB (PIIX3) 
 PCI-ISA Bridge (rev. 0x00)
 [   1.0168883] piixide0 at pci0 dev 1 function 1: Intel 82371SB IDE 
 Interface (PIIX3) (rev. 0x00)
 [   1.0168883] piixide0: primary channel interrupting at ioapic0 pin 14
 [   1.0168883] atabus0 at piixide0 channel 0
 [   1.0168883] piixide0: secondary channel ignored (disabled)
 [   1.0168883] piixpm0 at pci0 dev 1 function 3: Intel 82371AB (PIIX4) 
 Power Management Controller (rev. 0x03)
 [   1.0168883] piixpm0: 24-bit timer
 [   1.0168883] piixpm0: interrupting at ioapic0 pin 9
 [   1.0168883] iic0 at piixpm0 port 0: I2C bus
 [   1.0168883] virtio0 at pci0 dev 2 function 0
 [   1.0168883] virtio0: Unknown device (id 16, rev. 0x01)
 [   1.0168883] virtio0: no matching child driver; not configured
 [   1.0168883] wm0 at pci0 dev 3 function 0: Intel i82540EM 1000BASE-T 
 Ethernet (rev. 0x03)
 [   1.0168883] wm0: interrupting at ioapic0 pin 11
 [   1.0168883] wm0: Ethernet address 52:54:00:e7:05:1f
 [   1.0168883] makphy0 at wm0 phy 1: Marvell 88E1011 Gigabit PHY, rev. 0
 [   1.0168883] makphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 
 1000baseT, 1000baseT-FDX, auto
 [   1.0168883] hdaudio0 at pci0 dev 4 function 0: HD Audio Controller
 [   1.0168883] hdaudio0: interrupting at msi0 vec 0
 [   1.0168883] hdaudio0: HDA ver. 1.0, OSS 4, ISS 4, BSS 0, SDO 1, 64-bit
 [   1.0168883] hdafg0 at hdaudio0: vendor 1af4 product 0022
 [   1.0168883] hdafg0: DAC00 2ch: Speaker [Jack]
 [   1.0168883] hdafg0: ADC01 2ch: Line In [Jack]
 [   1.0168883] hdafg0: 2ch/2ch 16000Hz 22050Hz 32000Hz 44100Hz 48000Hz 
 88200Hz 96000Hz PCM16
 [   1.0168883] audio0 at hdafg0: playback, capture, full duplex, independent
 [   1.0168883] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for playback
 [   1.0168883] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for recording
 [   1.0168883] spkr0 at audio0: PC Speaker (synthesized)
 [   1.0168883] wsbell at spkr0 not configured
 [   1.0168883] uhci0 at pci0 dev 5 function 0: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0168883] uhci0: interrupting at ioapic0 pin 10
 [   1.0168883] usb0 at uhci0: USB revision 1.0
 [   1.0168883] uhci1 at pci0 dev 5 function 1: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0168883] uhci1: interrupting at ioapic0 pin 10
 [   1.0168883] usb1 at uhci1: USB revision 1.0
 [   1.0168883] uhci2 at pci0 dev 5 function 2: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0168883] uhci2: interrupting at ioapic0 pin 11
 [   1.0168883] usb2 at uhci2: USB revision 1.0
 [   1.0168883] ehci0 at pci0 dev 5 function 7: Intel 82801I USB EHCI 
 Controller (rev. 0x03)
 [   1.0168883] ehci0: interrupting at ioapic0 pin 11
 [   1.0168883] ehci0: 3 companion controllers, 2 ports each: uhci0 uhci1 
 uhci2
 [   1.0168883] ehci0: Using DMA subregion for control data structures
 [   1.0168883] usb3 at ehci0: USB revision 2.0
 [   1.0168883] virtio1 at pci0 dev 6 function 0
 [   1.0168883] virtio1: console device (id 3, rev. 0x00)
 [   1.0168883] virtio1: no matching child driver; not configured
 [   1.0168883] virtio2 at pci0 dev 7 function 0
 [   1.0168883] virtio2: memory balloon device (id 5, rev. 0x00)
 [   1.0168883] viomb0 at virtio2: features: 0x10000000<INDIRECT_DESC>
 [   1.0168883] virtio2: interrupting at ioapic0 pin 11
 [   1.0168883] isa0 at pcib0
 [   1.0168883] attimer0 at isa0 port 0x40-0x43
 [   1.0168883] pcppi0 at isa0 port 0x61
 [   1.0168883] spkr1 at pcppi0: PC Speaker
 [   1.0168883] wsbell at spkr1 not configured
 [   1.0168883] midi0 at pcppi0: PC speaker
 [   1.0168883] sysbeep0 at pcppi0
 [   1.0168883] attimer0: attached to pcppi0
 [   1.0168883] acpicpu0 at cpu0: ACPI CPU
 [   1.0168883] acpicpu1 at cpu1: ACPI CPU
 [   1.0168883] acpicpu2 at cpu2: ACPI CPU
 [   1.0168883] acpicpu3 at cpu3: ACPI CPU
 [   1.6401901] atapibus0 at atabus0: 2 targets
 [   1.6511211] cd0 at atapibus0 drive 1: <QEMU DVD-ROM, QM00002, 2.5+> 
 cdrom removable
 [   1.6618814] uhub0 at usb0: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.6727652] uhub1 at usb1: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.6836037] uhub2 at usb3: NetBSD (0x0000) EHCI root hub (0x0000), 
 class 9/0, rev 2.00/1.00, addr 1
 [   1.6943934] uhub3 at usb2: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.7100007] wd0 at atabus0 drive 0
 [   1.7100007] wd0: <QEMU HARDDISK>
 [   1.7161933] wd0: 20480 MB, 41610 cyl, 16 head, 63 sec, 512 bytes/sect 
 x 41943040 sectors
 [   1.7485961] dk0 at wd0: "EFI", 262144 blocks at 4096, type: msdos
 [   1.7485961] dk1 at wd0: "NetBSD", 16777216 blocks at 266240, type: ffs
 [   1.7595366] dk2 at wd0: "syscgd", 24895488 blocks at 17043456, type: cgd
 [   2.9305348] uhidev0 at uhub2 port 1 configuration 1 interface 0
 [   2.9413273] uhidev0: QEMU (0x0627) QEMU USB Tablet (0x0001), rev 
 2.00/0.00, addr 2, iclass 3/0
 [   2.9629767] ums0 at uhidev0: 3 buttons and Z dir
 [   2.9629767] wsmouse1 at ums0 mux 0
 [   2.9738353] swwdog0: software watchdog initialized
 [   3.0063266] WARNING: 2 errors while detecting hardware; check system log.
 [   3.0063266] boot device: cd0
 [   3.0497265] root on cd0a dumps on cd0b
 [   3.0930370] root file system type: cd9660
 [   3.1071073] kern.module.path=/stand/amd64/10.99.10/modules
 Created tmpfs /dev (1835008 byte, 3552 inodes)


 You are using a serial console, we do not know your terminal emulation.
 Please select one, typical values are:

          vt100
          ansi
          xterm

 Terminal type (just hit ENTER for 'vt220'): xterm
 # uname -a
 NetBSD  10.99.10 NetBSD 10.99.10 (GENERIC) #0: Thu Jun 27 20:02:04 CEST 
 2024  roddy@apollo:/home/roddy/obj/sys/arch/amd64/compile/GENERIC amd64
 # sysctl kern.detachall
 kern.detachall = 0
 # shutdown -r now
 Shutdown NOW!
 shutdown: [pid 507]
 # wall: You have write permission turned off; no reply possible
 wall: Cannot stat `/var/run/utmp': No such file or directory
 shutdown: reboot by root:

 System shutdown time has arrived

 About to run shutdown hooks...
 cron not running? (check /var/run/cron.pid).
 inetd not running? (check /var/run/inetd.pid).
 Saved entropy to /var/db/entropy-file.
 Forcibly unmounting /tmp
 Forcibly unmounting /var
 Forcibly unmounting /etc
 Removing block-type swap devices
 Fri Jun 28 10:10:54 UTC 2024

 Done running shutdown hooks.
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `console': Bad file descriptor
 [  86.3064332] syncing disks... done
 [  86.3931285] sysbeep0: detached
 [  86.3931285] midi0: detached
 [  86.4039573] dk2 at wd0 (syscgd) deleted
 [  86.4039573] dk1 at wd0 (NetBSD) deleted
 [  86.4039573] dk0 at wd0 (EFI) deleted
 [  86.4148699] wd0: detached
 [  86.4148699] uhub3: detached
 [  86.4148699] uhub1: detached
 [  86.4257710] uhub0: detached
 [  86.4257710] usb2: detached
 [  86.4257710] usb1: detached
 [  86.4377982] usb0: detached
 [  86.4377982] iic0: detached
 [  86.4377982] virtio1: detached
 [  86.4474575] uhci2: detached
 [  86.4474575] uhci1: detached
 [  86.4583100] uhci0: detached
 [  86.4691167] makphy0: detached
 [  86.4798988] wm0: detached
 [  86.4798988] virtio0: detached
 [  86.4798988] pchb0: detached
 [  86.5015733] cd0: detached
 [  86.5015733] atapibus0: detached
 [  86.5015733] atabus0: detached
 [  86.5124443] rebooting...
 ```

 And this is with kern.detachall = 1


 ```
    \\-__,------,___.
     \\        __,---`  NetBSD/x86 EFI Boot (x64)
      \\       `---,_.  Revision 1.2 (Thu Jun 27 16:24:39 UTC 2024)
       \\-,_____,.---`
        \\
         \\
          \\

  > boot
 21697920+795008+1302144 [967040+1416528+1038924]=0x1b44418
 Loading /stand/amd64/10.99.10/modules/cd9660/cd9660.kmod
 [   1.0000000] cpu_rng: rdrand/rdseed
 [   1.0000000] entropy: ready
 [   1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
 [   1.0000000]     2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 
 2013,
 [   1.0000000]     2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 
 2023,
 [   1.0000000]     2024
 [   1.0000000]     The NetBSD Foundation, Inc.  All rights reserved.
 [   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
 [   1.0000000]     The Regents of the University of California.  All 
 rights reserved.

 [   1.0000000] NetBSD 10.99.10 (GENERIC) #0: Thu Jun 27 20:02:04 CEST 2024
 [   1.0000000] 	roddy@apollo:/home/roddy/obj/sys/arch/amd64/compile/GENERIC
 [   1.0000000] total memory = 2043 MB
 [   1.0000000] avail memory = 1948 MB
 [   1.0000000] WARNING: module error: module `cd9660' pushed by boot 
 loader already exists
 [   1.0000040] efi: systbl at pa 7f9ed018
 [   1.0000040] mainbus0 (root)
 [   1.0000040] ACPI: RSDP 0x000000007FB7D014 000024 (v02 BOCHS )
 [   1.0000040] ACPI: XSDT 0x000000007FB7C0E8 000044 (v01 BOCHS  BXPC 
 00000001      01000013)
 [   1.0000040] ACPI: FACP 0x000000007FB79000 000074 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: DSDT 0x000000007FB7A000 001792 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: FACS 0x000000007FBDC000 000040
 [   1.0000040] ACPI: APIC 0x000000007FB78000 000090 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: WAET 0x000000007FB77000 000028 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: BGRT 0x000000007FB76000 000038 (v01 INTEL  EDK2 
 00000002      01000013)
 [   1.0000040] ACPI: 1 ACPI AML tables successfully acquired and loaded
 [   1.0000040] ioapic0 at mainbus0 apid 0
 [   1.0000040] cpu0 at mainbus0 apid 0
 [   1.0000040] cpu0: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu0: node 0, package 0, core 0, smt 0
 [   1.0000040] cpu1 at mainbus0 apid 1
 [   1.0000040] cpu1: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu1: node 0, package 1, core 0, smt 0
 [   1.0000040] cpu2 at mainbus0 apid 2
 [   1.0000040] cpu2: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu2: node 0, package 2, core 0, smt 0
 [   1.0000040] cpu3 at mainbus0 apid 3
 [   1.0000040] cpu3: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu3: node 0, package 3, core 0, smt 0
 [   1.0000040] acpi0 at mainbus0: Intel ACPICA 20230628
 [   1.0000040] LNKS: BIOS IRQ 10 for 0.1.INTA is invalid
 [   1.0000040] acpi0: fixed power button present
 [   1.0355392] com0 at acpi0 (COM2, PNP0501-2): io 0x2f8-0x2ff irq 3
 [   1.0355392] com0: ns16550a, 16-byte FIFO
 [   1.0355392] com1 at acpi0 (COM1, PNP0501-1): io 0x3f8-0x3ff irq 4
 [   1.0355392] com1: ns16550a, 16-byte FIFO
 [   1.0355392] com1: console
 [   1.0355392] pckbc1 at acpi0 (KBD, PNP0303) (kbd port): io 0x60,0x64 irq 1
 [   1.0355392] pckbc2 at acpi0 (MOU, PNP0F13) (aux port): irq 12
 [   1.0355392] fdc0 at acpi0 (FDC0, PNP0700): io 0x3f2-0x3f5,0x3f7 irq 6 
 drq 2
 [   1.0355392] qemufwcfg0 at acpi0 (FWCF, QEMU0002): io 0x510-0x51b
 [   1.0355392] ACPI: Enabled 2 GPEs in block 00 to 0F
 [   1.0355392] pckbd0 at pckbc1 (kbd slot)
 [   1.0355392] pckbc1: using irq 1 for kbd slot
 [   1.0355392] wskbd0 at pckbd0 mux 1
 [   1.0355392] pms0 at pckbc1 (aux slot)
 [   1.0355392] pckbc1: using irq 12 for aux slot
 [   1.0355392] wsmouse0 at pms0 mux 0
 [   1.0355392] pci0 at mainbus0 bus 0: configuration mode 1
 [   1.0355392] pchb0 at pci0 dev 0 function 0: Intel 82441FX (PMC) PCI 
 and Memory Controller (rev. 0x02)
 [   1.0355392] pcib0 at pci0 dev 1 function 0: Intel 82371SB (PIIX3) 
 PCI-ISA Bridge (rev. 0x00)
 [   1.0355392] piixide0 at pci0 dev 1 function 1: Intel 82371SB IDE 
 Interface (PIIX3) (rev. 0x00)
 [   1.0355392] piixide0: primary channel interrupting at ioapic0 pin 14
 [   1.0355392] atabus0 at piixide0 channel 0
 [   1.0355392] piixide0: secondary channel ignored (disabled)
 [   1.0355392] piixpm0 at pci0 dev 1 function 3: Intel 82371AB (PIIX4) 
 Power Management Controller (rev. 0x03)
 [   1.0355392] piixpm0: 24-bit timer
 [   1.0355392] piixpm0: interrupting at ioapic0 pin 9
 [   1.0355392] iic0 at piixpm0 port 0: I2C bus
 [   1.0355392] virtio0 at pci0 dev 2 function 0
 [   1.0355392] virtio0: Unknown device (id 16, rev. 0x01)
 [   1.0355392] virtio0: no matching child driver; not configured
 [   1.0355392] wm0 at pci0 dev 3 function 0: Intel i82540EM 1000BASE-T 
 Ethernet (rev. 0x03)
 [   1.0355392] wm0: interrupting at ioapic0 pin 11
 [   1.0355392] wm0: Ethernet address 52:54:00:e7:05:1f
 [   1.0355392] makphy0 at wm0 phy 1: Marvell 88E1011 Gigabit PHY, rev. 0
 [   1.0355392] makphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 
 1000baseT, 1000baseT-FDX, auto
 [   1.0355392] hdaudio0 at pci0 dev 4 function 0: HD Audio Controller
 [   1.0355392] hdaudio0: interrupting at msi0 vec 0
 [   1.0355392] hdaudio0: HDA ver. 1.0, OSS 4, ISS 4, BSS 0, SDO 1, 64-bit
 [   1.0355392] hdafg0 at hdaudio0: vendor 1af4 product 0022
 [   1.0355392] hdafg0: DAC00 2ch: Speaker [Jack]
 [   1.0355392] hdafg0: ADC01 2ch: Line In [Jack]
 [   1.0355392] hdafg0: 2ch/2ch 16000Hz 22050Hz 32000Hz 44100Hz 48000Hz 
 88200Hz 96000Hz PCM16
 [   1.0355392] audio0 at hdafg0: playback, capture, full duplex, independent
 [   1.0355392] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for playback
 [   1.0355392] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for recording
 [   1.0355392] spkr0 at audio0: PC Speaker (synthesized)
 [   1.0355392] wsbell at spkr0 not configured
 [   1.0355392] uhci0 at pci0 dev 5 function 0: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0355392] uhci0: interrupting at ioapic0 pin 10
 [   1.0355392] usb0 at uhci0: USB revision 1.0
 [   1.0355392] uhci1 at pci0 dev 5 function 1: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0355392] uhci1: interrupting at ioapic0 pin 10
 [   1.0355392] usb1 at uhci1: USB revision 1.0
 [   1.0355392] uhci2 at pci0 dev 5 function 2: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0355392] uhci2: interrupting at ioapic0 pin 11
 [   1.0355392] usb2 at uhci2: USB revision 1.0
 [   1.0355392] ehci0 at pci0 dev 5 function 7: Intel 82801I USB EHCI 
 Controller (rev. 0x03)
 [   1.0355392] ehci0: interrupting at ioapic0 pin 11
 [   1.0355392] ehci0: 3 companion controllers, 2 ports each: uhci0 uhci1 
 uhci2
 [   1.0355392] ehci0: Using DMA subregion for control data structures
 [   1.0355392] usb3 at ehci0: USB revision 2.0
 [   1.0355392] virtio1 at pci0 dev 6 function 0
 [   1.0355392] virtio1: console device (id 3, rev. 0x00)
 [   1.0355392] virtio1: no matching child driver; not configured
 [   1.0355392] virtio2 at pci0 dev 7 function 0
 [   1.0355392] virtio2: memory balloon device (id 5, rev. 0x00)
 [   1.0355392] viomb0 at virtio2: features: 0x10000000<INDIRECT_DESC>
 [   1.0355392] virtio2: interrupting at ioapic0 pin 11
 [   1.0355392] isa0 at pcib0
 [   1.0355392] attimer0 at isa0 port 0x40-0x43
 [   1.0355392] pcppi0 at isa0 port 0x61
 [   1.0355392] spkr1 at pcppi0: PC Speaker
 [   1.0355392] wsbell at spkr1 not configured
 [   1.0355392] midi0 at pcppi0: PC speaker
 [   1.0355392] sysbeep0 at pcppi0
 [   1.0355392] attimer0: attached to pcppi0
 [   1.0355392] acpicpu0 at cpu0: ACPI CPU
 [   1.0355392] acpicpu1 at cpu1: ACPI CPU
 [   1.0355392] acpicpu2 at cpu2: ACPI CPU
 [   1.0355392] acpicpu3 at cpu3: ACPI CPU
 [   1.4839499] atapibus0 at atabus0: 2 targets
 [   1.4938933] uhub0 at usb3: NetBSD (0x0000) EHCI root hub (0x0000), 
 class 9/0, rev 2.00/1.00, addr 1
 [   1.5038242] uhub1 at usb0: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.5137981] uhub2 at usb2: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.5237390] uhub3 at usb1: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.5337886] cd0 at atapibus0 drive 1: <QEMU DVD-ROM, QM00002, 2.5+> 
 cdrom removable
 [   1.5435583] wd0 at atabus0 drive 0
 [   1.5534936] wd0: <QEMU HARDDISK>
 [   1.5534936] wd0: 20480 MB, 41610 cyl, 16 head, 63 sec, 512 bytes/sect 
 x 41943040 sectors
 [   1.5832298] dk0 at wd0: "EFI", 262144 blocks at 4096, type: msdos
 [   1.5832298] dk1 at wd0: "NetBSD", 16777216 blocks at 266240, type: ffs
 [   1.5965614] dk2 at wd0: "syscgd", 24895488 blocks at 17043456, type: cgd
 [   2.6452958] uhidev0 at uhub0 port 1 configuration 1 interface 0
 [   2.6452958] uhidev0: QEMU (0x0627) QEMU USB Tablet (0x0001), rev 
 2.00/0.00, addr 2, iclass 3/0
 [   2.6652005] ums0 at uhidev0: 3 buttons and Z dir
 [   2.6765132] wsmouse1 at ums0 mux 0
 [   2.6765132] swwdog0: software watchdog initialized
 [   2.7148703] WARNING: 2 errors while detecting hardware; check system log.
 [   2.7279513] boot device: cd0
 [   2.7545127] root on cd0a dumps on cd0b
 [   2.7942253] root file system type: cd9660
 [   2.8055159] kern.module.path=/stand/amd64/10.99.10/modules
 Created tmpfs /dev (1835008 byte, 3552 inodes)


 You are using a serial console, we do not know your terminal emulation.
 Please select one, typical values are:

          vt100
          ansi
          xterm

 Terminal type (just hit ENTER for 'vt220'): xterm
 # sysctl -w kern.detachall=1
 kern.detachall: 0 -> 1
 # uname -a
 NetBSD  10.99.10 NetBSD 10.99.10 (GENERIC) #0: Thu Jun 27 20:02:04 CEST 
 2024  roddy@apollo:/home/roddy/obj/sys/arch/amd64/compile/GENERIC amd64
 # shutdown -p now
 Shutdown NOW!
 shutdown: [pid 507]
 # wall: You have write permission turned off; no reply possible
 wall: Cannot stat `/var/run/utmp': No such file or directory
 shutdown: poweroff by root:

 System shutdown time has arrived

 About to run shutdown hooks...
 cron not running? (check /var/run/cron.pid).
 inetd not running? (check /var/run/inetd.pid).
 Saved entropy to /var/db/entropy-file.
 Forcibly unmounting /tmp
 Forcibly unmounting /var
 Forcibly unmounting /etc
 Removing block-type swap devices
 Fri Jun 28 10:24:39 UTC 2024

 Done running shutdown hooks.
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `console': Bad file descriptor
 [ 420.0638423] syncing disks... done
 [ 420.1332980] wsmouse1: detached
 [ 420.1448123] ums0: detached
 [ 420.1448123] uhidev0: detached
 [ 420.1448123] sysbeep0: detached
 [ 420.1549217] midi0: detached
 [ 420.1549217] spkr1: detached
 [ 420.1549217] spkr0: detached
 [ 420.1630510] dk2 at wd0 (syscgd) deleted
 [ 420.1630510] dk1 at wd0 (NetBSD) deleted
 [ 420.1630510] dk0 at wd0 (EFI) deleted
 [ 420.1730377] wd0: detached
 [ 420.1730377] uhub3: detached
 [ 420.1730377] uhub2: detached
 [ 420.1841411] uhub1: detached
 [ 420.1841411] uhub0: detached
 [ 420.1938286] pcppi0: detached
 [ 420.1938286] attimer0: detached
 [ 420.1938286] audio0: detached
 [ 420.2045641] wsmouse0: detached
 [ 420.2045641] wskbd0: detached
 [ 420.2131548] isa0: detached
 [ 420.2131548] usb3: detached
 [ 420.2131548] usb2: detached
 [ 420.2229136] usb1: detached
 [ 420.2229136] usb0: detached
 [ 420.2325439] hdafg0: detached
 [ 420.2325439] makphy0: detached
 [ 420.2325439] iic0: detached
 [ 420.2325439] acpicpu3: detached
 [ 420.2463169] acpicpu2: detached
 [ 420.2463169] acpicpu1: detached
 [ 420.2524132] acpicpu0: detached
 [ 420.2524132] virtio1: detached
 [ 420.2623980] ehci0: detached
 [ 420.2623980] uhci2: detached
 [ 420.2722635] uhci1: detached
 [ 420.2722635] uhci0: detached
 [ 420.2822563] hdaudio0: detached
 [ 420.2921610] Skipping crash dump on recursive panic
 [ 420.2921610] panic: kernel diagnostic assertion "!dv->dv_detach_done" 
 failed: file "/home/roddy/src/src/sys/kern/subr_autoconf.c", line 2916 
 makphy0
 [ 420.3021390] cpu3: Begin traceback...
 [ 420.3119981] vpanic() at netbsd:vpanic+0x171
 [ 420.3219240] kern_assert() at netbsd:kern_assert+0x4b
 [ 420.3318518] config_detach() at netbsd:config_detach+0x67
 [ 420.3417765] mii_detach() at netbsd:mii_detach+0xde
 [ 420.3517018] wm_detach() at netbsd:wm_detach+0x3f9
 [ 420.3616282] config_detach_release() at netbsd:config_detach_release+0x1fc
 [ 420.3715331] config_detach_all() at netbsd:config_detach_all+0xd1
 [ 420.3814497] cpu_reboot() at netbsd:cpu_reboot+0x1b9
 [ 420.3814497] kern_reboot() at netbsd:kern_reboot+0x93
 [ 420.3914180] sys_reboot() at netbsd:sys_reboot+0x63
 [ 420.4013558] syscall() at netbsd:syscall+0x112
 [ 420.4112604] --- syscall (number 208) ---
 [ 420.4112604] netbsd:syscall+0x112:
 [ 420.4112604] cpu3: End traceback...
 [ 420.4211592] fatal breakpoint trap in supervisor mode
 [ 420.4211592] trap type 1 code 0 rip 0xffffffff80235415 cs 0x8 rflags 
 0x202 cr2 0x7296e806ce68 ilevel 0 rsp 0xffffad80b42d8c60
 [ 420.4310694] curlwp 0xfffff7709e5db000 pid 507.507 lowest kstack 
 0xffffad80b42d42c0
 Stopped in pid 507.507 (halt) at        netbsd:breakpoint+0x5:  leave
 breakpoint() at netbsd:breakpoint+0x5
 vpanic() at netbsd:vpanic+0x171
 kern_assert() at netbsd:kern_assert+0x4b
 config_detach() at netbsd:config_detach+0x67
 mii_detach() at netbsd:mii_detach+0xde
 wm_detach() at netbsd:wm_detach+0x3f9
 config_detach_release() at netbsd:config_detach_release+0x1fc
 config_detach_all() at netbsd:config_detach_all+0xd1
 cpu_reboot() at netbsd:cpu_reboot+0x1b9
 kern_reboot() at netbsd:kern_reboot+0x93
 sys_reboot() at netbsd:sys_reboot+0x63
 syscall() at netbsd:syscall+0x112
 --- syscall (number 208) ---
 netbsd:syscall+0x112:
 ds          8
 es          3
 fs          180
 gs          8c10
 rdi         0
 rsi         3f8
 rbp         ffffad80b42d8c60
 rbx         ffffffff813f4c98    ostype+0x5216f
 rdx         1
 rcx         ffffffffffffff
 rax         800000000000000
 r8          0
 r9          0
 r10         0
 r11         0
 r12         ffffad80b42d8ca8
 r13         4
 r14         ffffffff
 r15         ffffad8003eaa458
 rip         ffffffff80235415    breakpoint+0x5
 cs          8
 rflags      202
 rsp         ffffad80b42d8c60
 ss          10
 netbsd:breakpoint+0x5:  leave
 db{3}>

 ```


 On 6/26/24 16:39, Taylor R Campbell wrote:
 > Thanks!  Looks like we have another bug, and that one's a little more
 > work to deal with.
 > 
 > Can you try reverting this change?
 > 
 > https://mail-index.netbsd.org/source-changes/2024/06/25/msg151955.html
 > 
 > That change disables access to a code path, but I want to see if I
 > fixed that code path too.

From: Taylor R Campbell <riastradh@NetBSD.org>
To: =?UTF-8?Q?Roddy_Gonz=C3=A1lez?= <roddy.gonzalez.89@gmail.com>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	netbsd-bugs@NetBSD.org, gnats-admin@NetBSD.org
Subject: Re: kern/58335 (Kernel panic when shutting down a virtual machine
	with Virtio devices)
Date: Fri, 28 Jun 2024 13:16:33 +0000

 This is a multi-part message in MIME format.
 --=_3LM3Qr5snjR6jwWdKR2eeC80vJ4rOpBA
 Content-Type: text/plain; charset=utf-8
 Content-Transfer-Encoding: quoted-printable

 > Date: Fri, 28 Jun 2024 12:26:43 +0200
 > From: Roddy Gonz=C3=A1lez <roddy.gonzalez.89@gmail.com>
 >=20
 > I applied the patch and rebuilt. Same results.

 Great, thanks!  Unfortunately, I neglected to make it easy to confirm
 everything.  Once more, just to be sure it's running the code I
 intended to fix -- can you try the attached patch?

 No need to test with kern.detachall=3D1; that's a separate bug.

 --=_3LM3Qr5snjR6jwWdKR2eeC80vJ4rOpBA
 Content-Type: text/plain; charset="ISO-8859-1"; name="virtio_shutdown_printf"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="virtio_shutdown_printf.patch"

 diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c
 index 88afdd5e6d33..95a9fbfdcf47 100644
 --- a/sys/dev/pci/virtio_pci.c
 +++ b/sys/dev/pci/virtio_pci.c
 @@ -178,7 +178,7 @@ static bool	virtio_pci_msix_enabled(struct virtio_pci_s=
 oftc *);
 =20
  CFATTACH_DECL3_NEW(virtio_pci, sizeof(struct virtio_pci_softc),
      virtio_pci_match, virtio_pci_attach, virtio_pci_detach, NULL,
 -    virtio_pci_rescan, NULL, 0);
 +    virtio_pci_rescan, NULL, DVF_DETACH_SHUTDOWN);
 =20
  static const struct virtio_ops virtio_pci_ops_09 =3D {
  	.kick =3D virtio_pci_kick_09,
 @@ -374,12 +374,18 @@ virtio_pci_detach(device_t self, int flags)
  		for (i =3D 0; i < __arraycount(psc->sc_bars_iot); i++) {
  			if (psc->sc_bars_iosize[i] =3D=3D 0)
  				continue;
 +			printf("%s:%d: unmap space %p handle %p size %zu\n",
 +			    __func__, __LINE__, psc->sc_bars_iot[i],
 +			    psc->sc_bars_ioh[i], psc->sc_bars_iosize[i]);
  			bus_space_unmap(psc->sc_bars_iot[i],
  			    psc->sc_bars_ioh[i], psc->sc_bars_iosize[i]);
  			psc->sc_bars_iosize[i] =3D 0;
  		}
  	} else {
  		if (psc->sc_iosize) {
 +			printf("%s:%d: unmap space %p handle %p size %zu\n",
 +			    __func__, __LINE__, psc->sc_iot,
 +			    psc->sc_ioh, psc->sc_iosize);
  			bus_space_unmap(psc->sc_iot, psc->sc_ioh,
  			    psc->sc_iosize);
  			psc->sc_iosize =3D 0;

 --=_3LM3Qr5snjR6jwWdKR2eeC80vJ4rOpBA--

From: Taylor R Campbell <riastradh@NetBSD.org>
To: =?UTF-8?Q?Roddy_Gonz=C3=A1lez?= <roddy.gonzalez.89@gmail.com>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	netbsd-bugs@NetBSD.org, gnats-admin@NetBSD.org
Subject: Re: kern/58335 (Kernel panic when shutting down a virtual machine
	with Virtio devices)
Date: Fri, 28 Jun 2024 18:29:24 +0000

 This is a multi-part message in MIME format.
 --=_17Wymd7lPaKOmlAiVMiz9N/EY5eA0fm1

 Oops, corrected patch attached -- this one should actually build.

 --=_17Wymd7lPaKOmlAiVMiz9N/EY5eA0fm1
 Content-Type: text/plain; charset="ISO-8859-1"; name="virtio_shutdown_printf_v2"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="virtio_shutdown_printf_v2.patch"

 diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c
 index 88afdd5e6d33..9fb155454a72 100644
 --- a/sys/dev/pci/virtio_pci.c
 +++ b/sys/dev/pci/virtio_pci.c
 @@ -178,7 +178,7 @@ static bool	virtio_pci_msix_enabled(struct virtio_pci_s=
 oftc *);
 =20
  CFATTACH_DECL3_NEW(virtio_pci, sizeof(struct virtio_pci_softc),
      virtio_pci_match, virtio_pci_attach, virtio_pci_detach, NULL,
 -    virtio_pci_rescan, NULL, 0);
 +    virtio_pci_rescan, NULL, DVF_DETACH_SHUTDOWN);
 =20
  static const struct virtio_ops virtio_pci_ops_09 =3D {
  	.kick =3D virtio_pci_kick_09,
 @@ -374,12 +374,19 @@ virtio_pci_detach(device_t self, int flags)
  		for (i =3D 0; i < __arraycount(psc->sc_bars_iot); i++) {
  			if (psc->sc_bars_iosize[i] =3D=3D 0)
  				continue;
 +			printf("%s:%d: unmap space %p handle %p size %zu\n",
 +			    __func__, __LINE__, psc->sc_bars_iot[i],
 +			    (void *)psc->sc_bars_ioh[i],
 +			    psc->sc_bars_iosize[i]);
  			bus_space_unmap(psc->sc_bars_iot[i],
  			    psc->sc_bars_ioh[i], psc->sc_bars_iosize[i]);
  			psc->sc_bars_iosize[i] =3D 0;
  		}
  	} else {
  		if (psc->sc_iosize) {
 +			printf("%s:%d: unmap space %p handle %p size %zu\n",
 +			    __func__, __LINE__, psc->sc_iot,
 +			    (void *)psc->sc_ioh, psc->sc_iosize);
  			bus_space_unmap(psc->sc_iot, psc->sc_ioh,
  			    psc->sc_iosize);
  			psc->sc_iosize =3D 0;

 --=_17Wymd7lPaKOmlAiVMiz9N/EY5eA0fm1--

From: =?UTF-8?Q?Roddy_Gonz=C3=A1lez?= <roddy.gonzalez.89@gmail.com>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
 netbsd-bugs@NetBSD.org, gnats-admin@NetBSD.org
Subject: Re: kern/58335 (Kernel panic when shutting down a virtual machine
 with Virtio devices)
Date: Sat, 29 Jun 2024 21:02:59 +0200

 Hi! Thanks again.

 The relevant log section is:

 ```
 [  67.1497876] iic0: detached
 [  67.1497876] virtio_pci_detach:388: unmap space 0xffffffff818460c0 
 handle 0xc040 size 64
 [  67.1497876] virtio1: detached
 [  67.1497876] uhci2: detached
 [  67.1602788] uhci1: detached
 [  67.1602788] uhci0: detached
 [  67.1602788] makphy0: detached
 [  67.1602788] wm0: detached
 [  67.1602788] virtio_pci_detach:378: unmap space 0xffffffff81846080 
 handle 0xffff8780a4073000 size 16384
 [  67.1602788] virtio0: detached
 [  67.1602788] pchb0: detached
 [  67.1702167] cd0: detached
 [  67.1702167] atapibus0: detached
 [  67.1702167] atabus0: detached
 ```


 The whole thing is:

 ```
    \\-__,------,___.
     \\        __,---`  NetBSD/x86 EFI Boot (x64)
      \\       `---,_.  Revision 1.2 (Sat Jun 29 10:16:05 UTC 2024)
       \\-,_____,.---`
        \\
         \\
          \\

  > boot
 21707904+795008+1302144 [967040+1416552+1038924]=0x1b44430
 Loading /stand/amd64/10.99.10/modules/cd9660/cd9660.kmod
 [   1.0000000] WARNING: system needs entropy for security; see entropy(7)
 [   1.0000000] cpu_rng: rdrand/rdseed
 [   1.0000000] entropy: ready
 [   1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
 [   1.0000000]     2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 
 2013,
 [   1.0000000]     2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 
 2023,
 [   1.0000000]     2024
 [   1.0000000]     The NetBSD Foundation, Inc.  All rights reserved.
 [   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
 [   1.0000000]     The Regents of the University of California.  All 
 rights reserved.

 [   1.0000000] NetBSD 10.99.10 (GENERIC) #0: Sat Jun 29 13:49:21 CEST 2024
 [   1.0000000] 
 roddy@apollo:/home/roddy/src/NetBSD/obj/sys/arch/amd64/compile/GENERIC
 [   1.0000000] total memory = 2043 MB
 [   1.0000000] avail memory = 1948 MB
 [   1.0000000] WARNING: module error: module `cd9660' pushed by boot 
 loader already exists
 [   1.0000040] efi: systbl at pa 7f9ed018
 [   1.0000040] mainbus0 (root)
 [   1.0000040] ACPI: RSDP 0x000000007FB7D014 000024 (v02 BOCHS )
 [   1.0000040] ACPI: XSDT 0x000000007FB7C0E8 000044 (v01 BOCHS  BXPC 
 00000001      01000013)
 [   1.0000040] ACPI: FACP 0x000000007FB79000 000074 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: DSDT 0x000000007FB7A000 001792 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: FACS 0x000000007FBDC000 000040
 [   1.0000040] ACPI: APIC 0x000000007FB78000 000090 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: WAET 0x000000007FB77000 000028 (v01 BOCHS  BXPC 
 00000001 BXPC 00000001)
 [   1.0000040] ACPI: BGRT 0x000000007FB76000 000038 (v01 INTEL  EDK2 
 00000002      01000013)
 [   1.0000040] ACPI: 1 ACPI AML tables successfully acquired and loaded
 [   1.0000040] ioapic0 at mainbus0 apid 0
 [   1.0000040] cpu0 at mainbus0 apid 0
 [   1.0000040] cpu0: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu0: node 0, package 0, core 0, smt 0
 [   1.0000040] cpu1 at mainbus0 apid 1
 [   1.0000040] cpu1: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu1: node 0, package 1, core 0, smt 0
 [   1.0000040] cpu2 at mainbus0 apid 2
 [   1.0000040] cpu2: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu2: node 0, package 2, core 0, smt 0
 [   1.0000040] cpu3 at mainbus0 apid 3
 [   1.0000040] cpu3: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, id 0x906ea
 [   1.0000040] cpu3: node 0, package 3, core 0, smt 0
 [   1.0000040] acpi0 at mainbus0: Intel ACPICA 20230628
 [   1.0000040] LNKS: BIOS IRQ 10 for 0.1.INTA is invalid
 [   1.0000040] acpi0: fixed power button present
 [   1.0078176] com0 at acpi0 (COM2, PNP0501-2): io 0x2f8-0x2ff irq 3
 [   1.0078176] com0: ns16550a, 16-byte FIFO
 [   1.0078176] com1 at acpi0 (COM1, PNP0501-1): io 0x3f8-0x3ff irq 4
 [   1.0078176] com1: ns16550a, 16-byte FIFO
 [   1.0078176] com1: console
 [   1.0078176] pckbc1 at acpi0 (KBD, PNP0303) (kbd port): io 0x60,0x64 irq 1
 [   1.0078176] pckbc2 at acpi0 (MOU, PNP0F13) (aux port): irq 12
 [   1.0078176] fdc0 at acpi0 (FDC0, PNP0700): io 0x3f2-0x3f5,0x3f7 irq 6 
 drq 2
 [   1.0078176] qemufwcfg0 at acpi0 (FWCF, QEMU0002): io 0x510-0x51b
 [   1.0078176] ACPI: Enabled 2 GPEs in block 00 to 0F
 [   1.0078176] pckbd0 at pckbc1 (kbd slot)
 [   1.0078176] pckbc1: using irq 1 for kbd slot
 [   1.0078176] wskbd0 at pckbd0 mux 1
 [   1.0078176] pms0 at pckbc1 (aux slot)
 [   1.0078176] pckbc1: using irq 12 for aux slot
 [   1.0078176] wsmouse0 at pms0 mux 0
 [   1.0078176] pci0 at mainbus0 bus 0: configuration mode 1
 [   1.0078176] pchb0 at pci0 dev 0 function 0: Intel 82441FX (PMC) PCI 
 and Memory Controller (rev. 0x02)
 [   1.0078176] pcib0 at pci0 dev 1 function 0: Intel 82371SB (PIIX3) 
 PCI-ISA Bridge (rev. 0x00)
 [   1.0078176] piixide0 at pci0 dev 1 function 1: Intel 82371SB IDE 
 Interface (PIIX3) (rev. 0x00)
 [   1.0078176] piixide0: primary channel interrupting at ioapic0 pin 14
 [   1.0078176] atabus0 at piixide0 channel 0
 [   1.0078176] piixide0: secondary channel ignored (disabled)
 [   1.0078176] piixpm0 at pci0 dev 1 function 3: Intel 82371AB (PIIX4) 
 Power Management Controller (rev. 0x03)
 [   1.0078176] piixpm0: 24-bit timer
 [   1.0078176] piixpm0: interrupting at ioapic0 pin 9
 [   1.0078176] iic0 at piixpm0 port 0: I2C bus
 [   1.0078176] virtio0 at pci0 dev 2 function 0
 [   1.0078176] virtio0: Unknown device (id 16, rev. 0x01)
 [   1.0078176] virtio0: no matching child driver; not configured
 [   1.0078176] wm0 at pci0 dev 3 function 0: Intel i82540EM 1000BASE-T 
 Ethernet (rev. 0x03)
 [   1.0078176] wm0: interrupting at ioapic0 pin 11
 [   1.0078176] wm0: Ethernet address 52:54:00:e7:05:1f
 [   1.0078176] makphy0 at wm0 phy 1: Marvell 88E1011 Gigabit PHY, rev. 0
 [   1.0078176] makphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 
 1000baseT, 1000baseT-FDX, auto
 [   1.0078176] hdaudio0 at pci0 dev 4 function 0: HD Audio Controller
 [   1.0078176] hdaudio0: interrupting at msi0 vec 0
 [   1.0078176] hdaudio0: HDA ver. 1.0, OSS 4, ISS 4, BSS 0, SDO 1, 64-bit
 [   1.0078176] hdafg0 at hdaudio0: vendor 1af4 product 0022
 [   1.0078176] hdafg0: DAC00 2ch: Speaker [Jack]
 [   1.0078176] hdafg0: ADC01 2ch: Line In [Jack]
 [   1.0078176] hdafg0: 2ch/2ch 16000Hz 22050Hz 32000Hz 44100Hz 48000Hz 
 88200Hz 96000Hz PCM16
 [   1.0078176] audio0 at hdafg0: playback, capture, full duplex, independent
 [   1.0078176] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for playback
 [   1.0078176] audio0: slinear_le:16 2ch 48000Hz, blk 1920 bytes (10ms) 
 for recording
 [   1.0078176] spkr0 at audio0: PC Speaker (synthesized)
 [   1.0078176] wsbell at spkr0 not configured
 [   1.0078176] uhci0 at pci0 dev 5 function 0: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0078176] uhci0: interrupting at ioapic0 pin 10
 [   1.0078176] usb0 at uhci0: USB revision 1.0
 [   1.0078176] uhci1 at pci0 dev 5 function 1: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0078176] uhci1: interrupting at ioapic0 pin 10
 [   1.0078176] usb1 at uhci1: USB revision 1.0
 [   1.0078176] uhci2 at pci0 dev 5 function 2: Intel 82801I USB UHCI 
 Controller (rev. 0x03)
 [   1.0078176] uhci2: interrupting at ioapic0 pin 11
 [   1.0078176] usb2 at uhci2: USB revision 1.0
 [   1.0078176] ehci0 at pci0 dev 5 function 7: Intel 82801I USB EHCI 
 Controller (rev. 0x03)
 [   1.0078176] ehci0: interrupting at ioapic0 pin 11
 [   1.0078176] ehci0: 3 companion controllers, 2 ports each: uhci0 uhci1 
 uhci2
 [   1.0078176] ehci0: Using DMA subregion for control data structures
 [   1.0078176] usb3 at ehci0: USB revision 2.0
 [   1.0078176] virtio1 at pci0 dev 6 function 0
 [   1.0078176] virtio1: console device (id 3, rev. 0x00)
 [   1.0078176] virtio1: no matching child driver; not configured
 [   1.0078176] virtio2 at pci0 dev 7 function 0
 [   1.0078176] virtio2: memory balloon device (id 5, rev. 0x00)
 [   1.0078176] viomb0 at virtio2: features: 0x10000000<INDIRECT_DESC>
 [   1.0078176] virtio2: interrupting at ioapic0 pin 11
 [   1.0078176] isa0 at pcib0
 [   1.0078176] attimer0 at isa0 port 0x40-0x43
 [   1.0078176] pcppi0 at isa0 port 0x61
 [   1.0078176] spkr1 at pcppi0: PC Speaker
 [   1.0078176] wsbell at spkr1 not configured
 [   1.0078176] midi0 at pcppi0: PC speaker
 [   1.0078176] sysbeep0 at pcppi0
 [   1.0078176] attimer0: attached to pcppi0
 [   1.0078176] acpicpu0 at cpu0: ACPI CPU
 [   1.0078176] acpicpu1 at cpu1: ACPI CPU
 [   1.0078176] acpicpu2 at cpu2: ACPI CPU
 [   1.0078176] acpicpu3 at cpu3: ACPI CPU
 [   1.7352240] atapibus0 at atabus0: 2 targets
 [   1.7455222] cd0 at atapibus0 drive 1: <QEMU DVD-ROM, QM00002, 2.5+> 
 cdrom removable
 [   1.7455222] wd0 at atabus0 drive 0
 [   1.7455222] wd0: <QEMU HARDDISK>
 [   1.7455222] wd0: 20480 MB, 41610 cyl, 16 head, 63 sec, 512 bytes/sect 
 x 41943040 sectors
 [   1.7455222] uhub0 at usb1: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.7455222] uhub1 at usb2: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.7455222] uhub2 at usb0: NetBSD (0x0000) UHCI root hub (0x0000), 
 class 9/0, rev 1.00/1.00, addr 1
 [   1.7562618] uhub3 at usb3: NetBSD (0x0000) EHCI root hub (0x0000), 
 class 9/0, rev 2.00/1.00, addr 1
 [   1.7562618] dk0 at wd0: "EFI", 262144 blocks at 4096, type: msdos
 [   1.7562618] dk1 at wd0: "NetBSD", 16777216 blocks at 266240, type: ffs
 [   1.7562618] dk2 at wd0: "syscgd", 24895488 blocks at 17043456, type: cgd
 [   2.8876073] uhidev0 at uhub3 port 1 configuration 1 interface 0
 [   2.8989889] uhidev0: QEMU (0x0627) QEMU USB Tablet (0x0001), rev 
 2.00/0.00, addr 2, iclass 3/0
 [   2.9081798] ums0 at uhidev0: 3 buttons and Z dir
 [   2.9194206] wsmouse1 at ums0 mux 0
 [   2.9194206] swwdog0: software watchdog initialized
 [   2.9289156] WARNING: 2 errors while detecting hardware; check system log.
 [   2.9289156] boot device: cd0
 [   2.9389786] root on cd0a dumps on cd0b
 [   2.9389786] root file system type: cd9660
 [   2.9496680] kern.module.path=/stand/amd64/10.99.10/modules
 Created tmpfs /dev (1835008 byte, 3552 inodes)


 You are using a serial console, we do not know your terminal emulation.
 Please select one, typical values are:

          vt100
          ansi
          xterm

 Terminal type (just hit ENTER for 'vt220'): xterm
 # uname -a
 NetBSD  10.99.10 NetBSD 10.99.10 (GENERIC) #0: Sat Jun 29 13:49:21 CEST 
 2024 
 roddy@apollo:/home/roddy/src/NetBSD/obj/sys/arch/amd64/compile/GENERIC amd64
 # sysctl kern.detachall
 kern.detachall = 0
 # shutdown -p now
 Shutdown NOW!
 shutdown: [pid 383]
 # wall: You have write permission turned off; no reply possible
 wall: Cannot stat `/var/run/utmp': No such file or directory
 shutdown: poweroff by root:

 System shutdown time has arrived

 About to run shutdown hooks...
 cron not running? (check /var/run/cron.pid).
 inetd not running? (check /var/run/inetd.pid).
 Saved entropy to /var/db/entropy-file.
 Forcibly unmounting /tmp
 Forcibly unmounting /var
 Forcibly unmounting /etc
 Removing block-type swap devices
 Sat Jun 29 18:58:06 UTC 2024

 Done running shutdown hooks.
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `runlevel': Bad file descriptor
 init: can't add utmpx record for `console': Bad file descriptor
 [  67.1192027] syncing disks... done
 [  67.1393798] sysbeep0: detached
 [  67.1393798] midi0: detached
 [  67.1393798] uhub2: detached
 [  67.1393798] uhub1: detached
 [  67.1393798] uhub0: detached
 [  67.1393798] dk2 at wd0 (syscgd) deleted
 [  67.1393798] dk1 at wd0 (NetBSD) deleted
 [  67.1393798] dk0 at wd0 (EFI) deleted
 [  67.1497876] wd0: detached
 [  67.1497876] usb2: detached
 [  67.1497876] usb1: detached
 [  67.1497876] usb0: detached
 [  67.1497876] iic0: detached
 [  67.1497876] virtio_pci_detach:388: unmap space 0xffffffff818460c0 
 handle 0xc040 size 64
 [  67.1497876] virtio1: detached
 [  67.1497876] uhci2: detached
 [  67.1602788] uhci1: detached
 [  67.1602788] uhci0: detached
 [  67.1602788] makphy0: detached
 [  67.1602788] wm0: detached
 [  67.1602788] virtio_pci_detach:378: unmap space 0xffffffff81846080 
 handle 0xffff8780a4073000 size 16384
 [  67.1602788] virtio0: detached
 [  67.1602788] pchb0: detached
 [  67.1702167] cd0: detached
 [  67.1702167] atapibus0: detached
 [  67.1702167] atabus0: detached
 [  67.1702167] acpi0: entering state S5
 ``

 On 6/28/24 20:29, Taylor R Campbell wrote:
 > Oops, corrected patch attached -- this one should actually build.

From: =?UTF-8?Q?Roddy_Gonz=C3=A1lez?= <roddy.gonzalez.89@gmail.com>
To: Taylor R Campbell <riastradh@NetBSD.org>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
 netbsd-bugs@NetBSD.org, gnats-admin@NetBSD.org
Subject: Re: kern/58335 (Kernel panic when shutting down a virtual machine
 with Virtio devices)
Date: Sat, 20 Jul 2024 12:10:19 +0200

 Hi!

 Gnats is telling me that more feedback is needed.

 Besides the logs from the patch you sent me, is there anything else I 
 can help with?


 R

  > Oops, corrected patch attached -- this one should actually build.

  > Hi! Thanks again.
  > The relevant log section is:
  > ```
  > [  67.1497876] iic0: detached
  > [  67.1497876] virtio_pci_detach:388: unmap space 0xffffffff818460c0 
 handle 0xc040 size 64
  > [  67.1497876] virtio1: detached
  > [  67.1497876] uhci2: detached
  > [  67.1602788] uhci1: detached
  > [  67.1602788] uhci0: detached
  > [  67.1602788] makphy0: detached
  > [  67.1602788] wm0: detached
  > [  67.1602788] virtio_pci_detach:378: unmap space 0xffffffff81846080 
 handle 0xffff8780a4073000 size 16384
  > [  67.1602788] virtio0: detached
  > [  67.1602788] pchb0: detached
  > [  67.1702167] cd0: detached
  > [  67.1702167] atapibus0: detached
  > [  67.1702167] atabus0: detached
  > ```

State-Changed-From-To: feedback->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 20 Jul 2024 13:12:40 +0000
State-Changed-Why:
Feedback received, thanks!  Just forgot to update the state earlier.
Fix committed to HEAD, needs pullup-10 and possibly pullup-9.


State-Changed-From-To: needs-pullups->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 12 Oct 2024 22:49:12 +0000
State-Changed-Why:
fixed in HEAD, pulled up to 10, bug was new in 10 so no pullpu-9
pullup-10 #914 https://releng.netbsd.org/cgi-bin/req-10.cgi?show=914


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.