If system comes with a GICv2m, we can piggyback with it to emulate MSI-X
vector support of ivshmem. GICv2m means that the MSI data field contains
the target interrupt number, to be injected into the GICD. We validate
and cache the value on arch_ivshmem_update_msix and simply inject it via
the physical GICD on arch_ivshmem_write_doorbell.

Yet missing is validation of the MSI address field. Also, we do not have
any of the GICv2m quirk workaround implemented that Linux carries
because our reference system, AMD Seattle, is implemented according to
the Server Base System Architecture spec.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/arm-common/include/asm/ivshmem.h |  1 +
 hypervisor/arch/arm-common/ivshmem.c             | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/hypervisor/arch/arm-common/include/asm/ivshmem.h 
b/hypervisor/arch/arm-common/include/asm/ivshmem.h
index a03ec0a..cd7c823 100644
--- a/hypervisor/arch/arm-common/include/asm/ivshmem.h
+++ b/hypervisor/arch/arm-common/include/asm/ivshmem.h
@@ -14,6 +14,7 @@
 #define _JAILHOUSE_ASM_IVSHMEM_H
 
 struct arch_pci_ivshmem {
+       u16 irq_id;
 };
 
 #endif /* !_JAILHOUSE_ASM_IVSHMEM_H */
diff --git a/hypervisor/arch/arm-common/ivshmem.c 
b/hypervisor/arch/arm-common/ivshmem.c
index 188e972..797d8b5 100644
--- a/hypervisor/arch/arm-common/ivshmem.c
+++ b/hypervisor/arch/arm-common/ivshmem.c
@@ -11,12 +11,34 @@
  */
 
 #include <jailhouse/ivshmem.h>
+#include <asm/irqchip.h>
 
 void arch_ivshmem_write_doorbell(struct ivshmem_endpoint *ive)
 {
+       struct ivshmem_endpoint *remote = ive->remote;
+       unsigned int irq_id;
+
+       if (!remote)
+               return;
+
+       irq_id = remote->arch.irq_id;
+       if (irq_id)
+               irqchip_set_pending(NULL, irq_id);
 }
 
 int arch_ivshmem_update_msix(struct pci_device *device)
 {
+       struct ivshmem_endpoint *ive = device->ivshmem_endpoint;
+       unsigned int irq_id = 0;
+
+       if (!ivshmem_is_msix_masked(ive)) {
+               /* FIXME: validate MSI-X target address */
+               irq_id = device->msix_vectors[0].data;
+               if (irq_id < 32 || !irqchip_irq_in_cell(device->cell, irq_id))
+                       return -EPERM;
+       }
+
+       ive->arch.irq_id = irq_id;
+
        return 0;
 }
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to