• Anup Patel's avatar
    RISC-V: KVM: Fix kvm_riscv_vcpu_timer_pending() for Sstc · cea8896b
    Anup Patel authored
    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: 8f5cb44b ("RISC-V: KVM: Support sstc extension")
    Signed-off-by: default avatarAnup Patel <apatel@ventanamicro.com>
    Reviewed-by: default avatarAtish Patra <atishp@rivosinc.com>
    Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
    cea8896b
vcpu_timer.c 8.83 KB