Skip to content

Commit 6eff380

Browse files
rajnesh-kanwalavpatel
authored andcommitted
riscv/kvm: Fix VM hang in case of timer delta being zero.
In case when VCPU is blocked due to WFI, we schedule the timer from `kvm_riscv_vcpu_timer_blocking()` to keep timer interrupt ticking. But in case when delta_ns comes to be zero, we never schedule the timer and VCPU keeps sleeping indefinitely until any activity is done with VM console. This is easily reproduce-able using kvmtool. ./lkvm-static run -c1 --console virtio -p "earlycon root=/dev/vda" \ -k ./Image -d rootfs.ext4 Also, just add a print in kvm_riscv_vcpu_vstimer_expired() to check the interrupt delivery and run `top` or similar auto-upating cmd from guest. Within sometime one can notice that print from timer expiry routine stops and the `top` cmd output will stop updating. This change fixes this by making sure we schedule the timer even with delta_ns being zero to bring the VCPU out of sleep immediately. Fixes: 8f5cb44 ("RISC-V: KVM: Support sstc extension") Signed-off-by: Rajnesh Kanwal <[email protected]> Reviewed-by: Atish Patra <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent eeac8ed commit 6eff380

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

arch/riscv/kvm/vcpu_timer.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ static void kvm_riscv_vcpu_timer_blocking(struct kvm_vcpu *vcpu)
147147
return;
148148

149149
delta_ns = kvm_riscv_delta_cycles2ns(t->next_cycles, gt, t);
150-
if (delta_ns) {
151-
hrtimer_start(&t->hrt, ktime_set(0, delta_ns), HRTIMER_MODE_REL);
152-
t->next_set = true;
153-
}
150+
hrtimer_start(&t->hrt, ktime_set(0, delta_ns), HRTIMER_MODE_REL);
151+
t->next_set = true;
154152
}
155153

156154
static void kvm_riscv_vcpu_timer_unblocking(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)