|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2] xen/arm: ignore spurious interrupts from virtual timer
If the virtual timer IRQ fires but the timer is not pending (the ISTATUS
bit in CNTV_CTL_EL0 is clear), Xen masks the timer and injects the IRQ
into the guest. Linux unmasks the timer when it programs a new CVAL.
If ISTATUS is clear, its timer IRQ handler skips the clock event handler.
The timer can stay masked and the guest can miss the next timer IRQ.
This patch mirrors the Linux arm generic timer handler: if the interrupt
fires but the pending bit is not set, treat it as spurious and ignore it.
This issue is reproducible under heavy load on the R-Car X5H board
(Cortex-A720AE r0p0).
Add a performance counter for virtual timer IRQs ignored by this check.
Fixes: b765caf5101a ("xen/arm: support the ARM generic virtual timer")
Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
---
Changes in v2:
- Say "ISTATUS bit clear" in the commit message (Julien, Michal).
- Add the Fixes tag and a comment in vtimer_interrupt() (Michal).
- No functional change, so keep Volodymyr's Reviewed-by.
---
xen/arch/arm/include/asm/perfc_defn.h | 7 ++++---
xen/arch/arm/time.c | 16 +++++++++++++++-
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/xen/arch/arm/include/asm/perfc_defn.h
b/xen/arch/arm/include/asm/perfc_defn.h
index 8dfcac7e3b..50def279fa 100644
--- a/xen/arch/arm/include/asm/perfc_defn.h
+++ b/xen/arch/arm/include/asm/perfc_defn.h
@@ -70,9 +70,10 @@ PERFCOUNTER(ppis, "#PPIs")
PERFCOUNTER(spis, "#SPIs")
PERFCOUNTER(guest_irqs, "#GUEST-IRQS")
-PERFCOUNTER(hyp_timer_irqs, "Hypervisor timer interrupts")
-PERFCOUNTER(virt_timer_irqs, "Virtual timer interrupts")
-PERFCOUNTER(maintenance_irqs, "Maintenance interrupts")
+PERFCOUNTER(hyp_timer_irqs, "Hypervisor timer interrupts")
+PERFCOUNTER(virt_timer_irqs, "Virtual timer interrupts")
+PERFCOUNTER(virt_timer_spurious_irqs, "Virtual timer spurious interrupts")
+PERFCOUNTER(maintenance_irqs, "Maintenance interrupts")
PERFCOUNTER(atomics_guest, "atomics: guest access")
PERFCOUNTER(atomics_guest_paused, "atomics: guest paused")
diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 295afa685a..be52b24c67 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -262,6 +262,8 @@ static void htimer_interrupt(int irq, void *dev_id)
static void vtimer_interrupt(int irq, void *dev_id)
{
+ register_t ctl;
+
/*
* Edge-triggered interrupts can be used for the virtual timer. Even
* if the timer output signal is masked in the context switch, the
@@ -275,9 +277,21 @@ static void vtimer_interrupt(int irq, void *dev_id)
if ( unlikely(is_idle_vcpu(current)) )
return;
+ ctl = READ_SYSREG(CNTV_CTL_EL0);
+
+ /*
+ * If ISTATUS is clear, do not mask the timer or inject the vIRQ.
+ * A guest that ignores the IRQ may leave the timer masked.
+ */
+ if ( unlikely(!(ctl & CNTx_CTL_PENDING)) )
+ {
+ perfc_incr(virt_timer_spurious_irqs);
+ return;
+ }
+
perfc_incr(virt_timer_irqs);
- current->arch.virt_timer.ctl = READ_SYSREG(CNTV_CTL_EL0);
+ current->arch.virt_timer.ctl = ctl;
WRITE_SYSREG(current->arch.virt_timer.ctl | CNTx_CTL_MASK, CNTV_CTL_EL0);
vgic_inject_irq(current->domain, current, current->arch.virt_timer.irq,
true);
}
--
2.53.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |