Skip to contentSkip to conversation

fair.c:undefined reference to `__lshrti3'

PATCH Superseded kernel test robot 3 participants 4 messages May 15, 2025 – May 17, 2025

Subsystems (2)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   484803582c77061b470ac64a634f25f89715be3f
commit: c66d7ebbe2fa14e41913adb421090a7426f59786 [10914/11408] crypto: powerpc/poly1305 - Add SIMD fallback
config: powerpc64-randconfig-002-20250515 (https://download.01.org/0day-ci/archive/20250515/[email protected]/config)
compiler: powerpc64-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250515/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

powerpc64-linux-ld: kernel/sched/fair.o: in function `calc_delta_fair':

>> fair.c:(.text+0x2224): undefined reference to `__lshrti3'
   powerpc64-linux-ld: kernel/time/timekeeping.o: in function `delta_to_ns_safe':
>> timekeeping.c:(.text+0x108): undefined reference to `__lshrti3'
   powerpc64-linux-ld: kernel/time/clocksource.o: in function `cycles_to_nsec_safe':
>> clocksource.c:(.text+0xa4): undefined reference to `__lshrti3'
   powerpc64-linux-ld: lib/ubsan.o: in function `get_signed_val':
>> ubsan.c:(.text+0x1f8): undefined reference to `__ashlti3'
>> powerpc64-linux-ld: ubsan.c:(.text+0x204): undefined reference to `__ashrti3'
   powerpc64-linux-ld: drivers/clk/renesas/rzg2l-cpg.o: in function `rzg2l_cpg_pll_clk_recalc_rate':
>> rzg2l-cpg.c:(.text+0x820): undefined reference to `__lshrti3'
   powerpc64-linux-ld: drivers/clk/renesas/rzv2h-cpg.o: in function `rzv2h_cpg_pll_clk_recalc_rate':
>> rzv2h-cpg.c:(.text+0x3e8): undefined reference to `__lshrti3'
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
maintainer
#1 lore raw

PATCH 1/1 powerpc: Add gcc 128-bit shift helpers

Quoted 6 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   484803582c77061b470ac64a634f25f89715be3f
commit: c66d7ebbe2fa14e41913adb421090a7426f59786 [10914/11408] crypto: powerpc/poly1305 - Add SIMD fallback
config: powerpc64-randconfig-002-20250515 (https://download.01.org/0day-ci/archive/20250515/[email protected]/config)
compiler: powerpc64-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250515/[email protected]/reproduce)

Thanks for the report. This patch should fix the problem.

---8<---
When optimising for size, gcc generates out-of-line calls for 128-bit integer shifts. Add these functions to avoid build errors.

Fixes c66d7ebbe2fa ("crypto: powerpc/poly1305 - Add SIMD fallback")
arch/powerpc/lib/Makefile +2 -0
index 1cd74673cbf7..a41c071c1652 100644
@@ -87,3 +87,5 @@ obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-powerpc.o
 crc-t10dif-powerpc-y := crc-t10dif-glue.o crct10dif-vpmsum_asm.o
 
 obj-$(CONFIG_PPC64) += $(obj64-y)
+
+obj-$(CONFIG_ARCH_SUPPORTS_INT128) += tishift.o
arch/powerpc/lib/tishift.S new file +54 -0

54 lines not on this page · raw message

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw

Re: [PATCH] powerpc: Add gcc 128-bit shift helpers

