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] [day] [month] [year] [list]
Message-ID: <20251017103936.49fbafdd@kernel.org>
Date: Fri, 17 Oct 2025 10:39:36 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Michael Turquette <mturquette@...libre.com>, Stephen Boyd
 <sboyd@...nel.org>, Nicolas Ferre <nicolas.ferre@...rochip.com>, Alexandre
 Belloni <alexandre.belloni@...tlin.com>, Claudiu Beznea
 <claudiu.beznea@...on.dev>, Giovanni Cabiddu <giovanni.cabiddu@...el.com>,
 Herbert Xu <herbert@...dor.apana.org.au>, David Miller
 <davem@...emloft.net>, Linus Walleij <linus.walleij@...aro.org>, Bartosz
 Golaszewski <brgl@...ev.pl>, Joel Stanley <joel@....id.au>, Andrew Jeffery
 <andrew@...econstruct.com.au>, Crt Mori <cmo@...exis.com>, Jonathan Cameron
 <jic23@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>, Jacky Huang
 <ychuang3@...oton.com>, Shan-Chun Hung <schung@...oton.com>, Yury Norov
 <yury.norov@...il.com>, Rasmus Villemoes <linux@...musvillemoes.dk>,
 Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>, Johannes
 Berg <johannes@...solutions.net>, Alex Elder <elder@...e.org>, David Laight
 <david.laight.linux@...il.com>, Vincent Mailhol
 <mailhol.vincent@...adoo.fr>, linux-clk@...r.kernel.org,
 linux-arm-kernel@...ts.infradead.org, linux-renesas-soc@...r.kernel.org,
 linux-crypto@...r.kernel.org, qat-linux@...el.com,
 linux-gpio@...r.kernel.org, linux-aspeed@...ts.ozlabs.org,
 linux-iio@...r.kernel.org, linux-sound@...r.kernel.org,
 linux-kernel@...r.kernel.org, Jonathan Cameron
 <Jonathan.Cameron@...wei.com>
Subject: Re: [PATCH treewide v3 2/4] bitfield: Add non-constant
 field_{prep,get}() helpers

On Fri, 17 Oct 2025 18:00:41 +0200 Geert Uytterhoeven wrote:
> > +/**
> > + * u32_encode_bits() - prepare a u32 bitfield element (non-const)
> > + * @v: value to put in the field
> > + * @field: shifted mask defining the field's length and position
> > + *
> > + * Equivalent of FIELD_PREP() for u32, field does not have to be constant.
> > + *
> > + * Note that the helper is available for other field widths (generated below).
> > + */
> > +static __always_inline __u32 u32_encode_bits(u32 v, u32 field)
> > +{
> > +       if (__builtin_constant_p(v) && (v & ~field_mask(field)))
> > +               __field_overflow();
> > +       return ((v & field_mask(field)) * field_multiplier(field));  
> 
> Unfortunately gcc emits actual divisions or __*div*() calls, and
> multiplications in the non-constant case.
> 
> So I don't think this is suitable as-is.

Sorry I missed or forgot that you replied :(

The inline helpers exist already have have a lot of uses. If __ffs is
more optimal then why not make existing helpers use it as well? 
It'd be far more beneficial:

$ git grep u32_encode_bits | wc -l
391

Sorry if I'm being slow..

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