]> git.baikalelectronics.ru Git - kernel.git/commit
RISC-V: KVM: Fix kvm_riscv_vcpu_timer_pending() for Sstc
authorAnup Patel <apatel@ventanamicro.com>
Fri, 21 Oct 2022 06:22:45 +0000 (11:52 +0530)
committerAnup Patel <anup@brainfault.org>
Fri, 21 Oct 2022 06:22:45 +0000 (11:52 +0530)
commiteb4f4a3a5a35214ad090628eca24b7bf16e09ca4
treea5c94163df10e7c56cab18976231642efd44efa2
parent69a467dd3d6226f2fe84bbe78ec97836a71ec330
RISC-V: KVM: Fix kvm_riscv_vcpu_timer_pending() for Sstc

The kvm_riscv_vcpu_timer_pending() checks per-VCPU next_cycles
and per-VCPU software injected VS timer interrupt. This function
returns incorrect value when Sstc is available because the per-VCPU
next_cycles are only updated by kvm_riscv_vcpu_timer_save() called
from kvm_arch_vcpu_put(). As a result, when Sstc is available the
VCPU does not block properly upon WFI traps.

To fix the above issue, we introduce kvm_riscv_vcpu_timer_sync()
which will update per-VCPU next_cycles upon every VM exit instead
of kvm_riscv_vcpu_timer_save().

Fixes: 7b8d4fb15676 ("RISC-V: KVM: Support sstc extension")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/include/asm/kvm_vcpu_timer.h
arch/riscv/kvm/vcpu.c
arch/riscv/kvm/vcpu_timer.c