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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b47b02cc-642b-4a21-a932-25bca8352ae3@citrix.com>
Date: Fri, 9 Jan 2026 19:26:13 +0000
From: Andrew Cooper <andrew.cooper3@...rix.com>
To: ptesarik@...e.com
Cc: Andrew Cooper <andrew.cooper3@...rix.com>, agordeev@...ux.ibm.com,
 airlied@...il.com, akpm@...ux-foundation.org, andrew+netdev@...n.ch,
 arnd@...db.de, chris@...kel.net, davem@...emloft.net, edumazet@...gle.com,
 fw@...len.de, geert@...ux-m68k.org, gor@...ux.ibm.com, hca@...ux.ibm.com,
 jcmvbkbc@...il.com, johan.hedberg@...il.com, joro@...tes.org,
 kuba@...nel.org, linmag7@...il.com, linux-kernel@...r.kernel.org,
 linux@...musvillemoes.dk, luiz.dentz@...il.com,
 maarten.lankhorst@...ux.intel.com, macro@...am.me.uk, maddy@...ux.ibm.com,
 marcel@...tmann.org, mattst88@...il.com, mpe@...erman.id.au,
 mripard@...nel.org, oliver@...kum.org, pabeni@...hat.com,
 pablo@...filter.org, patrik.r.jakobsson@...il.com,
 richard.henderson@...aro.org, robin.murphy@....com, simona@...ll.ch,
 tsbogend@...ha.franken.de, tzimmermann@...e.de, vgupta@...nel.org,
 visitorckw@...il.com, will@...nel.org, yury.norov@...il.com
Subject: Re: [RFC PATCH 0/2] Helper to isolate least-significant bit

> diff --git a/arch/alpha/kernel/core_cia.c b/arch/alpha/kernel/core_cia.c
> index 6e577228e175d..b3c273c13c104 100644
> --- a/arch/alpha/kernel/core_cia.c
> +++ b/arch/alpha/kernel/core_cia.c
> @@ -1035,7 +1035,7 @@ cia_decode_ecc_error(struct el_CIA_sysdata_mcheck *cia, const char *msg)
>      cia_decode_mem_error(cia, msg);
>  
>      syn = cia->cia_syn & 0xff;
> -    if (syn == (syn & -syn)) {
> +    if (syn == ffs_val(syn)) {
>          fmt = KERN_CRIT "  ECC syndrome %#x -- check bit %d\n";
>          i = ffs(syn) - 1;
>      } else {

This is a check for multiple bits set, which has a simpler expression to
calculate.  (the ffs() in context shows that syn isn't expected to be 0.)

In Xen I added this helper while tiding things up, and it's applicable
to the more common pattern of checking hweight() of a bitmap against 1.

/*
 * Calculate if a value has two or more bits set.  Always use this in
 * preference to an expression of the form 'hweight(x) > 1'.
 */
#define multiple_bits_set(x)                    \
    ({                                          \
        typeof(x) _v = (x);                     \
        (_v & (_v - 1)) != 0;                   \
    })


~Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