]> xenbits.xensource.com Git - people/julieng/linux-arm.git/commitdiff
KVM: arm/arm64: enable MSI routing
authorEric Auger <eric.auger@linaro.org>
Thu, 18 Jun 2015 08:46:07 +0000 (10:46 +0200)
committerJulien Grall <julien.grall@citrix.com>
Mon, 28 Sep 2015 11:05:14 +0000 (12:05 +0100)
Up to now, only irqchip routing entries could be set. This patch
adds the capability to insert MSI routing entries, with or without
device id. Although standard MSI entries can be set, their
injection still is not supported. For ARM64, let's also increase
KVM_MAX_IRQ_ROUTES to 4096: include SPI irqchip flat routes plus
MSI routes. In the future this might be extended.

The new MSI routing entry type also must be managed similarly to
legacy KVM_IRQ_ROUTING_MSI in eventfd irqfd_wakeup and irqfd_update.

Signed-off-by: Eric Auger <eric.auger@linaro.org>
Documentation/virtual/kvm/api.txt
include/linux/kvm_host.h
virt/kvm/arm/vgic.c
virt/kvm/eventfd.c

index 459da3187b86e98fecb2a6059c77bf74a3e7e10f..8a772e05753a63f04db3baccb51c8273eb3bfb65 100644 (file)
@@ -1431,6 +1431,11 @@ Sets the GSI routing table entries, overwriting any previously set entries.
 On arm/arm64, GSI routing has the following limitation:
 - GSI routing does not apply to KVM_IRQ_LINE but only to KVM_IRQFD.
 
+On arm/arm64, MSI routing through in-kernel GICv3 ITS must use
+KVM_IRQ_ROUTING_EXTENDED_MSI routing type and device ID must be set
+in msi struct. Otherwise, KVM_IRQ_ROUTING_MSI must be used without
+populating the msi devid field.
+
 struct kvm_irq_routing {
        __u32 nr;
        __u32 flags;
@@ -2346,6 +2351,11 @@ On arm/arm64, gsi routing being supported, the following can happen:
 - in case no routing entry is associated to this gsi, injection fails
 - in case the gsi is associated to an irqchip routing entry,
   irqchip.pin + 32 corresponds to the injected SPI ID.
+- in case the gsi is associated to an MSI routing entry,
+  * without GICv3 ITS in-kernel emulation, MSI data matches the SPI ID
+    of the injected SPI
+  * with GICv3 ITS in-kernel emulation, the MSI message and device ID
+    are translated into an LPI.
 
 4.76 KVM_PPC_ALLOCATE_HTAB
 
index d2f7c8629ce2488dafbf28b3da9b3e94596e231e..f580f4b7af3b18e87e133b81301d0e81428f5595 100644 (file)
@@ -994,6 +994,8 @@ static inline int mmu_notifier_retry(struct kvm *kvm, unsigned long mmu_seq)
 
 #ifdef CONFIG_S390
 #define KVM_MAX_IRQ_ROUTES 4096 //FIXME: we can have more than that...
+#elif defined(CONFIG_ARM64)
+#define KVM_MAX_IRQ_ROUTES 4096
 #else
 #define KVM_MAX_IRQ_ROUTES 1024
 #endif
index 12391a911413075c6089a34ac51a5d0c42d5949a..ebf507350f31becc94514dda4f05ab6522a397ec 100644 (file)
@@ -2252,6 +2252,19 @@ int kvm_set_routing_entry(struct kvm_kernel_irq_routing_entry *e,
                    (e->irqchip.irqchip >= KVM_NR_IRQCHIPS))
                        goto out;
                break;
+       case KVM_IRQ_ROUTING_MSI:
+               e->set = kvm_set_msi;
+               e->msi.address_lo = ue->u.msi.address_lo;
+               e->msi.address_hi = ue->u.msi.address_hi;
+               e->msi.data = ue->u.msi.data;
+               break;
+       case KVM_IRQ_ROUTING_EXTENDED_MSI:
+               e->set = kvm_set_msi;
+               e->msi.address_lo = ue->u.msi.address_lo;
+               e->msi.address_hi = ue->u.msi.address_hi;
+               e->msi.data = ue->u.msi.data;
+               e->devid = ue->u.msi.devid;
+               break;
        default:
                goto out;
        }
index 9ff4193dfa493c3e226c3fd554061b171ca7b9c5..d76d05daf8ae3a7f03f7d089b356559e1da55209 100644 (file)
@@ -238,7 +238,8 @@ irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key)
                        irq = irqfd->irq_entry;
                } while (read_seqcount_retry(&irqfd->irq_entry_sc, seq));
                /* An event has been signaled, inject an interrupt */
-               if (irq.type == KVM_IRQ_ROUTING_MSI)
+               if (irq.type == KVM_IRQ_ROUTING_MSI ||
+                   irq.type == KVM_IRQ_ROUTING_EXTENDED_MSI)
                        kvm_set_msi(&irq, kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 1,
                                        false);
                else
@@ -294,7 +295,8 @@ static void irqfd_update(struct kvm *kvm, struct _irqfd *irqfd)
        e = entries;
        for (i = 0; i < n_entries; ++i, ++e) {
                /* Only fast-path MSI. */
-               if (e->type == KVM_IRQ_ROUTING_MSI)
+               if (e->type == KVM_IRQ_ROUTING_MSI ||
+                   e->type == KVM_IRQ_ROUTING_EXTENDED_MSI)
                        irqfd->irq_entry = *e;
        }