Bug 294706 - powerpc64: kernel crashes on boot and fails to initialize virtio-scsi
Summary: powerpc64: kernel crashes on boot and fails to initialize virtio-scsi
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: powerpc Any
: Normal Affects Many People
Assignee: Michael Tuexen
URL:
Keywords: crash, regression
Depends on:
Blocks:
 
Reported: 2026-04-22 15:14 UTC by Luke Yasuda
Modified: 2026-08-06 09:14 UTC (History)
3 users (show)

See Also:
tuexen: mfc-stable15+
tuexen: mfc-stable14+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luke Yasuda 2026-04-22 15:14:18 UTC
This issue only happens on powerpc64 but not powerpc64le. I have a FreeBSD VM that runs on qemu, with the root disk using the virtio-scsi disk controller. Until 16.snap20260323212910, everything was working fine.

serial output:

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...               
cas: selected radix MMU
Kernel entry at 0x1017d0 ...
GDB: no debug ports present
KDB: debugger backends: ddb
KDB: current backend: ddb
---<<BOOT>>---
Copyright (c) 1992-2026 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 16.0-CURRENT main-n285251-07a3501e6c85 GENERIC powerpc
FreeBSD clang version 19.1.7 (https://github.com/llvm/llvm-project.git llvmorg-19.1.7-0-gcd708029e0b2)
WARNING: WITNESS option enabled, expect reduced performance.
VT: init without driver.
cpu0: IBM POWER9 revision 2.2, 2400.00 MHz
cpu0: Features dc007182<PPC32,PPC64,ALTIVEC,FPU,MMU,SMT,ISNOOP,ARCH205,ARCH206,VSX,TRUELE>
cpu0: Features2 bee00000<ARCH207,DSCR,ISEL,TAR,VCRYPTO,ARCH300,IEEE128,DARN>
real memory  = 137393299456 (131028 MB)
avail memory = 133712596992 (127518 MB)
FreeBSD/SMP: Multiprocessor System Detected: 64 CPUs
random: registering fast source PowerISA DARN random number generator
random: fast provider: "PowerISA DARN random number generator"
random: unblocking device.
random: entropy device external interface
kbd0 at kbdmux0
ofwbus0: <Open Firmware Device Tree> on nexus0
cpulist0: <Open Firmware CPU Group> on ofwbus0
cpu0: <Open Firmware CPU> on cpulist0
xicp0: <External Interrupt Presentation Controller> on ofwbus0
xicp0: Handling CPUs 0-63
vdevice0: <POWER Hypervisor Virtual Device Root> on ofwbus0
uart0: <POWER Hypervisor Virtual Serial Port> irq 16781569 on vdevice0
pcib0: <RTAS Host-PCI bridge> on ofwbus0
pci0: <POWER Hypervisor PCI bus> on pcib0
virtio_pci0: <VirtIO PCI (modern) SCSI adapter> port 0xc0-0xff mem 0x80080000-0x80080fff,0x210000020000-0x210000023fff irq 4609 at device 5.0 numa-domain 0 on pci0
vtscsi0: <VirtIO SCSI Adapter> numa-domain 0 on virtio_pci0
virtio_pci0: virtqueue 1 (vtscsi0 event) does not exist (size is zero)
virtio_pci0: cannot allocate virtqueue 1: 19
vtscsi0: cannot allocate virtqueues

fatal kernel trap:

   exception       = 0x380 (data segment exception)
   virtual address = 0xdeadc0dedeadc0de
   dsisr           = 0x0
   srr0            = 0xc000000000e86490 (0xe86490)
   srr1            = 0x8000000000001032
   current msr     = 0x8000000000001032
   lr              = 0xc0000000006c3d78 (0x6c3d78)
   frame           = 0xc00800000000ba50
   curthread       = 0xc0000000017e4360
          pid = 0, comm = kernel

panic: data segment exception trap
cpuid = 0
time = 1
KDB: stack backtrace:
0xc00800000000b780: at vpanic+0x1b0
0xc00800000000b830: at panic+0x44
0xc00800000000b860: at trap+0x300
0xc00800000000b990: at powerpc_interrupt+0x1cc
0xc00800000000ba20: kernel DSE trap @ 0xdeadc0dedeadc0de by bus_dmamap_sync+0x20: srr1=0x8000000000001032
            r1=0xc00800000000bcd0 cr=0x22200282 xer=0 ctr=0x1 r2=0xc0000000018d4000 frame=0xc00800000000ba50
0xc00800000000bcd0: at -0x4
0xc00800000000bd20: at virtqueue_dequeue+0x3c
0xc00800000000bda0: at vtscsi_complete_vqs_locked+0x118
0xc00800000000bdf0: at vtscsi_detach+0xf0
0xc00800000000bf70: at vtscsi_attach+0x270
0xc00800000000c130: at device_attach+0x568
0xc00800000000c210: at vtpci_modern_probe_and_attach_child+0xb0
0xc00800000000c260: at vtpci_modern_attach+0x5e0
0xc00800000000c310: at device_attach+0x568
0xc00800000000c3f0: at bus_attach_children+0x88
0xc00800000000c430: at ofw_pcibus_attach+0x3bc
0xc00800000000c550: at device_attach+0x568
0xc00800000000c630: at bus_attach_children+0x88
0xc00800000000c670: at ofw_pcib_attach+0x54
0xc00800000000c6a0: at rtaspci_attach+0x19c
0xc00800000000c6f0: at device_attach+0x568
0xc00800000000c7d0: at bus_generic_new_pass+0x190
0xc00800000000c820: at bus_generic_new_pass+0x104
0xc00800000000c870: at bus_generic_new_pass+0x104
0xc00800000000c8c0: at root_bus_configure+0x6c
0xc00800000000c910: at configure+0x1c
0xc00800000000c940: at mi_startup+0x288
0xc00800000000ca50: at __start+0xc4
KDB: enter: panic
[ thread pid 0 tid 100000 ]
Stopped at      kdb_enter+0x70: ori     r0, r0, 0x0
db>


qemu command (example):

/usr/bin/qemu-system-ppc64 \
-smp 64 \
-cpu host \
-m 131072 \
-accel kvm \
-device 'virtio-scsi-pci,id=scsihw0,bus=pci.0,addr=0x5' \
-drive 'file=/dev/zvol/tank/dummy,if=none,id=drive-scsi0,cache=writeback,discard=on,format=raw,aio=io_uring,detect-zeroes=unmap' \
-device 'scsi-hd,bus=scsihw0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0,id=scsi0,rotation_rate=1' \
-vga none \
-nographic \
-machine 'type=pseries'
Comment 1 Adrian Chadd freebsd_committer freebsd_triage 2026-04-28 17:00:04 UTC
This is due to 0b39d72d0491c77e3e9883015b1fac46663c71de (virtio change).

You can work around it for now by putting this into /boot/loader.conf:

```
hw.virtio.pci.transitional=0
```

ivy@ thinks this may be an endian problem in the new code?
Comment 2 Adrian Chadd freebsd_committer freebsd_triage 2026-04-28 17:00:39 UTC
sorry, jrtc27@
Comment 3 Michael Tuexen freebsd_committer freebsd_triage 2026-04-28 19:39:16 UTC
(In reply to Adrian Chadd from comment #2)
Timo is investigating a byte ordering bug in the virtio code which is present when the guest OS is big endian. We have observed it when using vtnet interfaces.
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2026-05-30 20:03:25 UTC
^Triage: generally we only assign to people who have the ability to commit.

The person working on it is already on Cc:.
Comment 5 Michael Tuexen freebsd_committer freebsd_triage 2026-05-30 20:24:00 UTC
(In reply to Mark Linimon from comment #4)
I'll commit the fix Timo is working on once it has been reviewed.
Did not know about the policy...
Comment 6 Timo Voelker 2026-06-02 12:33:12 UTC
I created a patch to fix this bug. Please test it: review D57392.
Comment 7 commit-hook freebsd_committer freebsd_triage 2026-06-28 10:47:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=07b5d1ca52b113cecad3cda73ff5e782d8f4d07d

commit 07b5d1ca52b113cecad3cda73ff5e782d8f4d07d
Author:     Timo Völker <timo.voelker@fh-muenster.de>
AuthorDate: 2026-06-28 10:39:10 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-06-28 10:39:10 +0000

    virtio_pci_modern: Remove endianness conversion for config space

    The bus_* functions already handle converting from PCI endianness
    (i.e. little-endian) to native endianness when accessing the config
    space (see ofw_pcib_bus_get_bus_tag), so converting again with
    virtio_htogX/virtio_gtohX undoes any byte-swapping and breaks
    big-endian systems. They should only be used for operating on shared
    memory.
    Note part of this reverts commit fb53b42e36a9 ("virtio-modern: fix PCI
    common read/write functions on big endian targets").

    PR:                     294706
    Reviewed by:            adrian, tuexen
    Fixes:                  fb53b42e36a9 ("virtio-modern: fix PCI common read/write functions on big endian targets")
    Fixes:                  9da9560c4dd3 ("virtio: Add VirtIO PCI modern (V1) support")
    MFC after:              1 week
    Differential Revision:  https://reviews.freebsd.org/D57392

 sys/dev/virtio/pci/virtio_pci_modern.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2026-08-06 07:10:57 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b1afe190d7668d7c89eb6c350d03692a9b241088

commit b1afe190d7668d7c89eb6c350d03692a9b241088
Author:     Timo Völker <timo.voelker@fh-muenster.de>
AuthorDate: 2026-06-28 10:39:10 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-08-06 05:09:02 +0000

    virtio_pci_modern: Remove endianness conversion for config space

    The bus_* functions already handle converting from PCI endianness
    (i.e. little-endian) to native endianness when accessing the config
    space (see ofw_pcib_bus_get_bus_tag), so converting again with
    virtio_htogX/virtio_gtohX undoes any byte-swapping and breaks
    big-endian systems. They should only be used for operating on shared
    memory.
    Note part of this reverts commit fb53b42e36a9 ("virtio-modern: fix PCI
    common read/write functions on big endian targets").

    PR:                     294706
    Reviewed by:            adrian, tuexen
    Fixes:                  fb53b42e36a9 ("virtio-modern: fix PCI common read/write functions on big endian targets")
    Fixes:                  9da9560c4dd3 ("virtio: Add VirtIO PCI modern (V1) support")
    Differential Revision:  https://reviews.freebsd.org/D57392

    (cherry picked from commit 07b5d1ca52b113cecad3cda73ff5e782d8f4d07d)

 sys/dev/virtio/pci/virtio_pci_modern.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2026-08-06 09:04:13 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f059fcf3d1d85562ff21a348fec0573aa76d3648

commit f059fcf3d1d85562ff21a348fec0573aa76d3648
Author:     Timo Völker <timo.voelker@fh-muenster.de>
AuthorDate: 2026-06-28 10:39:10 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-08-06 09:02:00 +0000

    virtio_pci_modern: Remove endianness conversion for config space

    The bus_* functions already handle converting from PCI endianness
    (i.e. little-endian) to native endianness when accessing the config
    space (see ofw_pcib_bus_get_bus_tag), so converting again with
    virtio_htogX/virtio_gtohX undoes any byte-swapping and breaks
    big-endian systems. They should only be used for operating on shared
    memory.
    Note part of this reverts commit fb53b42e36a9 ("virtio-modern: fix PCI
    common read/write functions on big endian targets").

    PR:                     294706
    Reviewed by:            adrian, tuexen
    Fixes:                  fb53b42e36a9 ("virtio-modern: fix PCI common read/write functions on big endian targets")
    Fixes:                  9da9560c4dd3 ("virtio: Add VirtIO PCI modern (V1) support")
    Differential Revision:  https://reviews.freebsd.org/D57392

    (cherry picked from commit 07b5d1ca52b113cecad3cda73ff5e782d8f4d07d)

 sys/dev/virtio/pci/virtio_pci_modern.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)