From d7706d345c7cda3a0c6c5692839d7c2b8d0ed6e9 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 11 Sep 2024 09:57:51 +1000 Subject: [PATCH] Rebase against ee5bd3bab82903b26e360d077c93af4a26158367. --- ...for-sys-eventfd.h-ppoll-and-shm_open.patch | 34 +++++++++--------- ...orce-virtual-memory-allocation-order.patch | 24 ++++++------- ...tively-mapped-areas-from-free-areas-.patch | 36 ++++++++++--------- staging/upstream-commit | 2 +- 4 files changed, 50 insertions(+), 46 deletions(-) diff --git a/patches/eventfd_synchronization/0001-configure-Check-for-sys-eventfd.h-ppoll-and-shm_open.patch b/patches/eventfd_synchronization/0001-configure-Check-for-sys-eventfd.h-ppoll-and-shm_open.patch index 820e7514..e8e30a41 100644 --- a/patches/eventfd_synchronization/0001-configure-Check-for-sys-eventfd.h-ppoll-and-shm_open.patch +++ b/patches/eventfd_synchronization/0001-configure-Check-for-sys-eventfd.h-ppoll-and-shm_open.patch @@ -1,4 +1,4 @@ -From 3b9e832890ad710eecf08f7901d708cfebb3520c Mon Sep 17 00:00:00 2001 +From ff79cf149df18ecb2fe60e776673c6d428a13ae8 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 13 Jun 2018 10:44:49 -0500 Subject: [PATCH] configure: Check for sys/eventfd.h, ppoll(), and shm_open(). @@ -7,15 +7,15 @@ We use ppoll() instead of poll() for the better time granularity. Although perhaps we shouldn't since the server doesn't do this. --- - configure.ac | 8 ++++++++ - include/config.h.in | 9 +++++++++ - 2 files changed, 17 insertions(+) + configure.ac | 8 ++++++++ + include/config.h.in | 11 ++++++++++- + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 4314be5553c..920d8343925 100644 +index 52612934197..7a1b92a15d6 100644 --- a/configure.ac +++ b/configure.ac -@@ -407,6 +407,7 @@ AC_CHECK_HEADERS(\ +@@ -408,6 +408,7 @@ AC_CHECK_HEADERS(\ sys/cdio.h \ sys/epoll.h \ sys/event.h \ @@ -23,7 +23,7 @@ index 4314be5553c..920d8343925 100644 sys/extattr.h \ sys/filio.h \ sys/ipc.h \ -@@ -2076,6 +2077,7 @@ AC_CHECK_FUNCS(\ +@@ -2096,6 +2097,7 @@ AC_CHECK_FUNCS(\ port_create \ posix_fadvise \ posix_fallocate \ @@ -31,7 +31,7 @@ index 4314be5553c..920d8343925 100644 prctl \ sched_yield \ renameat \ -@@ -2100,6 +2102,12 @@ case $host_os in +@@ -2120,6 +2122,12 @@ case $host_os in ;; esac @@ -45,30 +45,32 @@ index 4314be5553c..920d8343925 100644 AC_LINK_IFELSE([AC_LANG_PROGRAM( [[#include ]], [[sched_setaffinity(0, 0, 0);]])],[wine_cv_have_sched_setaffinity=yes],[wine_cv_have_sched_setaffinity=no])) diff --git a/include/config.h.in b/include/config.h.in -index 096ecdf94ec..303fb7f2b69 100644 +index a09cea2c8ee..8ab002c0030 100644 --- a/include/config.h.in +++ b/include/config.h.in -@@ -312,6 +312,9 @@ - /* Define to 1 if you have the `posix_fallocate' function. */ +@@ -321,6 +321,9 @@ + /* Define to 1 if you have the 'posix_fallocate' function. */ #undef HAVE_POSIX_FALLOCATE +/* Define to 1 if you have the `ppoll' function. */ +#undef HAVE_PPOLL + - /* Define to 1 if you have the `prctl' function. */ + /* Define to 1 if you have the 'prctl' function. */ #undef HAVE_PRCTL -@@ -369,6 +372,9 @@ - /* Define to 1 if `interface_id' is a member of `sg_io_hdr_t'. */ +@@ -378,7 +381,10 @@ + /* Define to 1 if 'interface_id' is a member of 'sg_io_hdr_t'. */ #undef HAVE_SG_IO_HDR_T_INTERFACE_ID +-/* Define to 1 if 'si_fd' is a member of 'siginfo_t'. */ +/* Define to 1 if you have the `shm_open' function. */ +#undef HAVE_SHM_OPEN + - /* Define to 1 if `si_fd' is a member of `siginfo_t'. */ ++/* Define to 1 if `si_fd' is a member of `siginfo_t'. */ #undef HAVE_SIGINFO_T_SI_FD -@@ -498,6 +504,9 @@ + /* Define to 1 if you have the 'sigprocmask' function. */ +@@ -507,6 +513,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_EPOLL_H diff --git a/patches/ntdll-ForceBottomUpAlloc/0003-ntdll-Force-virtual-memory-allocation-order.patch b/patches/ntdll-ForceBottomUpAlloc/0003-ntdll-Force-virtual-memory-allocation-order.patch index eb830be4..7065c772 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0003-ntdll-Force-virtual-memory-allocation-order.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0003-ntdll-Force-virtual-memory-allocation-order.patch @@ -1,4 +1,4 @@ -From 8f9e309dc4b3e9c7328c86cc4993b9359f0e6839 Mon Sep 17 00:00:00 2001 +From 4c246e61f0de05a8b80e7a5d5ff2edcd21036fec Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Mon, 25 Nov 2019 12:19:20 +0300 Subject: [PATCH] ntdll: Force virtual memory allocation order. @@ -16,10 +16,10 @@ Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46568 1 file changed, 164 insertions(+), 246 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index cd1655d41b2..c0537375ab8 100644 +index 1a3d527f186..ec72d692c3a 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -1241,43 +1241,15 @@ static struct file_view *find_view_range( const void *addr, size_t size ) +@@ -1269,43 +1269,15 @@ static struct file_view *find_view_range( const void *addr, size_t size ) } @@ -71,7 +71,7 @@ index cd1655d41b2..c0537375ab8 100644 /*********************************************************************** * try_map_free_area -@@ -1312,112 +1284,6 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, +@@ -1338,112 +1310,6 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, } @@ -184,7 +184,7 @@ index cd1655d41b2..c0537375ab8 100644 /*********************************************************************** * remove_reserved_area * -@@ -1527,8 +1393,7 @@ static void free_view( struct file_view *view ) +@@ -1553,8 +1419,7 @@ static void free_view( struct file_view *view ) */ static void unregister_view( struct file_view *view ) { @@ -194,7 +194,7 @@ index cd1655d41b2..c0537375ab8 100644 wine_rb_remove( &views_tree, &view->entry ); } -@@ -1556,8 +1421,7 @@ static void delete_view( struct file_view *view ) /* [in] View */ +@@ -1582,8 +1447,7 @@ static void delete_view( struct file_view *view ) /* [in] View */ static void register_view( struct file_view *view ) { wine_rb_put( &views_tree, view->base, &view->entry ); @@ -204,7 +204,7 @@ index cd1655d41b2..c0537375ab8 100644 } -@@ -1830,89 +1694,176 @@ static inline void *unmap_extra_space( void *ptr, size_t total_size, size_t want +@@ -1855,89 +1719,176 @@ static inline void *unmap_extra_space( void *ptr, size_t total_size, size_t want return ptr; } @@ -343,7 +343,7 @@ index cd1655d41b2..c0537375ab8 100644 +static void *alloc_free_area( char *limit_low, char *limit_high, size_t size, BOOL top_down, int unix_prot, UINT_PTR align_mask ) { - void *ptr = NULL; -- struct reserved_area *area = LIST_ENTRY( ptr, struct reserved_area, entry ); +- struct reserved_area *area; + struct range_entry *range, *ranges_start, *ranges_end; + char *reserve_start, *reserve_end; + struct alloc_area area; @@ -442,7 +442,7 @@ index cd1655d41b2..c0537375ab8 100644 } /*********************************************************************** -@@ -2016,48 +1967,13 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +@@ -2041,48 +1992,13 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, } else { @@ -495,7 +495,7 @@ index cd1655d41b2..c0537375ab8 100644 status = create_view( view_ret, ptr, size, vprot ); if (status != STATUS_SUCCESS) unmap_area( ptr, size ); return status; -@@ -3236,6 +3152,7 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P +@@ -3275,6 +3191,7 @@ static unsigned int virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG_P done: server_leave_uninterrupted_section( &virtual_mutex, &sigset ); if (needs_close) close( unix_handle ); @@ -503,7 +503,7 @@ index cd1655d41b2..c0537375ab8 100644 return res; } -@@ -6143,6 +6060,7 @@ NTSTATUS WINAPI NtWow64AllocateVirtualMemory64( HANDLE process, ULONG64 *ret, UL +@@ -6394,6 +6311,7 @@ NTSTATUS WINAPI NtWow64AllocateVirtualMemory64( HANDLE process, ULONG64 *ret, UL *ret = (ULONG_PTR)base; *size_ptr = size; } @@ -512,5 +512,5 @@ index cd1655d41b2..c0537375ab8 100644 } -- -2.43.0 +2.45.2 diff --git a/patches/ntdll-ForceBottomUpAlloc/0004-ntdll-Exclude-natively-mapped-areas-from-free-areas-.patch b/patches/ntdll-ForceBottomUpAlloc/0004-ntdll-Exclude-natively-mapped-areas-from-free-areas-.patch index 16dc1fc4..79898855 100644 --- a/patches/ntdll-ForceBottomUpAlloc/0004-ntdll-Exclude-natively-mapped-areas-from-free-areas-.patch +++ b/patches/ntdll-ForceBottomUpAlloc/0004-ntdll-Exclude-natively-mapped-areas-from-free-areas-.patch @@ -1,14 +1,14 @@ -From d13a3f4498ddc7f10a1d435edb5c59b71dca1efc Mon Sep 17 00:00:00 2001 +From 844ba5e56a7231f65b65cabf06fe44ee49876aa0 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Fri, 1 Dec 2023 14:55:20 -0600 Subject: [PATCH] ntdll: Exclude natively mapped areas from free areas list. --- - dlls/ntdll/unix/virtual.c | 104 ++++++++++++++++++++++++++++++++++---- - 1 file changed, 95 insertions(+), 9 deletions(-) + dlls/ntdll/unix/virtual.c | 106 ++++++++++++++++++++++++++++++++++---- + 1 file changed, 97 insertions(+), 9 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index c0537375ab8..b4d7f6a580d 100644 +index ec72d692c3a..30d43afc076 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -127,6 +127,7 @@ struct file_view @@ -28,7 +28,7 @@ index c0537375ab8..b4d7f6a580d 100644 ULONG_PTR user_space_wow_limit = 0; struct _KUSER_SHARED_DATA *user_shared_data = (void *)0x7ffe0000; -@@ -1129,7 +1132,9 @@ static void dump_view( struct file_view *view ) +@@ -1157,7 +1160,9 @@ static void dump_view( struct file_view *view ) BYTE prot = get_page_vprot( addr ); TRACE( "View: %p - %p", addr, addr + view->size - 1 ); @@ -39,7 +39,7 @@ index c0537375ab8..b4d7f6a580d 100644 TRACE( " (builtin image)\n" ); else if (view->protect & VPROT_FREE_PLACEHOLDER) TRACE( " (placeholder)\n" ); -@@ -1249,6 +1254,8 @@ struct alloc_area +@@ -1277,6 +1282,8 @@ struct alloc_area int unix_prot; BOOL top_down; UINT_PTR align_mask; @@ -48,7 +48,7 @@ index c0537375ab8..b4d7f6a580d 100644 }; /*********************************************************************** -@@ -1257,9 +1264,12 @@ struct alloc_area +@@ -1285,9 +1292,14 @@ struct alloc_area * Try mmaping some expected free memory region, eventually stepping and * retrying inside it, and return where it actually succeeded, or NULL. */ @@ -60,10 +60,12 @@ index c0537375ab8..b4d7f6a580d 100644 + size_t abs_step = step > 0 ? step : -step; + size_t size = area->size; + int unix_prot = area->unix_prot; - void *ptr; - ++ void *ptr; ++ while (start && base <= start && (char*)start + size <= (char*)end) -@@ -1272,12 +1282,19 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, + { + if (anon_mmap_tryfixed( start, size, unix_prot, 0 ) != MAP_FAILED) return start; +@@ -1298,12 +1310,19 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step, strerror(errno), start, (char *)start + size, unix_prot ); return NULL; } @@ -84,7 +86,7 @@ index c0537375ab8..b4d7f6a580d 100644 } return NULL; -@@ -1702,11 +1719,11 @@ static void *try_map_free_area_range( struct alloc_area *area, char *start, char +@@ -1727,11 +1746,11 @@ static void *try_map_free_area_range( struct alloc_area *area, char *start, char { if (end - start < area->size) return NULL; alloc_start = ROUND_ADDR( end - area->size, area->align_mask ); @@ -98,7 +100,7 @@ index c0537375ab8..b4d7f6a580d 100644 } static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char *end ) -@@ -1796,9 +1813,10 @@ static void *alloc_free_area( char *limit_low, char *limit_high, size_t size, BO +@@ -1821,9 +1840,10 @@ static void *alloc_free_area( char *limit_low, char *limit_high, size_t size, BO struct range_entry *range, *ranges_start, *ranges_end; char *reserve_start, *reserve_end; struct alloc_area area; @@ -110,7 +112,7 @@ index c0537375ab8..b4d7f6a580d 100644 TRACE("limit %p-%p, size %p, top_down %#x.\n", limit_low, limit_high, (void *)size, top_down); -@@ -1863,6 +1881,50 @@ static void *alloc_free_area( char *limit_low, char *limit_high, size_t size, BO +@@ -1888,6 +1908,50 @@ static void *alloc_free_area( char *limit_low, char *limit_high, size_t size, BO if ((result = alloc_free_area_in_range( &area, base, end ))) break; } @@ -161,7 +163,7 @@ index c0537375ab8..b4d7f6a580d 100644 return result; } -@@ -1922,6 +1984,17 @@ failed: +@@ -1947,6 +2011,17 @@ failed: return status; } @@ -179,7 +181,7 @@ index c0537375ab8..b4d7f6a580d 100644 /*********************************************************************** * map_view * -@@ -1972,7 +2045,15 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, +@@ -1997,7 +2072,15 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, if (!align_mask) align_mask = granularity_mask; if (!(ptr = alloc_free_area( (void *)limit_low, (void *)limit_high, size, top_down, get_unix_prot( vprot ), align_mask ))) @@ -196,7 +198,7 @@ index c0537375ab8..b4d7f6a580d 100644 } status = create_view( view_ret, ptr, size, vprot ); if (status != STATUS_SUCCESS) unmap_area( ptr, size ); -@@ -4287,7 +4368,12 @@ void virtual_set_force_exec( BOOL enable ) +@@ -4346,7 +4429,12 @@ void virtual_set_force_exec( BOOL enable ) WINE_RB_FOR_EACH_ENTRY( view, &views_tree, struct file_view, entry ) { /* file mappings are always accessible */ @@ -211,5 +213,5 @@ index c0537375ab8..b4d7f6a580d 100644 mprotect_range( view->base, view->size, commit, 0 ); } -- -2.43.0 +2.45.2 diff --git a/staging/upstream-commit b/staging/upstream-commit index 7a3a6b82..32f55b46 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -30c135fe8662e7bcbafaa187914f28fdf9c052ff +ee5bd3bab82903b26e360d077c93af4a26158367