ntdll-ForceBottomUpAlloc: Add patch.

This commit is contained in:
Paul Gofman 2019-11-26 15:05:31 +03:00
parent ced0f96514
commit f4987b47e3
3 changed files with 94 additions and 0 deletions

View File

@ -0,0 +1,59 @@
From 54b9382fdda1798216b23db8273c79aaf649f8ff Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Mon, 25 Nov 2019 12:19:20 +0300
Subject: [PATCH] ntdll: Force bottom up allocation order for 64 bit arch
unless top down is requested.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48175
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46568
---
dlls/ntdll/virtual.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 9666e2051e..23acca6378 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1231,14 +1231,20 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
}
else
{
- size_t view_size = size + mask + 1;
struct alloc_area alloc;
+ size_t view_size;
alloc.size = size;
alloc.mask = mask;
alloc.top_down = top_down;
alloc.limit = (void*)(get_zero_bits_64_mask( zero_bits_64 ) & (UINT_PTR)user_space_limit);
+ if (is_win64 && !top_down)
+ {
+ /* Ditch 0x7ffffe000000 - 0x7fffffff0000 reserved area. */
+ alloc.limit = min(alloc.limit, (void *)0x7ffffe000000);
+ }
+
if (wine_mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down ))
{
ptr = alloc.result;
@@ -1248,7 +1254,7 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
goto done;
}
- if (zero_bits_64)
+ if (is_win64 || zero_bits_64)
{
if (!(ptr = find_free_area(address_space_start, alloc.limit, size,
mask, top_down, TRUE, VIRTUAL_GetUnixProt(vprot))))
@@ -1257,6 +1263,8 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
goto done;
}
+ view_size = size + mask + 1;
+
for (;;)
{
if ((ptr = wine_anon_mmap(NULL, view_size, VIRTUAL_GetUnixProt(vprot), 0 )) == (void *)-1)
--
2.23.0

View File

@ -0,0 +1,4 @@
Fixes: [48175] AION (64 bit) - crashes in crysystem.dll.CryFree() due to high memory pointers allocated
Fixes: [46568] 64-bit msxml6.dll from Microsoft Core XML Services 6.0 redist package fails to load (Wine doesn't respect 44-bit user-mode VA limitation from Windows < 8.1)
Depends: ntdll-BitmaskAllocAreaSearch

View File

@ -190,6 +190,7 @@ patch_enable_all ()
enable_ntdll_FileFsFullSizeInformation="$1"
enable_ntdll_FileFsVolumeInformation="$1"
enable_ntdll_Fix_Alignment="$1"
enable_ntdll_ForceBottomUpAlloc="$1"
enable_ntdll_HashLinks="$1"
enable_ntdll_Heap_Improvements="$1"
enable_ntdll_Hide_Wine_Exports="$1"
@ -694,6 +695,9 @@ patch_enable ()
ntdll-Fix_Alignment)
enable_ntdll_Fix_Alignment="$2"
;;
ntdll-ForceBottomUpAlloc)
enable_ntdll_ForceBottomUpAlloc="$2"
;;
ntdll-HashLinks)
enable_ntdll_HashLinks="$2"
;;
@ -1782,6 +1786,13 @@ if test "$enable_ntdll_HashLinks" -eq 1; then
enable_ntdll_LDR_MODULE=1
fi
if test "$enable_ntdll_ForceBottomUpAlloc" -eq 1; then
if test "$enable_ntdll_BitmaskAllocAreaSearch" -gt 1; then
abort "Patchset ntdll-BitmaskAllocAreaSearch disabled, but ntdll-ForceBottomUpAlloc depends on that."
fi
enable_ntdll_BitmaskAllocAreaSearch=1
fi
if test "$enable_ntdll_DOS_Attributes" -eq 1; then
if test "$enable_ntdll_Junction_Points" -gt 1; then
abort "Patchset ntdll-Junction_Points disabled, but ntdll-DOS_Attributes depends on that."
@ -4689,6 +4700,26 @@ if test "$enable_ntdll_Fix_Alignment" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-ForceBottomUpAlloc
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-BitmaskAllocAreaSearch
# |
# | This patchset fixes the following Wine bugs:
# | * [#48175] AION (64 bit) - crashes in crysystem.dll.CryFree() due to high memory pointers allocated
# | * [#46568] 64-bit msxml6.dll from Microsoft Core XML Services 6.0 redist package fails to load (Wine doesn't respect
# | 44-bit user-mode VA limitation from Windows < 8.1)
# |
# | Modified files:
# | * dlls/ntdll/virtual.c
# |
if test "$enable_ntdll_ForceBottomUpAlloc" -eq 1; then
patch_apply ntdll-ForceBottomUpAlloc/0001-ntdll-Force-bottom-up-allocation-order-for-64-bit-ar.patch
(
printf '%s\n' '+ { "Paul Gofman", "ntdll: Force bottom up allocation order for 64 bit arch unless top down is requested.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-LDR_MODULE
# |
# | Modified files: