Commit d3a68e43 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move the initialization of the thread register into signal_start_thread().

parent 6ecc8039
......@@ -2166,7 +2166,6 @@ static void start_main_thread(void)
signal_init_threading();
signal_alloc_thread( teb );
signal_init_thread( teb );
dbg_init();
startup_info_size = server_init_process();
virtual_map_user_shared_data();
......
......@@ -1546,15 +1546,6 @@ void signal_free_thread( TEB *teb )
/**********************************************************************
* signal_init_thread
*/
void signal_init_thread( TEB *teb )
{
__asm__ __volatile__( "mcr p15, 0, %0, c13, c0, 2" : : "r" (teb) );
}
/**********************************************************************
* signal_init_process
*/
void signal_init_process(void)
......
......@@ -1339,16 +1339,6 @@ void signal_free_thread( TEB *teb )
/**********************************************************************
* signal_init_thread
*/
void signal_init_thread( TEB *teb )
{
/* Win64/ARM applications expect the TEB pointer to be in the x18 platform register. */
__asm__ __volatile__( "mov x18, %0" : : "r" (teb) );
}
/**********************************************************************
* signal_init_process
*/
void signal_init_process(void)
......
......@@ -2368,21 +2368,6 @@ void signal_free_thread( TEB *teb )
/**********************************************************************
* signal_init_thread
*/
void signal_init_thread( TEB *teb )
{
const WORD fpu_cw = 0x27f;
struct x86_thread_data *thread_data = (struct x86_thread_data *)&teb->GdiTebBatch;
ldt_set_fs( thread_data->fs, teb );
thread_data->gs = get_gs();
__asm__ volatile ("fninit; fldcw %0" : : "m" (fpu_cw));
}
/**********************************************************************
* signal_init_process
*/
void signal_init_process(void)
......@@ -2436,11 +2421,14 @@ void DECLSPEC_HIDDEN call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, B
CONTEXT *ctx, context = { CONTEXT_ALL };
DWORD *stack;
ldt_set_fs( thread_data->fs, teb );
thread_data->gs = get_gs();
context.SegCs = get_cs();
context.SegDs = get_ds();
context.SegEs = get_ds();
context.SegFs = get_fs();
context.SegGs = get_gs();
context.SegFs = thread_data->fs;
context.SegGs = thread_data->gs;
context.SegSs = get_ds();
context.EFlags = 0x202;
context.Eax = (DWORD)entry;
......
......@@ -2373,46 +2373,6 @@ static void *mac_thread_gsbase(void)
/**********************************************************************
* signal_init_thread
*/
void signal_init_thread( TEB *teb )
{
const WORD fpu_cw = 0x27f;
#if defined __linux__
arch_prctl( ARCH_SET_GS, teb );
arch_prctl( ARCH_GET_FS, &amd64_thread_data()->pthread_teb );
if (fs32_sel) alloc_fs_sel( fs32_sel >> 3, (char *)teb + teb->WowTebOffset );
#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
amd64_set_gsbase( teb );
#elif defined(__NetBSD__)
sysarch( X86_64_SET_GSBASE, &teb );
#elif defined (__APPLE__)
__asm__ volatile (".byte 0x65\n\tmovq %0,%c1"
:
: "r" (teb->Tib.Self), "n" (FIELD_OFFSET(TEB, Tib.Self)));
__asm__ volatile (".byte 0x65\n\tmovq %0,%c1"
:
: "r" (teb->ThreadLocalStoragePointer), "n" (FIELD_OFFSET(TEB, ThreadLocalStoragePointer)));
amd64_thread_data()->pthread_teb = mac_thread_gsbase();
/* alloc_tls_slot() needs to poke a value to an address relative to each
thread's gsbase. Have each thread record its gsbase pointer into its
TEB so alloc_tls_slot() can find it. */
teb->Reserved5[0] = amd64_thread_data()->pthread_teb;
#else
# error Please define setting %gs for your architecture
#endif
#ifdef __GNUC__
__asm__ volatile ("fninit; fldcw %0" : : "m" (fpu_cw));
#else
FIXME_(seh)("FPU setup not implemented for this platform.\n");
#endif
}
/**********************************************************************
* signal_init_process
*/
void signal_init_process(void)
......@@ -2510,6 +2470,26 @@ void DECLSPEC_HIDDEN call_init_thunk( LPTHREAD_START_ROUTINE entry, void *arg, B
CONTEXT *ctx, context = { 0 };
I386_CONTEXT *wow_context;
#if defined __linux__
arch_prctl( ARCH_SET_GS, teb );
arch_prctl( ARCH_GET_FS, &amd64_thread_data()->pthread_teb );
if (fs32_sel) alloc_fs_sel( fs32_sel >> 3, (char *)teb + teb->WowTebOffset );
#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
amd64_set_gsbase( teb );
#elif defined(__NetBSD__)
sysarch( X86_64_SET_GSBASE, &teb );
#elif defined (__APPLE__)
__asm__ volatile (".byte 0x65\n\tmovq %0,%c1" :: "r" (teb->Tib.Self), "n" (FIELD_OFFSET(TEB, Tib.Self)));
__asm__ volatile (".byte 0x65\n\tmovq %0,%c1" :: "r" (teb->ThreadLocalStoragePointer), "n" (FIELD_OFFSET(TEB, ThreadLocalStoragePointer)));
amd64_thread_data()->pthread_teb = mac_thread_gsbase();
/* alloc_tls_slot() needs to poke a value to an address relative to each
thread's gsbase. Have each thread record its gsbase pointer into its
TEB so alloc_tls_slot() can find it. */
teb->Reserved5[0] = amd64_thread_data()->pthread_teb;
#else
# error Please define setting %gs for your architecture
#endif
context.ContextFlags = CONTEXT_ALL;
context.Rcx = (ULONG_PTR)entry;
context.Rdx = (ULONG_PTR)arg;
......
......@@ -1069,7 +1069,6 @@ static void start_thread( TEB *teb )
thread_data->pthread_id = pthread_self();
pthread_setspecific( teb_key, teb );
signal_init_thread( teb );
server_init_thread( thread_data->start, &suspend );
signal_start_thread( thread_data->start, thread_data->param, suspend, teb );
}
......
......@@ -234,7 +234,6 @@ extern BOOL get_thread_times( int unix_pid, int unix_tid, LARGE_INTEGER *kernel_
extern void signal_init_threading(void) DECLSPEC_HIDDEN;
extern NTSTATUS signal_alloc_thread( TEB *teb ) DECLSPEC_HIDDEN;
extern void signal_free_thread( TEB *teb ) DECLSPEC_HIDDEN;
extern void signal_init_thread( TEB *teb ) DECLSPEC_HIDDEN;
extern void signal_init_process(void) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE entry, void *arg,
BOOL suspend, TEB *teb ) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment