diff mbox series

[v2] crypto: arm64/poly1305 - move data to rodata section

Message ID 20240806055444.528932-1-justin.he@arm.com
State Accepted
Commit 9369693a2c8f4832f6cdc8a94cc63cc7f7f9c96c
Headers show
Series [v2] crypto: arm64/poly1305 - move data to rodata section | expand

Commit Message

Jia He Aug. 6, 2024, 5:54 a.m. UTC
When objtool gains support for ARM in the future, it may encounter issues
disassembling the following data in the .text section:
> .Lzeros:
> .long   0,0,0,0,0,0,0,0
> .asciz  "Poly1305 for ARMv8, CRYPTOGAMS by \@dot-asm"
> .align  2

Move it to .rodata which is a more appropriate section for read-only data.

There is a limit on how far the label can be from the instruction, hence
use "adrp" and low 12bits offset of the label to avoid the compilation
error.

Signed-off-by: Jia He <justin.he@arm.com>
---
v2:
  - use adrp+offset to avoid compilation error(kernel test bot and Andy)
v1: https://lkml.org/lkml/2024/8/2/616

 arch/arm64/crypto/poly1305-armv8.pl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Thorsten Leemhuis Aug. 8, 2024, 11:38 a.m. UTC | #1
On 06.08.24 14:55, Daniel Gomez wrote:
> On Tue, Aug 06, 2024 at 05:54:44AM GMT, Jia He wrote:
>> When objtool gains support for ARM in the future, it may encounter issues
>> disassembling the following data in the .text section:
>>> .Lzeros:
>>> .long   0,0,0,0,0,0,0,0
>>> .asciz  "Poly1305 for ARMv8, CRYPTOGAMS by \@dot-asm"
>>> .align  2
>>
>> Move it to .rodata which is a more appropriate section for read-only data.
>>
>> There is a limit on how far the label can be from the instruction, hence
>> use "adrp" and low 12bits offset of the label to avoid the compilation
>> error.
> [...]
> 
> I'm getting the following error with next-20240806
> 
> make LLVM=1 ARCH=arm64 allyesconfig
> make LLVM=1 ARCH=arm64 -j$(nproc)
> 
> ld.lld: error: vmlinux.a(arch/arm64/crypto/poly1305-core.o):(function poly1305_blocks_neon: .text+0x3d4): relocation R_AARCH64_ADR_PREL_LO21 out of range: 269166444 is not in [-1048576, 1048575]

Hmmm, I ran into build problems with -next today for arm64 and x86-64
(ppc64le failed at a later stage for a different reason) on all current
Fedora releases (yesterday everything worked fine). The error looks
different, but mentions R_AARCH64_ADR_PREL_LO21 as well on arm64.

/usr/bin/ld: /tmp/ccgC3toO.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `stderr@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /tmp/ccgC3toO.o(.text+0x8): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `stderr@@GLIBC_2.17'
/usr/bin/ld: final link failed: bad value

That's what brought be here, so allow me to ask: might that be related
somehow or is that likely a different problem?

arm64: https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-39-aarch64/07889669-next-next-all/builder-live.log.gz
"""
> + /usr/bin/make -s 'HOSTCFLAGS=-O2  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection   ' 'HOSTLDFLAGS=-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes ' ARCH=arm64 'KCFLAGS= ' WITH_GCOV=0 -j4 vmlinuz.efi
> /usr/bin/ld: /tmp/ccgC3toO.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `stderr@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /tmp/ccgC3toO.o(.text+0x8): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `stderr@@GLIBC_2.17'
> /usr/bin/ld: final link failed: bad value
> collect2: error: ld returned 1 exit status
> make[4]: *** [Makefile:47: /builddir/build/BUILD/kernel-next-20240808/linux-6.11.0-0.0.next.20240808.225.vanilla.fc39.aarch64/tools/bpf/resolve_btfids/fixdep] Error 1
> make[3]: *** [/builddir/build/BUILD/kernel-next-20240808/linux-6.11.0-0.0.next.20240808.225.vanilla.fc39.aarch64/tools/build/Makefile.include:15: fixdep] Error 2
> make[2]: *** [Makefile:76: bpf/resolve_btfids] Error 2
> make[1]: *** [/builddir/build/BUILD/kernel-next-20240808/linux-6.11.0-0.0.next.20240808.225.vanilla.fc39.aarch64/Makefile:1362: tools/bpf/resolve_btfids] Error 2
> make[1]: *** Waiting for unfinished jobs....
> make: *** [Makefile:226: __sub-make] Error 2
> error: Bad exit status from /var/tmp/rpm-tmp.iEcjn7 (%build)
"""

