linux-stable/arch
Nick Desaulniers 7854d3b926 ARM: 9256/1: NWFPE: avoid compiler-generated __aeabi_uldivmod
commit 3220022038 upstream.

clang-15's ability to elide loops completely became more aggressive when
it can deduce how a variable is being updated in a loop. Counting down
one variable by an increment of another can be replaced by a modulo
operation.

For 64b variables on 32b ARM EABI targets, this can result in the
compiler generating calls to __aeabi_uldivmod, which it does for a do
while loop in float64_rem().

For the kernel, we'd generally prefer that developers not open code 64b
division via binary / operators and instead use the more explicit
helpers from div64.h. On arm-linux-gnuabi targets, failure to do so can
result in linkage failures due to undefined references to
__aeabi_uldivmod().

While developers can avoid open coding divisions on 64b variables, the
compiler doesn't know that the Linux kernel has a partial implementation
of a compiler runtime (--rtlib) to enforce this convention.

It's also undecidable for the compiler whether the code in question
would be faster to execute the loop vs elide it and do the 64b division.

While I actively avoid using the internal -mllvm command line flags, I
think we get better code than using barrier() here, which will force
reloads+spills in the loop for all toolchains.

Link: https://github.com/ClangBuiltLinux/linux/issues/1666

Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-07 12:07:36 +01:00
..
alpha alpha: fix syscall entry in !AUDUT_SYSCALL case 2023-01-07 12:07:13 +01:00
arc arc: iounmap() arg is volatile 2022-11-03 23:49:17 +09:00
arm ARM: 9256/1: NWFPE: avoid compiler-generated __aeabi_uldivmod 2023-01-07 12:07:36 +01:00
arm64 arm64: errata: Fix KVM Spectre-v2 mitigation selection for Cortex-A57/A72 2022-12-08 11:15:41 +01:00
avr32
blackfin
c6x
cris
frv
h8300 h8300: fix PREEMPTION build, TI_PRE_COUNT undefined 2021-02-23 13:59:16 +01:00
hexagon hexagon: export raw I/O routines for modules 2021-11-26 11:48:42 +01:00
ia64 ia64, processor: fix -Wincompatible-pointer-types in ia64_get_irr() 2022-08-25 11:09:24 +02:00
m32r
m68k m68k: use fallback for random_get_entropy() instead of zero 2022-06-25 11:45:13 +02:00
metag
microblaze microblaze: Prevent the overflow of the start 2020-02-28 15:42:42 +01:00
mips MIPS: BCM63xx: Add check for NULL for clk in clk_enable 2023-01-07 12:07:15 +01:00
mn10300
nios2 nios2: add FORCE for vmlinuz.gz 2022-12-08 11:15:40 +01:00
openrisc openrisc: start CPU timer early in boot 2022-06-14 16:52:29 +02:00
parisc parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines 2022-09-15 12:39:45 +02:00
powerpc powerpc/rtas: avoid scheduling in rtas_os_term() 2023-01-07 12:07:34 +01:00
s390 s390/crashdump: fix TOD programmable field size 2022-12-08 11:15:40 +01:00
score
sh sh: machvec: Use char[] for section boundaries 2022-10-26 13:15:38 +02:00
sparc sparc: use fallback for random_get_entropy() instead of zero 2022-06-25 11:45:13 +02:00
tile locking/x86: Remove the unused atomic_inc_short() methd 2020-01-12 11:24:19 +01:00
um UM: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK 2022-10-26 13:15:37 +02:00
unicore32
x86 x86/xen: Fix memory leak in xen_init_lock_cpu() 2023-01-07 12:07:15 +01:00
xtensa xtensa: Fix refcount leak bug in time.c 2022-07-02 16:17:15 +02:00
.gitignore
Kconfig