diff mbox series

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

Message ID 20240806055444.528932-1-justin.he@arm.com (mailing list archive)
State New, archived
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

Daniel Gomez Aug. 6, 2024, 12:55 p.m. UTC | #1
On Tue, Aug 06, 2024 at 05:54:44AM GMT, Jia He wrote:

Hi Jia,

> 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(-)
> 
> 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
> +

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]

Full debug error with log context:

...
+ grep -q ^CONFIG_DEBUG_INFO_BTF=y include/config/auto.conf
+ strip_debug=1
+ vmlinux_link .tmp_vmlinux1
+ local output=.tmp_vmlinux1
+ local objs
+ local libs
+ local ld
+ local ldflags
+ local ldlibs
+ info LD .tmp_vmlinux1
+ printf   %-7s %s\n LD .tmp_vmlinux1
  LD      .tmp_vmlinux1
+ shift
+ is_enabled CONFIG_LTO_CLANG
+ grep -q ^CONFIG_LTO_CLANG=y include/config/auto.conf
+ is_enabled CONFIG_X86_KERNEL_IBT
+ grep -q ^CONFIG_X86_KERNEL_IBT=y include/config/auto.conf
+ objs=vmlinux.a
+ libs=./drivers/firmware/efi/libstub/lib.a
+ is_enabled CONFIG_MODULES
+ grep -q ^CONFIG_MODULES=y include/config/auto.conf
+ objs=vmlinux.a .vmlinux.export.o
+ objs=vmlinux.a .vmlinux.export.o init/version-timestamp.o
+ [ arm64 = um ]
+ wl=
+ ld=ld.lld
+ ldflags=-EL  -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext  --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error
+ ldlibs=
+ ldflags=-EL  -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext  --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error --script=./arch/arm64/kernel/vmlinux.lds
+ [ -n 1 ]
+ ldflags=-EL  -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext  --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error --script=./arch/arm64/kernel/vmlinux.lds --strip-debug
+ is_enabled CONFIG_VMLINUX_MAP
+ grep -q ^CONFIG_VMLINUX_MAP=y include/config/auto.conf
+ ldflags=-EL  -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext  --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error --script=./arch/arm64/kernel/vmlinux.lds --strip-debug -Map=.tmp_vmlinux1.map
+ ld.lld -EL -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error --script=./arch/arm64/kernel/vmlinux.lds --strip-debug -Map=.tmp_vmlinux1.map -o .tmp_vmlinux1 --whole-archive vmlinux.a .vmlinux.export.o init/version-timestamp.o --no-whole-archive --start-group ./drivers/firmware/efi/libstub/lib.a --end-group .tmp_vmlinux0.kallsyms.o
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]
make[2]: *** [scripts/Makefile.vmlinux:34: vmlinux] Error 1
make[1]: *** [/home/dagomez/src/linux-next/Makefile:1156: vmlinux] Error 2
make: *** [Makefile:224: __sub-make] Error 2

Any suggestion how to fix this?

Daniel

>  .align	2
>  #if !defined(__KERNEL__) && !defined(_WIN64)
>  .comm	OPENSSL_armcap_P,4,4
> -- 
> 2.34.1
>
Daniel Gomez Aug. 6, 2024, 1:02 p.m. UTC | #2
On Tue, Aug 06, 2024 at 02:55:45PM GMT, Daniel Gomez wrote:
> On Tue, Aug 06, 2024 at 05:54:44AM GMT, Jia He wrote:
> 
> Hi Jia,
> 
> > 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(-)
> > 
> > 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
> > +
> 
> I'm getting the following error with next-20240806

To clarify my report: the error below disappears when this patch is reverted.

