Skip to contentSkip to conversation

qemu-kvm: Limit MSI vector walk to actual array size

PATCH Applied Jan Kiszka 2 participants 2 messages Apr 29, 2011 – May 3, 2011 KVM

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 qemu-kvm: Limit MSI vector walk to actual array size

We only need to walk as many vectors on updates as the device supports.

---
 hw/msi.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
hw/msi.c +3 -1
index ddcfedd..92773e5 100644
@@ -134,13 +134,15 @@ static void kvm_msi_message_from_vector(PCIDevice *dev, unsigned vector,
 static void kvm_msi_update(PCIDevice *dev)
 {
     uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev));
+    unsigned int max_vectors = 1 <<
+        ((flags & PCI_MSI_FLAGS_QMASK) >> (ffs(PCI_MSI_FLAGS_QMASK) - 1));
     unsigned int nr_vectors = msi_nr_vectors(flags);
     KVMMsiMessage new_entry, *entry;
     bool changed = false;
     unsigned int vector;
     int r;
 
-    for (vector = 0; vector < 32; vector++) {
+    for (vector = 0; vector < max_vectors; vector++) {
         entry = dev->msi_irq_entries + vector;
 
         if (vector >= nr_vectors) {
Signature · 1 line
1.7.1