lkml.org 
[lkml]   [2023]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v5 11/14] RISC-V: KVM: Implement trap & emulate for hpmcounters
    On Sat, Feb 04, 2023 at 05:15:12PM -0800, Atish Patra wrote:
    > As the KVM guests only see the virtual PMU counters, all hpmcounter
    > access should trap and KVM emulates the read access on behalf of guests.
    >
    > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
    > Signed-off-by: Atish Patra <atishp@rivosinc.com>
    > ---
    > arch/riscv/include/asm/kvm_vcpu_pmu.h | 16 ++++++++
    > arch/riscv/kvm/vcpu_insn.c | 4 +-
    > arch/riscv/kvm/vcpu_pmu.c | 59 ++++++++++++++++++++++++++-
    > 3 files changed, 77 insertions(+), 2 deletions(-)
    >
    > diff --git a/arch/riscv/include/asm/kvm_vcpu_pmu.h b/arch/riscv/include/asm/kvm_vcpu_pmu.h
    > index 40905db..344a3ad 100644
    > --- a/arch/riscv/include/asm/kvm_vcpu_pmu.h
    > +++ b/arch/riscv/include/asm/kvm_vcpu_pmu.h
    > @@ -48,6 +48,19 @@ struct kvm_pmu {
    > #define vcpu_to_pmu(vcpu) (&(vcpu)->arch.pmu_context)
    > #define pmu_to_vcpu(pmu) (container_of((pmu), struct kvm_vcpu, arch.pmu_context))
    >
    > +#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 },
    ^ should be tabs?

    > +#else
    > +#define KVM_RISCV_VCPU_HPMCOUNTER_CSR_FUNCS \
    > +{.base = CSR_CYCLE, .count = 31, .func = kvm_riscv_vcpu_pmu_read_hpm },
    ^ here too
    > +#endif
    > +
    > +int kvm_riscv_vcpu_pmu_read_hpm(struct kvm_vcpu *vcpu, unsigned int csr_num,
    > + unsigned long *val, unsigned long new_val,
    > + unsigned long wr_mask);
    > +
    > int kvm_riscv_vcpu_pmu_num_ctrs(struct kvm_vcpu *vcpu, struct kvm_vcpu_sbi_return *retdata);
    > int kvm_riscv_vcpu_pmu_ctr_info(struct kvm_vcpu *vcpu, unsigned long cidx,
    > struct kvm_vcpu_sbi_return *retdata);
    > @@ -71,6 +84,9 @@ void kvm_riscv_vcpu_pmu_reset(struct kvm_vcpu *vcpu);
    > struct kvm_pmu {
    > };
    >
    > +#define KVM_RISCV_VCPU_HPMCOUNTER_CSR_FUNCS \
    > +{ .base = 0, .count = 0, .func = NULL },
    ^ and here and aligned with the ones above?

    Thanks,
    drew

    \
     
     \ /
      Last update: 2023-03-27 00:10    [W:4.503 / U:0.120 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site