From e3cca687befffb4baee144dcd55f01a3204176eb Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sat, 12 Jun 2021 01:46:26 -0500 Subject: [PATCH] Rebase against f5bd0be6a44c1c7d69afb8b8eb6311923e7762a1. --- ...dll-server-Implement-alertable-waits.patch | 28 ++--- ...-sinh-cosh-exp-pow-with-higher-preci.patch | 114 ------------------ patches/msvcrt-Math_Precision/definition | 3 - ...ow-to-allocate-thread-stack-for-curr.patch | 56 --------- patches/ntdll-Dealloc_Thread_Stack/definition | 1 - ...dll-Support-x86_64-syscall-emulation.patch | 32 ++--- ...rate-stack-when-starting-new-threads.patch | 81 ------------- ...valid-exit_frame-when-exiting-thread.patch | 81 ------------- patches/ntdll-Thread_Stack/definition | 3 - patches/patchinstall.sh | 15 +-- staging/upstream-commit | 2 +- 11 files changed, 32 insertions(+), 384 deletions(-) delete mode 100644 patches/msvcrt-Math_Precision/0001-msvcrt-Calculate-sinh-cosh-exp-pow-with-higher-preci.patch delete mode 100644 patches/msvcrt-Math_Precision/definition delete mode 100644 patches/ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch delete mode 100644 patches/ntdll-Dealloc_Thread_Stack/definition delete mode 100644 patches/ntdll-Thread_Stack/0001-ntdll-Use-a-separate-stack-when-starting-new-threads.patch delete mode 100644 patches/ntdll-Thread_Stack/0002-ntdll-Ignore-invalid-exit_frame-when-exiting-thread.patch delete mode 100644 patches/ntdll-Thread_Stack/definition diff --git a/patches/eventfd_synchronization/0035-ntdll-server-Implement-alertable-waits.patch b/patches/eventfd_synchronization/0035-ntdll-server-Implement-alertable-waits.patch index 1a621ab0..20c0bbea 100644 --- a/patches/eventfd_synchronization/0035-ntdll-server-Implement-alertable-waits.patch +++ b/patches/eventfd_synchronization/0035-ntdll-server-Implement-alertable-waits.patch @@ -1,4 +1,4 @@ -From 39109644ddeb39a7a42c2f10657b35c515dfee46 Mon Sep 17 00:00:00 2001 +From 52c6ab47d908e75409bb3b7f2faac66da16ea23a Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 6 Jul 2020 17:17:31 -0500 Subject: [PATCH] ntdll, server: Implement alertable waits. @@ -164,22 +164,22 @@ index d1a282c65e9..2a7c3865617 100644 /* We need to let the server know when we are doing a message wait, and when we diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h -index a5bade02b8a..76eef4220c5 100644 +index f6934ae9e91..c3ad33e282b 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h -@@ -53,6 +53,7 @@ struct ntdll_thread_data +@@ -61,6 +61,7 @@ struct ntdll_thread_data void *cpu_data[16]; /* reserved for CPU-specific data */ struct debug_info *debug_info; /* info for debugstr functions */ - void *start_stack; /* stack for thread startup */ + void *kernel_stack; /* stack for thread startup and kernel syscalls */ + int esync_apc_fd; /* fd to wait on for user APCs */ int request_fd; /* fd for sending server requests */ int reply_fd; /* fd for receiving server replies */ int wait_fd[2]; /* fd for sleeping server requests */ diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index f3e6b612b93..04c31a473af 100644 +index 422be6d8a73..1ff97ed5129 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -2876,6 +2876,7 @@ static TEB *init_teb( void *ptr, PEB *peb ) +@@ -2888,6 +2888,7 @@ static TEB *init_teb( void *ptr, PEB *peb, BOOL is_wow ) teb->StaticUnicodeString.Buffer = teb->StaticUnicodeBuffer; teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer); thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch; @@ -244,10 +244,10 @@ index aeb58c5469c..cea025d9308 100644 void esync_clear( int fd ); diff --git a/server/protocol.def b/server/protocol.def -index 00c89cce793..bb45c509685 100644 +index 14558f2d842..fad731bdc74 100644 --- a/server/protocol.def +++ b/server/protocol.def -@@ -3738,3 +3738,7 @@ enum esync_type +@@ -3794,3 +3794,7 @@ enum esync_type @REQ(esync_msgwait) int in_msgwait; /* are we in a message wait? */ @END @@ -256,10 +256,10 @@ index 00c89cce793..bb45c509685 100644 +@REQ(get_esync_apc_fd) +@END diff --git a/server/thread.c b/server/thread.c -index 409a28129b3..e4781e57c8c 100644 +index 10da1e3d4c7..258c3f28815 100644 --- a/server/thread.c +++ b/server/thread.c -@@ -227,6 +227,7 @@ static inline void init_thread_structure( struct thread *thread ) +@@ -228,6 +228,7 @@ static inline void init_thread_structure( struct thread *thread ) thread->teb = 0; thread->entry_point = 0; thread->esync_fd = -1; @@ -267,7 +267,7 @@ index 409a28129b3..e4781e57c8c 100644 thread->system_regs = 0; thread->queue = NULL; thread->wait = NULL; -@@ -374,7 +375,10 @@ struct thread *create_thread( int fd, struct process *process, const struct secu +@@ -375,7 +376,10 @@ struct thread *create_thread( int fd, struct process *process, const struct secu } if (do_esync()) @@ -278,7 +278,7 @@ index 409a28129b3..e4781e57c8c 100644 set_fd_events( thread->request_fd, POLLIN ); /* start listening to events */ add_process_thread( thread->process, thread ); -@@ -1156,8 +1160,13 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr +@@ -1164,8 +1168,13 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr grab_object( apc ); list_add_tail( queue, &apc->entry ); if (!list_prev( queue, &apc->entry )) /* first one */ @@ -292,7 +292,7 @@ index 409a28129b3..e4781e57c8c 100644 return 1; } -@@ -1203,6 +1212,10 @@ static struct thread_apc *thread_dequeue_apc( struct thread *thread, int system +@@ -1211,6 +1220,10 @@ static struct thread_apc *thread_dequeue_apc( struct thread *thread, int system apc = LIST_ENTRY( ptr, struct thread_apc, entry ); list_remove( ptr ); } @@ -304,7 +304,7 @@ index 409a28129b3..e4781e57c8c 100644 } diff --git a/server/thread.h b/server/thread.h -index 1eb501cbd52..13e4628d89a 100644 +index 8a5a8501d9c..e5145f9eb07 100644 --- a/server/thread.h +++ b/server/thread.h @@ -55,6 +55,7 @@ struct thread diff --git a/patches/msvcrt-Math_Precision/0001-msvcrt-Calculate-sinh-cosh-exp-pow-with-higher-preci.patch b/patches/msvcrt-Math_Precision/0001-msvcrt-Calculate-sinh-cosh-exp-pow-with-higher-preci.patch deleted file mode 100644 index f9429a0f..00000000 --- a/patches/msvcrt-Math_Precision/0001-msvcrt-Calculate-sinh-cosh-exp-pow-with-higher-preci.patch +++ /dev/null @@ -1,114 +0,0 @@ -From 99640ba7474a35f086d85bdb0b416e1e00d31c2f Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Fri, 10 Apr 2015 07:51:16 +0200 -Subject: [PATCH] msvcrt: Calculate sinh/cosh/exp/pow with higher precision. - (v2) - -Based on a patch by Zheng Chen. ---- - dlls/msvcrt/unixlib.c | 63 ++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 59 insertions(+), 4 deletions(-) - -diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c -index 6d3a3bd5a79..e0581f713cd 100644 ---- a/dlls/msvcrt/unixlib.c -+++ b/dlls/msvcrt/unixlib.c -@@ -42,12 +42,67 @@ - - WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); - -+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -+ -+static inline double precise_cosh( double x ) -+{ -+ WORD precise_cw = 0x37f, pre_cw; -+ double z; -+ __asm__ __volatile__( "fnstcw %0" : "=m" (pre_cw) ); -+ __asm__ __volatile__( "fldcw %0" : : "m" (precise_cw) ); -+ z = cosh( x ); -+ __asm__ __volatile__( "fldcw %0" : : "m" (pre_cw) ); -+ return z; -+} -+ -+static inline double precise_exp( double x ) -+{ -+ WORD precise_cw = 0x37f, pre_cw; -+ double z; -+ __asm__ __volatile__( "fnstcw %0" : "=m" (pre_cw) ); -+ __asm__ __volatile__( "fldcw %0" : : "m" (precise_cw) ); -+ z = exp( x ); -+ __asm__ __volatile__( "fldcw %0" : : "m" (pre_cw) ); -+ return z; -+} -+ -+static inline double precise_pow( double x, double y ) -+{ -+ WORD precise_cw = 0x37f, pre_cw; -+ double z; -+ __asm__ __volatile__( "fnstcw %0" : "=m" (pre_cw) ); -+ __asm__ __volatile__( "fldcw %0" : : "m" (precise_cw) ); -+ z = pow( x, y ); -+ __asm__ __volatile__( "fldcw %0" : : "m" (pre_cw) ); -+ return z; -+} -+ -+static inline double precise_sinh( double x ) -+{ -+ WORD precise_cw = 0x37f, pre_cw; -+ double z; -+ __asm__ __volatile__( "fnstcw %0" : "=m" (pre_cw) ); -+ __asm__ __volatile__( "fldcw %0" : : "m" (precise_cw) ); -+ z = sinh( x ); -+ __asm__ __volatile__( "fldcw %0" : : "m" (pre_cw) ); -+ return z; -+} -+ -+#else -+ -+#define precise_cosh cosh -+#define precise_exp exp -+#define precise_pow pow -+#define precise_sinh sinh -+ -+#endif -+ - /********************************************************************* - * cosh - */ - static double CDECL unix_cosh( double x ) - { -- return cosh( x ); -+ return precise_cosh( x ); - } - - /********************************************************************* -@@ -63,7 +118,7 @@ static float CDECL unix_coshf( float x ) - */ - static double CDECL unix_exp( double x ) - { -- return exp( x ); -+ return precise_exp( x ); - } - - /********************************************************************* -@@ -297,7 +352,7 @@ static float CDECL unix_log2f(float x) - */ - static double CDECL unix_pow( double x, double y ) - { -- return pow( x, y ); -+ return precise_pow( x, y ); - } - - /********************************************************************* -@@ -313,7 +368,7 @@ static float CDECL unix_powf( float x, float y ) - */ - static double CDECL unix_sinh( double x ) - { -- return sinh( x ); -+ return precise_sinh( x ); - } - - /********************************************************************* --- -2.30.2 - diff --git a/patches/msvcrt-Math_Precision/definition b/patches/msvcrt-Math_Precision/definition deleted file mode 100644 index c2f2f0c4..00000000 --- a/patches/msvcrt-Math_Precision/definition +++ /dev/null @@ -1,3 +0,0 @@ -Fixes: [37149] Calculate msvcrt exponential math operations with higher precision -# Needs retesting when exp() and pow() are moved as well. -Disabled: true diff --git a/patches/ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch b/patches/ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch deleted file mode 100644 index d5d9705c..00000000 --- a/patches/ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 1d56beba1aeb7acb135db5333c2f61f40988b23f Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Fri, 21 Aug 2015 06:39:47 +0800 -Subject: [PATCH] ntdll: Do not allow to deallocate thread stack for current - thread. - ---- - dlls/ntdll/unix/unix_private.h | 1 + - dlls/ntdll/unix/virtual.c | 12 ++++++++++++ - 2 files changed, 13 insertions(+) - -diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h -index 0714d9ff898..5ea9664edcf 100644 ---- a/dlls/ntdll/unix/unix_private.h -+++ b/dlls/ntdll/unix/unix_private.h -@@ -58,6 +58,7 @@ struct ntdll_thread_data - int reply_fd; /* fd for receiving server replies */ - int wait_fd[2]; /* fd for sleeping server requests */ - pthread_t pthread_id; /* pthread thread id */ -+ void *pthread_stack; /* pthread stack */ - struct list entry; /* entry in TEB list */ - PRTL_THREAD_START_ROUTINE start; /* thread entry point */ - void *param; /* thread entry point parameter */ -diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 9b1ca761e9b..cb5db2891c6 100644 ---- a/dlls/ntdll/unix/virtual.c -+++ b/dlls/ntdll/unix/virtual.c -@@ -2804,6 +2804,8 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SI - stack->DeallocationStack = view->base; - stack->StackBase = (char *)view->base + view->size; - stack->StackLimit = (char *)view->base + 2 * page_size; -+ ((struct ntdll_thread_data *)&NtCurrentTeb()->GdiTebBatch)->pthread_stack = view->base; -+ - done: - server_leave_uninterrupted_section( &virtual_mutex, &sigset ); - return status; -@@ -3594,6 +3596,16 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si - /* Free the pages */ - - if (size || (base != view->base)) status = STATUS_INVALID_PARAMETER; -+ else if (view->base == (void *)((ULONG_PTR)ntdll_get_thread_data()->pthread_stack & ~1)) -+ { -+ ULONG_PTR stack = (ULONG_PTR)ntdll_get_thread_data()->pthread_stack; -+ if (stack & 1) status = STATUS_INVALID_PARAMETER; -+ else -+ { -+ WARN( "Application tried to deallocate current pthread stack %p, deferring\n", view->base); -+ ntdll_get_thread_data()->pthread_stack = (void *)(stack | 1); -+ } -+ } - else - { - delete_view( view ); --- -2.27.0 - diff --git a/patches/ntdll-Dealloc_Thread_Stack/definition b/patches/ntdll-Dealloc_Thread_Stack/definition deleted file mode 100644 index b0f50a6f..00000000 --- a/patches/ntdll-Dealloc_Thread_Stack/definition +++ /dev/null @@ -1 +0,0 @@ -Fixes: Do not allow to deallocate thread stack for current thread diff --git a/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch b/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch index 3ca2f352..6d06577a 100644 --- a/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch +++ b/patches/ntdll-Syscall_Emulation/0001-ntdll-Support-x86_64-syscall-emulation.patch @@ -1,4 +1,4 @@ -From 8d1cfce5ceee03b91f9843e7b5123fed823687e7 Mon Sep 17 00:00:00 2001 +From 7744cca9f58990ee47b74f4fa967eb99f3dee862 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 14 Jul 2020 15:00:34 +0300 Subject: [PATCH] ntdll: Support x86_64 syscall emulation. @@ -10,10 +10,10 @@ Subject: [PATCH] ntdll: Support x86_64 syscall emulation. 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index caff5d1fe52..d30b437320a 100644 +index 8c74532dabc..36d2295c1ca 100644 --- a/configure.ac +++ b/configure.ac -@@ -467,6 +467,7 @@ AC_CHECK_HEADERS(\ +@@ -477,6 +477,7 @@ AC_CHECK_HEADERS(\ linux/joystick.h \ linux/major.h \ linux/param.h \ @@ -22,7 +22,7 @@ index caff5d1fe52..d30b437320a 100644 linux/types.h \ linux/ucdrom.h \ diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c -index 8d3353e959d..a8a142c2ab1 100644 +index 4845d3dd5f4..9a80cafeadd 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -28,6 +28,7 @@ @@ -47,7 +47,7 @@ index 8d3353e959d..a8a142c2ab1 100644 #define NONAMELESSUNION #define NONAMELESSSTRUCT #include "ntstatus.h" -@@ -2292,6 +2300,114 @@ static inline DWORD is_privileged_instr( CONTEXT *context ) +@@ -2075,6 +2083,114 @@ static inline DWORD is_privileged_instr( CONTEXT *context ) return 0; } @@ -162,7 +162,7 @@ index 8d3353e959d..a8a142c2ab1 100644 /*********************************************************************** * handle_interrupt -@@ -2751,6 +2867,7 @@ void signal_init_process(void) +@@ -2560,6 +2676,7 @@ void signal_init_process(void) if (sigaction( SIGSEGV, &sig_act, NULL ) == -1) goto error; if (sigaction( SIGILL, &sig_act, NULL ) == -1) goto error; if (sigaction( SIGBUS, &sig_act, NULL ) == -1) goto error; @@ -171,18 +171,18 @@ index 8d3353e959d..a8a142c2ab1 100644 error: diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c -index 0fddbaf6134..901423cc028 100644 +index f92c1b89c9c..13e1a3bb929 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c -@@ -1510,6 +1510,7 @@ static void output_syscall_dispatcher( int count, const char *variant ) - /* Legends of Runeterra hooks the first system call return instruction, and - * depends on us returning to it. Adjust the return address accordingly. */ - output( "\tsubq $0xb,0x8(%%rbp)\n" ); +@@ -1551,6 +1551,7 @@ static void output_syscall_dispatcher(void) + output( "\tjmp 5b\n" ); + break; + case CPU_x86_64: + output( "\tsubq $0xf000,%%rax\n" ); - output( "\tmovq 0x8(%%rbp),%%rbx\n" ); - output( "\tmovq %%rbx,-0x28(%%rbp)\n" ); - output( "\tleaq 0x10(%%rbp),%%rbx\n" ); -@@ -1779,7 +1780,7 @@ void output_syscalls( DLLSPEC *spec ) + output( "\tmovq %%gs:0x30,%%rcx\n" ); + output( "\tmovq 0x328(%%rcx),%%rcx\n" ); /* amd64_thread_data()->syscall_frame */ + output( "\tmovq %%rax,0x00(%%rcx)\n" ); +@@ -1940,7 +1941,7 @@ void output_syscalls( DLLSPEC *spec ) * validate that instruction, we can just put a jmp there instead. */ output( "\t.byte 0x4c,0x8b,0xd1\n" ); /* movq %rcx,%r10 */ output( "\t.byte 0xb8\n" ); /* movl $i,%eax */ @@ -192,5 +192,5 @@ index 0fddbaf6134..901423cc028 100644 output( "\t.byte 0x75,0x03\n" ); /* jne 1f */ output( "\t.byte 0x0f,0x05\n" ); /* syscall */ -- -2.20.1 +2.30.2 diff --git a/patches/ntdll-Thread_Stack/0001-ntdll-Use-a-separate-stack-when-starting-new-threads.patch b/patches/ntdll-Thread_Stack/0001-ntdll-Use-a-separate-stack-when-starting-new-threads.patch deleted file mode 100644 index db51e312..00000000 --- a/patches/ntdll-Thread_Stack/0001-ntdll-Use-a-separate-stack-when-starting-new-threads.patch +++ /dev/null @@ -1,81 +0,0 @@ -From ef57b2c7cadda78730cb57e117507c7a8a0ff6cb Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Wed, 13 Apr 2016 03:11:03 +0200 -Subject: ntdll: Use a separate stack when starting new threads. - ---- - dlls/ntdll/thread.c | 33 +++++++++++++++++++++++---------- - 1 file changed, 23 insertions(+), 10 deletions(-) - -diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c -index 07dc285..db27447 100644 ---- a/dlls/ntdll/thread.c -+++ b/dlls/ntdll/thread.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - #ifdef HAVE_SYS_MMAN_H - #include -@@ -452,15 +453,8 @@ void exit_thread( int status ) - static void start_thread( struct startup_info *info ) - { - TEB *teb = info->teb; -- struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)teb->SpareBytes1; - PRTL_THREAD_START_ROUTINE func = info->entry_point; - void *arg = info->entry_arg; -- struct debug_info debug_info; -- -- debug_info.str_pos = debug_info.strings; -- debug_info.out_pos = debug_info.output; -- thread_data->debug_info = &debug_info; -- thread_data->pthread_id = pthread_self(); - - signal_init_thread( teb ); - server_init_thread( func ); -@@ -476,6 +470,26 @@ static void start_thread( struct startup_info *info ) - - - /*********************************************************************** -+ * call_start_thread -+ * -+ * Setup debug_info struct and call start_thread on target stack. -+ */ -+static void call_start_thread( struct startup_info *info ) -+{ -+ TEB *teb = info->teb; -+ struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)teb->SpareBytes1; -+ struct debug_info debug_info; -+ -+ debug_info.str_pos = debug_info.strings; -+ debug_info.out_pos = debug_info.output; -+ thread_data->debug_info = &debug_info; -+ thread_data->pthread_id = pthread_self(); -+ -+ wine_switch_to_stack( (void (*)(void *))start_thread, info, teb->Tib.StackBase ); -+} -+ -+ -+/*********************************************************************** - * RtlCreateUserThread (NTDLL.@) - */ - NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *descr, -@@ -581,11 +595,10 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR * - if ((status = virtual_alloc_thread_stack( teb, stack_reserve, stack_commit ))) goto error; - - pthread_attr_init( &attr ); -- pthread_attr_setstack( &attr, teb->DeallocationStack, -- (char *)teb->Tib.StackBase - (char *)teb->DeallocationStack ); -+ pthread_attr_setstacksize( &attr, PTHREAD_STACK_MIN ); - pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ); /* force creating a kernel thread */ - interlocked_xchg_add( &nb_threads, 1 ); -- if (pthread_create( &pthread_id, &attr, (void * (*)(void *))start_thread, info )) -+ if (pthread_create( &pthread_id, &attr, (void * (*)(void *))call_start_thread, info )) - { - interlocked_xchg_add( &nb_threads, -1 ); - pthread_attr_destroy( &attr ); --- -2.7.1 - diff --git a/patches/ntdll-Thread_Stack/0002-ntdll-Ignore-invalid-exit_frame-when-exiting-thread.patch b/patches/ntdll-Thread_Stack/0002-ntdll-Ignore-invalid-exit_frame-when-exiting-thread.patch deleted file mode 100644 index e9640660..00000000 --- a/patches/ntdll-Thread_Stack/0002-ntdll-Ignore-invalid-exit_frame-when-exiting-thread.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 15ef836edec8fa90f4d02d15d6b071439a65b855 Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Wed, 13 Apr 2016 06:49:03 +0200 -Subject: ntdll: Ignore invalid exit_frame when exiting thread. - ---- - dlls/ntdll/signal_i386.c | 16 ++++++++++++++++ - dlls/ntdll/signal_x86_64.c | 16 ++++++++++++++++ - 2 files changed, 32 insertions(+) - -diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c -index 9834c9f..8c09758 100644 ---- a/dlls/ntdll/signal_i386.c -+++ b/dlls/ntdll/signal_i386.c -@@ -2832,6 +2832,14 @@ void call_thread_func( LPTHREAD_START_ROUTINE entry, void *arg, void *frame ) - void WINAPI RtlExitUserThread( ULONG status ) - { - if (!ntdll_get_thread_data()->exit_frame) exit_thread( status ); -+ if (ntdll_get_thread_data()->exit_frame <= NtCurrentTeb()->DeallocationStack || -+ ntdll_get_thread_data()->exit_frame > NtCurrentTeb()->Tib.StackBase) -+ { -+ WARN( "exit frame outside of stack limits in thread %04x frame %p stack %p-%p\n", -+ GetCurrentThreadId(), ntdll_get_thread_data()->exit_frame, -+ NtCurrentTeb()->Tib.StackLimit, NtCurrentTeb()->Tib.StackBase ); -+ exit_thread( status ); -+ } - call_thread_exit_func( status, exit_thread, ntdll_get_thread_data()->exit_frame ); - } - -@@ -2841,6 +2849,14 @@ void WINAPI RtlExitUserThread( ULONG status ) - void abort_thread( int status ) - { - if (!ntdll_get_thread_data()->exit_frame) terminate_thread( status ); -+ if (ntdll_get_thread_data()->exit_frame <= NtCurrentTeb()->DeallocationStack || -+ ntdll_get_thread_data()->exit_frame > NtCurrentTeb()->Tib.StackBase) -+ { -+ WARN( "exit frame outside of stack limits in thread %04x frame %p stack %p-%p\n", -+ GetCurrentThreadId(), ntdll_get_thread_data()->exit_frame, -+ NtCurrentTeb()->Tib.StackLimit, NtCurrentTeb()->Tib.StackBase ); -+ terminate_thread( status ); -+ } - call_thread_exit_func( status, terminate_thread, ntdll_get_thread_data()->exit_frame ); - } - -diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c -index 93475d54..ffbb0f0 100644 ---- a/dlls/ntdll/signal_x86_64.c -+++ b/dlls/ntdll/signal_x86_64.c -@@ -3831,6 +3831,14 @@ __ASM_GLOBAL_FUNC( call_thread_exit_func, - void WINAPI RtlExitUserThread( ULONG status ) - { - if (!ntdll_get_thread_data()->exit_frame) exit_thread( status ); -+ if (ntdll_get_thread_data()->exit_frame <= NtCurrentTeb()->DeallocationStack || -+ ntdll_get_thread_data()->exit_frame > NtCurrentTeb()->Tib.StackBase) -+ { -+ WARN( "exit frame outside of stack limits in thread %04x frame %p stack %p-%p\n", -+ GetCurrentThreadId(), ntdll_get_thread_data()->exit_frame, -+ NtCurrentTeb()->Tib.StackLimit, NtCurrentTeb()->Tib.StackBase ); -+ exit_thread( status ); -+ } - call_thread_exit_func( status, exit_thread, ntdll_get_thread_data()->exit_frame ); - } - -@@ -3840,6 +3848,14 @@ void WINAPI RtlExitUserThread( ULONG status ) - void abort_thread( int status ) - { - if (!ntdll_get_thread_data()->exit_frame) terminate_thread( status ); -+ if (ntdll_get_thread_data()->exit_frame <= NtCurrentTeb()->DeallocationStack || -+ ntdll_get_thread_data()->exit_frame > NtCurrentTeb()->Tib.StackBase) -+ { -+ WARN( "exit frame outside of stack limits in thread %04x frame %p stack %p-%p\n", -+ GetCurrentThreadId(), ntdll_get_thread_data()->exit_frame, -+ NtCurrentTeb()->Tib.StackLimit, NtCurrentTeb()->Tib.StackBase ); -+ terminate_thread( status ); -+ } - call_thread_exit_func( status, terminate_thread, ntdll_get_thread_data()->exit_frame ); - } - --- -2.7.1 - diff --git a/patches/ntdll-Thread_Stack/definition b/patches/ntdll-Thread_Stack/definition deleted file mode 100644 index e2fe47ff..00000000 --- a/patches/ntdll-Thread_Stack/definition +++ /dev/null @@ -1,3 +0,0 @@ -Fixes: Use a separate stack when starting new threads -Fixes: Ignore invalid exit_frame when exiting thread -Disabled: true diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index bfe521d9..6c866e4e 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -51,7 +51,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "2a505efb1ca14f33503657eb070de6edd484b4f3" + echo "f5bd0be6a44c1c7d69afb8b8eb6311923e7762a1" } # Show version information @@ -150,7 +150,6 @@ patch_enable_all () enable_ntdll_Builtin_Prot="$1" enable_ntdll_CriticalSection="$1" enable_ntdll_DOS_Attributes="$1" - enable_ntdll_Dealloc_Thread_Stack="$1" enable_ntdll_Exception="$1" enable_ntdll_FileDispositionInformation="$1" enable_ntdll_FileFsFullSizeInformation="$1" @@ -497,9 +496,6 @@ patch_enable () ntdll-DOS_Attributes) enable_ntdll_DOS_Attributes="$2" ;; - ntdll-Dealloc_Thread_Stack) - enable_ntdll_Dealloc_Thread_Stack="$2" - ;; ntdll-Exception) enable_ntdll_Exception="$2" ;; @@ -2628,15 +2624,6 @@ if test "$enable_ntdll_CriticalSection" -eq 1; then patch_apply ntdll-CriticalSection/0004-ntdll-Use-fast-CS-functions-for-threadpool-locking.patch fi -# Patchset ntdll-Dealloc_Thread_Stack -# | -# | Modified files: -# | * dlls/ntdll/unix/unix_private.h, dlls/ntdll/unix/virtual.c -# | -if test "$enable_ntdll_Dealloc_Thread_Stack" -eq 1; then - patch_apply ntdll-Dealloc_Thread_Stack/0001-ntdll-Do-not-allow-to-allocate-thread-stack-for-curr.patch -fi - # Patchset ntdll-Exception # | # | This patchset fixes the following Wine bugs: diff --git a/staging/upstream-commit b/staging/upstream-commit index 71d602e6..894323d3 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -2a505efb1ca14f33503657eb070de6edd484b4f3 +f5bd0be6a44c1c7d69afb8b8eb6311923e7762a1