x86_64
https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-39-x86_64/07889669-next-next-all/builder-live.log.gz
"""
> + /usr/bin/make -s 'HOSTCFLAGS=-O2  -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64   -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection   ' 'HOSTLDFLAGS=-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes ' ARCH=x86_64 'KCFLAGS= ' WITH_GCOV=0 -j2 bzImage
> /usr/bin/ld: /tmp/ccSPE2cG.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
> /usr/bin/ld: failed to set dynamic section sizes: bad value
> collect2: error: ld returned 1 exit status
> make[4]: *** [Makefile:47: /builddir/build/BUILD/kernel-next-20240808/linux-6.11.0-0.0.next.20240808.225.vanilla.fc39.x86_64/tools/objtool/fixdep] Error 1
> make[3]: *** [/builddir/build/BUILD/kernel-next-20240808/linux-6.11.0-0.0.next.20240808.225.vanilla.fc39.x86_64/tools/build/Makefile.include:15: fixdep] Error 2
> make[2]: *** [Makefile:73: objtool] Error 2
> make[1]: *** [/builddir/build/BUILD/kernel-next-20240808/linux-6.11.0-0.0.next.20240808.225.vanilla.fc39.x86_64/Makefile:1362: tools/objtool] Error 2
> make[1]: *** Waiting for unfinished jobs....
> make: *** [Makefile:226: __sub-make] Error 2
> error: Bad exit status from /var/tmp/rpm-tmp.MPS2x4 (%build)
"""

Ciao, Thorsten
Herbert Xu Aug. 17, 2024, 7:07 a.m. UTC | #2
On Tue, Aug 06, 2024 at 05:54:44AM +0000, Jia He wrote:
> When objtool gains support for ARM in the future, it may encounter issues
> disassembling the following data in the .text section:
> > .Lzeros:
> > .long   0,0,0,0,0,0,0,0
> > .asciz  "Poly1305 for ARMv8, CRYPTOGAMS by \@dot-asm"
> > .align  2
> 
> Move it to .rodata which is a more appropriate section for read-only data.
> 
> There is a limit on how far the label can be from the instruction, hence
> use "adrp" and low 12bits offset of the label to avoid the compilation
> error.
> 
> Signed-off-by: Jia He <justin.he@arm.com>
> ---
> v2:
>   - use adrp+offset to avoid compilation error(kernel test bot and Andy)
> v1: https://lkml.org/lkml/2024/8/2/616
> 
>  arch/arm64/crypto/poly1305-armv8.pl | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/arch/arm64/crypto/poly1305-armv8.pl b/arch/arm64/crypto/poly1305-armv8.pl
index cbc980fb02e3..22c9069c0650 100644
--- a/arch/arm64/crypto/poly1305-armv8.pl
+++ b/arch/arm64/crypto/poly1305-armv8.pl
@@ -473,7 +473,8 @@  poly1305_blocks_neon:
 	subs	$len,$len,#64
 	ldp	x9,x13,[$inp,#48]
 	add	$in2,$inp,#96
-	adr	$zeros,.Lzeros
+	adrp	$zeros,.Lzeros
+	add	$zeros,$zeros,#:lo12:.Lzeros
 
 	lsl	$padbit,$padbit,#24
 	add	x15,$ctx,#48
@@ -885,10 +886,13 @@  poly1305_blocks_neon:
 	ret
 .size	poly1305_blocks_neon,.-poly1305_blocks_neon
 
+.pushsection .rodata
 .align	5
 .Lzeros:
 .long	0,0,0,0,0,0,0,0
 .asciz	"Poly1305 for ARMv8, CRYPTOGAMS by \@dot-asm"
+.popsection
+
 .align	2
 #if !defined(__KERNEL__) && !defined(_WIN64)
 .comm	OPENSSL_armcap_P,4,4