[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <14b30b59-12bb-fc69-8447-aae86fcafcd1@huawei.com>
Date: Tue, 14 Oct 2025 22:45:37 +0800
From: Kunkun Jiang <jiangkunkun@...wei.com>
To: Marc Zyngier <maz@...nel.org>, Oliver Upton <oliver.upton@...ux.dev>, Joey
Gouly <joey.gouly@....com>, Suzuki K Poulose <suzuki.poulose@....com>,
Zenghui Yu <yuzenghui@...wei.com>, Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>
CC: "moderated list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)"
<linux-arm-kernel@...ts.infradead.org>, "open list:KERNEL VIRTUAL MACHINE FOR
ARM64 (KVM/arm64)" <kvmarm@...ts.linux.dev>, open list
<linux-kernel@...r.kernel.org>, "wanghaibin.wang@...wei.com"
<wanghaibin.wang@...wei.com>, Zenghui Yu <yuzenghui@...wei.com>
Subject: [Question] Received vtimer interrupt but ISTATUS is 0
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
Powered by blists - more mailing lists