]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RISC-V: KVM: Fix to allow hpmcounter31 from the guest
authorAtish Patra <atishp@rivosinc.com>
Fri, 16 Aug 2024 07:08:09 +0000 (00:08 -0700)
committerAnup Patel <anup@brainfault.org>
Mon, 19 Aug 2024 03:28:21 +0000 (08:58 +0530)
The csr_fun defines a count parameter which defines the total number
CSRs emulated in KVM starting from the base. This value should be
equal to total number of counters possible for trap/emulation (32).

Fixes: a9ac6c37521f ("RISC-V: KVM: Implement trap & emulate for hpmcounters")
Signed-off-by: Atish Patra <atishp@rivosinc.com>
Link: https://lore.kernel.org/r/20240816-kvm_pmu_fixes-v1-2-cdfce386dd93@rivosinc.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/include/asm/kvm_vcpu_pmu.h

index c309daa2d75a8acf6e6fb97d3c114ee172864eb9..1d85b6617508845025336e847f3fe4b7198c67ee 100644 (file)
@@ -65,11 +65,11 @@ struct kvm_pmu {
 
 #if defined(CONFIG_32BIT)
 #define KVM_RISCV_VCPU_HPMCOUNTER_CSR_FUNCS \
-{.base = CSR_CYCLEH,   .count = 31,    .func = kvm_riscv_vcpu_pmu_read_hpm }, \
-{.base = CSR_CYCLE,    .count = 31,    .func = kvm_riscv_vcpu_pmu_read_hpm },
+{.base = CSR_CYCLEH,   .count = 32,    .func = kvm_riscv_vcpu_pmu_read_hpm }, \
+{.base = CSR_CYCLE,    .count = 32,    .func = kvm_riscv_vcpu_pmu_read_hpm },
 #else
 #define KVM_RISCV_VCPU_HPMCOUNTER_CSR_FUNCS \
-{.base = CSR_CYCLE,    .count = 31,    .func = kvm_riscv_vcpu_pmu_read_hpm },
+{.base = CSR_CYCLE,    .count = 32,    .func = kvm_riscv_vcpu_pmu_read_hpm },
 #endif
 
 int kvm_riscv_vcpu_pmu_incr_fw(struct kvm_vcpu *vcpu, unsigned long fid);