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

[Xen-devel] [PATCH 22/28] ARM: vITS: handle MOVI command



The MOVI command moves the interrupt affinity from one redistributor
(read: VCPU) to another.
For now migration of "live" LPIs is not yet implemented, but we store
the changed affinity in the host LPI structure and in our virtual ITTE.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
---
 xen/arch/arm/gic-v3-its.c        | 14 ++++++++++++++
 xen/arch/arm/gic-v3-lpi.c        | 13 +++++++++++++
 xen/arch/arm/vgic-v3-its.c       | 23 +++++++++++++++++++++++
 xen/include/asm-arm/gic_v3_its.h |  4 ++++
 4 files changed, 54 insertions(+)

diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c
index 1268d64..d37b7b6 100644
--- a/xen/arch/arm/gic-v3-its.c
+++ b/xen/arch/arm/gic-v3-its.c
@@ -690,6 +690,20 @@ int gicv3_assign_guest_event(struct domain *d, uint32_t 
devid, uint32_t eventid,
     return 0;
 }
 
+/* Changes the target VCPU for a given host LPI assigned to a domain. */
+int gicv3_lpi_change_vcpu(struct domain *d,
+                          uint32_t devid, uint32_t eventid, int vcpu_id)
+{
+    uint32_t host_lpi = translate_event(d, devid, eventid);
+
+    if ( !host_lpi )
+        return -ENOENT;
+
+    gicv3_lpi_update_host_vcpuid(host_lpi, vcpu_id);
+
+    return 0;
+}
+
 /* Scan the DT for any ITS nodes and create a list of host ITSes out of it. */
 void gicv3_its_dt_init(const struct dt_device_node *node)
 {
diff --git a/xen/arch/arm/gic-v3-lpi.c b/xen/arch/arm/gic-v3-lpi.c
index 494ae22..66d6eff 100644
--- a/xen/arch/arm/gic-v3-lpi.c
+++ b/xen/arch/arm/gic-v3-lpi.c
@@ -153,6 +153,19 @@ int gicv3_lpi_update_host_entry(uint32_t host_lpi, int 
domain_id, int vcpu_id,
     return 0;
 }
 
+int gicv3_lpi_update_host_vcpuid(uint32_t host_lpi, int vcpu_id)
+{
+    union host_lpi *hlpip;
+
+    host_lpi -= LPI_OFFSET;
+
+    hlpip = &lpi_data.host_lpis[host_lpi / HOST_LPIS_PER_PAGE][host_lpi % 
HOST_LPIS_PER_PAGE];
+
+    write_u16_atomic(&hlpip->vcpu_id, vcpu_id);
+
+    return 0;
+}
+
 uint64_t gicv3_lpi_allocate_pendtable(void)
 {
     uint64_t reg;
diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c
index 3e74f46..fb9caf0 100644
--- a/xen/arch/arm/vgic-v3-its.c
+++ b/xen/arch/arm/vgic-v3-its.c
@@ -329,6 +329,23 @@ static int its_handle_mapti(struct virt_its *its, uint64_t 
*cmdptr)
     return 0;
 }
 
+static int its_handle_movi(struct virt_its *its, uint64_t *cmdptr)
+{
+    uint32_t devid = its_cmd_get_deviceid(cmdptr);
+    uint32_t eventid = its_cmd_get_id(cmdptr);
+    int collid = its_cmd_get_collection(cmdptr);
+    struct vcpu *vcpu;
+
+    if ( !write_itte(its, devid, eventid, collid, SKIP_LPI_UPDATE, &vcpu) )
+        return -1;
+
+    /* TODO: lookup currently-in-guest virtual IRQs and migrate them */
+
+    gicv3_lpi_change_vcpu(its->d, devid, eventid, vcpu->vcpu_id);
+
+    return 0;
+}
+
 #define ITS_CMD_BUFFER_SIZE(baser)      ((((baser) & 0xff) + 1) << 12)
 
 static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its,
@@ -365,6 +382,12 @@ static int vgic_its_handle_cmds(struct domain *d, struct 
virt_its *its,
         case GITS_CMD_MAPTI:
             its_handle_mapti(its, cmdptr);
             break;
+        case GITS_CMD_MOVALL:
+            gdprintk(XENLOG_G_INFO, "ITS: ignoring MOVALL command\n");
+            break;
+        case GITS_CMD_MOVI:
+            its_handle_movi(its, cmdptr);
+            break;
         case GITS_CMD_SYNC:
             /* We handle ITS commands synchronously, so we ignore SYNC. */
            break;
diff --git a/xen/include/asm-arm/gic_v3_its.h b/xen/include/asm-arm/gic_v3_its.h
index 160ece3..bac0fe5 100644
--- a/xen/include/asm-arm/gic_v3_its.h
+++ b/xen/include/asm-arm/gic_v3_its.h
@@ -162,8 +162,12 @@ int gicv3_free_host_lpi_block(struct host_its *its, 
uint32_t lpi);
 int gicv3_assign_guest_event(struct domain *d,
                              uint32_t devid, uint32_t eventid,
                              struct vcpu *v, uint32_t virt_lpi);
+int gicv3_lpi_change_vcpu(struct domain *d,
+                          uint32_t devid, uint32_t eventid, int vcpu_id);
 int gicv3_lpi_update_host_entry(uint32_t host_lpi, int domain_id, int vcpu_id,
                                 uint32_t virt_lpi);
+int gicv3_lpi_update_host_vcpuid(uint32_t host_lpi, int vcpu_id);
+
 #else
 
 static inline void gicv3_its_dt_init(const struct dt_device_node *node)
-- 
2.9.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.