Rebase against fdb3d9ae320363c1bd9fa716b167a7ad313e638b.

This commit is contained in:
Zebediah Figura
2020-07-13 17:56:04 -05:00
parent 4d315a6098
commit 913b39b117
5 changed files with 11 additions and 101 deletions

View File

@@ -1,35 +0,0 @@
From 980ca40adb1f4d268b42f434c353dc461df19b49 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Thu, 9 Jan 2020 15:05:09 +0300
Subject: [PATCH] ntdll: Stop search on mmap() error in try_map_free_area().
The anon mmap errors do not depend on start address hint. Ignoring them
makes the search take incredible time until it fails.
---
dlls/ntdll/unix/virtual.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 04889113c339..088e73b17b34 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1063,8 +1063,14 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
return start;
TRACE( "Found free area is already mapped, start %p.\n", start );
- if (ptr != (void *)-1)
- munmap( ptr, size );
+ if (ptr == (void *)-1)
+ {
+ ERR("wine_anon_mmap() error %s, start %p, size %p, unix_prot %#x.\n",
+ strerror(errno), start, (void *)size, unix_prot);
+ return NULL;
+ }
+
+ munmap( ptr, size );
if ((step > 0 && (char *)end - (char *)start < step) ||
(step < 0 && (char *)start - (char *)base < -step) ||
--
2.26.2

View File

@@ -1,51 +0,0 @@
From 1aa1c57302aef175849799185f324e461161f9eb Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Thu, 16 Jan 2020 16:09:24 +0300
Subject: [PATCH] ntdll: Use MAP_FIXED_NOREPLACE flag in try_map_free_area() if
available.
Avoids actual mapping followed by unmapping back if the memory range is
already mapped.
---
dlls/ntdll/unix/virtual.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 088e73b17b34..3907b0db70a9 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1055,22 +1055,28 @@ static struct wine_rb_entry *find_view_inside_range( void **base_ptr, void **end
static void* try_map_free_area( void *base, void *end, ptrdiff_t step,
void *start, size_t size, int unix_prot )
{
+#ifdef MAP_FIXED_NOREPLACE
+ static int flags = MAP_FIXED_NOREPLACE;
+#else
+ static int flags = 0;
+#endif
void *ptr;
while (start && base <= start && (char*)start + size <= (char*)end)
{
- if ((ptr = wine_anon_mmap( start, size, unix_prot, 0 )) == start)
+ if ((ptr = wine_anon_mmap( start, size, unix_prot, flags )) == start)
return start;
TRACE( "Found free area is already mapped, start %p.\n", start );
- if (ptr == (void *)-1)
+ if (ptr == (void *)-1 && errno != EEXIST)
{
ERR("wine_anon_mmap() error %s, start %p, size %p, unix_prot %#x.\n",
strerror(errno), start, (void *)size, unix_prot);
return NULL;
}
- munmap( ptr, size );
+ if (ptr != (void *)-1)
+ munmap( ptr, size );
if ((step > 0 && (char *)end - (char *)start < step) ||
(step < 0 && (char *)start - (char *)base < -step) ||
--
2.26.2