Rebase against 99e47361a37a4bf16de131401a0c231f86214a43.

This commit is contained in:
Alistair Leslie-Hughes 2021-05-08 13:13:58 +10:00
parent 50d26744b0
commit 8c06be6529
4 changed files with 34 additions and 34 deletions

View File

@ -1,4 +1,4 @@
From 43fc939825dd5d4d2fdbfd98f849d71eaebfa8d0 Mon Sep 17 00:00:00 2001
From 03e143d7abd6684600722fee6c96d05d2c70830d Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
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, 202 insertions(+), 216 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 4ca033b0e19..5bb9511be6d 100644
index 75fa0b91872..525c55b8097 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1013,44 +1013,6 @@ static struct file_view *find_view_range( const void *addr, size_t size )
@@ -1135,44 +1135,6 @@ static struct file_view *find_view_range( const void *addr, size_t size )
}
@ -64,7 +64,7 @@ index 4ca033b0e19..5bb9511be6d 100644
/***********************************************************************
* try_map_free_area
*
@@ -1083,110 +1045,6 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
@@ -1205,110 +1167,6 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
return NULL;
}
@ -175,7 +175,7 @@ index 4ca033b0e19..5bb9511be6d 100644
/***********************************************************************
* add_reserved_area
*
@@ -1344,8 +1202,7 @@ static void delete_view( struct file_view *view ) /* [in] View */
@@ -1466,8 +1324,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 );
@ -185,7 +185,7 @@ index 4ca033b0e19..5bb9511be6d 100644
wine_rb_remove( &views_tree, &view->entry );
*(struct file_view **)view = next_free_view;
next_free_view = view;
@@ -1393,8 +1250,7 @@ static NTSTATUS create_view( struct file_view **view_ret, void *base, size_t siz
@@ -1515,8 +1372,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 );
@ -195,7 +195,7 @@ index 4ca033b0e19..5bb9511be6d 100644
*view_ret = view;
@@ -1619,54 +1475,220 @@ static inline void *unmap_extra_space( void *ptr, size_t total_size, size_t want
@@ -1741,54 +1597,220 @@ static inline void *unmap_extra_space( void *ptr, size_t total_size, size_t want
return ptr;
}
@ -446,12 +446,12 @@ index 4ca033b0e19..5bb9511be6d 100644
/***********************************************************************
* map_fixed_area
*
@@ -1738,48 +1760,11 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
@@ -1860,48 +1882,11 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
if (status != STATUS_SUCCESS) return status;
ptr = base;
}
- else
+ else if (!(ptr = alloc_free_area( (void*)(get_zero_bits_64_mask( zero_bits_64 )
+ else if (!(ptr = alloc_free_area( (void*)(get_zero_bits_mask( zero_bits )
+ & (UINT_PTR)user_space_limit), size, top_down, get_unix_prot( vprot ) )))
{
- size_t view_size = size + granularity_mask + 1;
@ -459,7 +459,7 @@ index 4ca033b0e19..5bb9511be6d 100644
-
- alloc.size = size;
- alloc.top_down = top_down;
- alloc.limit = (void*)(get_zero_bits_64_mask( zero_bits_64 ) & (UINT_PTR)user_space_limit);
- alloc.limit = (void*)(get_zero_bits_mask( zero_bits ) & (UINT_PTR)user_space_limit);
-
- if (mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down ))
- {
@ -470,7 +470,7 @@ index 4ca033b0e19..5bb9511be6d 100644
- goto done;
- }
-
- if (zero_bits_64)
- if (zero_bits)
- {
- if (!(ptr = map_free_area( address_space_start, alloc.limit, size,
- top_down, get_unix_prot(vprot) )))
@ -498,7 +498,7 @@ index 4ca033b0e19..5bb9511be6d 100644
status = create_view( view_ret, ptr, size, vprot );
if (status != STATUS_SUCCESS) unmap_area( ptr, size );
return status;
@@ -2409,6 +2394,7 @@ void virtual_init(void)
@@ -2627,6 +2612,7 @@ void virtual_init(void)
if (preload_reserve_start)
address_space_start = min( address_space_start, preload_reserve_start );
}
@ -507,5 +507,5 @@ index 4ca033b0e19..5bb9511be6d 100644
/* try to find space in a reserved area for the views and pages protection table */
--
2.26.2
2.30.2

View File

@ -1,4 +1,4 @@
From 14825c31d376ab5e55991fd459583e3afd3dfcde Mon Sep 17 00:00:00 2001
From 9d123ae160a93e689b35e50682405f421d094c18 Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Tue, 2 Jun 2020 21:06:33 +0300
Subject: [PATCH] ntdll: Exclude natively mapped areas from free areas list.
@ -8,10 +8,10 @@ Subject: [PATCH] ntdll: Exclude natively mapped areas from free areas list.
1 file changed, 109 insertions(+), 28 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 5bb9511be6d..f5281128543 100644
index cee8d1d5041..7c26c79649e 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -103,6 +103,7 @@ struct file_view
@@ -116,6 +116,7 @@ struct file_view
#define VPROT_WRITEWATCH 0x40
/* per-mapping protection flags */
#define VPROT_SYSTEM 0x0200 /* system view (underlying mmap not under our control) */
@ -19,7 +19,7 @@ index 5bb9511be6d..f5281128543 100644
/* Conversion from VPROT_* to Win32 flags */
static const BYTE VIRTUAL_Win32Flags[16] =
@@ -870,7 +871,9 @@ static void dump_view( struct file_view *view )
@@ -999,7 +1000,9 @@ static void dump_view( struct file_view *view )
BYTE prot = get_page_vprot( addr );
TRACE( "View: %p - %p", addr, addr + view->size - 1 );
@ -30,7 +30,7 @@ index 5bb9511be6d..f5281128543 100644
TRACE( " (builtin image)\n" );
else if (view->protect & SEC_IMAGE)
TRACE( " (image)\n" );
@@ -1012,6 +1015,16 @@ static struct file_view *find_view_range( const void *addr, size_t size )
@@ -1134,6 +1137,16 @@ static struct file_view *find_view_range( const void *addr, size_t size )
return NULL;
}
@ -47,7 +47,7 @@ index 5bb9511be6d..f5281128543 100644
/***********************************************************************
* try_map_free_area
@@ -1019,21 +1032,27 @@ static struct file_view *find_view_range( const void *addr, size_t size )
@@ -1141,21 +1154,27 @@ static struct file_view *find_view_range( const void *addr, size_t size )
* Try mmaping some expected free memory region, eventually stepping and
* retrying inside it, and return where it actually succeeded, or NULL.
*/
@ -80,7 +80,7 @@ index 5bb9511be6d..f5281128543 100644
if ((step > 0 && (char *)end - (char *)start < step) ||
(step < 0 && (char *)start - (char *)base < -step) ||
step == 0)
@@ -1475,15 +1494,6 @@ static inline void *unmap_extra_space( void *ptr, size_t total_size, size_t want
@@ -1597,15 +1616,6 @@ static inline void *unmap_extra_space( void *ptr, size_t total_size, size_t want
return ptr;
}
@ -96,7 +96,7 @@ index 5bb9511be6d..f5281128543 100644
static int CDECL alloc_area_in_reserved_or_between_callback( void *start, SIZE_T size, void *arg )
{
char *intersect_start, *intersect_end;
@@ -1509,8 +1519,8 @@ static int CDECL alloc_area_in_reserved_or_between_callback( void *start, SIZE_T
@@ -1631,8 +1641,8 @@ static int CDECL alloc_area_in_reserved_or_between_callback( void *start, SIZE_T
if (area->map_area_end - intersect_end >= area->size)
{
alloc_start = ROUND_ADDR( (char *)area->map_area_end - size, granularity_mask );
@ -107,7 +107,7 @@ index 5bb9511be6d..f5281128543 100644
return 1;
}
@@ -1545,8 +1555,8 @@ static int CDECL alloc_area_in_reserved_or_between_callback( void *start, SIZE_T
@@ -1667,8 +1677,8 @@ static int CDECL alloc_area_in_reserved_or_between_callback( void *start, SIZE_T
if (intersect_start - area->map_area_start >= area->size)
{
@ -118,7 +118,7 @@ index 5bb9511be6d..f5281128543 100644
return 1;
}
@@ -1601,8 +1611,7 @@ static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char
@@ -1723,8 +1733,7 @@ static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char
if (start >= area->map_area_end || start < area->map_area_start)
return NULL;
@ -128,7 +128,7 @@ index 5bb9511be6d..f5281128543 100644
}
else
{
@@ -1611,8 +1620,7 @@ static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char
@@ -1733,8 +1742,7 @@ static void *alloc_free_area_in_range( struct alloc_area *area, char *base, char
|| area->map_area_end - start < area->size)
return NULL;
@ -138,7 +138,7 @@ index 5bb9511be6d..f5281128543 100644
}
}
@@ -1622,6 +1630,7 @@ static void *alloc_free_area( void *limit, size_t size, BOOL top_down, int unix_
@@ -1744,6 +1752,7 @@ static void *alloc_free_area( void *limit, size_t size, BOOL top_down, int unix_
char *reserve_start, *reserve_end;
struct alloc_area area;
char *base, *end;
@ -146,7 +146,7 @@ index 5bb9511be6d..f5281128543 100644
int ranges_inc;
TRACE("limit %p, size %p, top_down %#x.\n", limit, (void *)size, top_down);
@@ -1677,16 +1686,67 @@ static void *alloc_free_area( void *limit, size_t size, BOOL top_down, int unix_
@@ -1799,16 +1808,67 @@ static void *alloc_free_area( void *limit, size_t size, BOOL top_down, int unix_
{
/* range is split in two by the preloader reservation, try first part. */
if ((area.result = alloc_free_area_in_range( &area, base, reserve_start )))
@ -217,7 +217,7 @@ index 5bb9511be6d..f5281128543 100644
}
/***********************************************************************
@@ -1740,6 +1800,17 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot )
@@ -1862,6 +1922,17 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot )
return STATUS_SUCCESS;
}
@ -235,21 +235,21 @@ index 5bb9511be6d..f5281128543 100644
/***********************************************************************
* map_view
*
@@ -1763,7 +1834,12 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
else if (!(ptr = alloc_free_area( (void*)(get_zero_bits_64_mask( zero_bits_64 )
@@ -1885,7 +1956,12 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
else if (!(ptr = alloc_free_area( (void*)(get_zero_bits_mask( zero_bits )
& (UINT_PTR)user_space_limit), size, top_down, get_unix_prot( vprot ) )))
{
- return STATUS_NO_MEMORY;
+ WARN("Allocation failed, clearing native views.\n");
+
+ clear_native_views();
+ if (!(ptr = alloc_free_area( (void*)(get_zero_bits_64_mask( zero_bits_64 )
+ if (!(ptr = alloc_free_area( (void*)(get_zero_bits_mask( zero_bits )
+ & (UINT_PTR)user_space_limit), size, top_down, get_unix_prot( vprot ) )))
+ return STATUS_NO_MEMORY;
}
status = create_view( view_ret, ptr, size, vprot );
if (status != STATUS_SUCCESS) unmap_area( ptr, size );
@@ -3222,7 +3298,12 @@ void virtual_set_force_exec( BOOL enable )
@@ -3538,7 +3614,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 */
@ -264,5 +264,5 @@ index 5bb9511be6d..f5281128543 100644
mprotect_range( view->base, view->size, commit, 0 );
}
--
2.26.2
2.30.2

View File

@ -51,7 +51,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "a64861fb66be722f3a93ab73152c5d477ba3bd3e"
echo "99e47361a37a4bf16de131401a0c231f86214a43"
}
# Show version information

View File

@ -1 +1 @@
a64861fb66be722f3a93ab73152c5d477ba3bd3e
99e47361a37a4bf16de131401a0c231f86214a43