Skip to contentSkip to conversation

qemu-kvm: enable msi with irqchip

PATCH Superseded Michael S. Tsirkin 2 participants 2 messages Jul 5, 2009 KVM

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qemu-kvm: enable msi with irqchip

Support msi-x with irqchip in kernel: allocate entries when they are used, and update when they are unmasked.

---
Avi, please consider merging this in qemu-kvm.git.

Changes since v1:
add braces as per CODING_STYLE

 hw/apic.c    |    4 +--
 hw/msix.c    |   94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 hw/pci.h     |    3 ++
 libkvm-all.h |   14 ++++++++
 qemu-kvm.c   |   54 +++++++++++++++++++++++++++++++++
 5 files changed, 163 insertions(+), 6 deletions(-)
hw/apic.c +1 -3
index 778a853..cdb5972 100644
@@ -1088,9 +1088,7 @@ int apic_init(CPUState *env)
     s->cpu_env = env;
 
     apic_reset(s);
-    if (!kvm_enabled() || !qemu_kvm_irqchip_in_kernel()) {
-        msix_supported = 1;
-    }
+    msix_supported = 1;
 
     /* XXX: mapping more APICs at the same memory location */
     if (apic_io_memory == 0) {
hw/msix.c +91 -3

141 lines not on this page · raw message

hw/pci.h +3 -0
index 7ae9c93..66235e4 100644
@@ -5,6 +5,8 @@
 
 #include "qdev.h"
 
+struct kvm_irq_routing_entry;
+
 /* PCI includes legacy ISA access.  */
 #include "isa.h"
 
@@ -232,6 +234,7 @@ struct PCIDevice {
     unsigned *msix_entry_used;
     /* Region including the MSI-X table */
     uint32_t msix_bar_size;
+    struct kvm_irq_routing_entry *msix_irq_entries;
 
     /* Device capability configuration space */
     struct {
libkvm-all.h +14 -0
index ecd3065..4a98bcb 100644
@@ -898,6 +898,20 @@ int kvm_del_routing_entry(kvm_context_t kvm,
 		          struct kvm_irq_routing_entry* entry);
 
 /*!
+ * \brief Updates a routing in the temporary irq routing table
+ *
+ * Update a routing in the temporary irq routing table
+ * with a new value. entry type and GSI can not be changed.
+ * Nothing is committed to the running VM.
+ *
+ * \param kvm Pointer to the current kvm_context
+ */
+int kvm_update_routing_entry(kvm_context_t kvm,
+                             struct kvm_irq_routing_entry* entry,
+                             struct kvm_irq_routing_entry* newentry
+);
+
+/*!
  * \brief Commit the temporary irq routing table
  *
  * Commit the temporary irq routing table to the running VM.
qemu-kvm.c +54 -0

60 lines not on this page · raw message

Signature · 1 line
1.6.2.2
#1 lore raw
Quoted 13 lines · Michael S. Tsirkin

Support msi-x with irqchip in kernel: allocate entries when they are used, and update when they are unmasked.

  /* Declaration from linux/pci_regs.h */
  #define  PCI_CAP_ID_MSIX 0x11 /* MSI-X */
hw/msix.c +3 -0
@@ -109,6 +110,18 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries,
  static void msix_free_irq_entries(PCIDevice *dev)
  {
      int vector;
+    if (kvm_enabled()&&  qemu_kvm_irqchip_in_kernel()) {
+        int changed = 0;
+        for (vector = 0; vector<  dev->msix_entries_nr; ++vector) {

hw/msix.c static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries, · line 125

Quoted 10 lines
hw/msix.c +9 -0
+            if (dev->msix_entry_used[vector]) {
+                kvm_del_routing_entry(kvm_context,&dev->msix_irq_entries[vector]);
+                changed = 1;
+            }
+        }
+        if (changed) {
+            kvm_commit_irq_routes(kvm_context);
+        }
+    }
 

Please move this into a helper. Ditto all the code hunks in msix functions.

Signature · 1 line
error compiling committee.c: too many arguments to function