> 
> 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]
> 
> Full debug error with log context:
> 
> ...
> + grep -q ^CONFIG_DEBUG_INFO_BTF=y include/config/auto.conf
> + strip_debug=1
> + vmlinux_link .tmp_vmlinux1
> + local output=.tmp_vmlinux1
> + local objs
> + local libs
> + local ld
> + local ldflags
> + local ldlibs
> + info LD .tmp_vmlinux1
> + printf   %-7s %s\n LD .tmp_vmlinux1
>   LD      .tmp_vmlinux1
> + shift
> + is_enabled CONFIG_LTO_CLANG
> + grep -q ^CONFIG_LTO_CLANG=y include/config/auto.conf
> + is_enabled CONFIG_X86_KERNEL_IBT
> + grep -q ^CONFIG_X86_KERNEL_IBT=y include/config/auto.conf
> + objs=vmlinux.a
> + libs=./drivers/firmware/efi/libstub/lib.a
> + is_enabled CONFIG_MODULES
> + grep -q ^CONFIG_MODULES=y include/config/auto.conf
> + objs=vmlinux.a .vmlinux.export.o
> + objs=vmlinux.a .vmlinux.export.o init/version-timestamp.o
> + [ arm64 = um ]
> + wl=
> + ld=ld.lld
> + ldflags=-EL  -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext  --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error
> + ldlibs=
> + ldflags=-EL  -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext  --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error --script=./arch/arm64/kernel/vmlinux.lds
> + [ -n 1 ]
> + ldflags=-EL  -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext  --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error --script=./arch/arm64/kernel/vmlinux.lds --strip-debug
> + is_enabled CONFIG_VMLINUX_MAP
> + grep -q ^CONFIG_VMLINUX_MAP=y include/config/auto.conf
> + ldflags=-EL  -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext  --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error --script=./arch/arm64/kernel/vmlinux.lds --strip-debug -Map=.tmp_vmlinux1.map
> + ld.lld -EL -maarch64elf -z norelro -z noexecstack --no-undefined -X -shared -Bsymbolic -z notext --no-apply-dynamic-relocs --fix-cortex-a53-843419 --build-id=sha1 -X --pack-dyn-relocs=relr --orphan-handling=error --script=./arch/arm64/kernel/vmlinux.lds --strip-debug -Map=.tmp_vmlinux1.map -o .tmp_vmlinux1 --whole-archive vmlinux.a .vmlinux.export.o init/version-timestamp.o --no-whole-archive --start-group ./drivers/firmware/efi/libstub/lib.a --end-group .tmp_vmlinux0.kallsyms.o
> 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]
> make[2]: *** [scripts/Makefile.vmlinux:34: vmlinux] Error 1
> make[1]: *** [/home/dagomez/src/linux-next/Makefile:1156: vmlinux] Error 2
> make: *** [Makefile:224: __sub-make] Error 2
> 
> Any suggestion how to fix this?
> 
> Daniel
> 
> >  .align	2
> >  #if !defined(__KERNEL__) && !defined(_WIN64)
> >  .comm	OPENSSL_armcap_P,4,4
> > -- 
> > 2.34.1
> >
Andy Polyakov Aug. 6, 2024, 1:28 p.m. UTC | #3
> 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]

This looks like the original version of the path. At the very least the 
R_AARCH64_ADR_PREL_LO21 relocation is generated for the adr instruction. 
The v2 has adrp and add pair for which the relocations are 
R_AARCH64_ADR_PREL_PG_HI21 and R_AARCH64_ADD_ABS_LO12_NC.
Daniel Gomez Aug. 6, 2024, 2:47 p.m. UTC | #4
On Tue, Aug 06, 2024 at 03:28:25PM GMT, Andy Polyakov wrote:
> > 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]
> 
> This looks like the original version of the path. At the very least the
> R_AARCH64_ADR_PREL_LO21 relocation is generated for the adr instruction. The
> v2 has adrp and add pair for which the relocations are
> R_AARCH64_ADR_PREL_PG_HI21 and R_AARCH64_ADD_ABS_LO12_NC.
> 

I see, I thought v2 was already part of next-20240806 tag. Reverting v1 and
applying v2 works for me. Thanks for clarifying.

Tested-by: Daniel Gomez <da.gomez@samsung.com>

Daniel
Thorsten Leemhuis Aug. 8, 2024, 11:38 a.m. UTC | #5
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
Thorsten Leemhuis Aug. 12, 2024, 6:34 a.m. UTC | #6
On 08.08.24 13:38, Thorsten Leemhuis wrote:
> 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
>> [...]
>>
>> 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

Turned out my problem was caused by a different change:
https://lore.kernel.org/all/99ae0d34-ed76-4ca0-a9fd-c337da33c9f9@leemhuis.info/

Sorry for the noise.

Ciao, Thorsten
Herbert Xu Aug. 17, 2024, 7:07 a.m. UTC | #7
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