From 0c2c469c7ba5d69de752bcf46233a733a791eb97 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 26 Apr 2023 11:01:51 +1000 Subject: [PATCH] Rebase against a500bb72f05058c985511ff35f191565f45cd6c0. --- ...ort-unaligned-views-in-free-ranges-m.patch | 19 +++++++++--------- ...dll-Pass-allocation-type-to-map_view.patch | 20 +++++++++---------- staging/upstream-commit | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/patches/ntdll-Placeholders/0004-ntdll-Fully-support-unaligned-views-in-free-ranges-m.patch b/patches/ntdll-Placeholders/0004-ntdll-Fully-support-unaligned-views-in-free-ranges-m.patch index dd4fae63..ca2145cc 100644 --- a/patches/ntdll-Placeholders/0004-ntdll-Fully-support-unaligned-views-in-free-ranges-m.patch +++ b/patches/ntdll-Placeholders/0004-ntdll-Fully-support-unaligned-views-in-free-ranges-m.patch @@ -1,23 +1,22 @@ -From c97697f6bbc3c9671210e480f2fcfe761b54893d Mon Sep 17 00:00:00 2001 +From 6a2f524736ad25b89af90a74eedfa2f2b0f178e6 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Fri, 11 Nov 2022 18:30:20 -0600 Subject: [PATCH] ntdll: Fully support unaligned views in free ranges management. --- - dlls/ntdll/unix/virtual.c | 41 ++++++++++++++++++++------------------- - 1 file changed, 21 insertions(+), 20 deletions(-) + dlls/ntdll/unix/virtual.c | 40 ++++++++++++++++++++------------------- + 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 4cb0f349ffc..2dca5dfa45f 100644 +index 847cfd750f3..cfa69d8d7f5 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -749,18 +749,19 @@ static void free_ranges_insert_view( struct file_view *view ) +@@ -742,17 +742,19 @@ static void free_ranges_insert_view( struct file_view *view ) assert( range != free_ranges_end ); assert( range->end > view_base || next != free_ranges_end ); -- /* this happens because virtual_alloc_thread_stack shrinks a view, then creates another one on top, -- * or because AT_ROUND_TO_PAGE was used with NtMapViewOfSection to force 4kB aligned mapping. */ +- /* this happens because AT_ROUND_TO_PAGE was used with NtMapViewOfSection to force 4kB aligned mapping. */ - if ((range->end > view_base && range->base >= view_end) || - (range->end == view_base && next->base >= view_end)) - { @@ -43,7 +42,7 @@ index 4cb0f349ffc..2dca5dfa45f 100644 /* this should never happen */ if (range->base > view_base || range->end < view_end) -@@ -810,9 +811,7 @@ static void free_ranges_remove_view( struct file_view *view ) +@@ -802,9 +804,7 @@ static void free_ranges_remove_view( struct file_view *view ) struct range_entry *range = free_ranges_lower_bound( view_base ); struct range_entry *next = range + 1; @@ -54,7 +53,7 @@ index 4cb0f349ffc..2dca5dfa45f 100644 struct file_view *prev_view = RB_ENTRY_VALUE( rb_prev( &view->entry ), struct file_view, entry ); struct file_view *next_view = RB_ENTRY_VALUE( rb_next( &view->entry ), struct file_view, entry ); void *prev_view_base = prev_view ? ROUND_ADDR( prev_view->base, granularity_mask ) : NULL; -@@ -820,13 +819,15 @@ static void free_ranges_remove_view( struct file_view *view ) +@@ -812,13 +812,15 @@ static void free_ranges_remove_view( struct file_view *view ) void *next_view_base = next_view ? ROUND_ADDR( next_view->base, granularity_mask ) : NULL; void *next_view_end = next_view ? ROUND_ADDR( (char *)next_view->base + next_view->size + granularity_mask, granularity_mask ) : NULL; @@ -77,5 +76,5 @@ index 4cb0f349ffc..2dca5dfa45f 100644 /* free_ranges initial value is such that the view is either inside range or before another one. */ assert( range != free_ranges_end ); -- -2.38.1 +2.40.1 diff --git a/patches/ntdll-Placeholders/0010-ntdll-Pass-allocation-type-to-map_view.patch b/patches/ntdll-Placeholders/0010-ntdll-Pass-allocation-type-to-map_view.patch index 2fb22593..1f8091f5 100644 --- a/patches/ntdll-Placeholders/0010-ntdll-Pass-allocation-type-to-map_view.patch +++ b/patches/ntdll-Placeholders/0010-ntdll-Pass-allocation-type-to-map_view.patch @@ -1,4 +1,4 @@ -From 0a8dca419f3f5eacab2e9e11903cfc4c0a58dc93 Mon Sep 17 00:00:00 2001 +From 326a1a51a7fa3869a13522cf52a7b4c575aebc81 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Thu, 10 Nov 2022 18:48:14 -0600 Subject: [PATCH] ntdll: Pass allocation type to map_view(). @@ -9,10 +9,10 @@ Based on a patch by Nikolay Sivov. 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c -index 85c4ab878b3..eb1d186e11c 100644 +index 55d453c2504..69c8977250a 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c -@@ -2007,8 +2007,9 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot ) +@@ -1990,8 +1990,9 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot ) * virtual_mutex must be held by caller. */ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, @@ -23,7 +23,7 @@ index 85c4ab878b3..eb1d186e11c 100644 void *ptr; NTSTATUS status; -@@ -2223,7 +2224,7 @@ static NTSTATUS allocate_dos_memory( struct file_view **view, unsigned int vprot +@@ -2208,7 +2209,7 @@ static NTSTATUS allocate_dos_memory( struct file_view **view, unsigned int vprot if (mmap_is_in_reserved_area( low_64k, dosmem_size - 0x10000 ) != 1) { addr = anon_mmap_tryfixed( low_64k, dosmem_size - 0x10000, unix_prot, 0 ); @@ -32,15 +32,15 @@ index 85c4ab878b3..eb1d186e11c 100644 } /* now try to allocate the low 64K too */ -@@ -3236,7 +3237,7 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR zero_bits, SI +@@ -3220,7 +3221,7 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR zero_bits, SI server_enter_uninterrupted_section( &virtual_mutex, &sigset ); -- if ((status = map_view( &view, NULL, size + extra_size, FALSE, -+ if ((status = map_view( &view, NULL, size + extra_size, 0, - VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, get_zero_bits_mask( zero_bits ), 0 )) - != STATUS_SUCCESS) +- if ((status = map_view( &view, NULL, size, FALSE, VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, ++ if ((status = map_view( &view, NULL, size, 0, VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, + get_zero_bits_mask( zero_bits ), 0 )) != STATUS_SUCCESS) goto done; + -- -2.38.1 +2.40.1 diff --git a/staging/upstream-commit b/staging/upstream-commit index 70794e10..85c15b34 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -9e99c6f66d236101a084b6a3a24c98b5c8677fe5 +a500bb72f05058c985511ff35f191565f45cd6c0