lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251127093713.5a0f9d95@pumpkin>
Date: Thu, 27 Nov 2025 09:37:13 +0000
From: david laight <david.laight@...box.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Rasmus Villemoes <ravi@...vas.dk>, "Yury Norov (NVIDIA)"
 <yury.norov@...il.com>, Linus Walleij <linus.walleij@...aro.org>, Nicolas
 Frattaroli <nicolas.frattaroli@...labora.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 00/21] lib: add alternatives for GENMASK()

On Wed, 26 Nov 2025 15:47:28 -0800
Linus Torvalds <torvalds@...ux-foundation.org> wrote:

> On Wed, 26 Nov 2025 at 14:17, david laight <david.laight@...box.com> wrote:
> >
> > Mark B. will accuse you of abusing ?: :-)  
> 
> Compared to '__is_constexpr()', this is child's play.  Not *that* is
> abusing the ternary op.
> 
> > I've just looked at a .i file.
> > GENMASK() currently expands to 855 chars plus four copies of each argument.  
> 
> Yeah, I don't love it. It's a horrid macro. But because of the odd
> order of arguments, it needs all that crazy checking.
> 
> That said, I do think it could be simplified. Particularly if we just
> make the rule be that GENMASK _has_ to take just constant values.
> 
> Right now, I think 99.9% of all users are constants, and we spend a
> lot of effort on the 0.1% that isn't.

There is the other 0.1% that actually need an 'integer constant expression'.
They stop you using ({ ...}).
I doubt there are many (if any) for FIELD_PREP() and FIELD_GET() and using
	auto _mask = mask;
would shrink those massively.
(If there are any I suspect you are the only person who can fix them
in one release cycle.)

I've not looked closely at the expansions, but as well as some is_constexpr()
(that could probably be 'statically_true()') there is the _Generic() that
generates u8/u16/u32/u64 based on 'something'.
That is mostly entirely pointless, you just need to pick u32 or u64, the u8/u16
get promoted to 'int' as soon as they are used - so it only makes a difference
to code that looks at the type of the variable/result.

In spite of the faffing, the type of FIELD_GET() is u64.

	David

> 
>                Linus
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