[PATCH v2 4/9] arm64/sysreg: Provide a helper macro for defining sysreg bitmasks

Mark Rutland mark.rutland at arm.com
Wed Mar 23 10:58:25 PDT 2022


On Wed, Mar 16, 2022 at 05:08:44PM +0000, Mark Brown wrote:
> To ease the generation of headers for the bitfields in the system registers
> provide a macro for defining bitfields based on the top and bottom bit.
> 
> Ideally this should be provided along with the generic BIT() macros however
> there are a bunch of existing places with such macros including some that
> actually call their macro BITMASK() so rather than create a dependency on
> a wider cleanup let's define something local for now, this can be improved
> later. This also sidesteps the need to consider types other than u64.

In <linux/bits.h> we have GENMASK() and GENMASK_ULL() for this. Is there
a problem using those?

I think I got confused as to the name in the original version of the
scripting patch, and used BITMASK() by accident rather than by design,
but I could be mistaken.

Sorry about that!

Thanks,
Mark.

> 
> Signed-off-by: Mark Brown <broonie at kernel.org>
> ---
>  arch/arm64/include/asm/sysreg.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
> index abb1e0502e28..fa2ae02de465 100644
> --- a/arch/arm64/include/asm/sysreg.h
> +++ b/arch/arm64/include/asm/sysreg.h
> @@ -15,6 +15,8 @@
>  
>  #include <asm/gpr-num.h>
>  
> +#define ARM64_SYSREG_BITMASK(h, l) ((BIT(ULL(h)) - BIT(ULL(l))) | BIT(ULL(h)))
> +
>  /*
>   * ARMv8 ARM reserves the following encoding for system registers:
>   * (Ref: ARMv8 ARM, Section: "System instruction class encoding overview",
> -- 
> 2.30.2
> 



More information about the linux-arm-kernel mailing list