Re: [PATCH] arm64/boot: Don't set PMUv3p9 FGT2 bits without PMUv3

From: Will Deacon

Date: Sun Oct 04 2026 - 04:40:07 EST


On Fri, Oct 02, 2026 at 04:39:37PM +0100, Catalin Marinas wrote:
> On Fri, Oct 02, 2026 at 04:24:06PM +0100, Fuad Tabba wrote:
> > On Fri, Oct 02, 2026 at 03:51:16PM +0100, Catalin Marinas wrote:
> > > I couldn't figure out the #8 either. I wonder whether it's more readable
> > > as (untested):
> > >
> > > sub x1, x1, #ID_AA64DFR0_EL1_PMUVer_V3P9
> > > cmp x1, #(ID_AA64DFR0_EL1_PMUVer_IMP_DEF - ID_AA64DFR0_EL1_PMUVer_V3P9)
> > > b.hs .Lskip_pmuv3p9_\@ // Skip unless V3P9 <= PMUVer < IMP_DEF
> >
> > This looks correct to me.
> >
> > That said, if readability is the goal, I think the plainest is two
> > compares and two branches. It's one more instruction, but this runs
> > once at boot:
> >
> > cmp x1, #ID_AA64DFR0_EL1_PMUVer_IMP_DEF
> > b.eq .Lskip_pmuv3p9_\@
> > cmp x1, #ID_AA64DFR0_EL1_PMUVer_V3P9
> > b.lt .Lskip_pmuv3p9_\@
> >
> > I used ccmp to match __init_el2_debug in the same file, which does the
> > same NI/IMP_DEF check with a raw #4, as does reset_pmuserenr_el0 in
> > assembler.h (and hyp-entry.S uses the same pattern for HVC64/HVC32).
>
> I'll leave it to Will. My preference is whatever is more readable, no
> need to optimise another cycle or two here.

Now that Fuad's put me right and given that we already use ccmp in
__init_el2_debug, I think consistency is probably the winner so I'll queue
this as-is.

I wonder if it would be worth having some #defines for some of the common
conditions, so we could avoid having the bare immediates each time in
future? (obviously, that would be a separate cleanup rather than part of
this fix).

Will