diff mbox

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

Message ID 4DBAA00B.2000309@siemens.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka April 29, 2011, 11:24 a.m. UTC
We only need to walk as many vectors on updates as the device supports.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/msi.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Comments

Marcelo Tosatti May 3, 2011, 7:19 p.m. UTC | #1
On Fri, Apr 29, 2011 at 01:24:59PM +0200, Jan Kiszka wrote:
> We only need to walk as many vectors on updates as the device supports.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

Applied, thanks.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/hw/msi.c b/hw/msi.c
index ddcfedd..92773e5 100644
--- a/hw/msi.c
+++ b/hw/msi.c
@@ -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) {