]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
arm64/sysreg: Support feature-specific fields with 'Prefix' descriptor
authorSascha Bischoff <Sascha.Bischoff@arm.com>
Wed, 22 Oct 2025 13:45:36 +0000 (13:45 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 13 Nov 2025 18:09:46 +0000 (18:09 +0000)
commitfe2ef46995d5db49a37337f11fe2c6733676c24c
tree5b1e8c1dc551c45de49ccd45e99b15ad9ad94635
parent0aab5772a53dd006c13ba629e8dc8816b7cd213d
arm64/sysreg: Support feature-specific fields with 'Prefix' descriptor

Some system register field encodings change based on, for example the
in-use architecture features, or the context in which they are
accessed. In order to support these different field encodings,
introduce the Prefix descriptor (Prefix, EndPrefix) for describing
such sysregs.

The Prefix descriptor can be used in the following way:

        Sysreg  EXAMPLE 0    1    2    3    4
        Prefix    FEAT_A
Field   63:0    Foo
EndPrefix
Prefix    FEAT_B
Field   63:1    Bar
  Res0    0
        EndPrefix
        Field   63:0    Baz
        EndSysreg

This will generate a single set of system register encodings (REG_,
SYS_, ...), and then generate three sets of field definitions for the
system register called EXAMPLE. The first set is prefixed by FEAT_A,
e.g. FEAT_A_EXAMPLE_Foo. The second set is prefixed by FEAT_B, e.g.,
FEAT_B_EXAMPLE_Bar. The third set is not given a prefix at all,
e.g. EXAMPLE_BAZ. For each set, a corresponding set of defines for
Res0, Res1, and Unkn is generated.

The intent for the final prefix-less fields is to describe default or
legacy field encodings. This ensure that prefixed encodings can be
added to already-present sysregs without affecting existing legacy
code. Prefixed fields must be defined before those without a prefix,
and this is checked by the generator. This ensures consisnt ordering
within the sysregs definitions.

The Prefix descriptor can be used within Sysreg or SysregFields
blocks. Field, Res0, Res1, Unkn, Rax, SignedEnum, Enum can all be used
within a Prefix block. Fields and Mapping can not. Fields that vary
with features must be described as part of a SysregFields block,
instead. Mappings, which are just a code comment, make little sense in
this context, and have hence not been included.

There are no changes to the generated system register definitions as
part of this change.

Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/tools/gen-sysreg.awk