Re: [PATCH v6 3/3] selftests/lam: Update LAM tag width and cleanup names
From: Sohil Mehta
Date: Wed Apr 22 2026 - 14:15:45 EST
On 4/10/2026 2:55 AM, Maciej Wieczor-Retman wrote:
> diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c
> index 1919fa6daec0..f14600e74d8c 100644
> --- a/tools/testing/selftests/x86/lam.c
> +++ b/tools/testing/selftests/x86/lam.c
> @@ -24,11 +24,15 @@
> # error This test is 64-bit only
> #endif
>
> +#define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (__BITS_PER_LONG - 1 - (h))))
> +
Did you run into any problem when including linux/bits.h? It would be
preferable to avoid redefining generic macros. I see the GENMASK defines
in tools/include/linux/bits.h and include/uapi/linux/bits.h.
If you are running into issues with the x86 selftests header includes,
the uapi one should be safe to use.
You probably just need:
#define GENMASK(h, l) __GENMASK(h, l)
> /* LAM modes, these definitions were copied from kernel code */
> #define LAM_NONE 0
> -#define LAM_U57_BITS 6
> +#define LAM_TAG_BITS 4
> +#define LAM_LS_BIT 57
> +#define LAM_MS_BIT (LAM_LS_BIT + LAM_TAG_BITS - 1) /* 60 */
> +#define LAM_UNTAG_MASK ~GENMASK(LAM_MS_BIT, LAM_LS_BIT)
>
Same comment as patch 1:
#define LAM_UNTAG_MASK ~GENMASK(60, 57)
> -#define LAM_U57_MASK (0x3fULL << 57)
> /* arch prctl for LAM */
> #define ARCH_GET_UNTAG_MASK 0x4001
> #define ARCH_ENABLE_TAGGED_ADDR 0x4002
> @@ -51,8 +55,8 @@
> #define GET_USER_KERNEL 3
The rest of the patch looks fine.
With the above addressed,
Reviewed-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>