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

[Xen-devel] [RFC PATCH 17/24] ARM: vITS: handle MAPTI command



The MAPTI commands associates a DeviceID/EventID pair with a LPI/CPU
pair and actually instantiates LPI interrupts.
We allocate a new host LPI and connect that one to this virtual LPI,
so that any triggering IRQ on the host can be quickly forwarded to
a guest.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
---
 xen/arch/arm/vgic-its.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/xen/arch/arm/vgic-its.c b/xen/arch/arm/vgic-its.c
index 83d47e1..70897dd 100644
--- a/xen/arch/arm/vgic-its.c
+++ b/xen/arch/arm/vgic-its.c
@@ -278,6 +278,55 @@ static int its_handle_mapd(struct virt_its *its, uint64_t 
*cmdptr)
     return 0;
 }
 
+static int its_handle_mapti(struct virt_its *its, uint64_t *cmdptr)
+{
+    uint32_t devid = its_cmd_get_deviceid(cmdptr);
+    uint32_t eventid = its_cmd_get_id(cmdptr);
+    uint32_t intid = its_cmd_get_physical_id(cmdptr);
+    int collid = its_cmd_get_collection(cmdptr);
+    struct vits_itte *itte;
+    uint32_t host_lpi;
+    struct vcpu *vcpu;
+    int ret = -1;
+
+    if ( its_cmd_get_command(cmdptr) == GITS_CMD_MAPI )
+        intid = eventid;
+
+    if ( collid >= its->max_collections )
+        return -1;
+
+    spin_lock(&its->its_lock);
+    vcpu = get_vcpu_from_collection(its, collid);
+    if ( !vcpu )
+        goto out_unlock;
+
+    itte = get_devid_evid(its, devid, eventid);
+    if ( !itte )
+        goto out_unlock;
+
+    if ( itte->hlpi )
+        goto out_unmap;
+
+    host_lpi = gicv3_lpi_allocate_host_lpi(its->hw_its,
+                                           devid, eventid,
+                                           vcpu, intid);
+    if ( host_lpi >= 0 )
+        itte->hlpi = host_lpi;
+
+    itte->vlpi = intid;
+    itte->collection = collid;
+
+    ret = 0;
+
+out_unmap:
+    put_devid_evid(its, itte);
+
+out_unlock:
+    spin_unlock(&its->its_lock);
+    
+    return ret;
+}
+
 #define ITS_CMD_BUFFER_SIZE(baser)      ((((baser) & 0xff) + 1) << 12)
 
 static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its,
@@ -310,6 +359,10 @@ static int vgic_its_handle_cmds(struct domain *d, struct 
virt_its *its,
         case GITS_CMD_MAPD:
             its_handle_mapd(its, cmdptr);
            break;
+        case GITS_CMD_MAPI:
+        case GITS_CMD_MAPTI:
+            its_handle_mapti(its, cmdptr);
+            break;
         case GITS_CMD_SYNC:
             /* We handle ITS commands synchronously, so we ignore SYNC. */
            break;
-- 
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®.