Quoted 9 lines · Herbert Xu
Quoted 6 lines · kernel test robot
tree:   https://urldefense.com/v3/__https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git__;!!D9dNQwwGXtA!TSuOAutxjuD3Hp-RC0Fw9dTNuagdCKeNLTN71tv_OmhUxyAPLfIfwwpZop5pKFXgS4Jfkt830_tEMkbHT4vfog$  master
head:   484803582c77061b470ac64a634f25f89715be3f
commit: c66d7ebbe2fa14e41913adb421090a7426f59786 [10914/11408] crypto: powerpc/poly1305 - Add SIMD fallback
config: powerpc64-randconfig-002-20250515 (https://urldefense.com/v3/__https://download.01.org/0day-ci/archive/20250515/[email protected]/config__;!!D9dNQwwGXtA!TSuOAutxjuD3Hp-RC0Fw9dTNuagdCKeNLTN71tv_OmhUxyAPLfIfwwpZop5pKFXgS4Jfkt830_tEMkaPDLMaoA$ )
compiler: powerpc64-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://urldefense.com/v3/__https://download.01.org/0day-ci/archive/20250515/[email protected]/reproduce__;!!D9dNQwwGXtA!TSuOAutxjuD3Hp-RC0Fw9dTNuagdCKeNLTN71tv_OmhUxyAPLfIfwwpZop5pKFXgS4Jfkt830_tEMkbNYWK3LQ$ )

Thanks for the report. This patch should fix the problem.

It won't work for big endian, nor for 32 bit obviously.

Besides that, in arch/power/kernel/misc_32.S, you'll find a branchless version of these functions. It's for 64 bit shifts on 32 bit big-endian but it can easily be adapted to 128 bit shifts on 64 bit processors (swapping r3 and r4 depending on endianness).

Several functions of kernel/misc_32.S should arguably be moved to lib/.

Cheers,
Gabriel

Quoted 85 lines

---8<---
When optimising for size, gcc generates out-of-line calls for 128-bit integer shifts. Add these functions to avoid build errors.

arch/powerpc/lib/Makefile +2 -0
index 1cd74673cbf7..a41c071c1652 100644
@@ -87,3 +87,5 @@ obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-powerpc.o
 crc-t10dif-powerpc-y := crc-t10dif-glue.o crct10dif-vpmsum_asm.o
 
 obj-$(CONFIG_PPC64) += $(obj64-y)
+
+obj-$(CONFIG_ARCH_SUPPORTS_INT128) += tishift.o
arch/powerpc/lib/tishift.S new file +54 -0
new file mode 100644
index 000000000000..79afef2d8d54
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2025 Herbert Xu <[email protected]>
+ */
+#include <asm/ppc_asm.h>
+#include <linux/export.h>
+
+_GLOBAL(__lshrti3)
+	cmplwi	r5,63
+	ble	1f
+	addi	r5,r5,-64
+	srd	r3,r4,r5
+	li	r4,0
+	blr
+1:
+	subfic	r7,r5,64
+	srd	r3,r3,r5
+	sld	r6,r4,r7
+	srd	r4,r4,r5
+	or	r3,r3,r6
+	blr
+EXPORT_SYMBOL(__lshrti3)
+
+_GLOBAL(__ashrti3)
+	cmplwi	r5,63
+	ble	1f
+	addi	r5,r5,-64
+	srad	r3,r4,r5
+	sradi	r4,r4,63
+	blr
+1:
+	subfic	r7,r5,64
+	srd	r3,r3,r5
+	sld	r6,r4,r7
+	srad	r4,r4,r5
+	or	r3,r3,r6
+	blr
+EXPORT_SYMBOL(__ashrti3)
+
+_GLOBAL(__ashlti3)
+	cmplwi	r5,63
+	ble	1f
+	addi	r5,r5,-64
+	sld	r4,r3,r5
+	li	r3,0
+	blr
+1:
+	subfic	r7,r5,64
+	sld	r4,r4,r5
+	srd	r6,r3,r7
+	sld	r3,r3,r5
+	or	r4,r4,r6
+	blr
+EXPORT_SYMBOL(__ashlti3)
Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: https://urldefense.com/v3/__http://gondor.apana.org.au/*herbert/__;fg!!D9dNQwwGXtA!TSuOAutxjuD3Hp-RC0Fw9dTNuagdCKeNLTN71tv_OmhUxyAPLfIfwwpZop5pKFXgS4Jfkt830_tEMkbwt6bO1g$ 
PGP Key: https://urldefense.com/v3/__http://gondor.apana.org.au/*herbert/pubkey.txt__;fg!!D9dNQwwGXtA!TSuOAutxjuD3Hp-RC0Fw9dTNuagdCKeNLTN71tv_OmhUxyAPLfIfwwpZop5pKFXgS4Jfkt830_tEMkam0aoZDQ$ 
maintainer
#3 lore raw

PATCH v2 1/1 powerpc: Add gcc 128-bit shift helpers

Quoted 2 lines · Gabriel Paubert

It won't work for big endian, nor for 32 bit obviously.

Good catch, I will restrict the Kconfig option to little-endian. The accelerated crypto code which uses this is already restricted to little-endian anyway.

The Kconfig option is also dependent on PPC64 so 32-bit shouldn't be a problem.

Quoted 4 lines

Besides that, in arch/power/kernel/misc_32.S, you'll find a branchless version of these functions. It's for 64 bit shifts on 32 bit big-endian but it can easily be adapted to 128 bit shifts on 64 bit processors (swapping r3 and r4 depending on endianness).

Nice. I've replaced the shift code with one based on misc_32.S.

Quoted 1 line

Several functions of kernel/misc_32.S should arguably be moved to lib/.

I'll leave that to someone else :)

Thanks,

---8<---
When optimising for size, gcc generates out-of-line calls for 128-bit integer shifts. Add these functions to avoid build errors.

Also restrict ARCH_SUPPORTS_INT128 to little-endian since the only user that prompted this poly1305 only supports that.

arch/powerpc/Kconfig +1 -1
index 651e0c32957a..7a7d39fa8b01 100644
@@ -173,7 +173,7 @@ config PPC
 	select ARCH_STACKWALK
 	select ARCH_SUPPORTS_ATOMIC_RMW
 	select ARCH_SUPPORTS_DEBUG_PAGEALLOC	if PPC_BOOK3S || PPC_8xx
-	select ARCH_SUPPORTS_INT128		if PPC64 && CC_HAS_INT128
+	select ARCH_SUPPORTS_INT128		if PPC64 && CC_HAS_INT128 && CPU_LITTLE_ENDIAN
 	select ARCH_USE_BUILTIN_BSWAP
 	select ARCH_USE_CMPXCHG_LOCKREF		if PPC64
 	select ARCH_USE_MEMTEST
arch/powerpc/lib/Makefile +2 -0
index 1cd74673cbf7..a41c071c1652 100644
@@ -87,3 +87,5 @@ obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-powerpc.o
 crc-t10dif-powerpc-y := crc-t10dif-glue.o crct10dif-vpmsum_asm.o
 
 obj-$(CONFIG_PPC64) += $(obj64-y)
+
+obj-$(CONFIG_ARCH_SUPPORTS_INT128) += tishift.o
arch/powerpc/lib/tishift.S new file +47 -0

47 lines not on this page · raw message

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt