All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
@ 2012-04-03  7:23 ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Michael S. Tsirkin

This is v2 of the RFC, fixing a memory leak in
kvm_flush_dynamic_msi_routes and adding support for the proposed
KVM_SIGNAL_MSI IOCTL.

This series depends on "kvm: set gsi_bits and max_gsi correctly"
(http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).

Jan Kiszka (4):
  kvm: Refactor KVMState::max_gsi to gsi_count
  kvm: Introduce basic MSI support for in-kernel irqchips
  KVM: x86: Wire up MSI support for in-kernel irqchip
  kvm: Add support for direct MSI injections

 hw/apic.c     |    3 +
 hw/kvm/apic.c |   33 +++++++++-
 hw/pc.c       |    5 --
 kvm-all.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 kvm.h         |    1 +
 5 files changed, 225 insertions(+), 12 deletions(-)

-- 
1.7.3.4


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Qemu-devel] [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
@ 2012-04-03  7:23 ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm, Michael S. Tsirkin

This is v2 of the RFC, fixing a memory leak in
kvm_flush_dynamic_msi_routes and adding support for the proposed
KVM_SIGNAL_MSI IOCTL.

This series depends on "kvm: set gsi_bits and max_gsi correctly"
(http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).

Jan Kiszka (4):
  kvm: Refactor KVMState::max_gsi to gsi_count
  kvm: Introduce basic MSI support for in-kernel irqchips
  KVM: x86: Wire up MSI support for in-kernel irqchip
  kvm: Add support for direct MSI injections

 hw/apic.c     |    3 +
 hw/kvm/apic.c |   33 +++++++++-
 hw/pc.c       |    5 --
 kvm-all.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 kvm.h         |    1 +
 5 files changed, 225 insertions(+), 12 deletions(-)

-- 
1.7.3.4

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [RFC][PATCH v2 1/4] kvm: Refactor KVMState::max_gsi to gsi_count
  2012-04-03  7:23 ` [Qemu-devel] " Jan Kiszka
@ 2012-04-03  7:23   ` Jan Kiszka
  -1 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Michael S. Tsirkin

From: Jan Kiszka <jan.kiszka@siemens.com>

Instead of the bitmap size, store the maximum of GSIs the kernel
support. Move the GSI limit assertion to the API function
kvm_irqchip_add_route and make it stricter.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kvm-all.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index b8e9dc6..eb0b4c0 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -86,7 +86,7 @@ struct KVMState
     struct kvm_irq_routing *irq_routes;
     int nr_allocated_irq_routes;
     uint32_t *used_gsi_bitmap;
-    unsigned int max_gsi;
+    unsigned int gsi_count;
 #endif
 };
 
@@ -857,8 +857,6 @@ int kvm_irqchip_set_irq(KVMState *s, int irq, int level)
 #ifdef KVM_CAP_IRQ_ROUTING
 static void set_gsi(KVMState *s, unsigned int gsi)
 {
-    assert(gsi < s->max_gsi);
-
     s->used_gsi_bitmap[gsi / 32] |= 1U << (gsi % 32);
 }
 
@@ -873,7 +871,7 @@ static void kvm_init_irq_routing(KVMState *s)
         /* Round up so we can search ints using ffs */
         gsi_bits = ALIGN(gsi_count, 32);
         s->used_gsi_bitmap = g_malloc0(gsi_bits / 8);
-        s->max_gsi = gsi_bits;
+        s->gsi_count = gsi_count;
 
         /* Mark any over-allocated bits as already in use */
         for (i = gsi_count; i < gsi_bits; i++) {
@@ -918,6 +916,8 @@ void kvm_irqchip_add_route(KVMState *s, int irq, int irqchip, int pin)
 {
     struct kvm_irq_routing_entry e;
 
+    assert(pin < s->gsi_count);
+
     e.gsi = irq;
     e.type = KVM_IRQ_ROUTING_IRQCHIP;
     e.flags = 0;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [RFC][PATCH v2 1/4] kvm: Refactor KVMState::max_gsi to gsi_count
@ 2012-04-03  7:23   ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm, Michael S. Tsirkin

From: Jan Kiszka <jan.kiszka@siemens.com>

Instead of the bitmap size, store the maximum of GSIs the kernel
support. Move the GSI limit assertion to the API function
kvm_irqchip_add_route and make it stricter.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kvm-all.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index b8e9dc6..eb0b4c0 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -86,7 +86,7 @@ struct KVMState
     struct kvm_irq_routing *irq_routes;
     int nr_allocated_irq_routes;
     uint32_t *used_gsi_bitmap;
-    unsigned int max_gsi;
+    unsigned int gsi_count;
 #endif
 };
 
@@ -857,8 +857,6 @@ int kvm_irqchip_set_irq(KVMState *s, int irq, int level)
 #ifdef KVM_CAP_IRQ_ROUTING
 static void set_gsi(KVMState *s, unsigned int gsi)
 {
-    assert(gsi < s->max_gsi);
-
     s->used_gsi_bitmap[gsi / 32] |= 1U << (gsi % 32);
 }
 
@@ -873,7 +871,7 @@ static void kvm_init_irq_routing(KVMState *s)
         /* Round up so we can search ints using ffs */
         gsi_bits = ALIGN(gsi_count, 32);
         s->used_gsi_bitmap = g_malloc0(gsi_bits / 8);
-        s->max_gsi = gsi_bits;
+        s->gsi_count = gsi_count;
 
         /* Mark any over-allocated bits as already in use */
         for (i = gsi_count; i < gsi_bits; i++) {
@@ -918,6 +916,8 @@ void kvm_irqchip_add_route(KVMState *s, int irq, int irqchip, int pin)
 {
     struct kvm_irq_routing_entry e;
 
+    assert(pin < s->gsi_count);
+
     e.gsi = irq;
     e.type = KVM_IRQ_ROUTING_IRQCHIP;
     e.flags = 0;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC][PATCH v2 2/4] kvm: Introduce basic MSI support for in-kernel irqchips
  2012-04-03  7:23 ` [Qemu-devel] " Jan Kiszka
@ 2012-04-03  7:23   ` Jan Kiszka
  -1 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Michael S. Tsirkin

From: Jan Kiszka <jan.kiszka@siemens.com>

This patch basically adds kvm_irqchip_send_msi, a service for sending
arbitrary MSI messages to KVM's in-kernel irqchip models.

As the current KVI API requires us to establish a static route from a
pseudo GSI to the target MSI message and inject the MSI via toggling
that GSI, we need to play some tricks to make this unfortunately
interface transparent. We create those routes on demand and keep them
in a hash table. Succeeding messages can then search for an existing
route in the table first and reuse it whenever possible. If we should
run out of limited GSIs, we simply flush the table and rebuild it as
messages are sent.

This approach is rather simple and could be optimized further. However,
future kernels will contain a more efficient MSI injection interface
that will obsolete the GSI-based dynamic injection.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kvm-all.c |  171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 kvm.h     |    1 +
 2 files changed, 171 insertions(+), 1 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index eb0b4c0..5256511 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -48,6 +48,8 @@
     do { } while (0)
 #endif
 
+#define KVM_MSI_HASHTAB_SIZE    256
+
 typedef struct KVMSlot
 {
     target_phys_addr_t start_addr;
@@ -59,6 +61,11 @@ typedef struct KVMSlot
 
 typedef struct kvm_dirty_log KVMDirtyLog;
 
+typedef struct KVMMSIRoute {
+    struct kvm_irq_routing_entry kroute;
+    QTAILQ_ENTRY(KVMMSIRoute) entry;
+} KVMMSIRoute;
+
 struct KVMState
 {
     KVMSlot slots[32];
@@ -87,6 +94,7 @@ struct KVMState
     int nr_allocated_irq_routes;
     uint32_t *used_gsi_bitmap;
     unsigned int gsi_count;
+    QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
 #endif
 };
 
@@ -860,9 +868,14 @@ static void set_gsi(KVMState *s, unsigned int gsi)
     s->used_gsi_bitmap[gsi / 32] |= 1U << (gsi % 32);
 }
 
+static void clear_gsi(KVMState *s, unsigned int gsi)
+{
+    s->used_gsi_bitmap[gsi / 32] &= ~(1U << (gsi % 32));
+}
+
 static void kvm_init_irq_routing(KVMState *s)
 {
-    int gsi_count;
+    int gsi_count, i;
 
     gsi_count = kvm_check_extension(s, KVM_CAP_IRQ_ROUTING);
     if (gsi_count > 0) {
@@ -882,6 +895,10 @@ static void kvm_init_irq_routing(KVMState *s)
     s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
     s->nr_allocated_irq_routes = 0;
 
+    for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
+        QTAILQ_INIT(&s->msi_hashtab[i]);
+    }
+
     kvm_arch_init_irq_routing(s);
 }
 
@@ -912,6 +929,54 @@ static void kvm_add_routing_entry(KVMState *s,
     set_gsi(s, entry->gsi);
 }
 
+static void kvm_remove_routing_entry(KVMState *s,
+                                     struct kvm_irq_routing_entry *entry)
+{
+    struct kvm_irq_routing_entry *e;
+    int gsi = entry->gsi;
+    int i;
+
+    for (i = 0; i < s->irq_routes->nr; ++i) {
+        e = &s->irq_routes->entries[i];
+        if (e->type == entry->type && e->gsi == gsi) {
+            switch (e->type) {
+            case KVM_IRQ_ROUTING_IRQCHIP:
+                if (e->u.irqchip.irqchip == entry->u.irqchip.irqchip &&
+                    e->u.irqchip.pin == entry->u.irqchip.pin) {
+                    goto found;
+                }
+                break;
+            case KVM_IRQ_ROUTING_MSI:
+                if (e->u.msi.address_lo == entry->u.msi.address_lo &&
+                    e->u.msi.address_hi == entry->u.msi.address_hi &&
+                    e->u.msi.data == entry->u.msi.data) {
+                    goto found;
+                }
+                break;
+            default:
+                break;
+            }
+        }
+    }
+    /* route not found */
+    return;
+
+found:
+    s->irq_routes->nr--;
+    *e = s->irq_routes->entries[s->irq_routes->nr];
+
+    /* If there are no other users of this GSI, release it. */
+    for (i = 0; i < s->irq_routes->nr; i++) {
+        e = &s->irq_routes->entries[i];
+        if (e->gsi == gsi) {
+            break;
+        }
+    }
+    if (i == s->irq_routes->nr) {
+        clear_gsi(s, gsi);
+    }
+}
+
 void kvm_irqchip_add_route(KVMState *s, int irq, int irqchip, int pin)
 {
     struct kvm_irq_routing_entry e;
@@ -932,11 +997,115 @@ int kvm_irqchip_commit_routes(KVMState *s)
     return kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes);
 }
 
+static unsigned int kvm_hash_msi(uint32_t data)
+{
+    /* This is optimized for IA32 MSI layout. However, no other arch shall
+     * repeat the mistake of not providing a direct MSI injection API. */
+    return data & 0xff;
+}
+
+static void kvm_flush_dynamic_msi_routes(KVMState *s)
+{
+    KVMMSIRoute *route, *next;
+    unsigned int hash;
+
+    for (hash = 0; hash < KVM_MSI_HASHTAB_SIZE; hash++) {
+        QTAILQ_FOREACH_SAFE(route, &s->msi_hashtab[hash], entry, next) {
+            kvm_remove_routing_entry(s, &route->kroute);
+            QTAILQ_REMOVE(&s->msi_hashtab[hash], route, entry);
+            g_free(route);
+        }
+    }
+}
+
+static int kvm_get_pseudo_gsi(KVMState *s)
+{
+    uint32_t *word = s->used_gsi_bitmap;
+    int max_words = ALIGN(s->gsi_count, 32) / 32;
+    int i, bit;
+    bool retry = true;
+
+again:
+    /* Return the lowest unused GSI in the bitmap */
+    for (i = 0; i < max_words; i++) {
+        bit = ffs(~word[i]);
+        if (!bit) {
+            continue;
+        }
+
+        return bit - 1 + i * 32;
+    }
+    if (retry) {
+        retry = false;
+        kvm_flush_dynamic_msi_routes(s);
+        goto again;
+    }
+    return -ENOSPC;
+
+}
+
+static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, uint64_t addr,
+                                         uint32_t data)
+{
+    unsigned int hash = kvm_hash_msi(data);
+    KVMMSIRoute *route;
+
+    QTAILQ_FOREACH(route, &s->msi_hashtab[hash], entry) {
+        if (route->kroute.u.msi.address_lo == (uint32_t)addr &&
+            route->kroute.u.msi.address_hi == (addr >> 32) &&
+            route->kroute.u.msi.data == data) {
+            return route;
+        }
+    }
+    return NULL;
+}
+
+int kvm_irqchip_send_msi(KVMState *s, uint64_t addr, uint32_t data)
+{
+    KVMMSIRoute *route;
+
+    route = kvm_lookup_msi_route(s, addr, data);
+    if (!route) {
+        int gsi, ret;
+
+        gsi = kvm_get_pseudo_gsi(s);
+        if (gsi < 0) {
+            return gsi;
+        }
+
+        route = g_malloc(sizeof(KVMMSIRoute));
+        route->kroute.gsi = gsi;
+        route->kroute.type = KVM_IRQ_ROUTING_MSI;
+        route->kroute.flags = 0;
+        route->kroute.u.msi.address_lo = (uint32_t)addr;
+        route->kroute.u.msi.address_hi = addr >> 32;
+        route->kroute.u.msi.data = data;
+
+        kvm_add_routing_entry(s, &route->kroute);
+
+        QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(data)], route, entry);
+
+        ret = kvm_irqchip_commit_routes(s);
+        if (ret < 0) {
+            return ret;
+        }
+    }
+
+    assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);
+
+    return kvm_irqchip_set_irq(s, route->kroute.gsi, 1);
+}
+
 #else /* !KVM_CAP_IRQ_ROUTING */
 
 static void kvm_init_irq_routing(KVMState *s)
 {
 }
