Re: [PATCH v3] ubsan: Avoid unnecessary 128-bit shifts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 05, 2019 at 01:58:53AM +0000, George Spelvin wrote:
> If CONFIG_ARCH_SUPPORTS_INT128, s_max is 128 bits, and variable
> sign-extending shifts of such a double-word data type are a non-trivial
> amount of code and complexity.  Do a single-word sign-extension *before*
> the cast to (s_max), greatly simplifying the object code.
> 
> Rasmus Villemoes suggested using sign_extend* from <linux/bitops.h>.
> 
> On s390 (and perhaps some other arches), gcc implements variable
> 128-bit shifts using an __ashrti3 helper function which the kernel
> doesn't provide, causing a link error.  In that case, this patch is
> a prerequisite for enabling INT128 support.  Andrey Ryabinin has gven
> permission for any arch that needs it to cherry-pick it so they don't
> have to wait for ubsan to be merged into Linus' tree.

Still, this should go upstream via Andrew Morton.

As soon as this gets merged I'd like to select ARCH_SUPPORTS_INT128 on
s390 unconditionally.

However... ;)

> +static inline long sign_extend_long(unsigned long value, int index)
> +{
> +	if (sizeof(value) == 4)
> +		return sign_extend32(value);
> +	return sign_extend64(value);
> +}
> +

This doesn't compile:

In file included from ./include/linux/kernel.h:12,
                 from ./arch/s390/include/asm/bug.h:5,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/page-flags.h:10,
                 from kernel/bounds.c:10:
./include/linux/bitops.h: In function 'sign_extend_long':
./include/linux/bitops.h:163:10: error: too few arguments to function 'sign_extend32'
   return sign_extend32(value);
          ^~~~~~~~~~~~~
./include/linux/bitops.h:143:21: note: declared here
 static inline __s32 sign_extend32(__u32 value, int index)
                     ^~~~~~~~~~~~~
./include/linux/bitops.h:164:9: error: too few arguments to function 'sign_extend64'
  return sign_extend64(value);
         ^~~~~~~~~~~~~
./include/linux/bitops.h:154:21: note: declared here
 static inline __s64 sign_extend64(__u64 value, int index)
                     ^~~~~~~~~~~~~




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux