Skip to contentSkip to conversation

vfio/pci-quirks: Exclude non-ioport BAR from ATI quirk

RFC PATCH Applied Vasilis Liaskovitis 3 participants 3 messages Mar 11, 2025

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 vfio/pci-quirks: Exclude non-ioport BAR from ATI quirk

The ATI BAR4 quirk is targeting an ioport BAR. Older devices may have a BAR4 which is not an ioport, causing a segfault here. Test the BAR type to skip these devices.

Similar to
"8f419c5b: vfio/pci-quirks: Exclude non-ioport BAR from NVIDIA quirk"

Untested, as I don't have the card to test.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2856

---
 hw/vfio/pci-quirks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/pci-quirks.c +1 -1
index c53591fe2b..15598bbaf4 100644
@@ -403,7 +403,7 @@ static void vfio_probe_ati_bar4_quirk(VFIOPCIDevice *vdev, int nr)
 
     /* This windows doesn't seem to be used except by legacy VGA code */
     if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||
-        !vdev->vga || nr != 4) {
+        !vdev->vga || nr != 4 || !vdev->bars[4].ioport) {
         return;
     }
 
Signature · 1 line
2.46.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · On Tue, 11 Mar 2025 00:58:33 +0100 Vasilis Liaskovitis <[email protected]>…

The ATI BAR4 quirk is targeting an ioport BAR. Older devices may have a BAR4 which is not an ioport, causing a segfault here. Test the BAR type to skip these devices.

Similar to
"8f419c5b: vfio/pci-quirks: Exclude non-ioport BAR from NVIDIA quirk"

Untested, as I don't have the card to test.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2856

---
 hw/vfio/pci-quirks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/pci-quirks.c +0 -0
index c53591fe2b..15598bbaf4 100644

hw/vfio/pci-quirks.c static void vfio_probe_ati_bar4_quirk(VFIOPCIDevice *vdev, int nr) · line 409

Quoted 8 lines
hw/vfio/pci-quirks.c +1 -1
@@ -403,7 +403,7 @@ static void vfio_probe_ati_bar4_quirk(VFIOPCIDevice *vdev, int nr)
 
     /* This windows doesn't seem to be used except by legacy VGA code */
     if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||
-        !vdev->vga || nr != 4) {
+        !vdev->vga || nr != 4 || !vdev->bars[4].ioport) {
         return;
     }
 

We should probably predicate calls to vfio_bar_quirk_setup() on VFIOBAR.size to avoid such segfaults, but agree this likely fixes the reported issue as well.

#2 lore raw
In reply to Vasilis Liaskovitis
Quoted 20 lines · Vasilis Liaskovitis

The ATI BAR4 quirk is targeting an ioport BAR. Older devices may have a BAR4 which is not an ioport, causing a segfault here. Test the BAR type to skip these devices.

Similar to
"8f419c5b: vfio/pci-quirks: Exclude non-ioport BAR from NVIDIA quirk"

Untested, as I don't have the card to test.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2856

---
  hw/vfio/pci-quirks.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/pci-quirks.c +0 -0
index c53591fe2b..15598bbaf4 100644

hw/vfio/pci-quirks.c static void vfio_probe_ati_bar4_quirk(VFIOPCIDevice *vdev, int nr) · line 409

Quoted 8 lines
hw/vfio/pci-quirks.c +1 -1
@@ -403,7 +403,7 @@ static void vfio_probe_ati_bar4_quirk(VFIOPCIDevice *vdev, int nr)
 
      /* This windows doesn't seem to be used except by legacy VGA code */
      if (!vfio_pci_is(vdev, PCI_VENDOR_ID_ATI, PCI_ANY_ID) ||
-        !vdev->vga || nr != 4) {
+        !vdev->vga || nr != 4 || !vdev->bars[4].ioport) {
          return;
      }
 

Applied to vfio-next.

Thanks,

C.