RISC-V: KVM: Disable all hpmcounter access for VS/VU mode
authorAtish Patra <atishp@rivosinc.com>
Tue, 7 Feb 2023 09:55:25 +0000 (01:55 -0800)
committerAnup Patel <anup@brainfault.org>
Tue, 7 Feb 2023 15:05:58 +0000 (20:35 +0530)
commitf04bafb52f580552dc22bfb5b7af9a5dbcc2254f
treef1b41709a765c9e9d26ba6d2db7f87acb7aabc7b
parent470926a2900cfdc39b300d87a0ccdf037fa67b9a
RISC-V: KVM: Disable all hpmcounter access for VS/VU mode

Any guest must not get access to any hpmcounter including cycle/instret
without any checks. We achieve that by disabling all the bits except TM
bit in hcounteren.

However, instret and cycle access for guest user space can be enabled
upon explicit request (via ONE REG) or on first trap from VU mode
to maintain ABI requirement in the future. This patch doesn't support
that as ONE REG interface is not settled yet.

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/main.c