On Tue, May 12, 2020 at 11:53:43AM +0100, Mark Rutland wrote:
> >
> >     /* Clamp the IPA limit to the PA size supported by the kernel */
> >     ipa_max = (pa_max > PHYS_MASK_SHIFT) ? PHYS_MASK_SHIFT : pa_max;
> > @@ -411,7 +411,8 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long 
> > type)
> >             phys_shift = KVM_PHYS_SHIFT;
> >     }
> >  
> > -   parange = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1) & 7;
> > +   parange = id_aa64mmfr0_parange(read_sanitised_ftr_reg
> > +                                           (SYS_ID_AA64MMFR0_EL1));
> 
> Can't we add a system_ipa_range() helper, and avoid more boilerplate in
> each of these?
> 
> e.g.
> 
> int system_ipa_range(void)
> {
>       u64 mmfr0;
>       int parange;
> 
>       mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1);
>       parange = cpuid_feature_extract_unsigned_field(mmfr0,
>               ID_AA64MMFR0_PARANGE_SHIFT);
>       
>       return parange;
> }

As Per MarcZ's comments, that should be system_pa_range() rather than
system_ipa_range().

Mark.

Reply via email to