[PATCH v4 03/29] mm: use ARCH_PKEY_BITS to define VM_PKEY_BITN
Dave Hansen
dave.hansen at intel.com
Sat May 4 02:41:57 AEST 2024
On 5/3/24 06:01, Joey Gouly wrote:
> #ifdef CONFIG_ARCH_HAS_PKEYS
> -# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0
> -# define VM_PKEY_BIT0 VM_HIGH_ARCH_0 /* A protection key is a 4-bit value */
> -# define VM_PKEY_BIT1 VM_HIGH_ARCH_1 /* on x86 and 5-bit value on ppc64 */
> -# define VM_PKEY_BIT2 VM_HIGH_ARCH_2
> -# define VM_PKEY_BIT3 VM_HIGH_ARCH_3
> -#ifdef CONFIG_PPC
> +# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0
> +# define VM_PKEY_BIT0 VM_HIGH_ARCH_0
> +# define VM_PKEY_BIT1 VM_HIGH_ARCH_1
> +# define VM_PKEY_BIT2 VM_HIGH_ARCH_2
> +#if CONFIG_ARCH_PKEY_BITS > 3
> +# define VM_PKEY_BIT3 VM_HIGH_ARCH_3
> +#else
> +# define VM_PKEY_BIT3 0
> +#endif
> +#if CONFIG_ARCH_PKEY_BITS > 4
It's certainly not pretty, but it does get the arch #ifdef out of
generic code. We might need to rethink this if we get another
architecture or two, but this seems manageable for now.
Acked-by: Dave Hansen <dave.hansen at linux.intel.com>
More information about the Linuxppc-dev
mailing list