On Wed, Apr 10, 2024 at 05:07:42PM -0700, Atish Patra wrote: > KVM enables perf for guest via counter virtualization. However, the > sampling can not be supported as there is no mechanism to enabled > trap/emulate scountovf in ISA yet. Rely on the SBI PMU snapshot > to provide the counter overflow data via the shared memory. > > In case of sampling event, the host first sets the guest's LCOFI > interrupt and injects to the guest via irq filtering mechanism defined > in AIA specification. Thus, ssaia must be enabled in the host in order > to use perf sampling in the guest. No other AIA dependency w.r.t kernel > is required. > > Reviewed-by: Anup Patel <anup@xxxxxxxxxxxxxx> > Signed-off-by: Atish Patra <atishp@xxxxxxxxxxxx> > --- > arch/riscv/include/asm/csr.h | 3 +- > arch/riscv/include/asm/kvm_vcpu_pmu.h | 3 ++ > arch/riscv/include/uapi/asm/kvm.h | 1 + > arch/riscv/kvm/aia.c | 5 ++ > arch/riscv/kvm/vcpu.c | 15 ++++-- > arch/riscv/kvm/vcpu_onereg.c | 6 +++ > arch/riscv/kvm/vcpu_pmu.c | 68 +++++++++++++++++++++++++-- > 7 files changed, 93 insertions(+), 8 deletions(-) > Reviewed-by: Andrew Jones <ajones@xxxxxxxxxxxxxxxx>