arm64/cpufeature: Use helper macros to specify hwcaps
authorMark Brown <broonie@kernel.org>
Tue, 31 Jan 2023 00:18:47 +0000 (00:18 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 1 Feb 2023 17:51:19 +0000 (17:51 +0000)
commitbfffd469e5296b86418aacf6a0142bdef860b22d
tree7fee2b60c7ccfddbfaf0c74391fe6f09e4bdab38
parent82c5acefc9cb8478413610acf5904cec73ddd343
arm64/cpufeature: Use helper macros to specify hwcaps

At present the hwcaps are hard to read and a bit error prone since the
macros used to specify matches require us to write out the register name
multiple times and explicitly specify the width of the field, hopefully
using the correct constant. Now that all the ID registers are generated we
can improve this somewhat by redoing the macros so that we specify the
register, field and minimum value symbolically and use token pasting to
initialise the capability struct with the appropriate values.

We move from specifying like this:

      HWCAP_CAP(SYS_ID_AA64PFR1_EL1, ID_AA64PFR1_EL1_BT_SHIFT, 4, FTR_UNSIGNED, ID_AA64PFR1_EL1_BT_IMP, CAP_HWCAP, KERNEL_HWCAP_BTI),

to this:

      HWCAP_CAP(ID_AA64PFR1_EL1, BT, IMP, CAP_HWCAP, KERNEL_HWCAP_BTI),

which is shorter due to having less duplicate information and makes it
much harder to make an error like specifying the wrong field width or
an invalid enumeration value since everything must be a constant defined
for the sysreg and names are only typed once.

There should be no functional effect from this change, a check of the
generated .rodata showed no differences.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20221207-arm64-sysreg-helpers-v4-5-25b6b3fb9d18@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/cpufeature.c