diff --git a/patches/ntdll-APC_Performance/0001-ntdll-Reuse-old-async-fileio-structures-if-possible.patch b/patches/ntdll-APC_Performance/0001-ntdll-Reuse-old-async-fileio-structures-if-possible.patch index f50cc4b8..636c6215 100644 --- a/patches/ntdll-APC_Performance/0001-ntdll-Reuse-old-async-fileio-structures-if-possible.patch +++ b/patches/ntdll-APC_Performance/0001-ntdll-Reuse-old-async-fileio-structures-if-possible.patch @@ -1,4 +1,4 @@ -From 2fc74d8b5fd617e4b614e80c2eba9971a2dea00e Mon Sep 17 00:00:00 2001 +From 4a46bc2a1bf83744f8f5ad97594328986edd693e Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Tue, 3 Mar 2015 03:39:12 +0100 Subject: [PATCH] ntdll: Reuse old async fileio structures if possible. @@ -11,10 +11,10 @@ often possible to reuse old fileio structures. 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c -index ca6899b50f5..4c3f3dac465 100644 +index a10c4bf81aa..370dfe95471 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c -@@ -4433,6 +4433,7 @@ struct async_fileio +@@ -4553,6 +4553,7 @@ struct async_fileio { async_callback_t *callback; /* must be the first field */ struct async_fileio *next; @@ -22,7 +22,7 @@ index ca6899b50f5..4c3f3dac465 100644 HANDLE handle; }; -@@ -4484,18 +4485,29 @@ static void release_fileio( struct async_fileio *io ) +@@ -4604,18 +4605,29 @@ static void release_fileio( struct async_fileio *io ) static struct async_fileio *alloc_fileio( DWORD size, async_callback_t callback, HANDLE handle ) { /* first free remaining previous fileinfos */ @@ -34,7 +34,7 @@ index ca6899b50f5..4c3f3dac465 100644 + while (old_io) { - struct async_fileio *next = io->next; -- RtlFreeHeap( GetProcessHeap(), 0, io ); +- free( io ); - io = next; + if (!io && old_io->size >= size && old_io->size <= max(4096, 4 * size)) + { @@ -45,13 +45,13 @@ index ca6899b50f5..4c3f3dac465 100644 + else + { + struct async_fileio *next = old_io->next; -+ RtlFreeHeap( GetProcessHeap(), 0, old_io ); ++ free( old_io ); + old_io = next; + } } -- if ((io = RtlAllocateHeap( GetProcessHeap(), 0, size ))) -+ if (io || (io = RtlAllocateHeap( GetProcessHeap(), 0, size ))) +- if ((io = malloc( size ))) ++ if (io || (io = malloc( size ))) { io->callback = callback; + io->size = size; diff --git a/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch b/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch index 9c3036ca..315bd86b 100644 --- a/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch +++ b/patches/ntdll-Builtin_Prot/0001-ntdll-Fix-holes-in-ELF-mappings.patch @@ -1,4 +1,4 @@ -From be204ab84d031b7efb223ac7c4962246549c8eb0 Mon Sep 17 00:00:00 2001 +From aa9b48c7e76994f4b93fbc516eee5d39a597f63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 1 Jun 2017 06:04:53 +0200 Subject: [PATCH] ntdll: Fix holes in ELF mappings. (v2) @@ -10,10 +10,10 @@ Based on a patch by Andrew Wesie. 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index e824b9ced25..90143f5c07b 100644 +index 66bcde8aff1..734dd130817 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -966,6 +966,16 @@ static inline BOOL is_write_watch_range( const void *addr, size_t size ) +@@ -959,6 +959,16 @@ static inline BOOL is_write_watch_range( const void *addr, size_t size ) } @@ -30,7 +30,7 @@ index e824b9ced25..90143f5c07b 100644 /*********************************************************************** * find_view_range * -@@ -2812,6 +2822,19 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta +@@ -2920,6 +2930,19 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) /* ignore fault if page is writable now */ if (get_unix_prot( get_page_vprot( page ) ) & PROT_WRITE) ret = STATUS_SUCCESS; } @@ -47,7 +47,7 @@ index e824b9ced25..90143f5c07b 100644 + else + set_page_vprot_bits( page, page_size, 0, VPROT_READ | VPROT_EXEC ); + } - server_leave_uninterrupted_section( &csVirtual, &sigset ); + server_leave_uninterrupted_section( &virtual_mutex, &sigset ); return ret; } diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c @@ -86,5 +86,5 @@ index eb52fc690cf..178f5605a23 100644 static BOOL check_with_margin(SIZE_T perf, SIZE_T sysperf, int margin) -- -2.26.2 +2.27.0 diff --git a/patches/ntdll-DOS_Attributes/0004-ntdll-Implement-storing-DOS-attributes-in-NtCreateFi.patch b/patches/ntdll-DOS_Attributes/0004-ntdll-Implement-storing-DOS-attributes-in-NtCreateFi.patch index e78705b3..7fdc0af2 100644 --- a/patches/ntdll-DOS_Attributes/0004-ntdll-Implement-storing-DOS-attributes-in-NtCreateFi.patch +++ b/patches/ntdll-DOS_Attributes/0004-ntdll-Implement-storing-DOS-attributes-in-NtCreateFi.patch @@ -1,14 +1,14 @@ -From 769a1043bb174557b600c9ce38765846a3126e7f Mon Sep 17 00:00:00 2001 +From 7fbcb02d4e88819dead5b944c3b4676fb4c3bc35 Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Wed, 20 Aug 2014 15:28:00 -0600 Subject: [PATCH] ntdll: Implement storing DOS attributes in NtCreateFile. --- - dlls/ntdll/tests/directory.c | 24 ++++++------ - dlls/ntdll/unix/file.c | 74 +++++++++++++++++++++++------------- + dlls/ntdll/tests/directory.c | 24 +++++------ + dlls/ntdll/unix/file.c | 78 +++++++++++++++++++++++------------- include/wine/port.h | 2 + - libs/port/xattr.c | 20 ++++++++++ - 4 files changed, 81 insertions(+), 39 deletions(-) + libs/port/xattr.c | 20 +++++++++ + 4 files changed, 83 insertions(+), 41 deletions(-) diff --git a/dlls/ntdll/tests/directory.c b/dlls/ntdll/tests/directory.c index 248ed99ab20..e0f4debc624 100644 @@ -60,10 +60,10 @@ index 248ed99ab20..e0f4debc624 100644 } testfiles[i].nfound++; diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c -index 66ce2eb5fe4..0546039cc47 100644 +index e3477f5cb5b..73bacabb4f3 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c -@@ -3004,6 +3004,20 @@ void CDECL set_show_dot_files( BOOL enable ) +@@ -3572,6 +3572,20 @@ void CDECL set_show_dot_files( BOOL enable ) show_dot_files = enable; } @@ -84,7 +84,7 @@ index 66ce2eb5fe4..0546039cc47 100644 /****************************************************************************** * NtCreateFile (NTDLL.@) -@@ -3013,6 +3027,10 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU +@@ -3581,6 +3595,10 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU ULONG attributes, ULONG sharing, ULONG disposition, ULONG options, void *ea_buffer, ULONG ea_length ) { @@ -95,7 +95,7 @@ index 66ce2eb5fe4..0546039cc47 100644 ANSI_STRING unix_name; BOOL created = FALSE; -@@ -3055,36 +3073,34 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU +@@ -3623,36 +3641,34 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU io->u.Status = STATUS_SUCCESS; } @@ -106,10 +106,7 @@ index 66ce2eb5fe4..0546039cc47 100644 - OBJECT_ATTRIBUTES unix_attr = *attr; - data_size_t len; - struct object_attributes *objattr; -+ WARN("%s not found (%x)\n", debugstr_us(attr->ObjectName), io->u.Status ); -+ return io->u.Status; -+ } - +- - unix_attr.ObjectName = &empty_string; /* we send the unix name instead */ - if ((io->u.Status = alloc_object_attributes( &unix_attr, &objattr, &len ))) - { @@ -129,15 +126,20 @@ index 66ce2eb5fe4..0546039cc47 100644 - *handle = wine_server_ptr_handle( reply->handle ); - } - SERVER_END_REQ; -- RtlFreeHeap( GetProcessHeap(), 0, objattr ); +- free( objattr ); +- RtlFreeAnsiString( &unix_name ); ++ WARN("%s not found (%x)\n", debugstr_us(attr->ObjectName), io->u.Status ); ++ return io->u.Status; + } +- else WARN( "%s not found (%x)\n", debugstr_us(attr->ObjectName), io->u.Status ); ++ + unix_attr = *attr; + unix_attr.ObjectName = &empty_string; /* we send the unix name instead */ + if ((io->u.Status = alloc_object_attributes( &unix_attr, &objattr, &len ))) + { - RtlFreeAnsiString( &unix_name ); ++ RtlFreeAnsiString( &unix_name ); + return io->u.Status; - } -- else WARN( "%s not found (%x)\n", debugstr_us(attr->ObjectName), io->u.Status ); ++ } + + SERVER_START_REQ( create_file ) + { @@ -152,11 +154,11 @@ index 66ce2eb5fe4..0546039cc47 100644 + *handle = wine_server_ptr_handle( reply->handle ); + } + SERVER_END_REQ; -+ RtlFreeHeap( GetProcessHeap(), 0, objattr ); ++ free( objattr ); if (io->u.Status == STATUS_SUCCESS) { -@@ -3106,6 +3122,11 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU +@@ -3674,6 +3690,11 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU io->Information = FILE_OVERWRITTEN; break; } @@ -168,7 +170,7 @@ index 66ce2eb5fe4..0546039cc47 100644 } else if (io->u.Status == STATUS_TOO_MANY_OPENED_FILES) { -@@ -3113,6 +3134,7 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU +@@ -3681,6 +3702,7 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU if (!once++) ERR_(winediag)( "Too many open files, ulimit -n probably needs to be increased\n" ); } @@ -177,10 +179,10 @@ index 66ce2eb5fe4..0546039cc47 100644 } diff --git a/include/wine/port.h b/include/wine/port.h -index f90396727d6..7d2c7388707 100644 +index e0249b4c59f..930efeeea1f 100644 --- a/include/wine/port.h +++ b/include/wine/port.h -@@ -371,6 +371,8 @@ extern int xattr_fget( int filedes, const char *name, void *value, size_t size ) +@@ -362,6 +362,8 @@ extern int xattr_fget( int filedes, const char *name, void *value, size_t size ) extern int xattr_fremove( int filedes, const char *name ); extern int xattr_fset( int filedes, const char *name, void *value, size_t size ); extern int xattr_get( const char *path, const char *name, void *value, size_t size ); 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 index d0fb38b3..f7e1fc01 100644 --- 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 @@ -1,4 +1,4 @@ -From fcb28ef6b7e083e5b5d0992efc60a9bef6f08708 Mon Sep 17 00:00:00 2001 +From 299205b6bbf5156bad5514dd52cd1bcd67dc4f14 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 @@ -10,10 +10,10 @@ Subject: [PATCH] ntdll: Do not allow to deallocate thread stack for current 2 files changed, 13 insertions(+) diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h -index 71d6ee7d4f2..33326deea20 100644 +index b509994f7ab..2c7cf2c9b07 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h -@@ -56,6 +56,7 @@ struct ntdll_thread_data +@@ -57,6 +57,7 @@ struct ntdll_thread_data int wait_fd[2]; /* fd for sleeping server requests */ BOOL wow64_redir; /* Wow64 filesystem redirection flag */ pthread_t pthread_id; /* pthread thread id */ @@ -22,19 +22,19 @@ index 71d6ee7d4f2..33326deea20 100644 }; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index d998966b5fa..086eaa0b34e 100644 +index 66bcde8aff1..a08ef1ce140 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -2781,6 +2781,8 @@ NTSTATUS CDECL virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_si +@@ -2819,6 +2819,8 @@ NTSTATUS CDECL virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_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( &csVirtual, &sigset ); + server_leave_uninterrupted_section( &virtual_mutex, &sigset ); return status; -@@ -3530,6 +3532,16 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si +@@ -3590,6 +3592,16 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si /* Free the pages */ if (size || (base != view->base)) status = STATUS_INVALID_PARAMETER; diff --git a/patches/ntdll-ForceBottomUpAlloc/0005-ntdll-Use-free-area-list-for-virtual-memory-allocati.patch b/patches/ntdll-ForceBottomUpAlloc/0005-ntdll-Use-free-area-list-for-virtual-memory-allocati.patch index 19d09a62..9eb2f3f1 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0005-ntdll-Use-free-area-list-for-virtual-memory-allocati.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0005-ntdll-Use-free-area-list-for-virtual-memory-allocati.patch @@ -1,4 +1,4 @@ -From 93e4ba286e3eee3cb846d05014cea4e92bee6c1b Mon Sep 17 00:00:00 2001 +From 04a45064d81f63de64effc2748b70cf15bba5f5d Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 14 Jan 2020 21:42:21 +0300 Subject: [PATCH] ntdll: Use free area list for virtual memory allocation. @@ -8,10 +8,10 @@ Subject: [PATCH] ntdll: Use free area list for virtual memory allocation. 1 file changed, 230 insertions(+), 112 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index f4dba39cb160..4827a1d785a4 100644 +index 00b29bc5d1d..667401aaa93 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -195,7 +195,11 @@ static BYTE *pages_vprot; +@@ -186,7 +186,11 @@ static BYTE *pages_vprot; #endif static struct file_view *view_block_start, *view_block_end, *next_free_view; @@ -22,8 +22,8 @@ index f4dba39cb160..4827a1d785a4 100644 +#endif static void *preload_reserve_start; static void *preload_reserve_end; - static BOOL use_locks; -@@ -546,13 +550,13 @@ static struct range_entry *free_ranges_lower_bound( void *addr ) + static BOOL force_exec_prot; /* whether to force PROT_EXEC on all PROT_READ mmaps */ +@@ -521,13 +525,13 @@ static struct range_entry *free_ranges_lower_bound( void *addr ) * * Updates the free_ranges after a new view has been created. */ @@ -40,7 +40,7 @@ index f4dba39cb160..4827a1d785a4 100644 /* free_ranges initial value is such that the view is either inside range or before another one. */ assert( range != free_ranges_end ); assert( range->end > view_base || next != free_ranges_end ); -@@ -563,7 +567,7 @@ static void free_ranges_insert_view( struct file_view *view ) +@@ -538,7 +542,7 @@ static void free_ranges_insert_view( struct file_view *view ) (range->end == view_base && next->base >= view_end)) { /* on Win64, assert that it's correctly aligned so we're not going to be in trouble later */ @@ -49,7 +49,7 @@ index f4dba39cb160..4827a1d785a4 100644 WARN( "range %p - %p is already mapped\n", view_base, view_end ); return; } -@@ -603,6 +607,12 @@ static void free_ranges_insert_view( struct file_view *view ) +@@ -578,6 +582,12 @@ static void free_ranges_insert_view( struct file_view *view ) } } @@ -62,7 +62,7 @@ index f4dba39cb160..4827a1d785a4 100644 /*********************************************************************** * free_ranges_remove_view -@@ -633,6 +643,7 @@ static void free_ranges_remove_view( struct file_view *view ) +@@ -608,6 +618,7 @@ static void free_ranges_remove_view( struct file_view *view ) return; } #endif @@ -70,7 +70,7 @@ index f4dba39cb160..4827a1d785a4 100644 /* free_ranges initial value is such that the view is either inside range or before another one. */ assert( range != free_ranges_end ); -@@ -1008,44 +1019,6 @@ static struct file_view *find_view_range( const void *addr, size_t size ) +@@ -954,44 +965,6 @@ static struct file_view *find_view_range( const void *addr, size_t size ) } @@ -78,7 +78,7 @@ index f4dba39cb160..4827a1d785a4 100644 - * find_view_inside_range - * - * Find first (resp. last, if top_down) view inside a range. -- * The csVirtual section must be held by caller. +- * virtual_mutex must be held by caller. - */ -static struct wine_rb_entry *find_view_inside_range( void **base_ptr, void **end_ptr, int top_down ) -{ @@ -115,7 +115,7 @@ index f4dba39cb160..4827a1d785a4 100644 /*********************************************************************** * try_map_free_area * -@@ -1089,65 +1062,11 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, +@@ -1035,65 +1008,11 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, return NULL; } @@ -124,7 +124,7 @@ index f4dba39cb160..4827a1d785a4 100644 - * map_free_area - * - * Find a free area between views inside the specified range and map it. -- * The csVirtual section must be held by caller. +- * virtual_mutex must be held by caller. - */ -static void *map_free_area( void *base, void *end, size_t size, int top_down, int unix_prot ) -{ @@ -176,12 +176,12 @@ index f4dba39cb160..4827a1d785a4 100644 * find_reserved_free_area * * Find a free area between views inside the specified range. - * The csVirtual section must be held by caller. + * virtual_mutex must be held by caller. - * The range must be inside the preloader reserved range. */ static void *find_reserved_free_area( void *base, void *end, size_t size, int top_down ) { -@@ -1361,8 +1280,7 @@ static void delete_view( struct file_view *view ) /* [in] View */ +@@ -1307,8 +1226,7 @@ static void delete_view( struct file_view *view ) /* [in] View */ { if (!(view->protect & VPROT_SYSTEM)) unmap_area( view->base, view->size ); set_page_vprot( view->base, view->size, 0 ); @@ -191,7 +191,7 @@ index f4dba39cb160..4827a1d785a4 100644 wine_rb_remove( &views_tree, &view->entry ); *(struct file_view **)view = next_free_view; next_free_view = view; -@@ -1410,8 +1328,7 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz +@@ -1356,8 +1274,7 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz set_page_vprot( base, size, vprot ); wine_rb_put( &views_tree, view->base, &view->entry ); @@ -201,7 +201,7 @@ index f4dba39cb160..4827a1d785a4 100644 *view_ret = view; -@@ -1656,6 +1573,7 @@ struct alloc_area +@@ -1589,6 +1506,7 @@ struct alloc_area int top_down; void *limit; void *result; @@ -209,7 +209,7 @@ index f4dba39cb160..4827a1d785a4 100644 }; /*********************************************************************** -@@ -1697,6 +1615,210 @@ static int CDECL alloc_reserved_area_callback( void *start, SIZE_T size, void *a +@@ -1630,6 +1548,210 @@ static int CDECL alloc_reserved_area_callback( void *start, SIZE_T size, void *a return 0; } @@ -420,7 +420,7 @@ index f4dba39cb160..4827a1d785a4 100644 /*********************************************************************** * map_fixed_area * -@@ -1782,11 +1904,15 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +@@ -1715,11 +1837,15 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, alloc.size = size; alloc.top_down = top_down; alloc.limit = (void*)(get_zero_bits_64_mask( zero_bits_64 ) & (UINT_PTR)user_space_limit); @@ -439,7 +439,7 @@ index f4dba39cb160..4827a1d785a4 100644 } if (mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down )) -@@ -1798,15 +1924,6 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +@@ -1731,15 +1857,6 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, goto done; } @@ -455,7 +455,7 @@ index f4dba39cb160..4827a1d785a4 100644 view_size = size + granularity_mask + 1; for (;;) -@@ -2500,6 +2617,7 @@ void virtual_init(void) +@@ -2392,6 +2509,7 @@ void virtual_init(void) if (preload_reserve_start) address_space_start = min( address_space_start, preload_reserve_start ); } @@ -464,5 +464,5 @@ index f4dba39cb160..4827a1d785a4 100644 size = ROUND_SIZE( 0, sizeof(TEB) ) + max( MINSIGSTKSZ, 8192 ); -- -2.26.2 +2.27.0 diff --git a/patches/ntdll-ForceBottomUpAlloc/0006-ntdll-Permanently-exclude-natively-mapped-areas-from.patch b/patches/ntdll-ForceBottomUpAlloc/0006-ntdll-Permanently-exclude-natively-mapped-areas-from.patch index cc9507c9..d173bb9e 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0006-ntdll-Permanently-exclude-natively-mapped-areas-from.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0006-ntdll-Permanently-exclude-natively-mapped-areas-from.patch @@ -1,4 +1,4 @@ -From 957fc1577fb1b1f3184cb9d7710f7e9a2afebdb1 Mon Sep 17 00:00:00 2001 +From eda2aae6a4845e3b0f5e4edb805fb4add4316f17 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 2 Jun 2020 21:06:33 +0300 Subject: [PATCH] ntdll: Permanently exclude natively mapped areas from free @@ -9,20 +9,20 @@ Subject: [PATCH] ntdll: Permanently exclude natively mapped areas from free 1 file changed, 25 insertions(+) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 4827a1d785a4..ef5c5dafe8fb 100644 +index 667401aaa93..c49c60166c2 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -124,6 +124,9 @@ static const BYTE VIRTUAL_Win32Flags[16] = - static struct wine_rb_tree views_tree; + static pthread_mutex_t virtual_mutex; +static void *last_already_mapped; +static size_t last_already_mapped_size; + - static RTL_CRITICAL_SECTION csVirtual; - static RTL_CRITICAL_SECTION_DEBUG critsect_debug = - { -@@ -1051,6 +1054,13 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, + static const BOOL is_win64 = (sizeof(void *) > sizeof(int)); + static const UINT page_shift = 12; + static const UINT_PTR page_mask = 0xfff; +@@ -997,6 +1000,13 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, if (ptr != (void *)-1) munmap( ptr, size ); @@ -36,7 +36,7 @@ index 4827a1d785a4..ef5c5dafe8fb 100644 if ((step > 0 && (char *)end - (char *)start < step) || (step < 0 && (char *)start - (char *)base < -step) || step == 0) -@@ -1908,9 +1918,24 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +@@ -1841,9 +1851,24 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, if (is_win64 || zero_bits_64) { @@ -62,5 +62,5 @@ index 4827a1d785a4..ef5c5dafe8fb 100644 goto done; } -- -2.26.2 +2.27.0 diff --git a/patches/ntdll-NtSetLdtEntries/0002-libs-wine-Allow-to-modify-reserved-LDT-entries.patch b/patches/ntdll-NtSetLdtEntries/0002-libs-wine-Allow-to-modify-reserved-LDT-entries.patch index 1b87d3de..1be49d6d 100644 --- a/patches/ntdll-NtSetLdtEntries/0002-libs-wine-Allow-to-modify-reserved-LDT-entries.patch +++ b/patches/ntdll-NtSetLdtEntries/0002-libs-wine-Allow-to-modify-reserved-LDT-entries.patch @@ -1,4 +1,4 @@ -From f4d2bffd85329aed25b1add735fafd4efa69e7e3 Mon Sep 17 00:00:00 2001 +From 13b77a54bad4d9b390d2e31f70d8f130eab48635 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 28 Apr 2016 17:01:16 +0200 Subject: [PATCH] libs/wine: Allow to modify reserved LDT entries. @@ -22,7 +22,7 @@ fails. 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c -index 2c2a0fda843..dae3d8d97d7 100644 +index a76d74cb698..881db6d6513 100644 --- a/dlls/kernel32/tests/thread.c +++ b/dlls/kernel32/tests/thread.c @@ -1341,16 +1341,12 @@ static void test_NtSetLdtEntries(void) @@ -43,17 +43,17 @@ index 2c2a0fda843..dae3d8d97d7 100644 } } diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c -index a52490a096b..7b04be577ab 100644 +index 30f1aee4d62..0ab09c1b4df 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c -@@ -502,8 +502,6 @@ NTSTATUS WINAPI NtSetLdtEntries( ULONG sel1, LDT_ENTRY entry1, ULONG sel2, LDT_E +@@ -2098,8 +2098,6 @@ NTSTATUS WINAPI NtSetLdtEntries( ULONG sel1, LDT_ENTRY entry1, ULONG sel2, LDT_E sigset_t sigset; if (sel1 >> 16 || sel2 >> 16) return STATUS_INVALID_LDT_DESCRIPTOR; - if (sel1 && (sel1 >> 3) < first_ldt_entry) return STATUS_INVALID_LDT_DESCRIPTOR; - if (sel2 && (sel2 >> 3) < first_ldt_entry) return STATUS_INVALID_LDT_DESCRIPTOR; - server_enter_uninterrupted_section( &ldt_section, &sigset ); + server_enter_uninterrupted_section( &ldt_mutex, &sigset ); if (sel1) ldt_set_entry( sel1, entry1 ); diff --git a/libs/wine/ldt.c b/libs/wine/ldt.c index 18b0b9be9bf..30d9b945f73 100644 @@ -78,5 +78,5 @@ index 18b0b9be9bf..30d9b945f73 100644 return ret; } -- -2.26.2 +2.27.0 diff --git a/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch b/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch index 6c4b17de..19150af8 100644 --- a/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch +++ b/patches/ntdll-WRITECOPY/0004-ntdll-Properly-handle-PAGE_WRITECOPY-protection.-try.patch @@ -1,4 +1,4 @@ -From f5019b4f92b14ef22e7e96a38442f7f864488b10 Mon Sep 17 00:00:00 2001 +From d85f01d0f447026a9cb266cd85934f6f0874ef75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Sat, 4 Oct 2014 03:22:09 +0200 Subject: [PATCH] ntdll: Properly handle PAGE_WRITECOPY protection. (try 5) @@ -9,10 +9,10 @@ For now, only enable it when a special environment variable is set. 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 0346d0d9753..5a8ba8bae2a 100644 +index 90dfb62eed1..b059261b3c0 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -498,6 +498,21 @@ int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T si +@@ -491,6 +491,21 @@ int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T si return ret; } @@ -34,7 +34,7 @@ index 0346d0d9753..5a8ba8bae2a 100644 /*********************************************************************** * free_ranges_lower_bound -@@ -799,8 +814,19 @@ static int get_unix_prot( BYTE vprot ) +@@ -792,8 +807,19 @@ static int get_unix_prot( BYTE vprot ) { if (vprot & VPROT_READ) prot |= PROT_READ; if (vprot & VPROT_WRITE) prot |= PROT_WRITE | PROT_READ; @@ -55,7 +55,7 @@ index 0346d0d9753..5a8ba8bae2a 100644 if (vprot & VPROT_WRITEWATCH) prot &= ~PROT_WRITE; } if (!prot) prot = PROT_NONE; -@@ -1539,7 +1565,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size +@@ -1532,7 +1558,7 @@ static void update_write_watches( void *base, size_t size, size_t accessed_size { TRACE( "updating watch %p-%p-%p\n", base, (char *)base + accessed_size, (char *)base + size ); /* clear write watch flag on accessed pages */ @@ -64,7 +64,7 @@ index 0346d0d9753..5a8ba8bae2a 100644 /* restore page protections on the entire range */ mprotect_range( base, size, 0, 0 ); } -@@ -2746,12 +2772,13 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta +@@ -2854,12 +2880,13 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) set_page_vprot_bits( page, page_size, 0, VPROT_WRITEWATCH ); mprotect_range( page, page_size, 0, 0 ); } @@ -80,9 +80,9 @@ index 0346d0d9753..5a8ba8bae2a 100644 + /* ignore fault if page is writable now */ + if (get_unix_prot( get_page_vprot( page ) ) & PROT_WRITE) ret = STATUS_SUCCESS; } - server_leave_uninterrupted_section( &csVirtual, &sigset ); + server_leave_uninterrupted_section( &virtual_mutex, &sigset ); return ret; -@@ -2773,11 +2800,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat +@@ -2881,11 +2908,16 @@ static NTSTATUS check_write_access( void *base, size_t size, BOOL *has_write_wat { BYTE vprot = get_page_vprot( addr + i ); if (vprot & VPROT_WRITEWATCH) *has_write_watch = TRUE; @@ -101,5 +101,5 @@ index 0346d0d9753..5a8ba8bae2a 100644 } -- -2.26.2 +2.27.0 diff --git a/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch b/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch index 4e32ba6f..43a37ee5 100644 --- a/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch +++ b/patches/ntdll-WRITECOPY/0005-ntdll-Track-if-a-WRITECOPY-page-has-been-modified.patch @@ -1,4 +1,4 @@ -From 6836700fb6d9e0221de770c8b020822b6f4c9b55 Mon Sep 17 00:00:00 2001 +From f59e093e93d4ed55111489186ae73f8f3d7ee632 Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Fri, 24 Apr 2020 14:55:14 -0500 Subject: [PATCH] ntdll: Track if a WRITECOPY page has been modified. @@ -12,7 +12,7 @@ Signed-off-by: Andrew Wesie 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 5a8ba8bae2a..c81104bd266 100644 +index b059261b3c0..0a6d7691575 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -97,6 +97,7 @@ struct file_view @@ -23,7 +23,7 @@ index 5a8ba8bae2a..c81104bd266 100644 /* per-mapping protection flags */ #define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */ -@@ -818,7 +819,7 @@ static int get_unix_prot( BYTE vprot ) +@@ -811,7 +812,7 @@ static int get_unix_prot( BYTE vprot ) #if defined(__i386__) if (vprot & VPROT_WRITECOPY) { @@ -32,7 +32,7 @@ index 5a8ba8bae2a..c81104bd266 100644 prot = (prot & ~PROT_WRITE) | PROT_READ; else prot |= PROT_WRITE | PROT_READ; -@@ -1397,7 +1398,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz +@@ -1390,7 +1391,11 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz */ static DWORD get_win32_prot( BYTE vprot, unsigned int map_prot ) { @@ -45,7 +45,7 @@ index 5a8ba8bae2a..c81104bd266 100644 if (vprot & VPROT_GUARD) ret |= PAGE_GUARD; if (map_prot & SEC_NOCACHE) ret |= PAGE_NOCACHE; return ret; -@@ -1508,7 +1513,7 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr +@@ -1501,7 +1506,7 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr if (view->protect & VPROT_WRITEWATCH) { /* each page may need different protections depending on write watch flag */ @@ -54,7 +54,7 @@ index 5a8ba8bae2a..c81104bd266 100644 mprotect_range( base, size, 0, 0 ); return TRUE; } -@@ -1524,10 +1529,18 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr +@@ -1517,10 +1522,18 @@ static BOOL set_vprot( struct file_view *view, void *base, size_t size, BYTE vpr return TRUE; } @@ -74,7 +74,7 @@ index 5a8ba8bae2a..c81104bd266 100644 return TRUE; } -@@ -2774,7 +2787,7 @@ NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_sta +@@ -2882,7 +2895,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) } if (vprot & VPROT_WRITECOPY) { @@ -83,7 +83,7 @@ index 5a8ba8bae2a..c81104bd266 100644 mprotect_range( page, page_size, 0, 0 ); } /* ignore fault if page is writable now */ -@@ -3660,7 +3673,7 @@ static NTSTATUS get_basic_memory_info( HANDLE process, LPCVOID addr, +@@ -3812,7 +3825,7 @@ static NTSTATUS get_basic_memory_info( HANDLE process, LPCVOID addr, else if (view->protect & (SEC_FILE | SEC_RESERVE | SEC_COMMIT)) info->Type = MEM_MAPPED; else info->Type = MEM_PRIVATE; for (ptr = base; ptr < base + range_size; ptr += page_size) @@ -91,7 +91,7 @@ index 5a8ba8bae2a..c81104bd266 100644 + if ((get_page_vprot( ptr ) ^ vprot) & ~(VPROT_WRITEWATCH|VPROT_WRITTEN)) break; info->RegionSize = ptr - base; } - server_leave_uninterrupted_section( &csVirtual, &sigset ); + server_leave_uninterrupted_section( &virtual_mutex, &sigset ); -- -2.26.2 +2.27.0 diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index d43be4ec..953e5230 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -52,7 +52,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "8bd5fe30014c2aa60f0c4570db4ef936e8c51245" + echo "51dd1ba02e4a96a3e0c9381a434bfd1fd4347d83" } # Show version information diff --git a/staging/upstream-commit b/staging/upstream-commit index 74c824dc..2ad50461 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -8bd5fe30014c2aa60f0c4570db4ef936e8c51245 +51dd1ba02e4a96a3e0c9381a434bfd1fd4347d83