Module: wine Branch: master Commit: cec3db10f4e5af4aec8782423b1d4d05bb71b7e4 URL: https://source.winehq.org/git/wine.git/?a=commit;h=cec3db10f4e5af4aec8782423...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Jul 6 12:31:53 2021 +0200
ntdll: Store the pthread TEB value on thread init.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/unix/signal_x86_64.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index 56dc640e082..6175bb9b230 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -311,11 +311,13 @@ struct amd64_thread_data DWORD_PTR dr7; /* 0318 */ void *exit_frame; /* 0320 exit frame pointer */ struct syscall_frame *syscall_frame; /* 0328 syscall frame pointer */ + void *pthread_teb; /* 0330 thread data for pthread */ };
C_ASSERT( sizeof(struct amd64_thread_data) <= sizeof(((struct ntdll_thread_data *)0)->cpu_data) ); C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct amd64_thread_data, exit_frame ) == 0x320 ); C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct amd64_thread_data, syscall_frame ) == 0x328 ); +C_ASSERT( offsetof( TEB, GdiTebBatch ) + offsetof( struct amd64_thread_data, pthread_teb ) == 0x330 );
static inline struct amd64_thread_data *amd64_thread_data(void) { @@ -2740,6 +2742,7 @@ void signal_init_thread( TEB *teb )
#if defined __linux__ arch_prctl( ARCH_SET_GS, teb ); + arch_prctl( ARCH_GET_FS, &amd64_thread_data()->pthread_teb ); #elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__) amd64_set_gsbase( teb ); #elif defined(__NetBSD__) @@ -2751,11 +2754,12 @@ void signal_init_thread( TEB *teb ) __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] = mac_thread_gsbase(); + teb->Reserved5[0] = amd64_thread_data()->pthread_teb; #else # error Please define setting %gs for your architecture #endif