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
This commit is contained in:
Konstantin Belousov 2025-05-22 07:32:25 +03:00
parent 2e7cf772a4
commit aef025fc9b
2 changed files with 5 additions and 3 deletions

View file

@ -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

View file

@ -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