This is a note to let you know that I've just added the patch titled ARM: 9256/1: NWFPE: avoid compiler-generated __aeabi_uldivmod to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: arm-9256-1-nwfpe-avoid-compiler-generated-__aeabi_uldivmod.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 3220022038b9a3845eea762af85f1c5694b9f861 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> Date: Tue, 11 Oct 2022 20:00:12 +0100 Subject: ARM: 9256/1: NWFPE: avoid compiler-generated __aeabi_uldivmod From: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> commit 3220022038b9a3845eea762af85f1c5694b9f861 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@xxxxxxxxxx> Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx> Signed-off-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Russell King (Oracle) <rmk+kernel@xxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/arm/nwfpe/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) --- a/arch/arm/nwfpe/Makefile +++ b/arch/arm/nwfpe/Makefile @@ -11,3 +11,9 @@ nwfpe-y += fpa11.o fpa11_cpdo.o fpa11 entry.o nwfpe-$(CONFIG_FPE_NWFPE_XP) += extended_cpdo.o + +# Try really hard to avoid generating calls to __aeabi_uldivmod() from +# float64_rem() due to loop elision. +ifdef CONFIG_CC_IS_CLANG +CFLAGS_softfloat.o += -mllvm -replexitval=never +endif Patches currently in stable-queue which might be from ndesaulniers@xxxxxxxxxx are queue-4.19/arm-9256-1-nwfpe-avoid-compiler-generated-__aeabi_uldivmod.patch