From: Jacek Caban <jacek@codeweavers.com> Allows clients to use a different page size than the server. --- dlls/ntdll/unix/server.c | 1 + dlls/ntdll/unix/unix_private.h | 1 + dlls/ntdll/unix/virtual.c | 10 ++++++++++ server/mapping.c | 2 +- server/process.c | 1 + server/process.h | 1 + server/protocol.def | 1 + server/ptrace.c | 2 +- server/thread.c | 1 + 9 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index 24f2c20fbb1..60fa7704458 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -1672,6 +1672,7 @@ size_t server_init_process(void) req->reply_fd = reply_pipe; req->wait_fd = data->wait_fd[1]; req->debug_level = (TRACE_ON(server) != 0); + req->page_size = get_host_page_size(); wine_server_set_reply( req, supported_machines, sizeof(supported_machines) ); if (!(ret = wine_server_call( req ))) { diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 4188a30acd2..64b712261f7 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -295,6 +295,7 @@ extern void *anon_mmap_fixed( void *start, size_t size, int prot, int flags ); extern void *anon_mmap_alloc( size_t size, int prot ); extern void virtual_init(void); extern ULONG_PTR get_system_affinity_mask(void); +extern UINT_PTR get_host_page_size(void); extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info, BOOL wow64 ); extern NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size, SECTION_IMAGE_INFORMATION *info, ULONG_PTR limit_low, diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 3629fd1b2cf..40e5abb8b94 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -3733,6 +3733,16 @@ ULONG_PTR get_system_affinity_mask(void) return ((ULONG_PTR)1 << num_cpus) - 1; } + +/*********************************************************************** + * get_host_page_size + */ +UINT_PTR get_host_page_size(void) +{ + return host_page_size; +} + + /*********************************************************************** * virtual_get_system_info */ diff --git a/server/mapping.c b/server/mapping.c index f9a80bc6cf9..e9768091aba 100644 --- a/server/mapping.c +++ b/server/mapping.c @@ -437,7 +437,7 @@ static int is_valid_view_addr( struct process *process, client_ptr_t addr, mem_s struct memory_view *view; if (!size) return 0; - if (addr & host_page_mask) return 0; + if (addr & (process->page_size - 1)) return 0; if (addr + size < addr) return 0; /* overflow */ /* check for overlapping view */ diff --git a/server/process.c b/server/process.c index fb662005bcb..cb3f959436d 100644 --- a/server/process.c +++ b/server/process.c @@ -671,6 +671,7 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla process->sigkill_timeout = NULL; process->sigkill_delay = TICKS_PER_SEC / 64; process->machine = native_machine; + process->page_size = get_page_size(); process->unix_pid = -1; process->exit_code = STILL_ACTIVE; process->running_threads = 0; diff --git a/server/process.h b/server/process.h index 5c136fb5103..6c467bd33ea 100644 --- a/server/process.h +++ b/server/process.h @@ -50,6 +50,7 @@ struct process struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */ timeout_t sigkill_delay; /* delay before final SIGKILL */ unsigned short machine; /* client machine type */ + unsigned int page_size; /* client page size */ int unix_pid; /* Unix pid for final SIGKILL */ int exit_code; /* process exit code */ int running_threads; /* number of threads running in this process */ diff --git a/server/protocol.def b/server/protocol.def index 5bca381fd91..cf23258f8b1 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1154,6 +1154,7 @@ typedef volatile struct int debug_level; /* new debug level */ int reply_fd; /* fd for reply pipe */ int wait_fd; /* fd for blocking calls pipe */ + unsigned int page_size; /* client page size */ @REPLY process_id_t pid; /* process id of the new thread's process */ thread_id_t tid; /* thread id of the new thread */ diff --git a/server/ptrace.c b/server/ptrace.c index a8fb85a1794..2e6d93b7214 100644 --- a/server/ptrace.c +++ b/server/ptrace.c @@ -492,7 +492,7 @@ int read_process_memory( struct process *process, client_ptr_t ptr, data_size_t /* len is the total size (in longs) */ static int check_process_write_access( struct thread *thread, long *addr, data_size_t len ) { - size_t page = get_page_size() / sizeof(long); + size_t page = thread->process->page_size / sizeof(long); for (;;) { diff --git a/server/thread.c b/server/thread.c index 7207f918400..1d171b2232e 100644 --- a/server/thread.c +++ b/server/thread.c @@ -1751,6 +1751,7 @@ DECL_HANDLER(init_first_thread) struct process *process = current->process; int fd; + process->page_size = req->page_size; if (!init_thread( current, req->reply_fd, req->wait_fd )) return; current->unix_pid = process->unix_pid = req->unix_pid; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10839