From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [PATCH] qemu-kvm: Limit MSI vector walk to actual array size
Date: Fri, 29 Apr 2011 13:24:59 +0200 [thread overview]
Message-ID: <4DBAA00B.2000309@siemens.com> (raw)
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(-)
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) {
--
1.7.1
next reply other threads:[~2011-04-29 11:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-29 11:24 Jan Kiszka [this message]
2011-05-03 19:19 ` [PATCH] qemu-kvm: Limit MSI vector walk to actual array size Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DBAA00B.2000309@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).