Skip to contentSkip to conversation

qemu-kvm: Do not advertise MSI caps on lacking KVM support

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: Do not advertise MSI caps on lacking KVM support

As suggested by Michael Tsirkin: Move the check for GSI routing from kvm_msi_message_add to the MSI/MSI-X initalization. If it fails (and KVM is in in-kernel irqchip mode), do not advertise MSI at all.

---
 hw/msi.c   |    4 ++++
 hw/msix.c  |    4 +++-
 qemu-kvm.c |    4 ----
 3 files changed, 7 insertions(+), 5 deletions(-)
hw/msi.c +4 -0
index 725b2b7..ddcfedd 100644
@@ -208,6 +208,10 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,
                    " 64bit %d mask %d\n",
                    offset, nr_vectors, msi64bit, msi_per_vector_mask);
 
+    if (kvm_enabled() && kvm_irqchip_in_kernel() && !kvm_has_gsi_routing()) {
+        return -ENOTSUP;
+    }
+
     assert(!(nr_vectors & (nr_vectors - 1)));   /* power of 2 */
     assert(nr_vectors > 0);
     assert(nr_vectors <= PCI_MSI_VECTORS_MAX);
hw/msix.c +3 -1
index 9cee086..d371940 100644
@@ -350,8 +350,10 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
 {
     int ret;
     /* Nothing to do if MSI is not supported by interrupt controller */
-    if (!msix_supported)
+    if (!msix_supported ||
+        (kvm_enabled() && kvm_irqchip_in_kernel() && !kvm_has_gsi_routing())) {
         return -ENOTSUP;
+    }
 
     if (nentries > MSIX_MAX_ENTRIES)
         return -EINVAL;
qemu-kvm.c +0 -4
index e8c2009..b951146 100644
@@ -986,10 +986,6 @@ int kvm_msi_message_add(KVMMsiMessage *msg)
     struct kvm_irq_routing_entry e;
     int ret;
 
-    if (!kvm_has_gsi_routing()) {
-        return -EOPNOTSUPP;
-    }
-
     ret = kvm_get_irq_route_gsi();
     if (ret < 0) {
         return ret;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 5 lines · Jan Kiszka

As suggested by Michael Tsirkin: Move the check for GSI routing from kvm_msi_message_add to the MSI/MSI-X initalization. If it fails (and KVM is in in-kernel irqchip mode), do not advertise MSI at all.

Applied, thanks.