Skip to contentSkip to conversation

pci/msix: Fix msix pba read vector poll end calculation

PATCH In review Nicholas Piggin 3 participants 3 messages Dec 12, 2024 – Jan 17, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci/msix: Fix msix pba read vector poll end calculation

The end vector calculation has a bug that results in polling fewer than required vectors when reading at a non-zero offset in PBA memory.

Fixes bbef882cc193 ("msi: add API to get notified about pending bit poll")

---
Taking closer look at my msix pba mmio write patch, it looks like there might be a bug in the calculation from the code I copied? I haven't looked into how to test these poll notifiers though.

Thanks,
Nick

 hw/pci/msix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci/msix.c +1 -1
index 487e49834ee..cc6e79ec678 100644
@@ -250,7 +250,7 @@ static uint64_t msix_pba_mmio_read(void *opaque, hwaddr addr,
     PCIDevice *dev = opaque;
     if (dev->msix_vector_poll_notifier) {
         unsigned vector_start = addr * 8;
-        unsigned vector_end = MIN(addr + size * 8, dev->msix_entries_nr);
+        unsigned vector_end = MIN((addr + size) * 8, dev->msix_entries_nr);
         dev->msix_vector_poll_notifier(dev, vector_start, vector_end);
     }
 
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Nicholas Piggin

The end vector calculation has a bug that results in polling fewer than required vectors when reading at a non-zero offset in PBA memory.

Fixes bbef882cc193 ("msi: add API to get notified about pending bit poll")

---
Taking closer look at my msix pba mmio write patch, it looks like there might be a bug in the calculation from the code I copied? I haven't looked into how to test these poll notifiers though.

Quoted 5 lines

Thanks,
Nick

  hw/pci/msix.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
#2 lore raw
In reply to Nicholas Piggin
Quoted 5 lines · Nicholas Piggin

The end vector calculation has a bug that results in polling fewer than required vectors when reading at a non-zero offset in PBA memory.

Fixes bbef882cc193 ("msi: add API to get notified about pending bit poll")

This smells like a qemu-stable material?
Though given the bug age, maybe not?

Thanks,

/mjt

Quoted 13 lines
hw/pci/msix.c +1 -1
index 487e49834ee..cc6e79ec678 100644
@@ -250,7 +250,7 @@ static uint64_t msix_pba_mmio_read(void *opaque, hwaddr addr,
      PCIDevice *dev = opaque;
      if (dev->msix_vector_poll_notifier) {
          unsigned vector_start = addr * 8;
-        unsigned vector_end = MIN(addr + size * 8, dev->msix_entries_nr);
+        unsigned vector_end = MIN((addr + size) * 8, dev->msix_entries_nr);
          dev->msix_vector_poll_notifier(dev, vector_start, vector_end);
      }