Re: [PATCH next 10/14] bits: Fix assmebler expansions of GENMASK_Uxx() and BIT_Uxx()

From: Yury Norov

Date: Sat Feb 07 2026 - 22:32:01 EST


On Wed, Jan 21, 2026 at 02:57:27PM +0000, david.laight.linux@xxxxxxxxx wrote:
> From: David Laight <david.laight.linux@xxxxxxxxx>
>
> The assembler only supports one type of signed integers, so expressions
> using BITS_PER_LONG (etc) cannot be guaranteed to be correct.
>
> Use ((2 << (h)) - (1 << (l))) for all assembler GENMASK() expansions and
> add definitions of BIT_Uxx() as (1 << (nr)).
>
> Note that 64bit results are (probably) only correct for 64bit builds
> and 128bits results will never be valid.

And this important note will sink in git history.

> Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>

This has been discussed in details when those GENMASK_Uxx() were
introduced. Assembler doesn't support C types, and can't provide any
guarantees. It may only confuse readers when they see something like
GENMASK_U8() in the assembler code, and there's nothing on behalf of
that declaration to enforce the limitation.

That's why we didn't add fake C types support in the assembler. Unless
we find a way to enforce C types capacity in assembler(s), let's keep
those macros C-only.

Thanks,
Yury