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: <871q3470nn.ffs@tglx>
Date: Sun, 04 Aug 2024 17:44:44 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Koakuma via B4 Relay <devnull+koachan.protonmail.com@...nel.org>, "David
 S. Miller" <davem@...emloft.net>, Andreas Larsson <andreas@...sler.com>,
 Andy Lutomirski <luto@...nel.org>, Vincenzo Frascino
 <vincenzo.frascino@....com>, Nathan Chancellor <nathan@...nel.org>, Nick
 Desaulniers <ndesaulniers@...gle.com>, Bill Wendling <morbo@...gle.com>,
 Justin Stitt <justinstitt@...gle.com>
Cc: sparclinux@...r.kernel.org, linux-kernel@...r.kernel.org,
 llvm@...ts.linux.dev, Koakuma <koachan@...tonmail.com>
Subject: Re: [PATCH] sparc/vdso: Add helper function for 64-bit right shift
 on 32-bit target

On Sun, Aug 04 2024 at 10:39, Koakuma via wrote:
> From: Koakuma <koachan@...tonmail.com>
>
> Add helper function for 64-bit right shift on 32-bit target so that
> clang does not emit a runtime library call.
>
> Signed-off-by: Koakuma <koachan@...tonmail.com>
> ---
> Hi~
>
> This adds a small function to do 64-bit right shifts for use in vDSO
> code, needed so that clang does not emit a call to runtime library.
> ---
>  arch/sparc/vdso/vclock_gettime.c |  8 ++++----
>  include/vdso/math64.h            | 28 ++++++++++++++++++++++++++++

> --- a/include/vdso/math64.h
> +++ b/include/vdso/math64.h
> @@ -21,6 +21,34 @@ __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
>  	return ret;
>  }
>  
> +#if BITS_PER_LONG == 32
> +/* This is to prevent the compiler from emitting a call to __lshrdi3. */
> +static __always_inline u64
> +__shr64(u64 val, int amt)
> +{
> +	u32 mask = (1U << amt) - 1;
> +	u32 lo = val;
> +	u32 hi = val >> 32;
> +	u32 mi;
> +
> +	if (amt >= 32)
> +		return hi >> (amt - 32);
> +
> +
> +	mi = (hi & mask) << (32 - amt);
> +	hi >>= amt;
> +	lo = (lo >> amt) | mi;
> +
> +	return ((u64) hi) << 32 | lo;
> +}
> +#else
> +static __always_inline u64
> +__shr64(u64 val, int amt)
> +{
> +	return val >> amt;
> +}

Why does this sparc'ism need to be in generic code?

Thanks,

        tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