If an IRQ is a SGI, bits 10-12 in the IAR of a GICv2 encode the
requesting CPU.

So far, Jailhouse doesn't set those bits (while it should, refer GICv2
spec!) so we didn't get hurt.  Nevertheless, this hits us when issuing
SGIs on bare-metal applications without jailhouse.  This patch properly
decodes SGI IRQ numbers.

Signed-off-by: Ralf Ramsauer <[email protected]>
---
 inmates/lib/arm-common/include/gic.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/inmates/lib/arm-common/include/gic.h 
b/inmates/lib/arm-common/include/gic.h
index 7d6fc891..584dbe02 100644
--- a/inmates/lib/arm-common/include/gic.h
+++ b/inmates/lib/arm-common/include/gic.h
@@ -43,7 +43,10 @@
 
 #define GICD_ISENABLER                 0x0100
 
-#define is_sgi_ppi(irqn)               ((irqn) < 32)
+#define sgi_id(irqn)                   ((irqn) & 0x3ff)
+#define sgi_requesting_cpu(irqn)       (((irqn) >> 10) & 0x7)
+#define is_sgi(irqn)                   (sgi_id(irqn) < 16)
+#define is_sgi_ppi(irqn)               (sgi_id(irqn) < 32)
 #define is_spi(irqn)                   ((irqn) > 31 && (irqn) < 1020)
 
 #ifndef __ASSEMBLY__
-- 
2.14.1

-- 
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