[Question] Received vtimer interrupt but ISTATUS is 0
Kunkun Jiang
jiangkunkun at huawei.com
Tue Oct 14 07:45:37 PDT 2025
Hi all,
I'm having a very strange problem that can be simplified to a vtimer
interrupt being received but ISTATUS is 0. Why dose this happen?
According to analysis, it may be the timer condition is met and the
interrupt is generated. Maybe some actions(cancel timer?) are done in
the VM, ISTATUS becomes 0 and he hardware needs to clear the interrupt.
But the clear command is sent too slowly, the OS has already read the
ICC_IAR_EL1. So hypervisor executed kvm_arch_timer_handler but ISTATUS is 0.
The code flow is as follows:
kvm_arch_timer_handler
->if (kvm_timer_should_fire)
->the value of SYS_CNTV_CTL is 0b001(ISTATUS=0,IMASK=0,ENABLE=1)
->return IRQ_HANDLED
Because ISTATUS is 0, kvm_timer_update_irq will not be executed to
inject this interrupt into the VM. Since EOImode is 1 and the vtimer
interrupt has IRQD_FORWARDED_TO_VCPU flag, hypervisor will not write
ICC_DIR_EL1 to deactivate the interrupt. This interrupt remains in
active state, blocking subsequent interrupt from being process.
Fortunately, in kvm_timer_vcpu_load it will be determined again whether
an interrupt needs to be injected into the VM. But the delay will
definitely increase.
What I want to discuss is the solution to this problem. My solution is
to add a deactivation action:
diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c
index dbd74e4885e2..46baba531d51 100644
--- a/arch/arm64/kvm/arch_timer.c
+++ b/arch/arm64/kvm/arch_timer.c
@@ -228,8 +228,13 @@ static irqreturn_t kvm_arch_timer_handler(int irq,
void *dev_id)
else
ctx = map.direct_ptimer;
- if (kvm_timer_should_fire(ctx))
+ if (kvm_timer_should_fire(ctx)) {
kvm_timer_update_irq(vcpu, true, ctx);
+ } else {
+ struct vgic_irq *irq;
+ irq = vgic_get_vcpu_irq(vcpu, timer_irq(timer_ctx));
+ gic_write_dir(irq->hwintid);
+ }
if (userspace_irqchip(vcpu->kvm) &&
!static_branch_unlikely(&has_gic_active_state))
If you have any new ideas or other solutions to this problem, please let
me know.
Looking forward to your reply.
Kunkun Jiang
More information about the linux-arm-kernel
mailing list