Skip to content

Commit 032ca56

Browse files
atishp04gregkh
authored andcommitted
RISC-V: KVM: Fix to allow hpmcounter31 from the guest
[ Upstream commit 5aa0929 ] 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: a9ac6c3 ("RISC-V: KVM: Implement trap & emulate for hpmcounters") Signed-off-by: Atish Patra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3c39f25 commit 032ca56

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/riscv/include/asm/kvm_vcpu_pmu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ struct kvm_pmu {
5858

5959
#if defined(CONFIG_32BIT)
6060
#define KVM_RISCV_VCPU_HPMCOUNTER_CSR_FUNCS \
61-
{.base = CSR_CYCLEH, .count = 31, .func = kvm_riscv_vcpu_pmu_read_hpm }, \
62-
{.base = CSR_CYCLE, .count = 31, .func = kvm_riscv_vcpu_pmu_read_hpm },
61+
{.base = CSR_CYCLEH, .count = 32, .func = kvm_riscv_vcpu_pmu_read_hpm }, \
62+
{.base = CSR_CYCLE, .count = 32, .func = kvm_riscv_vcpu_pmu_read_hpm },
6363
#else
6464
#define KVM_RISCV_VCPU_HPMCOUNTER_CSR_FUNCS \
65-
{.base = CSR_CYCLE, .count = 31, .func = kvm_riscv_vcpu_pmu_read_hpm },
65+
{.base = CSR_CYCLE, .count = 32, .func = kvm_riscv_vcpu_pmu_read_hpm },
6666
#endif
6767

6868
int kvm_riscv_vcpu_pmu_incr_fw(struct kvm_vcpu *vcpu, unsigned long fid);

0 commit comments

Comments
 (0)