hw/vfio/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
When the host kernel fails to assign a BAR (broken BIOS "Above 4G
Decoding" or ReBAR configuration), the VFIO kernel interface reports
a zero size. In that case, vfio_region_setup() skips allocating
region->mem, leaving it NULL.
Then, vfio_bar_quirk_setup() calls the BAR quirk probes and passes
a NULL region->mem pointer to memory_region_add_subregion_overlap(),
causing a segfault in memory_region_update_container_subregions().
Skip quirk setup in vfio_realize() for zero size regions.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2732
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/pci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index aa03927bb783..765326b755f4 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1852,7 +1852,9 @@ static void vfio_pci_realize(PCIDevice *pdev, Error **errp)
}
for (i = 0; i < PCI_ROM_SLOT; i++) {
- vfio_bar_quirk_setup(vdev, i);
+ if (vdev->bars[i].size) {
+ vfio_bar_quirk_setup(vdev, i);
+ }
}
if (!vfio_pci_irq_setup(vdev, errp)) {
--
2.56.0
On 9/11/26 13:14, Cédric Le Goater wrote: > When the host kernel fails to assign a BAR (broken BIOS "Above 4G > Decoding" or ReBAR configuration), the VFIO kernel interface reports > a zero size. In that case, vfio_region_setup() skips allocating > region->mem, leaving it NULL. > > Then, vfio_bar_quirk_setup() calls the BAR quirk probes and passes > a NULL region->mem pointer to memory_region_add_subregion_overlap(), > causing a segfault in memory_region_update_container_subregions(). > > Skip quirk setup in vfio_realize() for zero size regions. > > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2732 > Signed-off-by: Cédric Le Goater <clg@redhat.com> > --- > hw/vfio/pci.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
© 2016 - 2026 Red Hat, Inc.