hw/intc/arm_gic.c: Implement GICv2 GICC_DIR
PATCH 1/1 hw/intc/arm_gic.c: Implement GICv2 GICC_DIR
The GICv2 introduces a new CPU interface register GICC_DIR, which allows an OS to split the "priority drop" and "deactivate interrupt" parts of interrupt completion. Implement this register. (Note that the register is at offset 0x1000 in the CPU interface, which means it is on a different 4K page from all the other registers.)
---
We've been missing this for ages, but since Linux defaults to not using it it hasn't mattered. However Linux will use GICC_DIR if it is started in Hyp mode, so this is needed for proper EL2 support. Luckily since I did the groundwork for this by implementing active priorities properly last year, this is now straightforward.
Tested with a hacked Linux kernel that disables the "return false if no hyp mode" check in gic_check_eoimode(). OTOH that hacked kernel will boot OK on the broken QEMU too because it's hard to tell the difference between correct behaviour and "EOI does prio-drop+deactivate regardless of EOIMode, and DIR is writes-ignored".
hw/cpu/a15mpcore.c | 2 +- hw/intc/arm_gic.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- hw/intc/arm_gic_common.c | 2 +- 3 files changed, 47 insertions(+), 3 deletions(-)
hw/cpu/a15mpcore.c +1 -1
@@ -109,7 +109,7 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)/* Memory map (addresses are offsets from PERIPHBASE): * 0x0000-0x0fff -- reserved * 0x1000-0x1fff -- GIC Distributor -* 0x2000-0x2fff -- GIC CPU interface +* 0x2000-0x3fff -- GIC CPU interface * 0x4000-0x4fff -- GIC virtual interface control (not modelled) * 0x5000-0x5fff -- GIC virtual interface control (not modelled) * 0x6000-0x7fff -- GIC virtual CPU interface (not modelled)
hw/intc/arm_gic.c +45 -1
64 lines not on this page · raw message
hw/intc/arm_gic_common.c +1 -1
@@ -121,7 +121,7 @@ void gic_init_irqs_and_mmio(GICState *s, qemu_irq_handler handler,* neither it can use KVM. */ memory_region_init_io (&s->cpuiomem[0 ],OBJECT (s), ops ? &ops[1 ] :NULL , - s,"gic_cpu" , s->revision ==2 ?0x1000 :0x100 ); + s,"gic_cpu" , s->revision ==2 ?0x2000 :0x100 );sysbus_init_mmio (sbd, &s->cpuiomem[0 ]); } }
Signature · 1 line
1.9.1
Quoted 17 lines · Peter Maydell
The GICv2 introduces a new CPU interface register
GICC_DIR, which allows an OS to split the "priority drop" and "deactivate interrupt" parts of interrupt completion. Implement this register. (Note that the register is at offset0x1000in the CPU interface, which means it is on a different 4K page from all the other registers.)Signed-off-by Peter Maydell <[email protected]>hw/intc/arm_gic.c +9
-0+static void gic_deactivate_irq (GICState *s,int cpu,int irq,MemTxAttrs attrs) +{ +int cm =1 << cpu; +int group =gic_has_groups (s) &&GIC_TEST_GROUP (irq, cm); + +if (!gic_eoi_split (s, cpu, attrs)) { +/* This is UNPREDICTABLE; we choose to ignore it */ +qemu_log_mask (LOG_GUEST_ERROR , +"gic_deactivate_irq: GICC_DIR write when EOIMode clear" );
hw/intc/arm_gic.c static uint8_t gic_get_running_priority(GICState *s, int cpu, MemTxAttrs attrs) · line 536
Quoted 10 lines
hw/intc/arm_gic.c +10
-0+return ; + } + +if (s->security_extn && !attrs.secure && !group) { +DPRINTF ("Non-secure DI for Group0 interrupt %d ignored\n" , irq); +return ; + } + +GIC_CLEAR_ACTIVE (irq, cm); +gic_update (s);
Whoops, this gic_update() call should be deleted, because the caller will do a gic_update anyway. (The extra call is harmless but unnecessary.)
thanks
-- PMM