Re: [PATCH V7 2/6] arm64/perf: Add BRBE registers and fields
From: Mark Rutland
Date: Wed Feb 08 2023 - 14:22:49 EST
On Fri, Jan 13, 2023 at 08:32:47AM +0530, Anshuman Khandual wrote:
> On 1/12/23 18:54, Mark Rutland wrote:
> > Hi Anshuman,
> >
> > On Thu, Jan 05, 2023 at 08:40:35AM +0530, Anshuman Khandual wrote:
> >> This adds BRBE related register definitions and various other related field
> >> macros there in. These will be used subsequently in a BRBE driver which is
> >> being added later on.
> >
> > I haven't verified the specific values, but this looks good to me aside from
> > one minor nit below.
> >
> > [...]
> >
> >> +# This is just a dummy register declaration to get all common field masks and
> >> +# shifts for accessing given BRBINF contents.
> >> +Sysreg BRBINF_EL1 2 1 8 0 0
> >
> > We don't need a dummy declaration, as we have 'SysregFields' that can be used
> > for this, e.g.
> >
> > SysregFields BRBINFx_EL1
> > ...
> > EndSysregFields
> >
> > ... which will avoid accidental usage of the register encoding. Note that I've
> > also added an 'x' there in place of the index, which we do for other registers,
> > e.g. TTBRx_EL1.
> >
> > Could you please update to that?
>
> There is a problem in defining SysregFields (which I did explore earlier as well).
> SysregFields unfortunately does not support enums fields. Following build failure
> comes up, while trying to convert BRBINFx_EL1 into a SysregFields definition.
>
> Error at 932: unexpected Enum (inside SysregFields)
This is a problem, but it's one that we can solve. We're in control of
gen-sysreg.awk and the language it parses, so we can make this an expected and
supported case -- see below.
> ===============================================================================
> diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg
> index a7f9054bd84c..519c4f080898 100644
> --- a/arch/arm64/tools/sysreg
> +++ b/arch/arm64/tools/sysreg
> @@ -921,10 +921,7 @@ Enum 3:0 BT
> EndEnum
> EndSysreg
>
> -
> -# This is just a dummy register declaration to get all common field masks and
> -# shifts for accessing given BRBINF contents.
> -Sysreg BRBINF_EL1 2 1 8 0 0
> +SysregFields BRBINFx_EL1
> Res0 63:47
> Field 46 CCU
> Field 45:32 CC
> @@ -967,7 +964,7 @@ Enum 1:0 VALID
> 0b10 SOURCE
> 0b11 FULL
> EndEnum
> -EndSysreg
> +EndSysregFields
>
> Sysreg BRBCR_EL1 2 1 9 0 0
> Res0 63:24
> ===============================================================================
>
> There are three enum fields in BRBINFx_EL1 as listed here.
>
> Enum 13:8 TYPE
> Enum 7:6 EL
> Enum 1:0 VALID
>
> However, BRBINF_EL1 can be changed as BRBINFx_EL1, indicating its more generic
> nature with a potential to be used for any index value register thereafter.
It's certainly better to use the BRBINFx_EL1 name, but my main concern here is
to avoid the dummy values used above to satisfy the tools, so that those cannot
be accidentally misused.
I'd prefer that we fix gen-sysreg.awk to support Enum blocks within
SysregFields blocks (patch below), then use SysregFields as described above.
Thanks,
Mark.
---->8----