aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Elisei <alexandru.elisei@arm.com>2020-01-31 16:37:24 +0000
committerAndrew Jones <drjones@redhat.com>2020-04-03 09:40:33 +0200
commitbae77e15d1d08e3f879064103431659664114947 (patch)
tree5e71c4fae5a90197383f4f11d375f8be952bf3bf
parent6240ec9413f179dffb588e5cffce1039023bb725 (diff)
downloadkvm-unit-tests-bae77e15d1d08e3f879064103431659664114947.tar.gz
arm64: timer: EOIR the interrupt after masking the timer
Writing to the EOIR register before masking the HW mapped timer interrupt can cause taking another timer interrupt immediately after exception return. This doesn't happen all the time, because KVM reevaluates the state of pending HW mapped level sensitive interrupts on each guest exit. If the second interrupt is pending and a guest exit occurs after masking the timer interrupt and before the ERET (which restores PSTATE.I), then KVM removes it. Move the write after the IMASK bit has been set to prevent this from happening. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Signed-off-by: Andrew Jones <drjones@redhat.com>
-rw-r--r--arm/timer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/arm/timer.c b/arm/timer.c
index 82f8911..b6f9dd1 100644
--- a/arm/timer.c
+++ b/arm/timer.c
@@ -157,19 +157,20 @@ static void irq_handler(struct pt_regs *regs)
u32 irqstat = gic_read_iar();
u32 irqnr = gic_iar_irqnr(irqstat);
- if (irqnr != GICC_INT_SPURIOUS)
- gic_write_eoir(irqstat);
-
if (irqnr == PPI(vtimer_info.irq)) {
info = &vtimer_info;
} else if (irqnr == PPI(ptimer_info.irq)) {
info = &ptimer_info;
} else {
+ if (irqnr != GICC_INT_SPURIOUS)
+ gic_write_eoir(irqstat);
report_info("Unexpected interrupt: %d\n", irqnr);
return;
}
info->write_ctl(ARCH_TIMER_CTL_IMASK | ARCH_TIMER_CTL_ENABLE);
+ gic_write_eoir(irqstat);
+
info->irq_received = true;
}