+
+int kvm_irqchip_send_msi(KVMState *s, uint64_t addr, uint32_t data)
+{
+    abort();
+}
 #endif /* !KVM_CAP_IRQ_ROUTING */
 
 static int kvm_irqchip_create(KVMState *s)
diff --git a/kvm.h b/kvm.h
index 4ccae8c..34db583 100644
--- a/kvm.h
+++ b/kvm.h
@@ -132,6 +132,7 @@ int kvm_arch_on_sigbus(int code, void *addr);
 void kvm_arch_init_irq_routing(KVMState *s);
 
 int kvm_irqchip_set_irq(KVMState *s, int irq, int level);
+int kvm_irqchip_send_msi(KVMState *s, uint64_t addr, uint32_t data);
 
 void kvm_irqchip_add_route(KVMState *s, int gsi, int irqchip, int pin);
 int kvm_irqchip_commit_routes(KVMState *s);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [RFC][PATCH v2 2/4] kvm: Introduce basic MSI support for in-kernel irqchips
@ 2012-04-03  7:23   ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm, Michael S. Tsirkin

From: Jan Kiszka <jan.kiszka@siemens.com>

This patch basically adds kvm_irqchip_send_msi, a service for sending
arbitrary MSI messages to KVM's in-kernel irqchip models.

As the current KVI API requires us to establish a static route from a
pseudo GSI to the target MSI message and inject the MSI via toggling
that GSI, we need to play some tricks to make this unfortunately
interface transparent. We create those routes on demand and keep them
in a hash table. Succeeding messages can then search for an existing
route in the table first and reuse it whenever possible. If we should
run out of limited GSIs, we simply flush the table and rebuild it as
messages are sent.

This approach is rather simple and could be optimized further. However,
future kernels will contain a more efficient MSI injection interface
that will obsolete the GSI-based dynamic injection.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kvm-all.c |  171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 kvm.h     |    1 +
 2 files changed, 171 insertions(+), 1 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index eb0b4c0..5256511 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -48,6 +48,8 @@
     do { } while (0)
 #endif
 
+#define KVM_MSI_HASHTAB_SIZE    256
+
 typedef struct KVMSlot
 {
     target_phys_addr_t start_addr;
@@ -59,6 +61,11 @@ typedef struct KVMSlot
 
 typedef struct kvm_dirty_log KVMDirtyLog;
 
+typedef struct KVMMSIRoute {
+    struct kvm_irq_routing_entry kroute;
+    QTAILQ_ENTRY(KVMMSIRoute) entry;
+} KVMMSIRoute;
+
 struct KVMState
 {
     KVMSlot slots[32];
@@ -87,6 +94,7 @@ struct KVMState
     int nr_allocated_irq_routes;
     uint32_t *used_gsi_bitmap;
     unsigned int gsi_count;
+    QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
 #endif
 };
 
@@ -860,9 +868,14 @@ static void set_gsi(KVMState *s, unsigned int gsi)
     s->used_gsi_bitmap[gsi / 32] |= 1U << (gsi % 32);
 }
 
+static void clear_gsi(KVMState *s, unsigned int gsi)
+{
+    s->used_gsi_bitmap[gsi / 32] &= ~(1U << (gsi % 32));
+}
+
 static void kvm_init_irq_routing(KVMState *s)
 {
-    int gsi_count;
+    int gsi_count, i;
 
     gsi_count = kvm_check_extension(s, KVM_CAP_IRQ_ROUTING);
     if (gsi_count > 0) {
@@ -882,6 +895,10 @@ static void kvm_init_irq_routing(KVMState *s)
     s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
     s->nr_allocated_irq_routes = 0;
 
+    for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
+        QTAILQ_INIT(&s->msi_hashtab[i]);
+    }
+
     kvm_arch_init_irq_routing(s);
 }
 
@@ -912,6 +929,54 @@ static void kvm_add_routing_entry(KVMState *s,
     set_gsi(s, entry->gsi);
 }
 
