OpenCloudOS-Kernel/arch/riscv/kvm
Rajnesh Kanwal 6eff380489 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: 8f5cb44b1b ("RISC-V: KVM: Support sstc extension")
Signed-off-by: Rajnesh Kanwal <rkanwal@rivosinc.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
2023-03-17 13:32:54 +05:30
..
Kconfig KVM: Opt out of generic hardware enabling on s390 and PPC 2022-12-29 15:48:37 -05:00
Makefile RISC-V: KVM: Add SBI PMU extension support 2023-02-07 20:35:53 +05:30
main.c KVM/riscv changes for 6.3 2023-02-15 12:33:28 -05:00
mmu.c KVM/riscv changes for 6.3 2023-02-15 12:33:28 -05:00
tlb.c ARM: 2023-02-25 11:30:21 -08:00
vcpu.c RISC-V: KVM: Add skeleton support for perf 2023-02-07 20:35:51 +05:30
vcpu_exit.c RISC-V: KVM: Redirect illegal instruction traps to guest 2023-02-07 20:35:28 +05:30
vcpu_fp.c RISC-V: KVM: Improve ISA extension by using a bitmap 2022-07-29 17:14:11 +05:30
vcpu_insn.c RISC-V: KVM: Implement trap & emulate for hpmcounters 2023-02-07 20:36:01 +05:30
vcpu_pmu.c RISC-V: KVM: Support firmware events 2023-02-07 20:36:06 +05:30
vcpu_sbi.c RISC-V: KVM: Add SBI PMU extension support 2023-02-07 20:35:53 +05:30
vcpu_sbi_base.c RISC-V: KVM: Modify SBI extension handler to return SBI error code 2023-02-07 20:35:45 +05:30
vcpu_sbi_hsm.c RISC-V: KVM: Modify SBI extension handler to return SBI error code 2023-02-07 20:35:45 +05:30
vcpu_sbi_pmu.c RISC-V: KVM: Add SBI PMU extension support 2023-02-07 20:35:53 +05:30
vcpu_sbi_replace.c RISC-V: KVM: Increment firmware pmu events 2023-02-07 20:36:08 +05:30
vcpu_sbi_v01.c RISC-V: KVM: Modify SBI extension handler to return SBI error code 2023-02-07 20:35:45 +05:30
vcpu_switch.S RISC-V: KVM: Refine __kvm_riscv_switch_to() implementation 2022-03-11 19:02:22 +05:30
vcpu_timer.c riscv/kvm: Fix VM hang in case of timer delta being zero. 2023-03-17 13:32:54 +05:30
vm.c RISC-V: KVM: Make kvm_riscv_guest_timer_init a void function 2022-07-29 17:14:26 +05:30
vmid.c KVM: RISC-V: Tag init functions and data with __init, __ro_after_init 2022-12-29 15:41:18 -05:00