From fe070bf2de1a854329e1546cd4479c64f4ab428e Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 16 Jun 2026 13:04:01 +0100 Subject: [PATCH] [virtio] Ignore capabilities that describe inaccessible PCI BARs In some configurations, newer versions of QEMU will end up placing the modern interface's BAR4 above 4GB, rendering it inaccessible in a 32-bit build of iPXE. We will currently detect the existence of the modern interface and attempt to use it, but fail at the point of attempting to map the PCI BARs. Fix by ignoring any virtio capabilities that describe an inaccessible PCI BAR, and thereby allowing iPXE to fall back to using the legacy interface if the modern interface's BAR cannot be used. Reported-by: Jan ONDREJ (SAL) Signed-off-by: Michael Brown --- src/drivers/bus/virtio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/drivers/bus/virtio.c b/src/drivers/bus/virtio.c index b7d75706e..7a307683a 100644 --- a/src/drivers/bus/virtio.c +++ b/src/drivers/bus/virtio.c @@ -409,6 +409,13 @@ static int virtio_pci_cap ( struct virtio_device *virtio, if ( reg > PCI_BASE_ADDRESS_5 ) continue; + /* Check BAR accessibility */ + if ( ! pci_bar_start ( pci, reg ) ) { + DBGC ( virtio, "VIRTIO %s capability type %d BAR%d is " + "not usable\n", virtio->name, type, cap->bar ); + continue; + } + /* Success */ cap->pos = pos; return 0;