+static void kvm_remove_routing_entry(KVMState *s,
+                                     struct kvm_irq_routing_entry *entry)
+{
+    struct kvm_irq_routing_entry *e;
+    int gsi = entry->gsi;
+    int i;
+
+    for (i = 0; i < s->irq_routes->nr; ++i) {
+        e = &s->irq_routes->entries[i];
+        if (e->type == entry->type && e->gsi == gsi) {
+            switch (e->type) {
+            case KVM_IRQ_ROUTING_IRQCHIP:
+                if (e->u.irqchip.irqchip == entry->u.irqchip.irqchip &&
+                    e->u.irqchip.pin == entry->u.irqchip.pin) {
+                    goto found;
+                }
+                break;
+            case KVM_IRQ_ROUTING_MSI:
+                if (e->u.msi.address_lo == entry->u.msi.address_lo &&
+                    e->u.msi.address_hi == entry->u.msi.address_hi &&
+                    e->u.msi.data == entry->u.msi.data) {
+                    goto found;
+                }
+                break;
+            default:
+                break;
+            }
+        }
+    }
+    /* route not found */
+    return;
+
+found:
+    s->irq_routes->nr--;
+    *e = s->irq_routes->entries[s->irq_routes->nr];
+
+    /* If there are no other users of this GSI, release it. */
+    for (i = 0; i < s->irq_routes->nr; i++) {
+        e = &s->irq_routes->entries[i];
+        if (e->gsi == gsi) {
+            break;
+        }
+    }
+    if (i == s->irq_routes->nr) {
+        clear_gsi(s, gsi);
+    }
+}
+
 void kvm_irqchip_add_route(KVMState *s, int irq, int irqchip, int pin)
 {
     struct kvm_irq_routing_entry e;
@@ -932,11 +997,115 @@ int kvm_irqchip_commit_routes(KVMState *s)
     return kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes);
 }
 
+static unsigned int kvm_hash_msi(uint32_t data)
+{
+    /* This is optimized for IA32 MSI layout. However, no other arch shall
+     * repeat the mistake of not providing a direct MSI injection API. */
+    return data & 0xff;
+}
+
+static void kvm_flush_dynamic_msi_routes(KVMState *s)
+{
+    KVMMSIRoute *route, *next;
+    unsigned int hash;
+
+    for (hash = 0; hash < KVM_MSI_HASHTAB_SIZE; hash++) {
+        QTAILQ_FOREACH_SAFE(route, &s->msi_hashtab[hash], entry, next) {
+            kvm_remove_routing_entry(s, &route->kroute);
+            QTAILQ_REMOVE(&s->msi_hashtab[hash], route, entry);
+            g_free(route);
+        }
+    }
+}
+
+static int kvm_get_pseudo_gsi(KVMState *s)
+{
+    uint32_t *word = s->used_gsi_bitmap;
+    int max_words = ALIGN(s->gsi_count, 32) / 32;
+    int i, bit;
+    bool retry = true;
+
+again:
+    /* Return the lowest unused GSI in the bitmap */
+    for (i = 0; i < max_words; i++) {
+        bit = ffs(~word[i]);
+        if (!bit) {
+            continue;
+        }
+
+        return bit - 1 + i * 32;
+    }
+    if (retry) {
+        retry = false;
+        kvm_flush_dynamic_msi_routes(s);
+        goto again;
+    }
+    return -ENOSPC;
+
+}
+
+static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, uint64_t addr,
+                                         uint32_t data)
+{
+    unsigned int hash = kvm_hash_msi(data);
+    KVMMSIRoute *route;
+
+    QTAILQ_FOREACH(route, &s->msi_hashtab[hash], entry) {
+        if (route->kroute.u.msi.address_lo == (uint32_t)addr &&
+            route->kroute.u.msi.address_hi == (addr >> 32) &&
+            route->kroute.u.msi.data == data) {
+            return route;
+        }
+    }
+    return NULL;
+}
+
+int kvm_irqchip_send_msi(KVMState *s, uint64_t addr, uint32_t data)
+{
+    KVMMSIRoute *route;
+
+    route = kvm_lookup_msi_route(s, addr, data);
+    if (!route) {
+        int gsi, ret;
+
+        gsi = kvm_get_pseudo_gsi(s);
+        if (gsi < 0) {
+            return gsi;
+        }
+
+        route = g_malloc(sizeof(KVMMSIRoute));
+        route->kroute.gsi = gsi;
+        route->kroute.type = KVM_IRQ_ROUTING_MSI;
+        route->kroute.flags = 0;
+        route->kroute.u.msi.address_lo = (uint32_t)addr;
+        route->kroute.u.msi.address_hi = addr >> 32;
+        route->kroute.u.msi.data = data;
+
+        kvm_add_routing_entry(s, &route->kroute);
+
+        QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(data)], route, entry);
+
+        ret = kvm_irqchip_commit_routes(s);
+        if (ret < 0) {
+            return ret;
+        }
+    }
+
+    assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);
+
+    return kvm_irqchip_set_irq(s, route->kroute.gsi, 1);
+}
+
 #else /* !KVM_CAP_IRQ_ROUTING */
 
 static void kvm_init_irq_routing(KVMState *s)
 {
 }
+
+int kvm_irqchip_send_msi(KVMState *s, uint64_t addr, uint32_t data)
+{
+    abort();
+}
 #endif /* !KVM_CAP_IRQ_ROUTING */
 
 static int kvm_irqchip_create(KVMState *s)
diff --git a/kvm.h b/kvm.h
index 4ccae8c..34db583 100644
--- a/kvm.h
+++ b/kvm.h
@@ -132,6 +132,7 @@ int kvm_arch_on_sigbus(int code, void *addr);
 void kvm_arch_init_irq_routing(KVMState *s);
 
 int kvm_irqchip_set_irq(KVMState *s, int irq, int level);
+int kvm_irqchip_send_msi(KVMState *s, uint64_t addr, uint32_t data);
 
 void kvm_irqchip_add_route(KVMState *s, int gsi, int irqchip, int pin);
 int kvm_irqchip_commit_routes(KVMState *s);
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC][PATCH v2 3/4] KVM: x86: Wire up MSI support for in-kernel irqchip
  2012-04-03  7:23 ` [Qemu-devel] " Jan Kiszka
@ 2012-04-03  7:23   ` Jan Kiszka
  -1 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Michael S. Tsirkin

From: Jan Kiszka <jan.kiszka@siemens.com>

Catch writes to the MSI MMIO region in the KVM APIC and forward them to
the kernel. Provide the kernel support GSI routing, this allows to
enable MSI support also for in-kernel irqchip mode.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/apic.c     |    3 +++
 hw/kvm/apic.c |   33 +++++++++++++++++++++++++++++++--
 hw/pc.c       |    5 -----
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/hw/apic.c b/hw/apic.c
index 4eeaf88..5fbf01c 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -19,6 +19,7 @@
 #include "apic_internal.h"
 #include "apic.h"
 #include "ioapic.h"
