NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/60247: virtio(4): legacy attach fails when BAR0 is MMIO
>Number: 60247
>Category: kern
>Synopsis: virtio(4): legacy attach fails when BAR0 is MMIO
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon May 11 00:40:00 +0000 2026
>Originator: Petri Koistinen
>Release: NetBSD 10.1 (virtio_pci.c rev 1.38.4.6); also rev 1.55 in -current
>Organization:
>Environment:
Host: macOS 26.4.1 on Apple Silicon
Hypervisor: Parallels Desktop 26.3.0
Guest: NetBSD 10.1 evbarm/aarch64
Guest NIC: virtio adapter
>Description:
virtio_pci_attach_09() hardcodes PCI_MAPREG_TYPE_IO when mapping
BAR0. Attach therefore fails on hosts that present BAR0 as
memory. Parallels does this for its legacy virtio NIC: the
driver reports "can't map i/o space" and the guest boots with
no NIC.
Legacy virtio is normally an I/O BAR interface, so the MMIO
BAR0 is not strictly spec-compliant. This is an
interoperability fix: use the BAR type PCI advertises instead
of forcing PCI_MAPREG_TYPE_IO. The modern (1.0) attach path
already does this.
>How-To-Repeat:
Boot NetBSD 10.1 evbarm/aarch64 GENERIC64 in Parallels Desktop
on Apple Silicon with the virtio NIC. dmesg contains:
virtio0 at pci0 dev 5 function 0
virtio0: can't map i/o space
and ifconfig -a shows only lo0.
>Fix:
--- src/sys/dev/pci/virtio_pci.c (revision 1.55)
+++ src/sys/dev/pci/virtio_pci.c (patched)
@@ -395,11 +395,14 @@
struct virtio_pci_softc * const psc = device_private(self);
const struct pci_attach_args * const pa = aux;
struct virtio_softc * const sc = &psc->sc_sc;
+ pcireg_t bar_type;
- /* complete IO region */
- if (pci_mapreg_map(pa, PCI_MAPREG_START, PCI_MAPREG_TYPE_IO, 0,
+ /* complete BAR0 region */
+ bar_type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START);
+ if (pci_mapreg_map(pa, PCI_MAPREG_START, bar_type, 0,
&psc->sc_iot, &psc->sc_ioh, NULL, &psc->sc_iosize)) {
- aprint_error_dev(self, "can't map i/o space\n");
+ aprint_error_dev(self, "can't map BAR0 (%s)\n",
+ bar_type == PCI_MAPREG_TYPE_IO ? "I/O" : "MEM");
return EIO;
}
Tested: GENERIC64 cross-built from netbsd-10.1 source with this
patch boots and attaches vioif0.
Home |
Main Index |
Thread Index |
Old Index