git: aef025fc9b6c - main - amd64: switch to amd64_set_tlsbase to set tls base
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 28 May 2025 11:11:45 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=aef025fc9b6c8b06677086a93c866ee09622f6fa
commit aef025fc9b6c8b06677086a93c866ee09622f6fa
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-05-22 04:32:25 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-05-28 11:11:23 +0000
amd64: switch to amd64_set_tlsbase to set tls base
Reported and tested: Alex S <iwtcex@gmail.com>
Tested by: pho
Reviewed by: olce
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D50482
---
libexec/rtld-elf/amd64/reloc.c | 6 ++++--
sys/x86/include/tls.h | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c
index 373a1cdd2d06..95f402995836 100644
--- a/libexec/rtld-elf/amd64/reloc.c
+++ b/libexec/rtld-elf/amd64/reloc.c
@@ -543,10 +543,12 @@ allocate_initial_tls(Obj_Entry *objs)
addr = allocate_tls(objs, 0, TLS_TCB_SIZE, TLS_TCB_ALIGN);
/*
- * This does not use _tcb_set() as it calls amd64_set_fsbase()
+ * This does not use _tcb_set() as it calls amd64_set_tlsbase()
* which is an ifunc and rtld must not use ifuncs.
*/
- if (__getosreldate() >= P_OSREL_WRFSBASE &&
+ if (__getosreldate() >= P_OSREL_TLSBASE)
+ sysarch(AMD64_SET_TLSBASE, &addr);
+ else if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
wrfsbase((uintptr_t)addr);
else
diff --git a/sys/x86/include/tls.h b/sys/x86/include/tls.h
index 29d036fd4871..1ed47bf01938 100644
--- a/sys/x86/include/tls.h
+++ b/sys/x86/include/tls.h
@@ -69,7 +69,7 @@ static __inline void
_tcb_set(struct tcb *tcb)
{
#ifdef __amd64__
- amd64_set_fsbase(tcb);
+ amd64_set_tlsbase(tcb);
#else
i386_set_gsbase(tcb);
#endif