+#include "msi.h"
 #include "host-utils.h"
 #include "trace.h"
 #include "pc.h"
@@ -862,6 +863,8 @@ static void apic_init(APICCommonState *s)
 
     s->timer = qemu_new_timer_ns(vm_clock, apic_timer, s);
     local_apics[s->idx] = s;
+
+    msi_supported = true;
 }
 
 static void apic_class_init(ObjectClass *klass, void *data)
diff --git a/hw/kvm/apic.c b/hw/kvm/apic.c
index ffe7a52..7d83b1a 100644
--- a/hw/kvm/apic.c
+++ b/hw/kvm/apic.c
@@ -10,6 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 #include "hw/apic_internal.h"
+#include "hw/msi.h"
 #include "kvm.h"
 
 static inline void kvm_apic_set_reg(struct kvm_lapic_state *kapic,
@@ -145,10 +146,38 @@ static void kvm_apic_external_nmi(APICCommonState *s)
     run_on_cpu(s->cpu_env, do_inject_external_nmi, s);
 }
 
+static uint64_t kvm_apic_mem_read(void *opaque, target_phys_addr_t addr,
+                                  unsigned size)
+{
+    return -1U;
+}
+
+static void kvm_apic_mem_write(void *opaque, target_phys_addr_t addr,
+                               uint64_t data, unsigned size)
+{
+    int ret;
+
+    ret = kvm_irqchip_send_msi(kvm_state, addr, data);
+    if (ret < 0) {
+        fprintf(stderr, "KVM: injection failed, MSI lost (%s)\n",
+                strerror(-ret));
+    }
+}
+
+static const MemoryRegionOps kvm_apic_io_ops = {
+    .read = kvm_apic_mem_read,
+    .write = kvm_apic_mem_write,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+};
+
 static void kvm_apic_init(APICCommonState *s)
 {
-    memory_region_init_reservation(&s->io_memory, "kvm-apic-msi",
-                                   MSI_SPACE_SIZE);
+    memory_region_init_io(&s->io_memory, &kvm_apic_io_ops, s, "kvm-apic-msi",
+                          MSI_SPACE_SIZE);
+
+    if (kvm_has_gsi_routing()) {
+        msi_supported = true;
+    }
 }
 
 static void kvm_apic_class_init(ObjectClass *klass, void *data)
diff --git a/hw/pc.c b/hw/pc.c
index 83a1b5b..fab620a 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -907,11 +907,6 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
         apic_mapped = 1;
     }
 
-    /* KVM does not support MSI yet. */
-    if (!kvm_irqchip_in_kernel()) {
-        msi_supported = true;
-    }
-
     return dev;
 }
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [RFC][PATCH v2 3/4] KVM: x86: Wire up MSI support for in-kernel irqchip
@ 2012-04-03  7:23   ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm, Michael S. Tsirkin

From: Jan Kiszka <jan.kiszka@siemens.com>

Catch writes to the MSI MMIO region in the KVM APIC and forward them to
the kernel. Provide the kernel support GSI routing, this allows to
enable MSI support also for in-kernel irqchip mode.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/apic.c     |    3 +++
 hw/kvm/apic.c |   33 +++++++++++++++++++++++++++++++--
 hw/pc.c       |    5 -----
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/hw/apic.c b/hw/apic.c
index 4eeaf88..5fbf01c 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -19,6 +19,7 @@
 #include "apic_internal.h"
 #include "apic.h"
 #include "ioapic.h"
+#include "msi.h"
 #include "host-utils.h"
 #include "trace.h"
 #include "pc.h"
@@ -862,6 +863,8 @@ static void apic_init(APICCommonState *s)
 
     s->timer = qemu_new_timer_ns(vm_clock, apic_timer, s);
     local_apics[s->idx] = s;
+
+    msi_supported = true;
 }
 
 static void apic_class_init(ObjectClass *klass, void *data)
diff --git a/hw/kvm/apic.c b/hw/kvm/apic.c
index ffe7a52..7d83b1a 100644
--- a/hw/kvm/apic.c
+++ b/hw/kvm/apic.c
@@ -10,6 +10,7 @@
  * See the COPYING file in the top-level directory.
  */
 #include "hw/apic_internal.h"
+#include "hw/msi.h"
 #include "kvm.h"
 
 static inline void kvm_apic_set_reg(struct kvm_lapic_state *kapic,
@@ -145,10 +146,38 @@ static void kvm_apic_external_nmi(APICCommonState *s)
     run_on_cpu(s->cpu_env, do_inject_external_nmi, s);
 }
 
+static uint64_t kvm_apic_mem_read(void *opaque, target_phys_addr_t addr,
+                                  unsigned size)
+{
+    return -1U;
+}
+
+static void kvm_apic_mem_write(void *opaque, target_phys_addr_t addr,
+                               uint64_t data, unsigned size)
+{
+    int ret;
+
+    ret = kvm_irqchip_send_msi(kvm_state, addr, data);
+    if (ret < 0) {
+        fprintf(stderr, "KVM: injection failed, MSI lost (%s)\n",
+                strerror(-ret));
+    }
+}
+
+static const MemoryRegionOps kvm_apic_io_ops = {
+    .read = kvm_apic_mem_read,
+    .write = kvm_apic_mem_write,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+};
+
 static void kvm_apic_init(APICCommonState *s)
 {
-    memory_region_init_reservation(&s->io_memory, "kvm-apic-msi",
-                                   MSI_SPACE_SIZE);
+    memory_region_init_io(&s->io_memory, &kvm_apic_io_ops, s, "kvm-apic-msi",
+                          MSI_SPACE_SIZE);
+
+    if (kvm_has_gsi_routing()) {
+        msi_supported = true;
+    }
 }
 
 static void kvm_apic_class_init(ObjectClass *klass, void *data)
diff --git a/hw/pc.c b/hw/pc.c
index 83a1b5b..fab620a 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -907,11 +907,6 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
         apic_mapped = 1;
     }
 
-    /* KVM does not support MSI yet. */
-    if (!kvm_irqchip_in_kernel()) {
-        msi_supported = true;
-    }
-
     return dev;
 }
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [RFC][PATCH v2 4/4] kvm: Add support for direct MSI injections
  2012-04-03  7:23 ` [Qemu-devel] " Jan Kiszka
@ 2012-04-03  7:23   ` Jan Kiszka
  -1 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Michael S. Tsirkin

