On Fri, 2023-06-02 at 00:51 +0000, Jing Zhang wrote: > Refactor writings for ID_AA64PFR0_EL1.[CSV2|CSV3], > ID_AA64DFR0_EL1.PMUVer and ID_DFR0_ELF.PerfMon based on utilities > specific to ID register. > > Signed-off-by: Jing Zhang <jingzhangos@xxxxxxxxxx> > --- > arch/arm64/include/asm/cpufeature.h | 1 + > arch/arm64/kernel/cpufeature.c | 2 +- > arch/arm64/kvm/sys_regs.c | 291 +++++++++++++++++++------- > -- > 3 files changed, 203 insertions(+), 91 deletions(-) > > > + > +static u64 read_sanitised_id_dfr0_el1(struct kvm_vcpu *vcpu, > + const struct sys_reg_desc *rd) > +{ > + u64 val; > + u32 id = reg_to_encoding(rd); > + > + val = read_sanitised_ftr_reg(id); > + /* > + * Initialise the default PMUver before there is a chance to > + * create an actual PMU. > + */ > + val &= ~ARM64_FEATURE_MASK(ID_DFR0_EL1_PerfMon); > + val |= FIELD_PREP(ARM64_FEATURE_MASK(ID_DFR0_EL1_PerfMon), > kvm_arm_pmu_get_pmuver_limit()); Maybe it's never possible, but does this need a: pmuver_to_perfmon(kvm_arm_pmu_get_pmuver_limit()) ? > + > + return val; > } > > Thanks - Suraj