]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
msix: Prevent bogus mask updates on MMIO accesses
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 21 Nov 2011 16:57:31 +0000 (18:57 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 21 Nov 2011 21:05:59 +0000 (15:05 -0600)
>From: Jan Kiszka <jan.kiszka@siemens.com>

Only accesses to the MSI-X table must trigger a call to
msix_handle_mask_update, otherwise the vector
value might be out of range.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/msix.c

index 63b41b99336d1f6748e6574bf78bba7596187d00..29696016ada4d606328ee0aca4c2371a57174bb9 100644 (file)
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -176,6 +176,12 @@ static void msix_mmio_write(void *opaque, target_phys_addr_t addr,
     PCIDevice *dev = opaque;
     unsigned int offset = addr & (MSIX_PAGE_SIZE - 1) & ~0x3;
     int vector = offset / PCI_MSIX_ENTRY_SIZE;
+
+    /* MSI-X page includes a read-only PBA and a writeable Vector Control. */
+    if (vector >= dev->msix_entries_nr) {
+        return;
+    }
+
     pci_set_long(dev->msix_table_page + offset, val);
     msix_handle_mask_update(dev, vector);
 }