From: Jan Kiszka <jan.kiszka@siemens.com>

If the kernel supports KVM_SIGNAL_MSI, we can avoid the route-based
MSI injection mechanism.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kvm-all.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 5256511..6225bab 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -95,6 +95,7 @@ struct KVMState
     uint32_t *used_gsi_bitmap;
     unsigned int gsi_count;
     QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
+    bool direct_msi;
 #endif
 };
 
@@ -895,8 +896,10 @@ static void kvm_init_irq_routing(KVMState *s)
     s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
     s->nr_allocated_irq_routes = 0;
 
-    for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
-        QTAILQ_INIT(&s->msi_hashtab[i]);
+    if (!s->direct_msi) {
+        for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
+            QTAILQ_INIT(&s->msi_hashtab[i]);
+        }
     }
 
     kvm_arch_init_irq_routing(s);
@@ -1035,7 +1038,7 @@ again:
 
         return bit - 1 + i * 32;
     }
-    if (retry) {
+    if (!s->direct_msi && retry) {
         retry = false;
         kvm_flush_dynamic_msi_routes(s);
         goto again;
@@ -1062,8 +1065,19 @@ static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, uint64_t addr,
 
 int kvm_irqchip_send_msi(KVMState *s, uint64_t addr, uint32_t data)
 {
+    struct kvm_msi msi;
     KVMMSIRoute *route;
 
+    if (s->direct_msi) {
+        msi.address_lo = (uint32_t)addr;
+        msi.address_hi = addr >> 32;
+        msi.data = data;
+        msi.flags = 0;
+        memset(msi.pad, 0, sizeof(msi.pad));
+
+        return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi);
+    }
+
     route = kvm_lookup_msi_route(s, addr, data);
     if (!route) {
         int gsi, ret;
@@ -1231,6 +1245,8 @@ int kvm_init(void)
     s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
 #endif
 
+    s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
+
     ret = kvm_arch_init(s);
     if (ret < 0) {
         goto err;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [RFC][PATCH v2 4/4] kvm: Add support for direct MSI injections
@ 2012-04-03  7:23   ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03  7:23 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm, Michael S. Tsirkin

From: Jan Kiszka <jan.kiszka@siemens.com>

If the kernel supports KVM_SIGNAL_MSI, we can avoid the route-based
MSI injection mechanism.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kvm-all.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 5256511..6225bab 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -95,6 +95,7 @@ struct KVMState
     uint32_t *used_gsi_bitmap;
     unsigned int gsi_count;
     QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
+    bool direct_msi;
 #endif
 };
 
@@ -895,8 +896,10 @@ static void kvm_init_irq_routing(KVMState *s)
     s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
     s->nr_allocated_irq_routes = 0;
 
-    for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
-        QTAILQ_INIT(&s->msi_hashtab[i]);
+    if (!s->direct_msi) {
+        for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) {
+            QTAILQ_INIT(&s->msi_hashtab[i]);
+        }
     }
 
     kvm_arch_init_irq_routing(s);
@@ -1035,7 +1038,7 @@ again:
 
         return bit - 1 + i * 32;
     }
-    if (retry) {
+    if (!s->direct_msi && retry) {
         retry = false;
         kvm_flush_dynamic_msi_routes(s);
         goto again;
@@ -1062,8 +1065,19 @@ static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, uint64_t addr,
 
 int kvm_irqchip_send_msi(KVMState *s, uint64_t addr, uint32_t data)
 {
+    struct kvm_msi msi;
     KVMMSIRoute *route;
 
+    if (s->direct_msi) {
+        msi.address_lo = (uint32_t)addr;
+        msi.address_hi = addr >> 32;
+        msi.data = data;
+        msi.flags = 0;
+        memset(msi.pad, 0, sizeof(msi.pad));
+
+        return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi);
+    }
+
     route = kvm_lookup_msi_route(s, addr, data);
     if (!route) {
         int gsi, ret;
@@ -1231,6 +1245,8 @@ int kvm_init(void)
     s->pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2);
 #endif
 
+    s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
+
     ret = kvm_arch_init(s);
     if (ret < 0) {
         goto err;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
  2012-04-03  7:23 ` [Qemu-devel] " Jan Kiszka
@ 2012-04-03 13:06   ` Michael S. Tsirkin
  -1 siblings, 0 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2012-04-03 13:06 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm, qemu-devel

On Tue, Apr 03, 2012 at 09:23:12AM +0200, Jan Kiszka wrote:
> This is v2 of the RFC, fixing a memory leak in
> kvm_flush_dynamic_msi_routes and adding support for the proposed
> KVM_SIGNAL_MSI IOCTL.
> 
> This series depends on "kvm: set gsi_bits and max_gsi correctly"
> (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).

Looks good to me.
How hard would it be to add irqfd support?

> Jan Kiszka (4):
>   kvm: Refactor KVMState::max_gsi to gsi_count
>   kvm: Introduce basic MSI support for in-kernel irqchips
>   KVM: x86: Wire up MSI support for in-kernel irqchip
>   kvm: Add support for direct MSI injections
> 
>  hw/apic.c     |    3 +
>  hw/kvm/apic.c |   33 +++++++++-
>  hw/pc.c       |    5 --
>  kvm-all.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  kvm.h         |    1 +
>  5 files changed, 225 insertions(+), 12 deletions(-)
> 
> -- 
> 1.7.3.4

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
@ 2012-04-03 13:06   ` Michael S. Tsirkin
  0 siblings, 0 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2012-04-03 13:06 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Marcelo Tosatti, Avi Kivity, kvm, qemu-devel

On Tue, Apr 03, 2012 at 09:23:12AM +0200, Jan Kiszka wrote:
> This is v2 of the RFC, fixing a memory leak in
> kvm_flush_dynamic_msi_routes and adding support for the proposed
> KVM_SIGNAL_MSI IOCTL.
> 
> This series depends on "kvm: set gsi_bits and max_gsi correctly"
> (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).

Looks good to me.
How hard would it be to add irqfd support?

> Jan Kiszka (4):
>   kvm: Refactor KVMState::max_gsi to gsi_count
>   kvm: Introduce basic MSI support for in-kernel irqchips
>   KVM: x86: Wire up MSI support for in-kernel irqchip
>   kvm: Add support for direct MSI injections
> 
>  hw/apic.c     |    3 +
>  hw/kvm/apic.c |   33 +++++++++-
>  hw/pc.c       |    5 --
>  kvm-all.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  kvm.h         |    1 +
>  5 files changed, 225 insertions(+), 12 deletions(-)
> 
> -- 
> 1.7.3.4

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
  2012-04-03 13:06   ` [Qemu-devel] " Michael S. Tsirkin
@ 2012-04-03 17:27     ` Jan Kiszka
  -1 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03 17:27 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Avi Kivity, Marcelo Tosatti, kvm, qemu-devel

On 2012-04-03 15:06, Michael S. Tsirkin wrote:
> On Tue, Apr 03, 2012 at 09:23:12AM +0200, Jan Kiszka wrote:
>> This is v2 of the RFC, fixing a memory leak in
>> kvm_flush_dynamic_msi_routes and adding support for the proposed
>> KVM_SIGNAL_MSI IOCTL.
>>
>> This series depends on "kvm: set gsi_bits and max_gsi correctly"
>> (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).
> 
> Looks good to me.
> How hard would it be to add irqfd support?

Shouldn't be, but the changes will be a bit bigger.

I'm thinking about a revamped interface between the MSI core and
affected devices for a while. Will try to put down in some lines of code
what I have in mind - once the dynamic MSI injection topic has settled.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
@ 2012-04-03 17:27     ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03 17:27 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Marcelo Tosatti, Avi Kivity, kvm, qemu-devel

On 2012-04-03 15:06, Michael S. Tsirkin wrote:
> On Tue, Apr 03, 2012 at 09:23:12AM +0200, Jan Kiszka wrote:
>> This is v2 of the RFC, fixing a memory leak in
>> kvm_flush_dynamic_msi_routes and adding support for the proposed
>> KVM_SIGNAL_MSI IOCTL.
>>
>> This series depends on "kvm: set gsi_bits and max_gsi correctly"
>> (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).
> 
> Looks good to me.
> How hard would it be to add irqfd support?

Shouldn't be, but the changes will be a bit bigger.

I'm thinking about a revamped interface between the MSI core and
affected devices for a while. Will try to put down in some lines of code
what I have in mind - once the dynamic MSI injection topic has settled.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
  2012-04-03  7:23 ` [Qemu-devel] " Jan Kiszka
@ 2012-04-03 19:17   ` Jan Kiszka
  -1 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03 19:17 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Michael S. Tsirkin

On 2012-04-03 09:23, Jan Kiszka wrote:
> This is v2 of the RFC, fixing a memory leak in
> kvm_flush_dynamic_msi_routes and adding support for the proposed
> KVM_SIGNAL_MSI IOCTL.
> 
> This series depends on "kvm: set gsi_bits and max_gsi correctly"
> (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).
> 
> Jan Kiszka (4):
>   kvm: Refactor KVMState::max_gsi to gsi_count
>   kvm: Introduce basic MSI support for in-kernel irqchips
>   KVM: x86: Wire up MSI support for in-kernel irqchip
>   kvm: Add support for direct MSI injections
> 
>  hw/apic.c     |    3 +
>  hw/kvm/apic.c |   33 +++++++++-
>  hw/pc.c       |    5 --
>  kvm-all.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  kvm.h         |    1 +
>  5 files changed, 225 insertions(+), 12 deletions(-)
> 

As we obviously agreed on the general direction regarding an MSI
injection interface, I think patches 1-3 can lose their RFC tags and are
ready for uq/master (provided there are no further review comments).
Patch 4 will be reworked once the kernel interface is finalized.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
@ 2012-04-03 19:17   ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2012-04-03 19:17 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm, Michael S. Tsirkin

On 2012-04-03 09:23, Jan Kiszka wrote:
> This is v2 of the RFC, fixing a memory leak in
> kvm_flush_dynamic_msi_routes and adding support for the proposed
> KVM_SIGNAL_MSI IOCTL.
> 
> This series depends on "kvm: set gsi_bits and max_gsi correctly"
> (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).
> 
> Jan Kiszka (4):
>   kvm: Refactor KVMState::max_gsi to gsi_count
>   kvm: Introduce basic MSI support for in-kernel irqchips
>   KVM: x86: Wire up MSI support for in-kernel irqchip
>   kvm: Add support for direct MSI injections
> 
>  hw/apic.c     |    3 +
>  hw/kvm/apic.c |   33 +++++++++-
>  hw/pc.c       |    5 --
>  kvm-all.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  kvm.h         |    1 +
>  5 files changed, 225 insertions(+), 12 deletions(-)
> 

As we obviously agreed on the general direction regarding an MSI
injection interface, I think patches 1-3 can lose their RFC tags and are
ready for uq/master (provided there are no further review comments).
Patch 4 will be reworked once the kernel interface is finalized.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
  2012-04-03 17:27     ` [Qemu-devel] " Jan Kiszka
@ 2012-04-04  8:39       ` Michael S. Tsirkin
  -1 siblings, 0 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2012-04-04  8:39 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm, qemu-devel

On Tue, Apr 03, 2012 at 07:27:36PM +0200, Jan Kiszka wrote:
> On 2012-04-03 15:06, Michael S. Tsirkin wrote:
> > On Tue, Apr 03, 2012 at 09:23:12AM +0200, Jan Kiszka wrote:
> >> This is v2 of the RFC, fixing a memory leak in
> >> kvm_flush_dynamic_msi_routes and adding support for the proposed
> >> KVM_SIGNAL_MSI IOCTL.
> >>
> >> This series depends on "kvm: set gsi_bits and max_gsi correctly"
> >> (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).
> > 
> > Looks good to me.
> > How hard would it be to add irqfd support?
> 
> Shouldn't be, but the changes will be a bit bigger.
> 
> I'm thinking about a revamped interface between the MSI core and
> affected devices for a while. Will try to put down in some lines of code
> what I have in mind - once the dynamic MSI injection topic has settled.
> 
> Jan

Yes it's not an objection - just a question.

> -- 
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
@ 2012-04-04  8:39       ` Michael S. Tsirkin
  0 siblings, 0 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2012-04-04  8:39 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Marcelo Tosatti, Avi Kivity, kvm, qemu-devel

On Tue, Apr 03, 2012 at 07:27:36PM +0200, Jan Kiszka wrote:
> On 2012-04-03 15:06, Michael S. Tsirkin wrote:
> > On Tue, Apr 03, 2012 at 09:23:12AM +0200, Jan Kiszka wrote:
> >> This is v2 of the RFC, fixing a memory leak in
> >> kvm_flush_dynamic_msi_routes and adding support for the proposed
> >> KVM_SIGNAL_MSI IOCTL.
> >>
> >> This series depends on "kvm: set gsi_bits and max_gsi correctly"
> >> (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).
> > 
> > Looks good to me.
> > How hard would it be to add irqfd support?
> 
> Shouldn't be, but the changes will be a bit bigger.
> 
> I'm thinking about a revamped interface between the MSI core and
> affected devices for a while. Will try to put down in some lines of code
> what I have in mind - once the dynamic MSI injection topic has settled.
> 
> Jan

Yes it's not an objection - just a question.

> -- 
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
  2012-04-03 19:17   ` [Qemu-devel] " Jan Kiszka
@ 2012-04-04  8:40     ` Michael S. Tsirkin
  -1 siblings, 0 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2012-04-04  8:40 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm, qemu-devel

On Tue, Apr 03, 2012 at 09:17:30PM +0200, Jan Kiszka wrote:
> On 2012-04-03 09:23, Jan Kiszka wrote:
> > This is v2 of the RFC, fixing a memory leak in
> > kvm_flush_dynamic_msi_routes and adding support for the proposed
> > KVM_SIGNAL_MSI IOCTL.
> > 
> > This series depends on "kvm: set gsi_bits and max_gsi correctly"
> > (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).
> > 
> > Jan Kiszka (4):
> >   kvm: Refactor KVMState::max_gsi to gsi_count
> >   kvm: Introduce basic MSI support for in-kernel irqchips
> >   KVM: x86: Wire up MSI support for in-kernel irqchip
> >   kvm: Add support for direct MSI injections
> > 
> >  hw/apic.c     |    3 +
> >  hw/kvm/apic.c |   33 +++++++++-
> >  hw/pc.c       |    5 --
> >  kvm-all.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> >  kvm.h         |    1 +
> >  5 files changed, 225 insertions(+), 12 deletions(-)
> > 
> 
> As we obviously agreed on the general direction regarding an MSI
> injection interface, I think patches 1-3 can lose their RFC tags and are
> ready for uq/master (provided there are no further review comments).
> Patch 4 will be reworked once the kernel interface is finalized.
> 
> Jan

I agree.
Acked-by: Michael S. Tsirkin <mst@redhat.com>

> -- 
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode
@ 2012-04-04  8:40     ` Michael S. Tsirkin
  0 siblings, 0 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2012-04-04  8:40 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Marcelo Tosatti, Avi Kivity, kvm, qemu-devel

On Tue, Apr 03, 2012 at 09:17:30PM +0200, Jan Kiszka wrote:
> On 2012-04-03 09:23, Jan Kiszka wrote:
> > This is v2 of the RFC, fixing a memory leak in
> > kvm_flush_dynamic_msi_routes and adding support for the proposed
> > KVM_SIGNAL_MSI IOCTL.
> > 
> > This series depends on "kvm: set gsi_bits and max_gsi correctly"
> > (http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88906).
> > 
> > Jan Kiszka (4):
> >   kvm: Refactor KVMState::max_gsi to gsi_count
> >   kvm: Introduce basic MSI support for in-kernel irqchips
> >   KVM: x86: Wire up MSI support for in-kernel irqchip
> >   kvm: Add support for direct MSI injections
> > 
> >  hw/apic.c     |    3 +
> >  hw/kvm/apic.c |   33 +++++++++-
> >  hw/pc.c       |    5 --
> >  kvm-all.c     |  195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> >  kvm.h         |    1 +
> >  5 files changed, 225 insertions(+), 12 deletions(-)
> > 
> 
> As we obviously agreed on the general direction regarding an MSI
> injection interface, I think patches 1-3 can lose their RFC tags and are
> ready for uq/master (provided there are no further review comments).
> Patch 4 will be reworked once the kernel interface is finalized.
> 
> Jan

I agree.
Acked-by: Michael S. Tsirkin <mst@redhat.com>

> -- 
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-04-04  8:40 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-03  7:23 [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode Jan Kiszka
2012-04-03  7:23 ` [Qemu-devel] " Jan Kiszka
2012-04-03  7:23 ` [RFC][PATCH v2 1/4] kvm: Refactor KVMState::max_gsi to gsi_count Jan Kiszka
2012-04-03  7:23   ` [Qemu-devel] " Jan Kiszka
2012-04-03  7:23 ` [RFC][PATCH v2 2/4] kvm: Introduce basic MSI support for in-kernel irqchips Jan Kiszka
2012-04-03  7:23   ` [Qemu-devel] " Jan Kiszka
2012-04-03  7:23 ` [RFC][PATCH v2 3/4] KVM: x86: Wire up MSI support for in-kernel irqchip Jan Kiszka
2012-04-03  7:23   ` [Qemu-devel] " Jan Kiszka
2012-04-03  7:23 ` [RFC][PATCH v2 4/4] kvm: Add support for direct MSI injections Jan Kiszka
2012-04-03  7:23   ` [Qemu-devel] " Jan Kiszka
2012-04-03 13:06 ` [RFC][PATCH v2 0/4] uq/master: Basic MSI support for in-kernel irqchip mode Michael S. Tsirkin
2012-04-03 13:06   ` [Qemu-devel] " Michael S. Tsirkin
2012-04-03 17:27   ` Jan Kiszka
2012-04-03 17:27     ` [Qemu-devel] " Jan Kiszka
2012-04-04  8:39     ` Michael S. Tsirkin
2012-04-04  8:39       ` [Qemu-devel] " Michael S. Tsirkin
2012-04-03 19:17 ` Jan Kiszka
2012-04-03 19:17   ` [Qemu-devel] " Jan Kiszka
2012-04-04  8:40   ` Michael S. Tsirkin
2012-04-04  8:40     ` [Qemu-devel] " Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.