>Synopsis: virtio-gpu does not work with virtio_mmio.c
>Category: kernel
>Environment:
System : OpenBSD 7.9
Details : OpenBSD 7.9 (GOEMU) #1: Wed Jul 29 07:01:37 CEST 2026
[email protected]:
/usr/src/sys/arch/ris
cv64/compile/GOEMU
Architecture: OpenBSD.riscv64
Machine : riscv64
>Description:
I am developing my own RISC-V 64 emulator
(https://github.com/markkurossi/riscv). The emulator implements only
the VirtIO MMIO drivers. On OpenBSD, the VirtIO GPU (virtio-gpu)
device does not initialize with the `virtio_mmio.c' driver. The
`viogpu.c' driver checks:
if (!vsc->sc_version_1) {
printf(": requires virtio version 1\n");
goto err;
}
The `vsc->sc_version_1' field is initialized in the `virtio_pci.c'
file but not in the `virtio_mmio.c' file. The `virtio_mmio.c' does a
version check and a trivial fix is to initialize the
`vsc->sc_version_1' field if `sc->sc_version == 2' (patch below).
>How-To-Repeat:
The `virtio-gpu' driver fails to initialize if the host implements
only the VirtIO MMIO transport.
>Fix:
mtr@mac openbsd $ diff -u sys/dev/fdt/virtio_mmio.c virtio_mmio.c
--- sys/dev/fdt/virtio_mmio.c 2026-04-16 20:25:02
+++ virtio_mmio.c 2026-07-29 14:08:47
@@ -287,6 +287,7 @@
printf(": unknown version 0x%02x; giving up\n", sc->sc_version);
return;
}
+ vsc->sc_version_1 = sc->sc_version == 2;
id = bus_space_read_4(sc->sc_iot, sc->sc_ioh, VIRTIO_MMIO_DEVICE_ID);
printf(": Virtio %s Device", virtio_device_string(id));
dmesg:
OpenBSD 7.9 (GOEMU) #1: Wed Jul 29 07:01:37 CEST 2026
[email protected]:
/usr/src/sys/arch/riscv64/compile/GOEMU
real mem = 536870912 (512MB)
avail mem = 489271296 (466MB)
SBI: OpenSBI v1.8, SBI Specification Version 3.0
random: good seed from bootblocks
mainbus0 at root: goemu,riscv-emulator
cpu0 at mainbus0: vendor 0 arch 100 imp 1
intc0 at cpu0
simplebus0 at mainbus0: "soc"
plic0 at simplebus0
syscon0 at simplebus0: "syscon"
syscon1 at syscon0: "poweroff"
syscon2 at syscon0: "reboot"
"clint" at simplebus0 not configured
com0 at simplebus0: ns16550, no working fifo
com0: console
gfrtc0 at simplebus0
virtio0 at simplebus0: Virtio Entropy Device
viornd0 at virtio0
virtio1 at simplebus0: Virtio Block Device
vioblk0 at virtio1
scsibus0 at vioblk0: 1 targets
sd0 at scsibus0 targ 0 lun 0: <VirtIO, Block Device, >
sd0: 9216MB, 512 bytes/sector, 18874368 sectors
virtio2 at simplebus0: Virtio Network Device
vio0 at virtio2: 1 queue, address 1a:31:2a:99:0e:4e
virtio3 at simplebus0: Virtio GPU Device
viogpu0 at virtio3: requires virtio version 1
virtio3: virtio configuration failed
virtio4 at simplebus0: Virtio Unknown Device
virtio4: no matching child driver; not configured
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
scsibus2 at softraid0: 256 targets
root on sd0a (9e13d1eafae715e0.a) swap on sd0b dump on sd0b
usbdevs:
usbdevs: no USB controllers found