[PATCH v2] arm64/sysreg: allow *Enum blocks in SysregFields blocks

Anshuman Khandual anshuman.khandual at arm.com
Wed Mar 8 00:10:50 PST 2023



On 3/6/23 17:18, Mark Rutland wrote:
> We'd like to support Enum/SignedEnum/UnsignedEnum blocks within
> SysregFields blocks, so that we can define enumerations for sets of
> registers. This isn't currently supported by gen-sysreg.awk due to the
> way we track the active block, which can't handle more than a single
> layer of nesting, which imposes an awkward requirement that when ending
> a block we know what the parent block is when calling change_block()
> 
> Make this nicer by using a stack of active blocks, with block_push() to
> start a block, and block_pop() to end a block. Doing so means that we
> only need to check the active block at the start of parsing a line: for
> the start of a block we can check the parent is valid, and for the end
> of a block we check that the active block is valid.
> 
> This structure makes the block parsing simpler and makes it easy to
> permit a block to live under several potential parents (e.g. by
> permitting Enum to start when the active block is Sysreg or
> SysregFields). It also permits further nesting, if we need that in
> future.
> 
> To aid debugging, the stack of active blocks is reported for fatal
> errors, and an error is raised if the file is terminated without ending
> the active block. For clarity I've renamed the top-level element from
> "None" to "Root".
> 
> The Fields element it intended only for use within Sysreg blocks, and
> does not make sense within SysregFields blocks, and so remains forbidden
> within a SysregFields block.
> 
> I've verified using sha1sum that this patch does not change the
> current generated contents of <asm/sysreg-defs.h>.
> 
> Signed-off-by: Mark Rutland <mark.rutland at arm.com>
> Cc: Anshuman Khandual <anshuman.khandual at arm.com>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Marc Zyngier <maz at kernel.org>
> Cc: Mark Brown <broonie at kernel.org>
> Cc: Will Deacon <will at kernel.org>
> ---
>  arch/arm64/tools/gen-sysreg.awk | 95 ++++++++++++++++++++-------------
>  1 file changed, 58 insertions(+), 37 deletions(-)
> 
> This is a preparatory patch for BRBE support, as the BRBE series will
> add a bunch of SysregFields with Enums. I'm sending this on its own as I
> think it's a useful improvement/cleanup of the sysreg code regardless.

This patch is indeed helpful for the upcoming BRBE V9 series which moves
to define all the BRBINF_EL1 register fields via this new 'SysregFields'
construct. This patch works as expected.

Reviewed-by: Anshuman Khandual <anshuman.khandual at arm.com>



More information about the linux-arm-kernel mailing list