Patch "riscv/kvm: Fix VM hang in case of timer delta being zero." has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    riscv/kvm: Fix VM hang in case of timer delta being zero.

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-kvm-fix-vm-hang-in-case-of-timer-delta-being-z.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit cd005a7f03da9a1c0f772e6f63bf736adfa1ff08
Author: Rajnesh Kanwal <rkanwal@xxxxxxxxxxxx>
Date:   Fri Feb 10 14:27:11 2023 +0000

    riscv/kvm: Fix VM hang in case of timer delta being zero.
    
    [ Upstream commit 6eff38048944cadc3cddcf117acfa5199ec32490 ]
    
    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: 8f5cb44b1bae ("RISC-V: KVM: Support sstc extension")
    Signed-off-by: Rajnesh Kanwal <rkanwal@xxxxxxxxxxxx>
    Reviewed-by: Atish Patra <atishp@xxxxxxxxxxxx>
    Signed-off-by: Anup Patel <anup@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/kvm/vcpu_timer.c b/arch/riscv/kvm/vcpu_timer.c
index ad34519c8a13d..3ac2ff6a65dac 100644
--- a/arch/riscv/kvm/vcpu_timer.c
+++ b/arch/riscv/kvm/vcpu_timer.c
@@ -147,10 +147,8 @@ static void kvm_riscv_vcpu_timer_blocking(struct kvm_vcpu *vcpu)
 		return;
 
 	delta_ns = kvm_riscv_delta_cycles2ns(t->next_cycles, gt, t);
-	if (delta_ns) {
-		hrtimer_start(&t->hrt, ktime_set(0, delta_ns), HRTIMER_MODE_REL);
-		t->next_set = true;
-	}
+	hrtimer_start(&t->hrt, ktime_set(0, delta_ns), HRTIMER_MODE_REL);
+	t->next_set = true;
 }
 
 static void kvm_riscv_vcpu_timer_unblocking(struct kvm_vcpu *vcpu)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux