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

[Minios-devel] [UNIKRAFT PATCHv8 6/6] plat/common: Add a trap function to handle Arm64 irq trap



From: Wei Chen <wei.chen@xxxxxxx>
As we have implemented the GICv2 interrupt controller, we
can enable the irq trap exception handler in exception entry.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
Signed-off-by: Jianyong Wu <jianyong.wu@xxxxxxx>
Signed-off-by: Jia He <justin.he@xxxxxxx>
Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 plat/common/arm/traps.c           |  6 ++++++
 plat/drivers/gic/gic-v2.c         | 24 ++++++++++++++++++++++++
 plat/drivers/include/gic/gic-v2.h |  3 +++
 plat/kvm/arm/exceptions.S         | 10 +++++++++-
 4 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/plat/common/arm/traps.c b/plat/common/arm/traps.c
index 43235be..ad9a8c3 100644
--- a/plat/common/arm/traps.c
+++ b/plat/common/arm/traps.c
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <uk/print.h>
 #include <uk/assert.h>
+#include <gic/gic-v2.h>
 
 static const char *exception_modes[]= {
        "Synchronous Abort",
@@ -68,3 +69,8 @@ void trap_el1_sync(struct __regs *regs, uint64_t far)
        dump_registers(regs, far);
        ukplat_crash();
 }
+
+void trap_el1_irq(void)
+{
+       gic_handle_irq();
+}
diff --git a/plat/drivers/gic/gic-v2.c b/plat/drivers/gic/gic-v2.c
index f3fb890..687714e 100644
--- a/plat/drivers/gic/gic-v2.c
+++ b/plat/drivers/gic/gic-v2.c
@@ -314,6 +314,30 @@ uint32_t gic_irq_translate(uint32_t type, uint32_t hw_irq)
        return -EINVAL;
 }
 
+void gic_handle_irq(void)
+{
+       uint32_t stat, irq;
+
+       do {
+               stat = gic_ack_irq();
+               irq = stat & GICC_IAR_INTID_MASK;
+
+               uk_pr_info("Unikraft: EL1 IRQ#%d trap caught\n", irq);
+
+               /*
+                * TODO: Handle IPI&SGI interrupts here
+                */
+               if (irq < GIC_MAX_IRQ) {
+                       isb();
+                       _ukplat_irq_handle((unsigned long)irq);
+                       gic_eoi_irq(stat);
+                       continue;
+               }
+
+               break;
+       } while (1);
+}
+
 static void gic_init_dist(void)
 {
        uint32_t val, cpuif_number, irq_number;
diff --git a/plat/drivers/include/gic/gic-v2.h 
b/plat/drivers/include/gic/gic-v2.h
index 9a5dbef..24da1eb 100644
--- a/plat/drivers/include/gic/gic-v2.h
+++ b/plat/drivers/include/gic/gic-v2.h
@@ -367,6 +367,9 @@ void gic_set_irq_type(uint32_t irq, int trigger);
 /* Translate to hwirq according to type e.g. PPI SPI SGI */
 uint32_t gic_irq_translate(uint32_t type, uint32_t hw_irq);
 
+/* Handle IRQ entry */
+void gic_handle_irq(void);
+
 /* Initialize GICv2 from device tree */
 int _dtb_init_gic(const void *fdt);
 
diff --git a/plat/kvm/arm/exceptions.S b/plat/kvm/arm/exceptions.S
index 704bd0a..929d900 100644
--- a/plat/kvm/arm/exceptions.S
+++ b/plat/kvm/arm/exceptions.S
@@ -166,6 +166,14 @@ el1_sync:
        bl trap_el1_sync
        LEAVE_TRAP 1
 
+.align 6
+el1_irq:
+       ENTER_TRAP 1
+       msr daifclr, #(8 | 4 | 1)
+       mov x0, sp
+       bl trap_el1_irq
+       LEAVE_TRAP 1
+
 /* Bad Abort numbers */
 #define BAD_SYNC  0
 #define BAD_IRQ   1
@@ -216,7 +224,7 @@ ENTRY(vector_table)
 
        /* Current Exception level with SP_EL1 */
        vector_entry el1_sync           /* Synchronous EL1h       */
-       vector_entry el1_irq_invalid    /* IRQ EL1h               */
+       vector_entry el1_irq            /* IRQ EL1h               */
        vector_entry el1_fiq_invalid    /* FIQ EL1h               */
        vector_entry el1_error_invalid  /* Error EL1h             */
 
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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