glibc/sysdeps/aarch64
H.J. Lu 848f0e46f0 i386: Update ___tls_get_addr to preserve vector registers
Compiler generates the following instruction sequence for dynamic TLS
access:

	leal	tls_var@tlsgd(,%ebx,1), %eax
	call	___tls_get_addr@PLT

CALL instruction is transparent to compiler which assumes all registers,
except for EFLAGS, AX, CX, and DX, are unchanged after CALL.  But
___tls_get_addr is a normal function which doesn't preserve any vector
registers.

1. Rename the generic __tls_get_addr function to ___tls_get_addr_internal.
2. Change ___tls_get_addr to a wrapper function with implementations for
FNSAVE, FXSAVE, XSAVE and XSAVEC to save and restore all vector registers.
3. dl-tlsdesc-dynamic.h has:

_dl_tlsdesc_dynamic:
	/* Like all TLS resolvers, preserve call-clobbered registers.
	   We need two scratch regs anyway.  */
	subl	$32, %esp
	cfi_adjust_cfa_offset (32)

It is wrong to use

	movl	%ebx, -28(%esp)
	movl	%esp, %ebx
	cfi_def_cfa_register(%ebx)
	...
	mov	%ebx, %esp
	cfi_def_cfa_register(%esp)
	movl	-28(%esp), %ebx

to preserve EBX on stack.  Fix it with:

	movl	%ebx, 28(%esp)
	movl	%esp, %ebx
	cfi_def_cfa_register(%ebx)
	...
	mov	%ebx, %esp
	cfi_def_cfa_register(%esp)
	movl	28(%esp), %ebx

4. Update _dl_tlsdesc_dynamic to call ___tls_get_addr_internal directly.
5. Add have-test-mtls-traditional to compile tst-tls23-mod.c with
traditional TLS variant to verify the fix.
6. Define DL_RUNTIME_RESOLVE_REALIGN_STACK in sysdeps/x86/sysdep.h.

This fixes BZ #32996.

Co-Authored-By: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-06-19 04:30:31 +08:00
..
bits AArch64: Remove LP64 and ILP32 ifdefs 2025-02-24 14:20:29 +00:00
fpu AArch64: Improve codegen SVE log1p helper 2025-06-18 17:28:51 +00:00
multiarch AArch64: Cleanup SVE config and defines 2025-05-20 10:33:55 +00:00
nptl AArch64: Remove LP64 and ILP32 ifdefs 2025-02-24 14:20:29 +00:00
sys aarch64: add __ifunc_hwcap function to be used in ifunc resolvers 2025-06-05 14:38:51 +01:00
Implies
Makefile aarch64: fix typo in sysdeps/aarch64/Makefile 2025-06-10 10:48:07 +01:00
Versions
__alloc_gcs.c aarch64: GCS: use internal struct in __alloc_gcs 2025-06-18 09:37:13 +01:00
__arm_za_disable.S AArch64: Cleanup PAC and BTI 2025-05-19 15:35:32 +00:00
__longjmp.S aarch64: simplify calls to __libc_arm_za_disable in assembly 2025-06-18 09:42:33 +01:00
__mtag_tag_region.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
__mtag_tag_zero_region.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
aarch64-gcs.h aarch64: GCS: use internal struct in __alloc_gcs 2025-06-18 09:37:13 +01:00
abort-instr.h
atomic-machine.h
bsd-_setjmp.c
bsd-setjmp.c
configure AArch64: Cleanup SVE config and defines 2025-05-20 10:33:55 +00:00
configure.ac AArch64: Cleanup SVE config and defines 2025-05-20 10:33:55 +00:00
cpu-features.h
crti.S AArch64: Cleanup PAC and BTI 2025-05-19 15:35:32 +00:00
crtn.S AArch64: Cleanup PAC and BTI 2025-05-19 15:35:32 +00:00
dl-audit-check.h
dl-bti.c
dl-diagnostics-cpu.c
dl-dtprocnum.h
dl-gcs.c
dl-irel.h aarch64: add support for hwcap3,4 2025-06-05 14:38:03 +01:00
dl-link.sym
dl-lookupcfg.h
dl-machine.h AArch64: Remove AARCH64_R macro 2025-02-24 14:19:19 +00:00
dl-prop.h
dl-start.S AArch64: Remove PTR_REG defines 2025-02-24 14:16:55 +00:00
dl-tlsdesc.S AArch64: Cleanup PAC and BTI 2025-05-19 15:35:32 +00:00
dl-tlsdesc.h
dl-trampoline.S AArch64: Cleanup PAC and BTI 2025-05-19 15:35:32 +00:00
dl-tunables.list
e_sqrtl.c
elf-initfini.h
hp-timing.h
jmpbuf-offsets.h
jmpbuf-unwind.h
ldsodefs.h
libc-mtag.h
libc-start.c
libc-tls.c
linkmap.h
machine-gmon.h AArch64: Cleanup PAC and BTI 2025-05-19 15:35:32 +00:00
math-tests-trap.h
math-use-builtins-ffs.h
mcount.c
memchr.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
memcmp.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
memcpy.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
memmove.c
memrchr.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
memset.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
preconfigure i386: Update ___tls_get_addr to preserve vector registers 2025-06-19 04:30:31 +08:00
rawmemchr.S
rtld-global-offsets.sym
setjmp.S aarch64: simplify calls to __libc_arm_za_disable in assembly 2025-06-18 09:42:33 +01:00
sfp-machine.h
sotruss-lib.c
start.S AArch64: Cleanup PAC and BTI 2025-05-19 15:35:32 +00:00
stpcpy.S
strchr.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
strchrnul.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
strcmp.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
strcpy.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
strlen.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
strncmp.S
strnlen.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
strrchr.S AArch64: Remove PTR_ARG/SIZE_ARG defines 2025-02-24 14:15:15 +00:00
sysdep.h AArch64: Cleanup PAC and BTI 2025-05-19 15:35:32 +00:00
tlsdesc.c
tlsdesc.sym
tst-audit.h
tst-audit26.c
tst-audit26mod.c
tst-audit26mod.h
tst-audit27.c
tst-audit27mod.c
tst-audit27mod.h
tst-auditmod26.c
tst-auditmod27.c
tst-ifunc-arg-1.c aarch64: add __ifunc_hwcap function to be used in ifunc resolvers 2025-06-05 14:38:51 +01:00
tst-ifunc-arg-2.c aarch64: add __ifunc_hwcap function to be used in ifunc resolvers 2025-06-05 14:38:51 +01:00
tst-ifunc-arg-3.c aarch64: add __ifunc_hwcap function to be used in ifunc resolvers 2025-06-05 14:38:51 +01:00
tst-ifunc-arg-4.c aarch64: add __ifunc_hwcap function to be used in ifunc resolvers 2025-06-05 14:38:51 +01:00
tst-sme-helper.h aarch64: update tests for SME 2025-05-15 14:23:35 +01:00
tst-sme-jmp.c aarch64: update tests for SME 2025-05-15 14:23:35 +01:00
tst-sme-za-state.c aarch64: update tests for SME 2025-05-15 14:23:35 +01:00
tst-vpcs-mod.S
tst-vpcs.c
wordcopy.c