Re: [PATCH v4 6/6] arm64: cpufeature: Detect BBML3 based on ID_AA64MMFR2_EL1.BBM

Linu Cherian <[email protected]>
Newsgroups org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hi,

On Tue, Aug 04, 2026 at 02:51:28PM +0100, Will Deacon wrote:
> On Mon, Aug 03, 2026 at 09:22:02AM +0530, Linu Cherian wrote:
> > Hi Will,
> > 
> > On Fri, Jul 31, 2026 at 04:13:20PM +0100, Will Deacon wrote:
> > > On Thu, Jul 23, 2026 at 10:10:33AM +0530, Linu Cherian wrote:
> > > > Add ID_AA64MMFR2_EL1.BBM based BBML3 feature detection in
> > > > cpu_supports_bbml3() so that cpus with the feature would
> > > > not have to be added into MIDR based supports_bbml3_list.
> > > > 
> > > > Reviewed-by: Gavin Shan <[email protected]>
> > > > Reviewed-by: Anshuman Khandual <[email protected]>
> > > > Signed-off-by: Linu Cherian <[email protected]>
> > > > ---
> > > >  arch/arm64/kernel/cpufeature.c | 17 +++++++++--------
> > > >  1 file changed, 9 insertions(+), 8 deletions(-)
> > > > 
> > > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> > > > index 896bafdb00b1..dbd7d187520c 100644
> > > > --- a/arch/arm64/kernel/cpufeature.c
> > > > +++ b/arch/arm64/kernel/cpufeature.c
> > > > @@ -2133,6 +2133,12 @@ static bool hvhe_possible(const struct arm64_cpu_capabilities *entry,
> > > >  
> > > >  bool cpu_supports_bbml3(void)
> > > >  {
> > > > +	u64 mmfr2;
> > > > +
> > > > +	mmfr2 = __read_sysreg_by_encoding(SYS_ID_AA64MMFR2_EL1);
> > > > +	if (SYS_FIELD_GET(ID_AA64MMFR2_EL1, BBM, mmfr2) >= ID_AA64MMFR2_EL1_BBM_3)
> > > > +		return true;
> > > 
> > > This is a bit of a nit, but I think it would be more consistent to use
> > > has_cpuid_feature() here instead of __read_sysreg_by_encoding(), similarly
> > > to how we handle kpti in unmap_kernel_at_el0() (which also has both an
> > > ID register field and a list of MIDRs).
> > 
> > force_pte_mapping required by map_mem(during early boot) needs
> > cpu_supports_bbml3 check and cpu features/capabilities are not 
> > initialized by that time. Should i add a comment there to clarify this ?
> 
> It looks to me like has_cpuid_feature() will call
> __read_sysreg_by_encoding() under the hood for SCOPE_LOCAL_CPU.
> 
> What am I missing?

Below is my understanding. Correct me if i am wrong.
has_cpuid_feature depends on struct arm64_cpu_capabilities *entry.
Inorder to derive *entry from a capability ID, cpucap_ptrs should be
in initialized state and that wont be the case when force_pte_mapping
invokes cpu_supports_bbml3. 


  
> 
> Will
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.