Signed-off-by: Fan WenJie fanwj@mail.ustc.edu.cn
Hook mmap and munmap seem to be the only solution for drivers such as OpenGL to allocate over 32-bit address. For example, Fairy and Sword 4 has some render problems on master branch of wine. The patch can solve the problems.
-- v2: ntdll:setting limit with checking server:setting range64 with checking
From: Fan WenJie fanwj@mail.ustc.edu.cn
Signed-off-by: Fan WenJie fanwj@mail.ustc.edu.cn --- server/mapping.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/server/mapping.c b/server/mapping.c index a795dc4b38b..e2003fbc10e 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -229,9 +229,24 @@ static struct addr_range ranges64;
void init_memory(void) { - page_mask = sysconf( _SC_PAGESIZE ) - 1; + size_t page_size = sysconf( _SC_PAGESIZE ); + page_mask = page_size - 1; free_map_addr( 0x60000000, 0x1c000000 ); - free_map_addr( 0x600000000000, 0x100000000000 ); + if (sizeof(void*) > 4) + { + size_t limit = 1LLU << 48U; + while(limit > 0x100000000LLU) + { + void* addr = (void*)(limit - page_size); + void* ret = mmap(addr, page_size, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); + size_t next = limit >> 1U; + if (ret == (void*)-1) ret = NULL; + if (ret) munmap(ret, page_size); + if (ret >= (void*)next) break; + limit = next; + } + free_map_addr( limit - (limit >> 4U), limit >> 4U ); + } }
static void ranges_dump( struct object *obj, int verbose )
From: Fan WenJie fanwj@mail.ustc.edu.cn
Signed-off-by: Fan WenJie fanwj@mail.ustc.edu.cn --- dlls/ntdll/unix/virtual.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 464f343a575..374d317ca33 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -557,7 +557,7 @@ static void mmap_init( const struct preload_info *preload_info ) /* if we don't have a preloader, try to reserve the space now */ reserve_area( (void *)0x000000010000, (void *)0x000068000000 ); reserve_area( (void *)0x00007f000000, (void *)0x00007fff0000 ); - reserve_area( (void *)0x7ffffe000000, (void *)0x7fffffff0000 ); + reserve_area( ((char *)user_space_limit) - 0x1ff0000, user_space_limit );
#endif } @@ -3245,6 +3245,24 @@ static void *alloc_virtual_heap( SIZE_T size ) return anon_mmap_alloc( size, PROT_READ | PROT_WRITE ); }
+#ifdef _WIN64 +static void set_space_limit(void) +{ + size_t limit = 1LLU << 48U; + while(limit > 0x100000000LLU) + { + void* addr = (void*)(limit - page_size); + void* ret = mmap(addr, page_size, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); + size_t next = limit >> 1U; + if (ret == (void*)-1) ret = NULL; + if (ret) munmap(ret, page_size); + if (ret >= (void*)next) break; + limit = next; + } + address_space_limit = user_space_limit = working_set_limit = (void*)(limit - 0x10000LLU); +} +#endif + /*********************************************************************** * virtual_init */ @@ -3261,6 +3279,10 @@ void virtual_init(void) pthread_mutex_init( &virtual_mutex, &attr ); pthread_mutexattr_destroy( &attr );
+#ifdef _WIN64 + set_space_limit(); +#endif + if (preload_info && *preload_info) for (i = 0; (*preload_info)[i].size; i++) mmap_add_reserved_area( (*preload_info)[i].addr, (*preload_info)[i].size );
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=139584
Your paranoid android.
=== debian11b (64 bit WoW report) ===
kernel32: loader.c:2383: Test failed: 4: NtMapViewOfSection failed 40000003 loader.c:2397: Test failed: 4: not at base 00007FFFFF460000 / 00007FFFFF210000 loader.c:2399: Test failed: 4: tls not relocated 00007FFFFF4610B8 / 00007FFFFF2110B8