Kernel/LibC: Replace SYS_{GET,SET}_TLS with SYS_{SET,GET}_{FS,GS}BASE
This allows userspace to use both registers
This commit is contained in:
@@ -101,8 +101,10 @@ __BEGIN_DECLS
|
||||
O(SYS_HARDLINKAT, hardlinkat) \
|
||||
O(SYS_UTIMENSAT, utimensat) \
|
||||
O(SYS_YIELD, yield) \
|
||||
O(SYS_SET_TLS, set_tls) \
|
||||
O(SYS_GET_TLS, get_tls) \
|
||||
O(SYS_SET_FSBASE, set_fsbase) \
|
||||
O(SYS_GET_FSBASE, get_fsbase) \
|
||||
O(SYS_SET_GSBASE, set_gsbase) \
|
||||
O(SYS_GET_GSBASE, get_gsbase) \
|
||||
O(SYS_PTHREAD_CREATE, pthread_create) \
|
||||
O(SYS_PTHREAD_EXIT, pthread_exit) \
|
||||
O(SYS_PTHREAD_JOIN, pthread_join) \
|
||||
|
||||
@@ -49,7 +49,13 @@ extern "C" void _pthread_trampoline_cpp(void* arg)
|
||||
{
|
||||
auto info = *reinterpret_cast<pthread_trampoline_info_t*>(arg);
|
||||
info.uthread->id = syscall(SYS_PTHREAD_SELF);
|
||||
syscall(SYS_SET_TLS, info.uthread);
|
||||
#if defined(__x86_64__)
|
||||
syscall(SYS_SET_FSBASE, info.uthread);
|
||||
#elif defined(__i686__)
|
||||
syscall(SYS_SET_GSBASE, info.uthread);
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
free(arg);
|
||||
pthread_exit(info.start_routine(info.arg));
|
||||
ASSERT_NOT_REACHED();
|
||||
|
||||
@@ -34,7 +34,13 @@ extern "C" void _init_libc(char** environ, init_funcs_t init_funcs, init_funcs_t
|
||||
if (::environ == nullptr)
|
||||
::environ = environ;
|
||||
|
||||
if (uthread* self = reinterpret_cast<uthread*>(syscall(SYS_GET_TLS)))
|
||||
#if defined(__x86_64__)
|
||||
if (uthread* self = reinterpret_cast<uthread*>(syscall(SYS_GET_FSBASE)))
|
||||
#elif defined(__i686__)
|
||||
if (uthread* self = reinterpret_cast<uthread*>(syscall(SYS_GET_GSBASE)))
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
{
|
||||
self->cleanup_stack = nullptr;
|
||||
self->id = syscall(SYS_PTHREAD_SELF);
|
||||
@@ -61,7 +67,13 @@ extern "C" void _init_libc(char** environ, init_funcs_t init_funcs, init_funcs_t
|
||||
};
|
||||
uthread.dtv[0] = 0;
|
||||
|
||||
syscall(SYS_SET_TLS, &uthread);
|
||||
#if defined(__x86_64__)
|
||||
syscall(SYS_SET_FSBASE, &uthread);
|
||||
#elif defined(__i686__)
|
||||
syscall(SYS_SET_GSBASE, &uthread);
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
||||
|
||||
// call global constructors
|
||||
|
||||
@@ -1366,7 +1366,13 @@ static void initialize_tls(MasterTLS master_tls)
|
||||
uthread.dtv[elf.tls_module] = reinterpret_cast<uintptr_t>(tls_addr) + uthread.master_tls_size - elf.tls_offset;
|
||||
}
|
||||
|
||||
syscall(SYS_SET_TLS, &uthread);
|
||||
#if defined(__x86_64__)
|
||||
syscall(SYS_SET_FSBASE, &uthread);
|
||||
#elif defined(__i686__)
|
||||
syscall(SYS_SET_GSBASE, &uthread);
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
}
|
||||
|
||||
static void initialize_environ(char** envp)
|
||||
|
||||
Reference in New Issue
Block a user