From d7d95ca4b68e06485695f91685db66ad9e31b9d5 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 21 Mar 2015 00:14:26 +0100 Subject: [PATCH] server-Shared_Memory: Add a winediag warning message when shared memory is used. --- patches/patchinstall.sh | 2 - ...-Implement-virtual_map_shared_memory.patch | 6 +-- ...-support-for-global-and-local-shared.patch | 40 ++++++++++------ ...of-wineserver-call-for-GetInputState.patch | 2 +- ...ecessary-wineserver-calls-in-PeekMes.patch | 2 +- ...f-wineserver-call-for-GetLastInputIn.patch | 2 +- ...e-wineserver-shared-memory-communica.patch | 31 +++++++++--- ...ll-number-from-sys-syscall.h-if-poss.patch | 47 ------------------- 8 files changed, 57 insertions(+), 75 deletions(-) delete mode 100644 patches/server-Shared_Memory/0007-server-Use-syscall-number-from-sys-syscall.h-if-poss.patch diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 71103f8f..a7920e55 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -3841,7 +3841,6 @@ if test "$enable_server_Shared_Memory" -eq 1; then patch_apply server-Shared_Memory/0004-user32-Avoid-unnecessary-wineserver-calls-in-PeekMes.patch patch_apply server-Shared_Memory/0005-user32-Get-rid-of-wineserver-call-for-GetLastInputIn.patch patch_apply server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch - patch_apply server-Shared_Memory/0007-server-Use-syscall-number-from-sys-syscall.h-if-poss.patch ( echo '+ { "Sebastian Lackner", "ntdll: Implement virtual_map_shared_memory.", 1 },'; echo '+ { "Michael Müller", "server: Implement support for global and local shared memory blocks based on memfd.", 1 },'; @@ -3849,7 +3848,6 @@ if test "$enable_server_Shared_Memory" -eq 1; then echo '+ { "Sebastian Lackner", "user32: Avoid unnecessary wineserver calls in PeekMessage/GetMessage.", 1 },'; echo '+ { "Michael Müller", "user32: Get rid of wineserver call for GetLastInputInfo.", 1 },'; echo '+ { "Sebastian Lackner", "ntdll: Only enable wineserver shared memory communication when a special environment variable is set.", 1 },'; - echo '+ { "Sebastian Lackner", "server: Use syscall number from sys/syscall.h if possible.", 1 },'; ) >> "$patchlist" fi diff --git a/patches/server-Shared_Memory/0001-ntdll-Implement-virtual_map_shared_memory.patch b/patches/server-Shared_Memory/0001-ntdll-Implement-virtual_map_shared_memory.patch index 68b1b52f..81780452 100644 --- a/patches/server-Shared_Memory/0001-ntdll-Implement-virtual_map_shared_memory.patch +++ b/patches/server-Shared_Memory/0001-ntdll-Implement-virtual_map_shared_memory.patch @@ -1,4 +1,4 @@ -From 3298a6ca8d888b2636c870d34cb4f78272409bfd Mon Sep 17 00:00:00 2001 +From bbcb2837fc29e7823c89f408611dfc6c8700d058 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 18 Mar 2015 23:03:01 +0100 Subject: ntdll: Implement virtual_map_shared_memory. @@ -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 ab6bf9b..eb81294 100644 +index 9d29c33..bfe7266 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c -@@ -2739,6 +2739,58 @@ done: +@@ -2758,6 +2758,58 @@ done: /*********************************************************************** diff --git a/patches/server-Shared_Memory/0002-server-Implement-support-for-global-and-local-shared.patch b/patches/server-Shared_Memory/0002-server-Implement-support-for-global-and-local-shared.patch index e9ee56c2..29e637cc 100644 --- a/patches/server-Shared_Memory/0002-server-Implement-support-for-global-and-local-shared.patch +++ b/patches/server-Shared_Memory/0002-server-Implement-support-for-global-and-local-shared.patch @@ -1,4 +1,4 @@ -From 52d65729080fcbc24bda5578d81eff7414d9ca5e Mon Sep 17 00:00:00 2001 +From d4226297d14857b3b5d069af8ba7437fc2504939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 19 Mar 2015 01:22:34 +0100 Subject: server: Implement support for global and local shared memory blocks @@ -6,18 +6,18 @@ Subject: server: Implement support for global and local shared memory blocks --- dlls/ntdll/ntdll_misc.h | 1 + - dlls/ntdll/server.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ - dlls/ntdll/thread.c | 4 ++++ - include/wine/server.h | 11 +++++++++ + dlls/ntdll/server.c | 64 ++++++++++++++++++++++++++++++++++++++++++ + dlls/ntdll/thread.c | 4 +++ + include/wine/server.h | 11 ++++++++ include/winternl.h | 2 +- - server/fd.c | 27 +++++++++++++++++++++ - server/file.h | 8 +++++++ + server/fd.c | 27 ++++++++++++++++++ + server/file.h | 8 ++++++ server/main.c | 1 + - server/mapping.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ - server/protocol.def | 15 ++++++++++++ - server/thread.c | 7 ++++++ + server/mapping.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ + server/protocol.def | 15 ++++++++++ + server/thread.c | 7 +++++ server/thread.h | 2 ++ - 12 files changed, 205 insertions(+), 1 deletion(-) + 12 files changed, 215 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 41ef5cb..18e00c9 100644 @@ -240,31 +240,43 @@ index 7aed338..f984bfc 100644 return 0; } diff --git a/server/mapping.c b/server/mapping.c -index 64b3003..be624e5 100644 +index 64b3003..063dbb8 100644 --- a/server/mapping.c +++ b/server/mapping.c -@@ -31,6 +31,20 @@ +@@ -29,8 +29,32 @@ + #ifdef HAVE_SYS_MMAN_H + # include #endif ++#ifdef HAVE_SYS_SYSCALL_H ++# include ++#endif #include +#if defined(__linux__) && (defined(__i386__) || defined(__x86_64__)) ++ ++/* __NR_memfd_create might not yet be available when buildservers use an old kernel */ ++#ifndef __NR_memfd_create +#ifdef __x86_64__ +#define __NR_memfd_create 319 +#else +#define __NR_memfd_create 356 +#endif ++#endif ++ ++/* the following declarations are only available in linux/fcntl.h, but not fcntl.h */ +#define F_LINUX_SPECIFIC_BASE 1024 +#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) +#define MFD_ALLOW_SEALING 0x0002U +#define F_SEAL_SEAL 0x0001 +#define F_SEAL_SHRINK 0x0002 +#define F_SEAL_GROW 0x0004 ++ +#endif + #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" -@@ -112,6 +126,10 @@ static struct list shared_list = LIST_INIT(shared_list); +@@ -112,6 +136,10 @@ static struct list shared_list = LIST_INIT(shared_list); static size_t page_mask; @@ -275,7 +287,7 @@ index 64b3003..be624e5 100644 #define ROUND_SIZE(size) (((size) + page_mask) & ~page_mask) -@@ -156,6 +174,52 @@ static int check_current_dir_for_exec(void) +@@ -156,6 +184,52 @@ static int check_current_dir_for_exec(void) return (ret != MAP_FAILED); } diff --git a/patches/server-Shared_Memory/0003-user32-Get-rid-of-wineserver-call-for-GetInputState.patch b/patches/server-Shared_Memory/0003-user32-Get-rid-of-wineserver-call-for-GetInputState.patch index 7bd80de6..e5f0fd90 100644 --- a/patches/server-Shared_Memory/0003-user32-Get-rid-of-wineserver-call-for-GetInputState.patch +++ b/patches/server-Shared_Memory/0003-user32-Get-rid-of-wineserver-call-for-GetInputState.patch @@ -1,4 +1,4 @@ -From 494442ff993ad741dda2f6676e4d7d0cd7294ae8 Mon Sep 17 00:00:00 2001 +From 8a1c06c34baa7e2d2b6f0186932d86c0a9597824 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 19 Mar 2015 01:32:51 +0100 Subject: user32: Get rid of wineserver call for GetInputState. diff --git a/patches/server-Shared_Memory/0004-user32-Avoid-unnecessary-wineserver-calls-in-PeekMes.patch b/patches/server-Shared_Memory/0004-user32-Avoid-unnecessary-wineserver-calls-in-PeekMes.patch index eb49ff2e..09ce3806 100644 --- a/patches/server-Shared_Memory/0004-user32-Avoid-unnecessary-wineserver-calls-in-PeekMes.patch +++ b/patches/server-Shared_Memory/0004-user32-Avoid-unnecessary-wineserver-calls-in-PeekMes.patch @@ -1,4 +1,4 @@ -From 07da6f20d2cb5decee8362297af6c27a83da0137 Mon Sep 17 00:00:00 2001 +From de18d43e05db389d2d9d8d8e92e68bce609f720b Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 19 Mar 2015 02:07:24 +0100 Subject: user32: Avoid unnecessary wineserver calls in PeekMessage/GetMessage. diff --git a/patches/server-Shared_Memory/0005-user32-Get-rid-of-wineserver-call-for-GetLastInputIn.patch b/patches/server-Shared_Memory/0005-user32-Get-rid-of-wineserver-call-for-GetLastInputIn.patch index e027c204..284178e5 100644 --- a/patches/server-Shared_Memory/0005-user32-Get-rid-of-wineserver-call-for-GetLastInputIn.patch +++ b/patches/server-Shared_Memory/0005-user32-Get-rid-of-wineserver-call-for-GetLastInputIn.patch @@ -1,4 +1,4 @@ -From 4ea257275cb1453288507cf536974ee3c013d449 Mon Sep 17 00:00:00 2001 +From 23feeb06aebf6f8f040fb3b31d5088354284f976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 19 Mar 2015 02:18:37 +0100 Subject: user32: Get rid of wineserver call for GetLastInputInfo. diff --git a/patches/server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch b/patches/server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch index 3424b8f7..4e7065ac 100644 --- a/patches/server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch +++ b/patches/server-Shared_Memory/0006-ntdll-Only-enable-wineserver-shared-memory-communica.patch @@ -1,18 +1,26 @@ -From c7b1b681995a397cfc3fa9e9bba3415102217da1 Mon Sep 17 00:00:00 2001 +From 43b9d13abbf16e59eb7e4b807a68a3c2426c2698 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 19 Mar 2015 02:55:36 +0100 Subject: ntdll: Only enable wineserver shared memory communication when a special environment variable is set. --- - dlls/ntdll/server.c | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) + dlls/ntdll/server.c | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c -index 0b8e007..349fcc7 100644 +index 0b8e007..6155b6e 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c -@@ -968,6 +968,21 @@ static int server_get_shared_memory_fd( HANDLE thread, int *unix_fd ) +@@ -81,6 +81,7 @@ + #include "ntdll_misc.h" + + WINE_DEFAULT_DEBUG_CHANNEL(server); ++WINE_DECLARE_DEBUG_CHANNEL(winediag); + + /* Some versions of glibc don't define this */ + #ifndef SCM_RIGHTS +@@ -968,6 +969,21 @@ static int server_get_shared_memory_fd( HANDLE thread, int *unix_fd ) return ret; } @@ -34,7 +42,7 @@ index 0b8e007..349fcc7 100644 /*********************************************************************** * server_get_shared_memory -@@ -980,6 +995,9 @@ void *server_get_shared_memory( HANDLE thread ) +@@ -980,6 +996,9 @@ void *server_get_shared_memory( HANDLE thread ) void *mem = NULL; int fd = -1; @@ -44,6 +52,17 @@ index 0b8e007..349fcc7 100644 /* The global memory block is only requested once. No locking is * required because this function is called very early during the * process initialization for the first time. */ +@@ -994,7 +1013,10 @@ void *server_get_shared_memory( HANDLE thread ) + } + + if (!thread) ++ { ++ if (mem) WARN_(winediag)("Using shared memory wineserver communication\n"); + shmglobal = mem; ++ } + + return mem; + } -- 2.3.2 diff --git a/patches/server-Shared_Memory/0007-server-Use-syscall-number-from-sys-syscall.h-if-poss.patch b/patches/server-Shared_Memory/0007-server-Use-syscall-number-from-sys-syscall.h-if-poss.patch deleted file mode 100644 index b60b3021..00000000 --- a/patches/server-Shared_Memory/0007-server-Use-syscall-number-from-sys-syscall.h-if-poss.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 3fa7e694712c386d6dc6e3e4d708d2d8ad529bfe Mon Sep 17 00:00:00 2001 -From: Sebastian Lackner -Date: Thu, 19 Mar 2015 03:08:35 +0100 -Subject: server: Use syscall number from sys/syscall.h if possible. - ---- - server/mapping.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/server/mapping.c b/server/mapping.c -index be624e5..063dbb8 100644 ---- a/server/mapping.c -+++ b/server/mapping.c -@@ -29,20 +29,30 @@ - #ifdef HAVE_SYS_MMAN_H - # include - #endif -+#ifdef HAVE_SYS_SYSCALL_H -+# include -+#endif - #include - - #if defined(__linux__) && (defined(__i386__) || defined(__x86_64__)) -+ -+/* __NR_memfd_create might not yet be available when buildservers use an old kernel */ -+#ifndef __NR_memfd_create - #ifdef __x86_64__ - #define __NR_memfd_create 319 - #else - #define __NR_memfd_create 356 - #endif -+#endif -+ -+/* the following declarations are only available in linux/fcntl.h, but not fcntl.h */ - #define F_LINUX_SPECIFIC_BASE 1024 - #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) - #define MFD_ALLOW_SEALING 0x0002U - #define F_SEAL_SEAL 0x0001 - #define F_SEAL_SHRINK 0x0002 - #define F_SEAL_GROW 0x0004 -+ - #endif - - #include "ntstatus.h" --- -2.3.2 -