The virtio-gpu does not work with virtio_mmio.c transport

Markku Rossi <[email protected]> Wed, 29 Jul 2026 14:25:37 +0200
Newsgroups gmane.os.openbsd.bugs
Message-ID <CAGgDp3nFMpHqF=nTvYy8=YpFpxXEPo4DSCK+M9abb=N2eChhNQ@mail.gmail.com>
--00000000000032ace20657bf0ed5
Content-Type: text/plain; charset="UTF-8"

>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

--00000000000032ace20657bf0ed5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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

--00000000000032ace20657bf0ed5--