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

From: Catalin Marinas

Date: Fri Oct 02 2026 - 11:40:36 EST


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.

--
Catalin