[PATCH v2 4/8] Avoid use of kvm_irq_routing_entry in hw/msix.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kvm_irq_routing_entry cannot be used when CONFIG_KVM is disabled; add a new
interface to the kvm support code that uses scalars instead.

Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
---
 hw/msix.c    |   35 ++++++++++-------------------------
 qemu-kvm.c   |   44 ++++++++++++++++++++++++++++++++++++++++++++
 qemu-kvm.h   |    9 +++++++++
 roms/seabios |    2 +-
 4 files changed, 64 insertions(+), 26 deletions(-)

diff --git a/hw/msix.c b/hw/msix.c
index e00fc6c..c752e90 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -49,28 +49,16 @@ int msix_supported;
 
 #ifdef CONFIG_KVM
 
-static void kvm_msix_message_to_routing_entry(struct kvm_msix_message *kmm,
-                                              struct kvm_irq_routing_entry *e)
-{
-    e->type = KVM_IRQ_ROUTING_MSI;
-    e->flags = 0;
-    e->u.msi.address_lo = kmm->addr_lo;
-    e->u.msi.address_hi = kmm->addr_hi;
-    e->u.msi.data = kmm->data;
-}
-
 /* KVM specific MSIX helpers */
 static void kvm_msix_free(PCIDevice *dev)
 {
     int vector, changed = 0;
     struct kvm_msix_message *kmm;
-    struct kvm_irq_routing_entry entry;
 
     for (vector = 0; vector < dev->msix_entries_nr; ++vector) {
         if (dev->msix_entry_used[vector]) {
             kmm = &dev->msix_irq_entries[vector];
-            kvm_msix_message_to_routing_entry(kmm, &entry);
-            kvm_del_routing_entry(&entry);
+            kvm_del_msix(kmm->gsi, kmm->addr_lo, kmm->addr_hi, kmm->data);
             changed = 1;
         }
     }
@@ -106,14 +94,13 @@ static void kvm_msix_update(PCIDevice *dev, int vector,
     e.gsi = entry->gsi;
     kvm_msix_message_from_vector(dev, vector, &e);
     if (memcmp(entry, &e, sizeof e) != 0) {
-        struct kvm_irq_routing_entry old, new;
         int r;
 
-        kvm_msix_message_to_routing_entry(entry, &old);
-        kvm_msix_message_to_routing_entry(&e, &new);
-        r = kvm_update_routing_entry(&old, &new);
+        r = kvm_update_msix(entry->gsi, entry->addr_lo,
+                            entry->addr_hi, entry->data,
+                            e.gsi, e.addr_lo, e.addr_hi, e.data);
         if (r) {
-            fprintf(stderr, "%s: kvm_update_routing_entry failed: %s\n", __func__,
+            fprintf(stderr, "%s: kvm_update_msix failed: %s\n", __func__,
 		    strerror(-r));
             exit(1);
         }
@@ -130,7 +117,6 @@ static void kvm_msix_update(PCIDevice *dev, int vector,
 static int kvm_msix_add(PCIDevice *dev, unsigned vector)
 {
     struct kvm_msix_message *kmm = dev->msix_irq_entries + vector;
-    struct kvm_irq_routing_entry entry;
     int r;
 
     if (!kvm_has_gsi_routing()) {
@@ -147,10 +133,9 @@ static int kvm_msix_add(PCIDevice *dev, unsigned vector)
     }
     kmm->gsi = r;
     kvm_msix_message_from_vector(dev, vector, kmm);
-    kvm_msix_message_to_routing_entry(kmm, &entry);
-    r = kvm_add_routing_entry(&entry);
+    r = kvm_add_msix(kmm->gsi, kmm->addr_lo, kmm->addr_hi, kmm->data);
     if (r < 0) {
-        fprintf(stderr, "%s: kvm_add_routing_entry failed: %s\n", __func__, strerror(-r));
+        fprintf(stderr, "%s: kvm_add_msix failed: %s\n", __func__, strerror(-r));
         return r;
     }
 
@@ -164,13 +149,13 @@ static int kvm_msix_add(PCIDevice *dev, unsigned vector)
 
 static void kvm_msix_del(PCIDevice *dev, unsigned vector)
 {
-    struct kvm_irq_routing_entry entry;
+    struct kvm_msix_message *kmm;
 
     if (dev->msix_entry_used[vector]) {
         return;
     }
-    kvm_msix_message_to_routing_entry(&dev->msix_irq_entries[vector], &entry);
-    kvm_del_routing_entry(&entry);
+    kmm = &dev->msix_irq_entries[vector];
+    kvm_del_msix(kmm->gsi, kmm->addr_lo, kmm->addr_hi, kmm->data);
     kvm_commit_irq_routes();
 }
 #else
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 3966523..733d0a9 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1036,6 +1036,50 @@ int kvm_get_irq_route_gsi(void)
     return -ENOSPC;
 }
 
+static void kvm_msix_routing_entry(struct kvm_irq_routing_entry *e,
+                                   uint32_t gsi, uint32_t addr_lo,
+                                   uint32_t addr_hi, uint32_t data)
+
+{
+    e->gsi = gsi;
+    e->type = KVM_IRQ_ROUTING_MSI;
+    e->flags = 0;
+    e->u.msi.address_lo = addr_lo;
+    e->u.msi.address_hi = addr_hi;
+    e->u.msi.data = data;
+}
+
+int kvm_add_msix(uint32_t gsi, uint32_t addr_lo,
+                        uint32_t addr_hi, uint32_t data)
+{
+    struct kvm_irq_routing_entry e;
+
+    kvm_msix_routing_entry(&e, gsi, addr_lo, addr_hi, data);
+    return kvm_add_routing_entry(&e);
+}
+
+int kvm_del_msix(uint32_t gsi, uint32_t addr_lo,
+                        uint32_t addr_hi, uint32_t data)
+{
+    struct kvm_irq_routing_entry e;
+
+    kvm_msix_routing_entry(&e, gsi, addr_lo, addr_hi, data);
+    return kvm_del_routing_entry(&e);
+}
+
+int kvm_update_msix(uint32_t old_gsi, uint32_t old_addr_lo,
+                    uint32_t old_addr_hi, uint32_t old_data,
+                    uint32_t new_gsi, uint32_t new_addr_lo,
+                    uint32_t new_addr_hi, uint32_t new_data)
+{
+    struct kvm_irq_routing_entry e1, e2;
+
+    kvm_msix_routing_entry(&e1, old_gsi, old_addr_lo, old_addr_hi, old_data);
+    kvm_msix_routing_entry(&e2, new_gsi, new_addr_lo, new_addr_hi, new_data);
+    return kvm_update_routing_entry(&e1, &e2);
+}
+
+
 #ifdef KVM_CAP_DEVICE_MSIX
 int kvm_assign_set_msix_nr(kvm_context_t kvm,
                            struct kvm_assigned_msix_nr *msix_nr)
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 1030a02..25f71db 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -704,6 +704,15 @@ int kvm_add_irq_route(int gsi, int irqchip, int pin);
  */
 int kvm_del_irq_route(int gsi, int irqchip, int pin);
 
+int kvm_add_msix(uint32_t gsi, uint32_t addr_lo,
+                 uint32_t addr_hi, uint32_t data);
+int kvm_del_msix(uint32_t gsi, uint32_t addr_lo,
+                 uint32_t addr_hi, uint32_t data);
+int kvm_update_msix(uint32_t old_gsi, uint32_t old_addr_lo,
+                    uint32_t old_addr_hi, uint32_t old_data,
+                    uint32_t new_gsi, uint32_t new_addr_lo,
+                    uint32_t new_addr_hi, uint32_t new_data);
+
 struct kvm_irq_routing_entry;
 /*!
  * \brief Adds a routing entry to the temporary irq routing table
diff --git a/roms/seabios b/roms/seabios
index 17d3e46..94dc9c4 160000
--- a/roms/seabios
+++ b/roms/seabios
@@ -1 +1 @@
-Subproject commit 17d3e46511aeedc9f09a8216d194d749187b80aa
+Subproject commit 94dc9c49c283cd576c25692d17567035557a2505
-- 
1.7.3.1

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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux