summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2011-04-29 13:24:59 +0200
committerMarcelo Tosatti <mtosatti@redhat.com>2011-05-03 16:19:09 -0300
commit70757dcaa40e14978bf287084d8fab9efb815a2d (patch)
treef879ea130449225d3aff09005f60f0ef84f0c185
parent6c1ec4cf90f2dfb299ac4469952fbbc8a9f8294c (diff)
qemu-kvm: Limit MSI vector walk to actual array size
We only need to walk as many vectors on updates as the device supports. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r--hw/msi.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/msi.c b/hw/msi.c
index ddcfedd6e..92773e547 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) {