mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
Added patch to reduce stack usage of virtual memory functions.
This commit is contained in:
parent
2f4c5ae81e
commit
f64d5ad94d
@ -39,11 +39,12 @@ Wine. All those differences are also documented on the
|
||||
Included bug fixes and improvements
|
||||
-----------------------------------
|
||||
|
||||
**Bug fixes and features included in the next upcoming release [4]:**
|
||||
**Bug fixes and features included in the next upcoming release [5]:**
|
||||
|
||||
* Add implementation for msidb commandline tool
|
||||
* Codepage conversion should fail when destination length is < 0
|
||||
* Implement semi-stub for d3d8 swapchain effect D3DSWAPEFFECT_COPY_VSYNC ([Wine Bug #37587](https://bugs.winehq.org/show_bug.cgi?id=37587))
|
||||
* Reduce stack usage of virtual memory functions ([Wine Bug #34558](https://bugs.winehq.org/show_bug.cgi?id=34558))
|
||||
* Return STATUS_INVALID_DEVICE_REQUEST when trying to call NtReadFile on directory
|
||||
|
||||
|
||||
|
1
debian/changelog
vendored
1
debian/changelog
vendored
@ -8,6 +8,7 @@ wine-staging (1.7.52) UNRELEASED; urgency=low
|
||||
* Added patches for msidb commandline utility (to read and write *.msi files).
|
||||
* Added patch to implement semi-stub for d3d8 swapchain effect
|
||||
D3DSWAPEFFECT_COPY_VSYNC.
|
||||
* Added patch to reduce stack usage of virtual memory functions.
|
||||
* Removed patch to fix possible memory leak in netprofm init_networks (fixed
|
||||
upstream).
|
||||
* Removed patch for stub of dwmapi.DwmUpdateThumbnailProperties (accepted
|
||||
|
@ -1,4 +1,4 @@
|
||||
From dae71e69de99580ced403804e944c7a13e0519e9 Mon Sep 17 00:00:00 2001
|
||||
From 25288a6031d1a4cf1a7e409eb06ac234d21761ac Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Fri, 21 Aug 2015 06:39:47 +0800
|
||||
Subject: ntdll: Do not allow to deallocate thread stack for current thread.
|
||||
@ -14,10 +14,10 @@ Subject: ntdll: Do not allow to deallocate thread stack for current thread.
|
||||
7 files changed, 57 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
|
||||
index 46776a6..14b47ac 100644
|
||||
index cbd19db..6e25915 100644
|
||||
--- a/dlls/ntdll/ntdll_misc.h
|
||||
+++ b/dlls/ntdll/ntdll_misc.h
|
||||
@@ -242,8 +242,18 @@ struct ntdll_thread_data
|
||||
@@ -240,8 +240,18 @@ struct ntdll_thread_data
|
||||
WINE_VM86_TEB_INFO vm86; /* 1fc vm86 private data */
|
||||
void *exit_frame; /* 204 exit frame pointer */
|
||||
#endif
|
||||
@ -37,7 +37,7 @@ index 46776a6..14b47ac 100644
|
||||
{
|
||||
return (struct ntdll_thread_data *)NtCurrentTeb()->SpareBytes1;
|
||||
diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c
|
||||
index cfb9df1..07c8b0a 100644
|
||||
index 1f6da96..a82eb91 100644
|
||||
--- a/dlls/ntdll/signal_arm.c
|
||||
+++ b/dlls/ntdll/signal_arm.c
|
||||
@@ -902,12 +902,19 @@ NTSTATUS signal_alloc_thread( TEB **teb )
|
||||
@ -61,7 +61,7 @@ index cfb9df1..07c8b0a 100644
|
||||
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
|
||||
}
|
||||
diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c
|
||||
index 7259831..09bdfe0 100644
|
||||
index 3a41c84..3ad412a 100644
|
||||
--- a/dlls/ntdll/signal_arm64.c
|
||||
+++ b/dlls/ntdll/signal_arm64.c
|
||||
@@ -776,12 +776,19 @@ NTSTATUS signal_alloc_thread( TEB **teb )
|
||||
@ -85,10 +85,10 @@ index 7259831..09bdfe0 100644
|
||||
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
|
||||
}
|
||||
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
|
||||
index f550c63..1007358 100644
|
||||
index 5c3aa819..28d9e29 100644
|
||||
--- a/dlls/ntdll/signal_i386.c
|
||||
+++ b/dlls/ntdll/signal_i386.c
|
||||
@@ -2616,12 +2616,18 @@ void signal_free_thread( TEB *teb )
|
||||
@@ -2367,12 +2367,18 @@ void signal_free_thread( TEB *teb )
|
||||
SIZE_T size;
|
||||
struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)teb->SpareBytes1;
|
||||
|
||||
@ -109,7 +109,7 @@ index f550c63..1007358 100644
|
||||
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
|
||||
}
|
||||
diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c
|
||||
index d2e7819..c673d6e 100644
|
||||
index 886da86..90644a4 100644
|
||||
--- a/dlls/ntdll/signal_powerpc.c
|
||||
+++ b/dlls/ntdll/signal_powerpc.c
|
||||
@@ -982,12 +982,19 @@ NTSTATUS signal_alloc_thread( TEB **teb )
|
||||
@ -133,7 +133,7 @@ index d2e7819..c673d6e 100644
|
||||
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
|
||||
}
|
||||
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
|
||||
index a1ee02d..1db9f27 100644
|
||||
index 575a770..2ced91e 100644
|
||||
--- a/dlls/ntdll/signal_x86_64.c
|
||||
+++ b/dlls/ntdll/signal_x86_64.c
|
||||
@@ -2732,12 +2732,19 @@ NTSTATUS signal_alloc_thread( TEB **teb )
|
||||
@ -157,19 +157,19 @@ index a1ee02d..1db9f27 100644
|
||||
NtFreeVirtualMemory( NtCurrentProcess(), (void **)&teb, &size, MEM_RELEASE );
|
||||
}
|
||||
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
|
||||
index 9d35693..b40674b 100644
|
||||
index 020a6c0..98de9e6 100644
|
||||
--- a/dlls/ntdll/virtual.c
|
||||
+++ b/dlls/ntdll/virtual.c
|
||||
@@ -1486,6 +1486,8 @@ NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, SIZE_T commi
|
||||
@@ -1469,6 +1469,8 @@ NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, SIZE_T commi
|
||||
teb->DeallocationStack = view->base;
|
||||
teb->Tib.StackBase = (char *)view->base + view->size;
|
||||
teb->Tib.StackLimit = (char *)view->base + 2 * page_size;
|
||||
+ ((struct ntdll_thread_data *)teb->SpareBytes1)->pthread_stack = view->base;
|
||||
+
|
||||
done:
|
||||
server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
virtual_unlock();
|
||||
return status;
|
||||
@@ -2119,6 +2121,16 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
@@ -2060,6 +2062,16 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
/* Free the pages */
|
||||
|
||||
if (size || (base != view->base)) status = STATUS_INVALID_PARAMETER;
|
||||
@ -187,5 +187,5 @@ index 9d35693..b40674b 100644
|
||||
{
|
||||
delete_view( view );
|
||||
--
|
||||
2.5.0
|
||||
2.5.1
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
Fixes: Do not allow to deallocate thread stack for current thread
|
||||
Depends: ntdll-Virtual_Memory_Stack
|
||||
|
@ -1,20 +1,20 @@
|
||||
From 9f83442a212635a7921420c56c217df0c0e46fc4 Mon Sep 17 00:00:00 2001
|
||||
From 134f935483d49fad68e814d21a30f483f606d386 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Wed, 20 Aug 2014 19:21:18 +0200
|
||||
Subject: ntdll: Move NtProtectVirtualMemory and NtCreateSection to separate
|
||||
pages on x86. (try 2)
|
||||
|
||||
---
|
||||
dlls/ntdll/virtual.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
dlls/ntdll/virtual.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
|
||||
index 4819d2d..63ba0a3 100644
|
||||
index 020a6c0..592d65f 100644
|
||||
--- a/dlls/ntdll/virtual.c
|
||||
+++ b/dlls/ntdll/virtual.c
|
||||
@@ -150,6 +150,13 @@ static void *preload_reserve_end;
|
||||
static BOOL use_locks;
|
||||
static BOOL force_exec_prot; /* whether to force PROT_EXEC on all PROT_READ mmaps */
|
||||
@@ -170,6 +170,14 @@ static void virtual_unlock(void)
|
||||
else RtlLeaveCriticalSection( &csVirtual );
|
||||
}
|
||||
|
||||
+#if defined(__i386__)
|
||||
+NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *size_ptr,
|
||||
@ -23,9 +23,10 @@ index 4819d2d..63ba0a3 100644
|
||||
+ const LARGE_INTEGER *size, ULONG protect,
|
||||
+ ULONG sec_flags, HANDLE file ) DECLSPEC_ALIGN(4096);
|
||||
+#endif
|
||||
|
||||
+
|
||||
/***********************************************************************
|
||||
* VIRTUAL_GetProtStr
|
||||
*/
|
||||
--
|
||||
1.9.1
|
||||
2.5.1
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
Fixes: [33162] Ensure NtProtectVirtualMemory and NtCreateSection are on separate pages
|
||||
Depends: ntdll-Virtual_Memory_Stack
|
||||
Category: stable
|
||||
|
@ -0,0 +1,549 @@
|
||||
From 14ab06b0949d7d2209fd767fbb83ce8a29fa1ac9 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Sat, 26 Sep 2015 23:14:58 +0200
|
||||
Subject: ntdll: Reduce stack usage by storing sigset in static memory.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Michael Müller <michael@fds-team.de>
|
||||
---
|
||||
dlls/ntdll/virtual.c | 128 +++++++++++++++++++++++++--------------------------
|
||||
1 file changed, 64 insertions(+), 64 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
|
||||
index 4d4bc3b..67857c6 100644
|
||||
--- a/dlls/ntdll/virtual.c
|
||||
+++ b/dlls/ntdll/virtual.c
|
||||
@@ -148,7 +148,27 @@ static void *preload_reserve_start;
|
||||
static void *preload_reserve_end;
|
||||
static BOOL use_locks;
|
||||
static BOOL force_exec_prot; /* whether to force PROT_EXEC on all PROT_READ mmaps */
|
||||
+static sigset_t virtual_sigset;
|
||||
|
||||
+static void virtual_lock(void)
|
||||
+{
|
||||
+ sigset_t sigset;
|
||||
+
|
||||
+ pthread_sigmask( SIG_BLOCK, &server_block_set, &sigset );
|
||||
+ RtlEnterCriticalSection( &csVirtual );
|
||||
+ if (csVirtual.RecursionCount == 1) virtual_sigset = sigset;
|
||||
+}
|
||||
+
|
||||
+static void virtual_unlock(void)
|
||||
+{
|
||||
+ if (csVirtual.RecursionCount == 1)
|
||||
+ {
|
||||
+ sigset_t sigset = virtual_sigset;
|
||||
+ RtlLeaveCriticalSection( &csVirtual );
|
||||
+ pthread_sigmask( SIG_SETMASK, &sigset, NULL );
|
||||
+ }
|
||||
+ else RtlLeaveCriticalSection( &csVirtual );
|
||||
+}
|
||||
|
||||
/***********************************************************************
|
||||
* VIRTUAL_GetProtStr
|
||||
@@ -227,16 +247,15 @@ static void VIRTUAL_DumpView( struct file_view *view )
|
||||
#ifdef WINE_VM_DEBUG
|
||||
static void VIRTUAL_Dump(void)
|
||||
{
|
||||
- sigset_t sigset;
|
||||
struct file_view *view;
|
||||
|
||||
TRACE( "Dump of all virtual memory views:\n" );
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
LIST_FOR_EACH_ENTRY( view, &views_list, struct file_view, entry )
|
||||
{
|
||||
VIRTUAL_DumpView( view );
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1069,14 +1088,13 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
|
||||
NTSTATUS status = STATUS_CONFLICTING_ADDRESSES;
|
||||
int i;
|
||||
off_t pos;
|
||||
- sigset_t sigset;
|
||||
struct stat st;
|
||||
struct file_view *view = NULL;
|
||||
char *ptr, *header_end, *header_start;
|
||||
|
||||
/* zero-map the whole range */
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
if (base >= (char *)address_space_start) /* make sure the DOS area remains free */
|
||||
status = map_view( &view, base, total_size, mask, FALSE,
|
||||
@@ -1267,7 +1285,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
|
||||
done:
|
||||
view->mapping = dup_mapping;
|
||||
view->map_protect = map_vprot;
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
|
||||
*addr_ptr = ptr;
|
||||
#ifdef VALGRIND_LOAD_PDB_DEBUGINFO
|
||||
@@ -1278,7 +1296,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
|
||||
|
||||
error:
|
||||
if (view) delete_view( view );
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
if (dup_mapping) NtClose( dup_mapping );
|
||||
return status;
|
||||
}
|
||||
@@ -1376,7 +1394,6 @@ void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info )
|
||||
NTSTATUS virtual_create_builtin_view( void *module )
|
||||
{
|
||||
NTSTATUS status;
|
||||
- sigset_t sigset;
|
||||
IMAGE_NT_HEADERS *nt = RtlImageNtHeader( module );
|
||||
SIZE_T size = nt->OptionalHeader.SizeOfImage;
|
||||
IMAGE_SECTION_HEADER *sec;
|
||||
@@ -1386,11 +1403,11 @@ NTSTATUS virtual_create_builtin_view( void *module )
|
||||
|
||||
size = ROUND_SIZE( module, size );
|
||||
base = ROUND_ADDR( module, page_mask );
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
status = create_view( &view, base, size, VPROT_SYSTEM | VPROT_IMAGE |
|
||||
VPROT_COMMITTED | VPROT_READ | VPROT_WRITECOPY | VPROT_EXEC );
|
||||
if (!status) TRACE( "created %p-%p\n", base, (char *)base + size );
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
|
||||
if (status) return status;
|
||||
|
||||
@@ -1420,7 +1437,6 @@ NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, SIZE_T commi
|
||||
{
|
||||
struct file_view *view;
|
||||
NTSTATUS status;
|
||||
- sigset_t sigset;
|
||||
SIZE_T size;
|
||||
|
||||
if (!reserve_size || !commit_size)
|
||||
@@ -1434,7 +1450,7 @@ NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, SIZE_T commi
|
||||
if (size < 1024 * 1024) size = 1024 * 1024; /* Xlib needs a large stack */
|
||||
size = (size + 0xffff) & ~0xffff; /* round to 64K boundary */
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
if ((status = map_view( &view, NULL, size, 0xffff, 0,
|
||||
VPROT_READ | VPROT_WRITE | VPROT_COMMITTED | VPROT_VALLOC )) != STATUS_SUCCESS)
|
||||
@@ -1454,7 +1470,7 @@ NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, SIZE_T commi
|
||||
teb->Tib.StackBase = (char *)view->base + view->size;
|
||||
teb->Tib.StackLimit = (char *)view->base + 2 * page_size;
|
||||
done:
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1481,9 +1497,8 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack )
|
||||
{
|
||||
struct file_view *view;
|
||||
NTSTATUS ret = STATUS_ACCESS_VIOLATION;
|
||||
- sigset_t sigset;
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
if ((view = VIRTUAL_FindView( addr, 0 )))
|
||||
{
|
||||
void *page = ROUND_ADDR( addr, page_mask );
|
||||
@@ -1504,7 +1519,7 @@ NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack )
|
||||
ret = STATUS_GUARD_PAGE_VIOLATION;
|
||||
}
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1517,12 +1532,11 @@ BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size )
|
||||
{
|
||||
struct file_view *view;
|
||||
BOOL ret = FALSE;
|
||||
- sigset_t sigset;
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
if ((view = VIRTUAL_FindView( addr, size )))
|
||||
ret = !(view->protect & VPROT_SYSTEM); /* system views are not visible to the app */
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1637,12 +1651,11 @@ BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size )
|
||||
SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T size )
|
||||
{
|
||||
struct file_view *view;
|
||||
- sigset_t sigset;
|
||||
SIZE_T bytes_read = 0;
|
||||
|
||||
if (!size) return 0;
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
if ((view = VIRTUAL_FindView( addr, size )))
|
||||
{
|
||||
if (!(view->protect & VPROT_SYSTEM))
|
||||
@@ -1661,7 +1674,7 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T
|
||||
}
|
||||
}
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
@@ -1676,12 +1689,11 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T
|
||||
SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size )
|
||||
{
|
||||
struct file_view *view;
|
||||
- sigset_t sigset;
|
||||
SIZE_T bytes_written = 0;
|
||||
|
||||
if (!size) return 0;
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
if ((view = VIRTUAL_FindView( addr, size )))
|
||||
{
|
||||
if (!(view->protect & VPROT_SYSTEM))
|
||||
@@ -1719,7 +1731,7 @@ SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_
|
||||
}
|
||||
}
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
@@ -1732,9 +1744,8 @@ SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_
|
||||
void VIRTUAL_SetForceExec( BOOL enable )
|
||||
{
|
||||
struct file_view *view;
|
||||
- sigset_t sigset;
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
if (!force_exec_prot != !enable) /* change all existing views */
|
||||
{
|
||||
force_exec_prot = enable;
|
||||
@@ -1776,7 +1787,7 @@ void VIRTUAL_SetForceExec( BOOL enable )
|
||||
}
|
||||
}
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
}
|
||||
|
||||
struct free_range
|
||||
@@ -1810,11 +1821,10 @@ static int free_reserved_memory( void *base, size_t size, void *arg )
|
||||
void virtual_release_address_space(void)
|
||||
{
|
||||
struct free_range range;
|
||||
- sigset_t sigset;
|
||||
|
||||
if (is_win64) return;
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
range.base = (char *)0x82000000;
|
||||
range.limit = user_space_limit;
|
||||
@@ -1832,7 +1842,7 @@ void virtual_release_address_space(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -1866,7 +1876,6 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
|
||||
SIZE_T mask = get_mask( zero_bits );
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
struct file_view *view;
|
||||
- sigset_t sigset;
|
||||
|
||||
TRACE("%p %p %08lx %x %08x\n", process, *ret, size, type, protect );
|
||||
|
||||
@@ -1916,14 +1925,14 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
|
||||
/* address 1 is magic to mean DOS area */
|
||||
if (!base && *ret == (void *)1 && size == 0x110000)
|
||||
{
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
status = allocate_dos_memory( &view, vprot );
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
*ret = view->base;
|
||||
*size_ptr = view->size;
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1950,7 +1959,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
|
||||
|
||||
/* Reserve the memory */
|
||||
|
||||
- if (use_locks) server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ if (use_locks) virtual_lock();
|
||||
|
||||
if ((type & MEM_RESERVE) || !base)
|
||||
{
|
||||
@@ -1981,7 +1990,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
|
||||
}
|
||||
}
|
||||
|
||||
- if (use_locks) server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ if (use_locks) virtual_unlock();
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
@@ -2000,7 +2009,6 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
{
|
||||
struct file_view *view;
|
||||
char *base;
|
||||
- sigset_t sigset;
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
LPVOID addr = *addr_ptr;
|
||||
SIZE_T size = *size_ptr;
|
||||
@@ -2037,7 +2045,7 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
/* avoid freeing the DOS area when a broken app passes a NULL pointer */
|
||||
if (!base) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
if (!(view = VIRTUAL_FindView( base, size )) || !(view->protect & VPROT_VALLOC))
|
||||
{
|
||||
@@ -2070,7 +2078,7 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T *si
|
||||
status = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2111,7 +2119,6 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T
|
||||
ULONG new_prot, ULONG *old_prot )
|
||||
{
|
||||
struct file_view *view;
|
||||
- sigset_t sigset;
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
char *base;
|
||||
BYTE vprot;
|
||||
@@ -2152,7 +2159,7 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T
|
||||
size = ROUND_SIZE( addr, size );
|
||||
base = ROUND_ADDR( addr, page_mask );
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
if ((view = VIRTUAL_FindView( base, size )))
|
||||
{
|
||||
@@ -2179,7 +2186,7 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T
|
||||
}
|
||||
else status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
@@ -2244,7 +2251,6 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr,
|
||||
struct list *ptr;
|
||||
SIZE_T size = 0;
|
||||
MEMORY_BASIC_INFORMATION *info = buffer;
|
||||
- sigset_t sigset;
|
||||
|
||||
if (info_class != MemoryBasicInformation)
|
||||
{
|
||||
@@ -2296,7 +2302,7 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr,
|
||||
|
||||
/* Find the view containing the address */
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
ptr = list_head( &views_list );
|
||||
for (;;)
|
||||
{
|
||||
@@ -2369,7 +2375,7 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr,
|
||||
if ((view->prot[size >> page_shift] ^ vprot) & ~VPROT_WRITEWATCH) break;
|
||||
info->RegionSize = size - (base - alloc_base);
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
|
||||
if (res_len) *res_len = sizeof(*info);
|
||||
return STATUS_SUCCESS;
|
||||
@@ -2549,7 +2555,6 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
|
||||
DWORD header_size;
|
||||
HANDLE dup_mapping, shared_file;
|
||||
LARGE_INTEGER offset;
|
||||
- sigset_t sigset;
|
||||
|
||||
offset.QuadPart = offset_ptr ? offset_ptr->QuadPart : 0;
|
||||
|
||||
@@ -2687,14 +2692,14 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
|
||||
|
||||
/* Reserve a properly aligned area */
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
get_vprot_flags( protect, &vprot, map_vprot & VPROT_IMAGE );
|
||||
vprot |= (map_vprot & VPROT_COMMITTED);
|
||||
res = map_view( &view, *addr_ptr, size, mask, FALSE, vprot );
|
||||
if (res)
|
||||
{
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -2719,7 +2724,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
|
||||
delete_view( view );
|
||||
}
|
||||
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
|
||||
done:
|
||||
if (dup_mapping) NtClose( dup_mapping );
|
||||
@@ -2736,7 +2741,6 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
|
||||
{
|
||||
struct file_view *view;
|
||||
NTSTATUS status = STATUS_NOT_MAPPED_VIEW;
|
||||
- sigset_t sigset;
|
||||
void *base = ROUND_ADDR( addr, page_mask );
|
||||
|
||||
if (process != NtCurrentProcess())
|
||||
@@ -2753,13 +2757,13 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
|
||||
return status;
|
||||
}
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
if ((view = VIRTUAL_FindView( base, 0 )) && (base == view->base) && !(view->protect & VPROT_VALLOC))
|
||||
{
|
||||
delete_view( view );
|
||||
status = STATUS_SUCCESS;
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2773,7 +2777,6 @@ NTSTATUS WINAPI NtFlushVirtualMemory( HANDLE process, LPCVOID *addr_ptr,
|
||||
{
|
||||
struct file_view *view;
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
- sigset_t sigset;
|
||||
void *addr = ROUND_ADDR( *addr_ptr, page_mask );
|
||||
|
||||
if (process != NtCurrentProcess())
|
||||
@@ -2797,7 +2800,7 @@ NTSTATUS WINAPI NtFlushVirtualMemory( HANDLE process, LPCVOID *addr_ptr,
|
||||
return result.virtual_flush.status;
|
||||
}
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
if (!(view = VIRTUAL_FindView( addr, *size_ptr ))) status = STATUS_INVALID_PARAMETER;
|
||||
else
|
||||
{
|
||||
@@ -2807,7 +2810,7 @@ NTSTATUS WINAPI NtFlushVirtualMemory( HANDLE process, LPCVOID *addr_ptr,
|
||||
if (msync( addr, *size_ptr, MS_ASYNC )) status = STATUS_NOT_MAPPED_DATA;
|
||||
#endif
|
||||
}
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2821,7 +2824,6 @@ NTSTATUS WINAPI NtGetWriteWatch( HANDLE process, ULONG flags, PVOID base, SIZE_T
|
||||
{
|
||||
struct file_view *view;
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
- sigset_t sigset;
|
||||
|
||||
size = ROUND_SIZE( base, size );
|
||||
base = ROUND_ADDR( base, page_mask );
|
||||
@@ -2835,7 +2837,7 @@ NTSTATUS WINAPI NtGetWriteWatch( HANDLE process, ULONG flags, PVOID base, SIZE_T
|
||||
TRACE( "%p %x %p-%p %p %lu\n", process, flags, base, (char *)base + size,
|
||||
addresses, *count );
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
if ((view = VIRTUAL_FindView( base, size )) && (view->protect & VPROT_WRITEWATCH))
|
||||
{
|
||||
@@ -2855,7 +2857,7 @@ NTSTATUS WINAPI NtGetWriteWatch( HANDLE process, ULONG flags, PVOID base, SIZE_T
|
||||
}
|
||||
else status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2868,7 +2870,6 @@ NTSTATUS WINAPI NtResetWriteWatch( HANDLE process, PVOID base, SIZE_T size )
|
||||
{
|
||||
struct file_view *view;
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
- sigset_t sigset;
|
||||
|
||||
size = ROUND_SIZE( base, size );
|
||||
base = ROUND_ADDR( base, page_mask );
|
||||
@@ -2877,14 +2878,14 @@ NTSTATUS WINAPI NtResetWriteWatch( HANDLE process, PVOID base, SIZE_T size )
|
||||
|
||||
if (!size) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
if ((view = VIRTUAL_FindView( base, size )) && (view->protect & VPROT_WRITEWATCH))
|
||||
reset_write_watches( view, base, size );
|
||||
else
|
||||
status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2958,11 +2959,10 @@ NTSTATUS WINAPI NtAreMappedFilesTheSame(PVOID addr1, PVOID addr2)
|
||||
struct file_view *view1, *view2;
|
||||
struct stat st1, st2;
|
||||
NTSTATUS status;
|
||||
- sigset_t sigset;
|
||||
|
||||
TRACE("%p %p\n", addr1, addr2);
|
||||
|
||||
- server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
|
||||
view1 = VIRTUAL_FindView( addr1, 0 );
|
||||
view2 = VIRTUAL_FindView( addr2, 0 );
|
||||
@@ -2981,6 +2981,6 @@ NTSTATUS WINAPI NtAreMappedFilesTheSame(PVOID addr1, PVOID addr2)
|
||||
else
|
||||
status = STATUS_NOT_SAME_DEVICE;
|
||||
|
||||
- server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
return status;
|
||||
}
|
||||
--
|
||||
2.5.1
|
||||
|
@ -0,0 +1,83 @@
|
||||
From 4facab424747869e5e6d99a95c8b984e0bf1f6af Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Sat, 26 Sep 2015 22:59:51 +0200
|
||||
Subject: ntdll: Save stack in NtAllocateVirtualMemory by moving remote memory
|
||||
allocation into separate function.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Michael Müller <michael@fds-team.de>
|
||||
---
|
||||
dlls/ntdll/virtual.c | 48 ++++++++++++++++++++++++++----------------------
|
||||
1 file changed, 26 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
|
||||
index 67857c6..020a6c0 100644
|
||||
--- a/dlls/ntdll/virtual.c
|
||||
+++ b/dlls/ntdll/virtual.c
|
||||
@@ -1862,6 +1862,31 @@ void virtual_set_large_address_space(void)
|
||||
user_space_limit = working_set_limit = address_space_limit;
|
||||
}
|
||||
|
||||
+static NTSTATUS allocate_memory_remote( HANDLE process, PVOID *ret, ULONG zero_bits,
|
||||
+ SIZE_T *size_ptr, ULONG type, ULONG protect )
|
||||
+{
|
||||
+ NTSTATUS status;
|
||||
+ apc_call_t call;
|
||||
+ apc_result_t result;
|
||||
+
|
||||
+ memset( &call, 0, sizeof(call) );
|
||||
+
|
||||
+ call.virtual_alloc.type = APC_VIRTUAL_ALLOC;
|
||||
+ call.virtual_alloc.addr = wine_server_client_ptr( *ret );
|
||||
+ call.virtual_alloc.size = *size_ptr;
|
||||
+ call.virtual_alloc.zero_bits = zero_bits;
|
||||
+ call.virtual_alloc.op_type = type;
|
||||
+ call.virtual_alloc.prot = protect;
|
||||
+ status = server_queue_process_apc( process, &call, &result );
|
||||
+ if (status != STATUS_SUCCESS) return status;
|
||||
+
|
||||
+ if (result.virtual_alloc.status == STATUS_SUCCESS)
|
||||
+ {
|
||||
+ *ret = wine_server_get_ptr( result.virtual_alloc.addr );
|
||||
+ *size_ptr = result.virtual_alloc.size;
|
||||
+ }
|
||||
+ return result.virtual_alloc.status;
|
||||
+}
|
||||
|
||||
/***********************************************************************
|
||||
* NtAllocateVirtualMemory (NTDLL.@)
|
||||
@@ -1882,28 +1907,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
|
||||
if (!size) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
if (process != NtCurrentProcess())
|
||||
- {
|
||||
- apc_call_t call;
|
||||
- apc_result_t result;
|
||||
-
|
||||
- memset( &call, 0, sizeof(call) );
|
||||
-
|
||||
- call.virtual_alloc.type = APC_VIRTUAL_ALLOC;
|
||||
- call.virtual_alloc.addr = wine_server_client_ptr( *ret );
|
||||
- call.virtual_alloc.size = *size_ptr;
|
||||
- call.virtual_alloc.zero_bits = zero_bits;
|
||||
- call.virtual_alloc.op_type = type;
|
||||
- call.virtual_alloc.prot = protect;
|
||||
- status = server_queue_process_apc( process, &call, &result );
|
||||
- if (status != STATUS_SUCCESS) return status;
|
||||
-
|
||||
- if (result.virtual_alloc.status == STATUS_SUCCESS)
|
||||
- {
|
||||
- *ret = wine_server_get_ptr( result.virtual_alloc.addr );
|
||||
- *size_ptr = result.virtual_alloc.size;
|
||||
- }
|
||||
- return result.virtual_alloc.status;
|
||||
- }
|
||||
+ return allocate_memory_remote( process, ret, zero_bits, size_ptr, type, protect );
|
||||
|
||||
/* Round parameters to a page boundary */
|
||||
|
||||
--
|
||||
2.5.1
|
||||
|
1
patches/ntdll-Virtual_Memory_Stack/definition
Normal file
1
patches/ntdll-Virtual_Memory_Stack/definition
Normal file
@ -0,0 +1 @@
|
||||
Fixes: [34558] Reduce stack usage of virtual memory functions
|
@ -207,6 +207,7 @@ patch_enable_all ()
|
||||
enable_ntdll_ThreadTime="$1"
|
||||
enable_ntdll_Threading="$1"
|
||||
enable_ntdll_User_Shared_Data="$1"
|
||||
enable_ntdll_Virtual_Memory_Stack="$1"
|
||||
enable_ntdll_WRITECOPY="$1"
|
||||
enable_ntdll_WinSqm="$1"
|
||||
enable_ntdll_WriteWatches="$1"
|
||||
@ -715,6 +716,9 @@ patch_enable ()
|
||||
ntdll-User_Shared_Data)
|
||||
enable_ntdll_User_Shared_Data="$2"
|
||||
;;
|
||||
ntdll-Virtual_Memory_Stack)
|
||||
enable_ntdll_Virtual_Memory_Stack="$2"
|
||||
;;
|
||||
ntdll-WRITECOPY)
|
||||
enable_ntdll_WRITECOPY="$2"
|
||||
;;
|
||||
@ -1893,6 +1897,13 @@ if test "$enable_ntdll_NtQueryEaFile" -eq 1; then
|
||||
enable_ntdll_Empty_Path=1
|
||||
fi
|
||||
|
||||
if test "$enable_ntdll_Fix_Alignment" -eq 1; then
|
||||
if test "$enable_ntdll_Virtual_Memory_Stack" -gt 1; then
|
||||
abort "Patchset ntdll-Virtual_Memory_Stack disabled, but ntdll-Fix_Alignment depends on that."
|
||||
fi
|
||||
enable_ntdll_Virtual_Memory_Stack=1
|
||||
fi
|
||||
|
||||
if test "$enable_ntdll_DllRedirects" -eq 1; then
|
||||
if test "$enable_ntdll_Loader_Machine_Type" -gt 1; then
|
||||
abort "Patchset ntdll-Loader_Machine_Type disabled, but ntdll-DllRedirects depends on that."
|
||||
@ -1900,6 +1911,13 @@ if test "$enable_ntdll_DllRedirects" -eq 1; then
|
||||
enable_ntdll_Loader_Machine_Type=1
|
||||
fi
|
||||
|
||||
if test "$enable_ntdll_Dealloc_Thread_Stack" -eq 1; then
|
||||
if test "$enable_ntdll_Virtual_Memory_Stack" -gt 1; then
|
||||
abort "Patchset ntdll-Virtual_Memory_Stack disabled, but ntdll-Dealloc_Thread_Stack depends on that."
|
||||
fi
|
||||
enable_ntdll_Virtual_Memory_Stack=1
|
||||
fi
|
||||
|
||||
if test "$enable_ntdll_CLI_Images" -eq 1; then
|
||||
if test "$enable_mscoree_CorValidateImage" -gt 1; then
|
||||
abort "Patchset mscoree-CorValidateImage disabled, but ntdll-CLI_Images depends on that."
|
||||
@ -2010,6 +2028,13 @@ if test "$enable_ntdll_WRITECOPY" -eq 1; then
|
||||
enable_ws2_32_WriteWatches=1
|
||||
fi
|
||||
|
||||
if test "$enable_ws2_32_WriteWatches" -eq 1; then
|
||||
if test "$enable_ntdll_Virtual_Memory_Stack" -gt 1; then
|
||||
abort "Patchset ntdll-Virtual_Memory_Stack disabled, but ws2_32-WriteWatches depends on that."
|
||||
fi
|
||||
enable_ntdll_Virtual_Memory_Stack=1
|
||||
fi
|
||||
|
||||
|
||||
# If autoupdate is enabled then create a tempfile to keep track of all patches
|
||||
if test "$enable_patchlist" -eq 1; then
|
||||
@ -2038,8 +2063,28 @@ if test "$enable_Compiler_Warnings" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset ntdll-Virtual_Memory_Stack
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#34558] Reduce stack usage of virtual memory functions
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/ntdll/virtual.c
|
||||
# |
|
||||
if test "$enable_ntdll_Virtual_Memory_Stack" -eq 1; then
|
||||
patch_apply ntdll-Virtual_Memory_Stack/0001-ntdll-Reduce-stack-usage-by-storing-sigset-in-static.patch
|
||||
patch_apply ntdll-Virtual_Memory_Stack/0002-ntdll-Save-stack-in-NtAllocateVirtualMemory-by-movin.patch
|
||||
(
|
||||
echo '+ { "Michael Müller", "ntdll: Reduce stack usage by storing sigset in static memory.", 1 },';
|
||||
echo '+ { "Michael Müller", "ntdll: Save stack in NtAllocateVirtualMemory by moving remote memory allocation into separate function.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset ws2_32-WriteWatches
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * ntdll-Virtual_Memory_Stack
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/ntdll/ntdll.spec, dlls/ntdll/ntdll_misc.h, dlls/ntdll/signal_i386.c, dlls/ntdll/virtual.c, dlls/ws2_32/socket.c,
|
||||
# | include/winternl.h
|
||||
@ -2056,7 +2101,7 @@ fi
|
||||
# Patchset ntdll-WRITECOPY
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * ws2_32-WriteWatches
|
||||
# | * ntdll-Virtual_Memory_Stack, ws2_32-WriteWatches
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#29384] Voobly expects correct handling of WRITECOPY memory protection
|
||||
@ -2085,7 +2130,7 @@ fi
|
||||
# Patchset Exagear
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * ws2_32-WriteWatches, ntdll-WRITECOPY
|
||||
# | * ntdll-Virtual_Memory_Stack, ws2_32-WriteWatches, ntdll-WRITECOPY
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * configure.ac, dlls/ntdll/signal_i386.c, dlls/ntdll/virtual.c, server/ptrace.c
|
||||
@ -3878,6 +3923,9 @@ fi
|
||||
|
||||
# Patchset ntdll-Dealloc_Thread_Stack
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * ntdll-Virtual_Memory_Stack
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/ntdll/ntdll_misc.h, dlls/ntdll/signal_arm.c, dlls/ntdll/signal_arm64.c, dlls/ntdll/signal_i386.c,
|
||||
# | dlls/ntdll/signal_powerpc.c, dlls/ntdll/signal_x86_64.c, dlls/ntdll/virtual.c
|
||||
@ -4000,6 +4048,9 @@ fi
|
||||
|
||||
# Patchset ntdll-Fix_Alignment
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * ntdll-Virtual_Memory_Stack
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#33162] Ensure NtProtectVirtualMemory and NtCreateSection are on separate pages
|
||||
# |
|
||||
@ -4277,7 +4328,7 @@ fi
|
||||
# Patchset ntdll-WriteWatches
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * rpcrt4-Pipe_Transport, kernel32-Named_Pipe, ws2_32-WriteWatches
|
||||
# | * rpcrt4-Pipe_Transport, kernel32-Named_Pipe, ntdll-Virtual_Memory_Stack, ws2_32-WriteWatches
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/ntdll/file.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
From bbcb2837fc29e7823c89f408611dfc6c8700d058 Mon Sep 17 00:00:00 2001
|
||||
From b7a6d8f0acb9dca71c277ded977d6cf60240dbba Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Wed, 18 Mar 2015 23:03:01 +0100
|
||||
Subject: ntdll: Implement virtual_map_shared_memory.
|
||||
@ -6,11 +6,11 @@ Subject: ntdll: Implement virtual_map_shared_memory.
|
||||
Preparation for shared memory wineserver communication.
|
||||
---
|
||||
dlls/ntdll/ntdll_misc.h | 1 +
|
||||
dlls/ntdll/virtual.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 53 insertions(+)
|
||||
dlls/ntdll/virtual.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 52 insertions(+)
|
||||
|
||||
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
|
||||
index 674fcbc..41ef5cb 100644
|
||||
index cbd19db..7eded42 100644
|
||||
--- a/dlls/ntdll/ntdll_misc.h
|
||||
+++ b/dlls/ntdll/ntdll_misc.h
|
||||
@@ -166,6 +166,7 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S
|
||||
@ -22,10 +22,10 @@ index 674fcbc..41ef5cb 100644
|
||||
extern BOOL virtual_handle_stack_fault( void *addr ) DECLSPEC_HIDDEN;
|
||||
extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLSPEC_HIDDEN;
|
||||
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
|
||||
index 9d29c33..bfe7266 100644
|
||||
index 91db4d6..8027556 100644
|
||||
--- a/dlls/ntdll/virtual.c
|
||||
+++ b/dlls/ntdll/virtual.c
|
||||
@@ -2758,6 +2758,58 @@ done:
|
||||
@@ -2734,6 +2734,57 @@ done:
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
@ -37,7 +37,6 @@ index 9d29c33..bfe7266 100644
|
||||
+ SIZE_T size, mask = get_mask( zero_bits );
|
||||
+ struct file_view *view;
|
||||
+ unsigned int vprot;
|
||||
+ sigset_t sigset;
|
||||
+ NTSTATUS res;
|
||||
+ int prot;
|
||||
+
|
||||
@ -45,7 +44,7 @@ index 9d29c33..bfe7266 100644
|
||||
+ if (size < *size_ptr)
|
||||
+ return STATUS_INVALID_PARAMETER;
|
||||
+
|
||||
+ server_enter_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_lock();
|
||||
+
|
||||
+ get_vprot_flags( protect, &vprot, FALSE );
|
||||
+ vprot |= VPROT_COMMITTED;
|
||||
@ -75,7 +74,7 @@ index 9d29c33..bfe7266 100644
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ server_leave_uninterrupted_section( &csVirtual, &sigset );
|
||||
+ virtual_unlock();
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
@ -85,5 +84,5 @@ index 9d29c33..bfe7266 100644
|
||||
* ZwUnmapViewOfSection (NTDLL.@)
|
||||
*/
|
||||
--
|
||||
2.3.2
|
||||
2.5.1
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From c81fa97c5fc573dd3bc40dcee861ad7c70abc4d9 Mon Sep 17 00:00:00 2001
|
||||
From e09548baea24d9965e2beafc251bb69443424b25 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Sat, 3 Jan 2015 20:07:08 +0100
|
||||
Subject: ntdll: Expose wine_uninterrupted_[read|write]_memory as exports.
|
||||
@ -12,10 +12,10 @@ Subject: ntdll: Expose wine_uninterrupted_[read|write]_memory as exports.
|
||||
5 files changed, 34 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
|
||||
index 9355d04..c13a555 100644
|
||||
index ca3561d..52e7276 100644
|
||||
--- a/dlls/ntdll/ntdll.spec
|
||||
+++ b/dlls/ntdll/ntdll.spec
|
||||
@@ -1430,6 +1430,10 @@
|
||||
@@ -1463,6 +1463,10 @@
|
||||
# signal handling
|
||||
@ cdecl __wine_set_signal_handler(long ptr)
|
||||
|
||||
@ -27,7 +27,7 @@ index 9355d04..c13a555 100644
|
||||
@ cdecl wine_nt_to_unix_file_name(ptr ptr long long)
|
||||
@ cdecl wine_unix_to_nt_file_name(ptr ptr)
|
||||
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
|
||||
index 674fcbc..79eea52 100644
|
||||
index cbd19db..f5b5339 100644
|
||||
--- a/dlls/ntdll/ntdll_misc.h
|
||||
+++ b/dlls/ntdll/ntdll_misc.h
|
||||
@@ -172,8 +172,6 @@ extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLS
|
||||
@ -75,10 +75,10 @@ index 5c3aa819..cf20483 100644
|
||||
{
|
||||
context->Ecx = stack[0];
|
||||
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
|
||||
index e5bf705..4392c3e 100644
|
||||
index 020a6c0..eb8893b 100644
|
||||
--- a/dlls/ntdll/virtual.c
|
||||
+++ b/dlls/ntdll/virtual.c
|
||||
@@ -1672,13 +1672,14 @@ BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size )
|
||||
@@ -1642,13 +1642,14 @@ BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size )
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
@ -95,8 +95,8 @@ index e5bf705..4392c3e 100644
|
||||
+SIZE_T CDECL wine_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T size )
|
||||
{
|
||||
struct file_view *view;
|
||||
sigset_t sigset;
|
||||
@@ -1697,10 +1698,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T
|
||||
SIZE_T bytes_read = 0;
|
||||
@@ -1666,10 +1667,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T
|
||||
while (bytes_read < size && (VIRTUAL_GetUnixProt( *p++ ) & PROT_READ))
|
||||
{
|
||||
SIZE_T block_size = min( size, page_size - ((UINT_PTR)addr & page_mask) );
|
||||
@ -114,7 +114,7 @@ index e5bf705..4392c3e 100644
|
||||
bytes_read += block_size;
|
||||
}
|
||||
}
|
||||
@@ -1711,13 +1716,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T
|
||||
@@ -1680,13 +1685,14 @@ SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
@ -131,8 +131,8 @@ index e5bf705..4392c3e 100644
|
||||
+SIZE_T CDECL wine_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size )
|
||||
{
|
||||
struct file_view *view;
|
||||
sigset_t sigset;
|
||||
@@ -1756,10 +1762,14 @@ SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_
|
||||
SIZE_T bytes_written = 0;
|
||||
@@ -1723,10 +1729,14 @@ SIZE_T virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_
|
||||
}
|
||||
|
||||
block_size = min( size, page_size - ((UINT_PTR)addr & page_mask) );
|
||||
@ -151,10 +151,10 @@ index e5bf705..4392c3e 100644
|
||||
}
|
||||
}
|
||||
diff --git a/include/winternl.h b/include/winternl.h
|
||||
index 1a694da..02dda9a 100644
|
||||
index 2b10f8d..bd7ba4e 100644
|
||||
--- a/include/winternl.h
|
||||
+++ b/include/winternl.h
|
||||
@@ -2605,6 +2605,9 @@ NTSYSAPI NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW,
|
||||
@@ -2660,6 +2660,9 @@ NTSYSAPI NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW,
|
||||
UINT disposition, BOOLEAN check_case );
|
||||
NTSYSAPI NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRING *nt );
|
||||
|
||||
@ -165,5 +165,5 @@ index 1a694da..02dda9a 100644
|
||||
/***********************************************************************
|
||||
* Inline functions
|
||||
--
|
||||
2.3.0
|
||||
2.5.1
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
Fixes: Avoid race-conditions of async WSARecv() operations with write watches.
|
||||
Fixes: Avoid race-conditions with write watches in WS2_async_accept.
|
||||
Fixes: Basic handling of write watches triggered while we're on the signal stack.
|
||||
Depends: ntdll-Virtual_Memory_Stack
|
||||
Category: stable
|
||||
|
Loading…
x
Reference in New Issue
Block a user