winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
December 2022
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
539 discussions
Start a n
N
ew thread
Piotr Caban : localspl: Add cups port extension.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: b09f8714ae87ab35fe799767a6e6089a44349c17 URL:
https://gitlab.winehq.org/wine/wine/-/commit/b09f8714ae87ab35fe799767a6e608…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Tue Nov 29 20:53:53 2022 +0100 localspl: Add cups port extension. --- dlls/localspl/Makefile.in | 2 + dlls/localspl/cups.c | 290 ++++++++++++++++++++++++++++++++++++++- dlls/localspl/localmon.c | 24 +++- dlls/localspl/localspl_private.h | 2 + dlls/localspl/provider.c | 3 +- 5 files changed, 312 insertions(+), 9 deletions(-)
1
0
0
0
Alexandre Julliard : ntdll: Replace the __wine_unix_call() syscall by a function calling through the dispatcher.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: ee147d92160cf61cdf808df6fad277198b37a0d4 URL:
https://gitlab.winehq.org/wine/wine/-/commit/ee147d92160cf61cdf808df6fad277…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Dec 1 16:05:28 2022 +0100 ntdll: Replace the __wine_unix_call() syscall by a function calling through the dispatcher. --- dlls/ntdll/loader.c | 10 ++++++++++ dlls/ntdll/ntdll.spec | 2 +- dlls/ntdll/unix/loader.c | 10 ---------- dlls/ntdll/unixlib.h | 2 +- dlls/wow64/syscall.c | 13 ------------- dlls/wow64/syscall.h | 1 - 6 files changed, 12 insertions(+), 26 deletions(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index d8dba0ea357..3214493c995 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -3192,6 +3192,16 @@ NTSTATUS WINAPI __wine_ctrl_routine( void *arg ) RtlExitUserThread( ret ); } + +/*********************************************************************** + * __wine_unix_call + */ +NTSTATUS WINAPI __wine_unix_call( unixlib_handle_t handle, unsigned int code, void *args ) +{ + return __wine_unix_call_dispatcher( handle, code, args ); +} + + /****************************************************************** * LdrLoadDll (NTDLL.@) */ diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 9225779eeaa..1e6576a5422 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1690,7 +1690,7 @@ @ cdecl -syscall wine_server_handle_to_fd(long long ptr ptr) # Unix interface -@ stdcall -syscall __wine_unix_call(int64 long ptr) +@ stdcall __wine_unix_call(int64 long ptr) @ stdcall -syscall __wine_unix_spawnvp(long ptr) @ stdcall __wine_ctrl_routine(ptr) @ extern -private __wine_syscall_dispatcher diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index ae99832635f..0a445966cc0 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -356,7 +356,6 @@ static void * const syscalls[] = NtWriteVirtualMemory, NtYieldExecution, __wine_dbg_write, - __wine_unix_call, __wine_unix_spawnvp, wine_nt_to_unix_file_name, wine_server_call, @@ -1347,15 +1346,6 @@ NTSTATUS ntdll_init_syscalls( ULONG id, SYSTEM_SERVICE_TABLE *table, void **disp } -/*********************************************************************** - * __wine_unix_call - */ -NTSTATUS WINAPI __wine_unix_call( unixlib_handle_t handle, unsigned int code, void *args ) -{ - return ((unixlib_entry_t*)(UINT_PTR)handle)[code]( args ); -} - - /*********************************************************************** * load_so_dll */ diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index 97d93ba1724..2f89808e760 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -48,6 +48,6 @@ enum ntdll_unix_funcs extern unixlib_handle_t ntdll_unix_handle; -#define NTDLL_UNIX_CALL( func, params ) __wine_unix_call( ntdll_unix_handle, unix_ ## func, params ) +#define NTDLL_UNIX_CALL( func, params ) __wine_unix_call_dispatcher( ntdll_unix_handle, unix_ ## func, params ) #endif /* __NTDLL_UNIXLIB_H */ diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index a521c8c16c5..8be5a1c300c 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -320,19 +320,6 @@ NTSTATUS WINAPI wow64___wine_dbg_write( UINT *args ) } -/********************************************************************** - * wow64___wine_unix_call - */ -NTSTATUS WINAPI wow64___wine_unix_call( UINT *args ) -{ - unixlib_handle_t handle = get_ulong64( &args ); - unsigned int code = get_ulong( &args ); - void *args_ptr = get_ptr( &args ); - - return __wine_unix_call( handle, code, args_ptr ); -} - - /********************************************************************** * wow64___wine_unix_spawnvp */ diff --git a/dlls/wow64/syscall.h b/dlls/wow64/syscall.h index 935d2bc7fce..d4216b8c04c 100644 --- a/dlls/wow64/syscall.h +++ b/dlls/wow64/syscall.h @@ -255,7 +255,6 @@ SYSCALL_ENTRY( NtWriteVirtualMemory ) \ SYSCALL_ENTRY( NtYieldExecution ) \ SYSCALL_ENTRY( __wine_dbg_write ) \ - SYSCALL_ENTRY( __wine_unix_call ) \ SYSCALL_ENTRY( __wine_unix_spawnvp ) \ SYSCALL_ENTRY( wine_nt_to_unix_file_name ) \ SYSCALL_ENTRY( wine_server_call ) \
1
0
0
0
Alexandre Julliard : wow64cpu: Add a custom 32->64 thunk for Unix calls.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: 7e680152d41eadd9363719f5a8afef7fac89e8b7 URL:
https://gitlab.winehq.org/wine/wine/-/commit/7e680152d41eadd9363719f5a8afef…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Dec 1 16:03:06 2022 +0100 wow64cpu: Add a custom 32->64 thunk for Unix calls. --- dlls/wow64/syscall.c | 3 ++ dlls/wow64cpu/cpu.c | 97 ++++++++++++++++++++++++++++++++++++++++----- dlls/wow64cpu/wow64cpu.spec | 1 + 3 files changed, 92 insertions(+), 9 deletions(-) diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 86c5b61157e..a521c8c16c5 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -94,6 +94,7 @@ static void * (WINAPI *pBTCpuGetBopCode)(void); static void (WINAPI *pBTCpuProcessInit)(void); static void (WINAPI *pBTCpuSimulate)(void); static NTSTATUS (WINAPI *pBTCpuResetToConsistentState)( EXCEPTION_POINTERS * ); +static void * (WINAPI *p__wine_get_unix_opcode)(void); void *dummy = RtlUnwind; @@ -588,6 +589,7 @@ static DWORD WINAPI process_init( RTL_RUN_ONCE *once, void *param, void **contex GET_PTR( BTCpuProcessInit ); GET_PTR( BTCpuResetToConsistentState ); GET_PTR( BTCpuSimulate ); + GET_PTR( __wine_get_unix_opcode ); module = load_64bit_module( L"wow64win.dll" ); GET_PTR( sdwhwin32 ); @@ -598,6 +600,7 @@ static DWORD WINAPI process_init( RTL_RUN_ONCE *once, void *param, void **contex init_image_mapping( module ); init_syscall_table( module, 0, &ntdll_syscall_table ); *(void **)RtlFindExportedRoutineByName( module, "__wine_syscall_dispatcher" ) = pBTCpuGetBopCode(); + *(void **)RtlFindExportedRoutineByName( module, "__wine_unix_call_dispatcher" ) = p__wine_get_unix_opcode(); module = load_32bit_module( L"win32u.dll" ); init_syscall_table( module, 1, psdwhwin32 ); diff --git a/dlls/wow64cpu/cpu.c b/dlls/wow64cpu/cpu.c index fa1c22aafc6..750ab68d071 100644 --- a/dlls/wow64cpu/cpu.c +++ b/dlls/wow64cpu/cpu.c @@ -39,6 +39,18 @@ struct thunk_32to64 DWORD addr; WORD cs; }; +struct thunk_opcodes +{ + struct thunk_32to64 syscall_thunk; + struct + { + BYTE pushl; /* pushl $dispatcher_high */ + DWORD dispatcher_high; + BYTE pushl2; /* pushl $dispatcher_low */ + DWORD dispatcher_low; + struct thunk_32to64 t; + } unix_thunk; +}; #include "poppack.h" static BYTE DECLSPEC_ALIGN(4096) code_buffer[0x1000]; @@ -187,7 +199,7 @@ __ASM_GLOBAL_FUNC( syscall_32to64, "movl 0xa4(%r13),%ebx\n\t" /* context->Ebx */ "movl 0xb4(%r13),%ebp\n\t" /* context->Ebp */ "btrl $0,-4(%r13)\n\t" /* cpu->Flags & WOW64_CPURESERVED_FLAG_RESET_STATE */ - "jc 1f\n\t" + "jc .Lsyscall_32to64_return\n\t" "movl 0xb8(%r13),%edx\n\t" /* context->Eip */ "movl %edx,(%rsp)\n\t" "movl 0xbc(%r13),%edx\n\t" /* context->SegCs */ @@ -195,7 +207,8 @@ __ASM_GLOBAL_FUNC( syscall_32to64, "movl 0xc4(%r13),%r14d\n\t" /* context->Esp */ "xchgq %r14,%rsp\n\t" "ljmp *(%r14)\n" - "1:\tmovq %rsp,%r14\n\t" + ".Lsyscall_32to64_return:\n\t" + "movq %rsp,%r14\n\t" "movl 0xa8(%r13),%edx\n\t" /* context->Edx */ "movl 0xac(%r13),%ecx\n\t" /* context->Ecx */ "movl 0xc8(%r13),%eax\n\t" /* context->SegSs */ @@ -215,6 +228,41 @@ __ASM_GLOBAL_FUNC( syscall_32to64, "iretq" ) +/********************************************************************** + * unix_call_32to64 + * + * Execute a 64-bit Unix call from 32-bit code, then return to 32-bit. + */ +extern void WINAPI unix_call_32to64(void) DECLSPEC_HIDDEN; +__ASM_GLOBAL_FUNC( unix_call_32to64, + /* cf. BTCpuSimulate prolog */ + __ASM_SEH(".seh_stackalloc 0x28\n\t") + __ASM_SEH(".seh_endprologue\n\t") + __ASM_CFI(".cfi_adjust_cfa_offset 0x28\n\t") + "xchgq %r14,%rsp\n\t" + "movl %edi,0x9c(%r13)\n\t" /* context->Edi */ + "movl %esi,0xa0(%r13)\n\t" /* context->Esi */ + "movl %ebx,0xa4(%r13)\n\t" /* context->Ebx */ + "movl %ebp,0xb4(%r13)\n\t" /* context->Ebp */ + "movl 8(%r14),%edx\n\t" + "movl %edx,0xb8(%r13)\n\t" /* context->Eip */ + "leaq 28(%r14),%rdx\n\t" + "movl %edx,0xc4(%r13)\n\t" /* context->Esp */ + "movq 12(%r14),%rcx\n\t" /* handle */ + "movl 20(%r14),%edx\n\t" /* code */ + "movl 24(%r14),%r8d\n\t" /* args */ + "callq *(%r14)\n\t" + "btrl $0,-4(%r13)\n\t" /* cpu->Flags & WOW64_CPURESERVED_FLAG_RESET_STATE */ + "jc .Lsyscall_32to64_return\n\t" + "movl 0xb8(%r13),%edx\n\t" /* context->Eip */ + "movl %edx,(%rsp)\n\t" + "movl 0xbc(%r13),%edx\n\t" /* context->SegCs */ + "movl %edx,4(%rsp)\n\t" + "movl 0xc4(%r13),%r14d\n\t" /* context->Esp */ + "xchgq %r14,%rsp\n\t" + "ljmp *(%r14)" ) + + /********************************************************************** * BTCpuSimulate (wow64cpu.@) */ @@ -234,10 +282,13 @@ __ASM_STDCALL_FUNC( BTCpuSimulate, 0, */ NTSTATUS WINAPI BTCpuProcessInit(void) { - struct thunk_32to64 *thunk = (struct thunk_32to64 *)code_buffer; + struct thunk_opcodes *thunk = (struct thunk_opcodes *)code_buffer; SIZE_T size = sizeof(*thunk); ULONG old_prot; CONTEXT context; + HMODULE module; + UNICODE_STRING str; + void **p__wine_unix_call_dispatcher; if ((ULONG_PTR)syscall_32to64 >> 32) { @@ -245,16 +296,31 @@ NTSTATUS WINAPI BTCpuProcessInit(void) return STATUS_INVALID_ADDRESS; } + RtlInitUnicodeString( &str, L"ntdll.dll" ); + LdrGetDllHandle( NULL, 0, &str, &module ); + p__wine_unix_call_dispatcher = RtlFindExportedRoutineByName( module, "__wine_unix_call_dispatcher" ); + RtlCaptureContext( &context ); cs64_sel = context.SegCs; ds64_sel = context.SegDs; fs32_sel = context.SegFs; - thunk->ljmp = 0xff; - thunk->modrm = 0x2d; - thunk->op = PtrToUlong( &thunk->addr ); - thunk->addr = PtrToUlong( syscall_32to64 ); - thunk->cs = cs64_sel; + thunk->syscall_thunk.ljmp = 0xff; + thunk->syscall_thunk.modrm = 0x2d; + thunk->syscall_thunk.op = PtrToUlong( &thunk->syscall_thunk.addr ); + thunk->syscall_thunk.addr = PtrToUlong( syscall_32to64 ); + thunk->syscall_thunk.cs = cs64_sel; + + thunk->unix_thunk.pushl = 0x68; + thunk->unix_thunk.dispatcher_high = (ULONG_PTR)*p__wine_unix_call_dispatcher >> 32; + thunk->unix_thunk.pushl2 = 0x68; + thunk->unix_thunk.dispatcher_low = (ULONG_PTR)*p__wine_unix_call_dispatcher; + thunk->unix_thunk.t.ljmp = 0xff; + thunk->unix_thunk.t.modrm = 0x2d; + thunk->unix_thunk.t.op = PtrToUlong( &thunk->unix_thunk.t.addr ); + thunk->unix_thunk.t.addr = PtrToUlong( unix_call_32to64 ); + thunk->unix_thunk.t.cs = cs64_sel; + NtProtectVirtualMemory( GetCurrentProcess(), (void **)&thunk, &size, PAGE_EXECUTE_READ, &old_prot ); return STATUS_SUCCESS; } @@ -265,7 +331,20 @@ NTSTATUS WINAPI BTCpuProcessInit(void) */ void * WINAPI BTCpuGetBopCode(void) { - return code_buffer; + struct thunk_opcodes *thunk = (struct thunk_opcodes *)code_buffer; + + return &thunk->syscall_thunk; +} + + +/********************************************************************** + * __wine_get_unix_opcode (wow64cpu.@) + */ +void * WINAPI __wine_get_unix_opcode(void) +{ + struct thunk_opcodes *thunk = (struct thunk_opcodes *)code_buffer; + + return &thunk->unix_thunk; } diff --git a/dlls/wow64cpu/wow64cpu.spec b/dlls/wow64cpu/wow64cpu.spec index 6346cc54733..48c4800a611 100644 --- a/dlls/wow64cpu/wow64cpu.spec +++ b/dlls/wow64cpu/wow64cpu.spec @@ -7,3 +7,4 @@ @ stdcall BTCpuTurboThunkControl(long) #@ stub TurboDispatchJumpAddressEnd #@ stub TurboDispatchJumpAddressStart +@ stdcall __wine_get_unix_opcode()
1
0
0
0
Alexandre Julliard : ntdll: Implement a faster Unix call dispatcher on ARM.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: a6bb3662dc484e7809e29308364438ea65cc7637 URL:
https://gitlab.winehq.org/wine/wine/-/commit/a6bb3662dc484e7809e29308364438…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Nov 30 22:47:02 2022 +0100 ntdll: Implement a faster Unix call dispatcher on ARM. --- dlls/ntdll/unix/loader.c | 2 -- dlls/ntdll/unix/signal_arm.c | 42 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 08dc08e3672..ae99832635f 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -2190,9 +2190,7 @@ static void start_main_thread(void) if (main_image_info.Machine != current_machine) load_wow64_ntdll( main_image_info.Machine ); load_apiset_dll(); ntdll_init_syscalls( 0, &syscall_table, p__wine_syscall_dispatcher ); -#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) *p__wine_unix_call_dispatcher = __wine_unix_call_dispatcher; -#endif server_init_process_done(); } diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c index 90a30e1ab3a..9bdb2f6d6fb 100644 --- a/dlls/ntdll/unix/signal_arm.c +++ b/dlls/ntdll/unix/signal_arm.c @@ -1701,7 +1701,8 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "ldr r5, [r4]\n\t" /* table->ServiceTable */ "ldr ip, [r5, ip, lsl #2]\n\t" "blx ip\n" - "4:\tldr ip, [r8, #0x44]\n\t" /* frame->restore_flags */ + ".L__wine_syscall_dispatcher_return:\n\t" + "ldr ip, [r8, #0x44]\n\t" /* frame->restore_flags */ #ifndef __SOFTFP__ "tst ip, #4\n\t" /* CONTEXT_FLOATING_POINT */ "beq 3f\n\t" @@ -1721,12 +1722,47 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "5:\tmovw r0, #0x000d\n\t" /* STATUS_INVALID_PARAMETER */ "movt r0, #0xc000\n\t" "add sp, sp, #0x10\n\t" - "b 4b\n\t" + "b .L__wine_syscall_dispatcher_return\n\t" ".globl " __ASM_NAME("__wine_syscall_dispatcher_return") "\n" __ASM_NAME("__wine_syscall_dispatcher_return") ":\n\t" "mov r8, r0\n\t" "mov r0, r1\n\t" - "b 4b" ) + "b .L__wine_syscall_dispatcher_return" ) + + +/*********************************************************************** + * __wine_unix_call_dispatcher + */ +__ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, + __ASM_EHABI(".cantunwind\n\t") + "mrc p15, 0, r1, c13, c0, 2\n\t" /* NtCurrentTeb() */ + "ldr r1, [r1, #0x1d8]\n\t" /* arm_thread_data()->syscall_frame */ + "add ip, r1, #0x10\n\t" + "stm ip, {r4-r12,lr}\n\t" + "str sp, [r1, #0x38]\n\t" + "str lr, [r1, #0x3c]\n\t" + "mrs r4, CPSR\n\t" + "bfi r4, lr, #5, #1\n\t" /* set thumb bit */ + "str r4, [r1, #0x40]\n\t" + "mov r4, #0\n\t" + "str r4, [r1, #0x44]\n\t" /* frame->restore_flags */ +#ifndef __SOFTFP__ + "vmrs r4, fpscr\n\t" + "str r4, [r1, #0x48]\n\t" + "add r4, r1, #0x60\n\t" + "vstm r4, {d0-d15}\n\t" +#endif + "ldr ip, [r0, r2, lsl #2]\n\t" + "mov sp, r1\n\t" + "mov r0, r3\n\t" /* args */ + "blx ip\n" + "mov r8, sp\n\t" + "ldr r1, [r8, #0x44]\n\t" /* frame->restore_flags */ + "cbnz r1, 1f\n\t" + "ldr sp, [r8, #0x38]\n\t" + "add r8, r8, #0x10\n\t" + "ldm r8, {r4-r12,pc}\n\t" + "1:\tb .L__wine_syscall_dispatcher_return" ) /***********************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Implement a faster Unix call dispatcher on ARM64.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: 2332fe79353686ce98a57ac65b6d17123b263200 URL:
https://gitlab.winehq.org/wine/wine/-/commit/2332fe79353686ce98a57ac65b6d17…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Nov 30 22:17:19 2022 +0100 ntdll: Implement a faster Unix call dispatcher on ARM64. --- dlls/ntdll/unix/loader.c | 2 +- dlls/ntdll/unix/signal_arm64.c | 46 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 54eee57d2ad..08dc08e3672 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -2190,7 +2190,7 @@ static void start_main_thread(void) if (main_image_info.Machine != current_machine) load_wow64_ntdll( main_image_info.Machine ); load_apiset_dll(); ntdll_init_syscalls( 0, &syscall_table, p__wine_syscall_dispatcher ); -#if defined(__i386__) || defined(__x86_64__) +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) *p__wine_unix_call_dispatcher = __wine_unix_call_dispatcher; #endif server_init_process_done(); diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c index 794aa7b2925..4483303decc 100644 --- a/dlls/ntdll/unix/signal_arm64.c +++ b/dlls/ntdll/unix/signal_arm64.c @@ -1522,7 +1522,8 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "ldr x16, [x16, x20, lsl 3]\n\t" "blr x16\n\t" "mov sp, x22\n" - "3:\tldp x18, x19, [sp, #0x90]\n\t" + ".L__wine_syscall_dispatcher_return:\n\t" + "ldp x18, x19, [sp, #0x90]\n\t" "ldp x20, x21, [sp, #0xa0]\n\t" "ldp x22, x23, [sp, #0xb0]\n\t" "ldp x24, x25, [sp, #0xc0]\n\t" @@ -1566,12 +1567,51 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "ret x16\n" "4:\tmov x0, #0xc0000000\n\t" /* STATUS_INVALID_PARAMETER */ "movk x0, #0x000d\n\t" - "b 3b\n\t" + "b .L__wine_syscall_dispatcher_return\n\t" ".globl " __ASM_NAME("__wine_syscall_dispatcher_return") "\n" __ASM_NAME("__wine_syscall_dispatcher_return") ":\n\t" "mov sp, x0\n\t" "mov x0, x1\n\t" - "b 3b" ) + "b .L__wine_syscall_dispatcher_return" ) + + +/*********************************************************************** + * __wine_unix_call_dispatcher + */ +__ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, + /* FIXME: use x18 directly instead */ + "stp x0, x1, [sp, #-32]!\n\t" + "stp x2, x30,[sp, #16]\n\t" + "bl " __ASM_NAME("NtCurrentTeb") "\n\t" + "mov x18, x0\n\t" + "ldp x2, x30,[sp, #16]\n\t" + "ldp x0, x1, [sp], #32\n\t" + + "ldr x10, [x18, #0x2f8]\n\t" /* arm64_thread_data()->syscall_frame */ + "stp x18, x19, [x10, #0x90]\n\t" + "stp x20, x21, [x10, #0xa0]\n\t" + "stp x22, x23, [x10, #0xb0]\n\t" + "stp x24, x25, [x10, #0xc0]\n\t" + "stp x26, x27, [x10, #0xd0]\n\t" + "stp x28, x29, [x10, #0xe0]\n\t" + "stp q8, q9, [x10, #0x1b0]\n\t" + "stp q10, q11, [x10, #0x1d0]\n\t" + "stp q12, q13, [x10, #0x1f0]\n\t" + "stp q14, q15, [x10, #0x210]\n\t" + "mov x9, sp\n\t" + "stp x30, x9, [x10, #0xf0]\n\t" + "mrs x9, NZCV\n\t" + "stp x30, x9, [x10, #0x100]\n\t" + "mov sp, x10\n\t" + "ldr x16, [x0, x1, lsl 3]\n\t" + "mov x0, x2\n\t" /* args */ + "blr x16\n\t" + "ldr w16, [sp, #0x10c]\n\t" /* frame->restore_flags */ + "cbnz w16, .L__wine_syscall_dispatcher_return\n\t" + "ldr x18, [sp, #0x90]\n\t" + "ldp x16, x17, [sp, #0xf8]\n\t" + "mov sp, x16\n\t" + "ret x17" ) /***********************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Implement a faster Unix call dispatcher on x86_64.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: 5277c75406d7e0d95f3b942afaaccf4665ed7b5a URL:
https://gitlab.winehq.org/wine/wine/-/commit/5277c75406d7e0d95f3b942afaaccf…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Nov 30 17:20:32 2022 +0100 ntdll: Implement a faster Unix call dispatcher on x86_64. Inspired by a patch from Rémi Bernon. --- dlls/ntdll/unix/loader.c | 2 +- dlls/ntdll/unix/signal_x86_64.c | 129 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 122 insertions(+), 9 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 7857862c702..54eee57d2ad 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -2190,7 +2190,7 @@ static void start_main_thread(void) if (main_image_info.Machine != current_machine) load_wow64_ntdll( main_image_info.Machine ); load_apiset_dll(); ntdll_init_syscalls( 0, &syscall_table, p__wine_syscall_dispatcher ); -#if defined(__i386__) +#if defined(__i386__) || defined(__x86_64__) *p__wine_unix_call_dispatcher = __wine_unix_call_dispatcher; #endif server_init_process_done(); diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index e22654f6d29..460f81545a3 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -1921,12 +1921,24 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, EXCEPTION_RECORD *rec, */ static BOOL handle_syscall_trap( ucontext_t *sigcontext ) { - extern void __wine_syscall_dispatcher_prolog_end(void); struct syscall_frame *frame = amd64_thread_data()->syscall_frame; /* disallow single-stepping through a syscall */ - if ((void *)RIP_sig( sigcontext ) != __wine_syscall_dispatcher) return FALSE; + if ((void *)RIP_sig( sigcontext ) == __wine_syscall_dispatcher) + { + extern void __wine_syscall_dispatcher_prolog_end(void); + + RIP_sig( sigcontext ) = (ULONG64)__wine_syscall_dispatcher_prolog_end; + } + else if ((void *)RIP_sig( sigcontext ) == __wine_unix_call_dispatcher) + { + extern void __wine_unix_call_dispatcher_prolog_end(void); + + RIP_sig( sigcontext ) = (ULONG64)__wine_unix_call_dispatcher_prolog_end; + R10_sig( sigcontext ) = RCX_sig( sigcontext ); + } + else return FALSE; TRACE_(seh)( "ignoring trap in syscall rip=%p eflags=%08x\n", (void *)RIP_sig(sigcontext), (ULONG)EFL_sig(sigcontext) ); @@ -1935,7 +1947,6 @@ static BOOL handle_syscall_trap( ucontext_t *sigcontext ) frame->eflags = EFL_sig(sigcontext); frame->restore_flags = CONTEXT_CONTROL; - RIP_sig( sigcontext ) = (ULONG64)__wine_syscall_dispatcher_prolog_end; RCX_sig( sigcontext ) = (ULONG64)frame; RSP_sig( sigcontext ) += sizeof(ULONG64); EFL_sig( sigcontext ) &= ~0x100; /* clear single-step flag */ @@ -2617,8 +2628,12 @@ __ASM_GLOBAL_FUNC( signal_exit_thread, * __wine_syscall_dispatcher */ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, +#ifdef __APPLE__ "movq %gs:0x30,%rcx\n\t" - "movq 0x328(%rcx),%rcx\n\t" /* amd64_thread_data()->syscall_frame */ + "movq 0x328(%rcx),%rcx\n\t" +#else + "movq %gs:0x328,%rcx\n\t" /* amd64_thread_data()->syscall_frame */ +#endif "popq 0x70(%rcx)\n\t" /* frame->rip */ __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") __ASM_CFI_REG_IS_AT2(rip, rcx, 0xf0,0x00) @@ -2733,10 +2748,11 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "subq $0x20,%rsp\n\t" "movq (%rbx),%r10\n\t" /* table->ServiceTable */ "callq *(%r10,%rax,8)\n\t" - "leaq -0x98(%rbp),%rcx\n" + "leaq -0x98(%rbp),%rcx\n\t" /* $rcx is now pointing to "frame" again */ - __ASM_CFI(".cfi_restore_state\n\t") - "2:\tmovl 0x94(%rcx),%edx\n\t" /* frame->restore_flags */ + __ASM_CFI(".cfi_restore_state\n") + ".L__wine_syscall_dispatcher_return:\n\t" + "movl 0x94(%rcx),%edx\n\t" /* frame->restore_flags */ #ifdef __linux__ "testl $12,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB | SYSCALL_HAVE_WRFSGSBASE */ "jz 1f\n\t" @@ -2825,7 +2841,104 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, __ASM_NAME("__wine_syscall_dispatcher_return") ":\n\t" "movl 0xb0(%rcx),%r14d\n\t" /* frame->syscall_flags */ "movq %rdx,%rax\n\t" - "jmp 2b" ) + "jmp .L__wine_syscall_dispatcher_return" ) + + +/*********************************************************************** + * __wine_unix_call_dispatcher + */ +__ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, + "movq %rcx,%r10\n\t" +#ifdef __APPLE__ + "movq %gs:0x30,%rcx\n\t" + "movq 0x328(%rcx),%rcx\n\t" +#else + "movq %gs:0x328,%rcx\n\t" /* amd64_thread_data()->syscall_frame */ +#endif + "popq 0x70(%rcx)\n\t" /* frame->rip */ + __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t") + __ASM_CFI_REG_IS_AT2(rip, rcx, 0xf0,0x00) + "movl $0,0x94(%rcx)\n\t" /* frame->restore_flags */ + ".globl " __ASM_NAME("__wine_unix_call_dispatcher_prolog_end") "\n" + __ASM_NAME("__wine_unix_call_dispatcher_prolog_end") ":\n\t" + "movq %rbx,0x08(%rcx)\n\t" + __ASM_CFI_REG_IS_AT1(rbx, rcx, 0x08) + "movq %rsi,0x20(%rcx)\n\t" + __ASM_CFI_REG_IS_AT1(rsi, rcx, 0x20) + "movq %rdi,0x28(%rcx)\n\t" + __ASM_CFI_REG_IS_AT1(rdi, rcx, 0x28) + "movq %r12,0x50(%rcx)\n\t" + __ASM_CFI_REG_IS_AT2(r12, rcx, 0xd0, 0x00) + "movq %r13,0x58(%rcx)\n\t" + __ASM_CFI_REG_IS_AT2(r13, rcx, 0xd8, 0x00) + "movq %r14,0x60(%rcx)\n\t" + __ASM_CFI_REG_IS_AT2(r14, rcx, 0xe0, 0x00) + "movq %r15,0x68(%rcx)\n\t" + __ASM_CFI_REG_IS_AT2(r15, rcx, 0xe8, 0x00) + "movq %rsp,0x88(%rcx)\n\t" + __ASM_CFI_CFA_IS_AT2(rcx, 0x88, 0x01) + __ASM_CFI_REG_IS_AT2(rsp, rcx, 0x88, 0x01) + "movq %rbp,0x98(%rcx)\n\t" + __ASM_CFI_REG_IS_AT2(rbp, rcx, 0x98, 0x01) + "movdqa %xmm6,0x1c0(%rcx)\n\t" + "movdqa %xmm7,0x1d0(%rcx)\n\t" + "movdqa %xmm8,0x1e0(%rcx)\n\t" + "movdqa %xmm9,0x1f0(%rcx)\n\t" + "movdqa %xmm10,0x200(%rcx)\n\t" + "movdqa %xmm11,0x210(%rcx)\n\t" + "movdqa %xmm12,0x220(%rcx)\n\t" + "movdqa %xmm13,0x230(%rcx)\n\t" + "movdqa %xmm14,0x240(%rcx)\n\t" + "movdqa %xmm15,0x250(%rcx)\n\t" + "movl 0xb0(%rcx),%r14d\n\t" /* frame->syscall_flags */ +#ifdef __linux__ + "testl $12,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB | SYSCALL_HAVE_WRFSGSBASE */ + "jz 2f\n\t" + "movw %fs,0x7e(%rcx)\n\t" + "movq %gs:0x330,%rsi\n\t" /* amd64_thread_data()->pthread_teb */ + "testl $8,%r14d\n\t" /* SYSCALL_HAVE_WRFSGSBASE */ + "jz 1f\n\t" + "wrfsbase %rsi\n\t" + "jmp 2f\n" + "1:\tmov $0x1002,%edi\n\t" /* ARCH_SET_FS */ + "mov $158,%eax\n\t" /* SYS_arch_prctl */ + "mov %rcx,%r9\n\t" + "syscall\n\t" + "mov %r9,%rcx\n\t" + "2:\n\t" +#endif + "movq %rcx,%rsp\n" + "movq %r8,%rdi\n\t" /* args */ + "callq *(%r10,%rdx,8)\n\t" + "movq %rsp,%rcx\n" + "testl $0xffff,0x94(%rcx)\n\t" /* frame->restore_flags */ + "jnz .L__wine_syscall_dispatcher_return\n\t" +#ifdef __linux__ + "testl $12,%r14d\n\t" /* SYSCALL_HAVE_PTHREAD_TEB | SYSCALL_HAVE_WRFSGSBASE */ + "jz 1f\n\t" + "movw 0x7e(%rcx),%fs\n" + "1:\n\t" +#endif + "movdqa 0x1c0(%rcx),%xmm6\n\t" + "movdqa 0x1d0(%rcx),%xmm7\n\t" + "movdqa 0x1e0(%rcx),%xmm8\n\t" + "movdqa 0x1f0(%rcx),%xmm9\n\t" + "movdqa 0x200(%rcx),%xmm10\n\t" + "movdqa 0x210(%rcx),%xmm11\n\t" + "movdqa 0x220(%rcx),%xmm12\n\t" + "movdqa 0x230(%rcx),%xmm13\n\t" + "movdqa 0x240(%rcx),%xmm14\n\t" + "movdqa 0x250(%rcx),%xmm15\n\t" + "movq 0x60(%rcx),%r14\n\t" + __ASM_CFI(".cfi_same_value r14\n\t") + "movq 0x28(%rcx),%rdi\n\t" + __ASM_CFI(".cfi_same_value rdi\n\t") + "movq 0x20(%rcx),%rsi\n\t" + __ASM_CFI(".cfi_same_value rsi\n\t") + "movq 0x88(%rcx),%rsp\n\t" + __ASM_CFI(".cfi_def_cfa rsp, 0\n\t") + __ASM_CFI(".cfi_same_value rsp\n\t") + "jmpq *0x70(%rcx)" ) /* frame->rip */ /***********************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Implement a faster Unix call dispatcher on i386.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: 911789e757b6f2400946d50fba7ad8b54cae155d URL:
https://gitlab.winehq.org/wine/wine/-/commit/911789e757b6f2400946d50fba7ad8…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Nov 30 17:11:20 2022 +0100 ntdll: Implement a faster Unix call dispatcher on i386. Inspired by a patch from Rémi Bernon. --- dlls/ntdll/unix/loader.c | 5 +++ dlls/ntdll/unix/signal_i386.c | 76 ++++++++++++++++++++++++++++++++++++++---- dlls/ntdll/unix/unix_private.h | 1 + 3 files changed, 76 insertions(+), 6 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 8e7bb155c86..7857862c702 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -117,6 +117,7 @@ void (WINAPI *p__wine_ctrl_routine)(void*); SYSTEM_DLL_INIT_BLOCK *pLdrSystemDllInitBlock = NULL; static void *p__wine_syscall_dispatcher; +static void **p__wine_unix_call_dispatcher; static void * const syscalls[] = { @@ -1053,6 +1054,7 @@ static void load_ntdll_functions( HMODULE module ) GET_FUNC( RtlUserThreadStart ); GET_FUNC( __wine_ctrl_routine ); GET_FUNC( __wine_syscall_dispatcher ); + GET_FUNC( __wine_unix_call_dispatcher ); #ifdef __aarch64__ { void **p__wine_current_teb; @@ -2188,6 +2190,9 @@ static void start_main_thread(void) if (main_image_info.Machine != current_machine) load_wow64_ntdll( main_image_info.Machine ); load_apiset_dll(); ntdll_init_syscalls( 0, &syscall_table, p__wine_syscall_dispatcher ); +#if defined(__i386__) + *p__wine_unix_call_dispatcher = __wine_unix_call_dispatcher; +#endif server_init_process_done(); } diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c index 02322accf9e..6aa5219f963 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c @@ -1817,12 +1817,23 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, void *stack_ptr, */ static BOOL handle_syscall_trap( ucontext_t *sigcontext ) { - extern void __wine_syscall_dispatcher_prolog_end(void) DECLSPEC_HIDDEN; struct syscall_frame *frame = x86_thread_data()->syscall_frame; /* disallow single-stepping through a syscall */ - if ((void *)EIP_sig( sigcontext ) != __wine_syscall_dispatcher) return FALSE; + if ((void *)EIP_sig( sigcontext ) == __wine_syscall_dispatcher) + { + extern void __wine_syscall_dispatcher_prolog_end(void) DECLSPEC_HIDDEN; + + EIP_sig( sigcontext ) = (ULONG)__wine_syscall_dispatcher_prolog_end; + } + else if ((void *)EIP_sig( sigcontext ) == __wine_unix_call_dispatcher) + { + extern void __wine_unix_call_dispatcher_prolog_end(void) DECLSPEC_HIDDEN; + + EIP_sig( sigcontext ) = (ULONG)__wine_unix_call_dispatcher_prolog_end; + } + else return FALSE; TRACE( "ignoring trap in syscall eip=%08x eflags=%08x\n", EIP_sig(sigcontext), EFL_sig(sigcontext) ); @@ -1830,7 +1841,6 @@ static BOOL handle_syscall_trap( ucontext_t *sigcontext ) frame->eflags = EFL_sig(sigcontext); frame->restore_flags = LOWORD(CONTEXT_CONTROL); - EIP_sig( sigcontext ) = (ULONG)__wine_syscall_dispatcher_prolog_end; ECX_sig( sigcontext ) = (ULONG)frame; ESP_sig( sigcontext ) += sizeof(ULONG); EFL_sig( sigcontext ) &= ~0x100; /* clear single-step flag */ @@ -2617,7 +2627,8 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "rep; movsl\n\t" "call *(%eax,%edx,4)\n\t" "leal -0x34(%ebp),%esp\n" - "5:\t" + + ".L__wine_syscall_dispatcher_return:\t" __ASM_CFI_CFA_IS_AT1(esp, 0x0c) __ASM_CFI_REG_IS_AT1(esp, esp, 0x0c) __ASM_CFI_REG_IS_AT1(eip, esp, 0x08) @@ -2692,7 +2703,8 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "iret\n" __ASM_CFI("\t.cfi_restore_state\n") "6:\tmovl $0xc000000d,%eax\n\t" /* STATUS_INVALID_PARAMETER */ - "jmp 5b\n\t" + "jmp .L__wine_syscall_dispatcher_return\n\t" + ".globl " __ASM_NAME("__wine_syscall_dispatcher_return") "\n" __ASM_NAME("__wine_syscall_dispatcher_return") ":\n\t" __ASM_CFI(".cfi_remember_state\n\t") @@ -2706,7 +2718,59 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "movl 8(%esp),%eax\n\t" "movl 4(%esp),%esp\n\t" __ASM_CFI(".cfi_restore_state\n\t") - "jmp 5b" ) + "jmp .L__wine_syscall_dispatcher_return" ) + + +/*********************************************************************** + * __wine_unix_call_dispatcher + */ +__ASM_GLOBAL_FUNC( __wine_unix_call_dispatcher, + "movl %fs:0x1f8,%ecx\n\t" /* x86_thread_data()->syscall_frame */ + "movw $0,0x02(%ecx)\n\t" /* frame->restore_flags */ + "popl 0x08(%ecx)\n\t" /* frame->eip */ + __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t") + __ASM_CFI_REG_IS_AT1(eip, ecx, 0x08) + ".globl " __ASM_NAME("__wine_unix_call_dispatcher_prolog_end") "\n" + __ASM_NAME("__wine_unix_call_dispatcher_prolog_end") ":\n\t" + "leal 0x10(%esp),%edx\n\t" + "movl %edx,0x0c(%ecx)\n\t" /* frame->esp */ + __ASM_CFI_CFA_IS_AT1(ecx, 0x0c) + __ASM_CFI_REG_IS_AT1(esp, ecx, 0x0c) + "movw %cs,0x10(%ecx)\n\t" + "movw %ss,0x12(%ecx)\n\t" + "movw %ds,0x14(%ecx)\n\t" + "movw %es,0x16(%ecx)\n\t" + "movw %fs,0x18(%ecx)\n\t" + "movw %gs,0x1a(%ecx)\n\t" + "movl %ebx,0x20(%ecx)\n\t" + __ASM_CFI_REG_IS_AT1(ebx, ecx, 0x20) + "movl %edi,0x2c(%ecx)\n\t" + __ASM_CFI_REG_IS_AT1(edi, ecx, 0x2c) + "movl %esi,0x30(%ecx)\n\t" + __ASM_CFI_REG_IS_AT1(esi, ecx, 0x30) + "movl %ebp,0x34(%ecx)\n\t" + __ASM_CFI_REG_IS_AT1(ebp, ecx, 0x34) + "movl 12(%esp),%edx\n\t" /* args */ + "movl %edx,-16(%ecx)\n\t" + "movl (%esp),%eax\n\t" /* handle */ + "movl 8(%esp),%edx\n\t" /* code */ + "leal -16(%ecx),%esp\n\t" + "call *(%eax,%edx,4)\n\t" + "leal 16(%esp),%esp\n\t" + __ASM_CFI_CFA_IS_AT1(esp, 0x0c) + __ASM_CFI_REG_IS_AT1(esp, esp, 0x0c) + __ASM_CFI_REG_IS_AT1(eip, esp, 0x08) + __ASM_CFI_REG_IS_AT1(ebx, esp, 0x20) + __ASM_CFI_REG_IS_AT1(edi, esp, 0x2c) + __ASM_CFI_REG_IS_AT1(esi, esp, 0x30) + __ASM_CFI_REG_IS_AT1(ebp, esp, 0x34) + "testw $0xffff,2(%esp)\n\t" /* frame->restore_flags */ + "jnz .L__wine_syscall_dispatcher_return\n\t" + "movl 0x08(%esp),%ecx\n\t" /* frame->eip */ + __ASM_CFI(".cfi_register %eip, %ecx\n\t") + "movl 0x0c(%esp),%esp\n\t" /* frame->esp */ + __ASM_CFI(".cfi_same_value %esp\n\t") + "jmpl *%ecx" ) /*********************************************************************** diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index aad472faff8..9b3d92c7620 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -245,6 +245,7 @@ extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int), extern SYSTEM_SERVICE_TABLE KeServiceDescriptorTable[4] DECLSPEC_HIDDEN; extern void __wine_syscall_dispatcher(void) DECLSPEC_HIDDEN; extern void WINAPI DECLSPEC_NORETURN __wine_syscall_dispatcher_return( void *frame, ULONG_PTR retval ) DECLSPEC_HIDDEN; +extern void __wine_unix_call_dispatcher(void) DECLSPEC_HIDDEN; extern NTSTATUS signal_set_full_context( CONTEXT *context ) DECLSPEC_HIDDEN; extern NTSTATUS get_thread_wow64_context( HANDLE handle, void *ctx, ULONG size ) DECLSPEC_HIDDEN; extern NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size ) DECLSPEC_HIDDEN;
1
0
0
0
Alexandre Julliard : ntdll: Export the Unix call dispatcher function pointer.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: 90adeb125f3c9f0a42d1768b42dee620c067ae71 URL:
https://gitlab.winehq.org/wine/wine/-/commit/90adeb125f3c9f0a42d1768b42dee6…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Nov 30 17:02:54 2022 +0100 ntdll: Export the Unix call dispatcher function pointer. --- dlls/ntdll/loader.c | 1 + dlls/ntdll/ntdll.spec | 3 ++- dlls/winecrt0/unix_lib.c | 8 ++++---- dlls/winevulkan/loader.c | 2 +- include/wine/unixlib.h | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 682fda9ed15..d8dba0ea357 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -71,6 +71,7 @@ typedef DWORD (CALLBACK *DLLENTRYPROC)(HMODULE,DWORD,LPVOID); typedef void (CALLBACK *LDRENUMPROC)(LDR_DATA_TABLE_ENTRY *, void *, BOOLEAN *); void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *) = NULL; +NTSTATUS (WINAPI *__wine_unix_call_dispatcher)( unixlib_handle_t, unsigned int, void * ) = __wine_unix_call; static DWORD (WINAPI *pCtrlRoutine)(void *); diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 1d4218e7b52..9225779eeaa 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1693,7 +1693,8 @@ @ stdcall -syscall __wine_unix_call(int64 long ptr) @ stdcall -syscall __wine_unix_spawnvp(long ptr) @ stdcall __wine_ctrl_routine(ptr) -@ extern __wine_syscall_dispatcher +@ extern -private __wine_syscall_dispatcher +@ extern -private __wine_unix_call_dispatcher @ extern -arch=arm64 __wine_current_teb # Debugging diff --git a/dlls/winecrt0/unix_lib.c b/dlls/winecrt0/unix_lib.c index 1c8e2117dd0..5b809b6949d 100644 --- a/dlls/winecrt0/unix_lib.c +++ b/dlls/winecrt0/unix_lib.c @@ -44,17 +44,17 @@ static NTSTATUS WINAPI unix_call_fallback( unixlib_handle_t handle, unsigned int } unixlib_handle_t __wine_unixlib_handle = 0; -NTSTATUS (WINAPI *__wine_unix_call_ptr)( unixlib_handle_t, unsigned int, void * ) = unix_call_fallback; +NTSTATUS (WINAPI *__wine_unix_call_dispatcher)( unixlib_handle_t, unsigned int, void * ) = unix_call_fallback; NTSTATUS WINAPI __wine_init_unix_call(void) { NTSTATUS status; HMODULE module = GetModuleHandleW( L"ntdll.dll" ); - void *proc = GetProcAddress( module, "__wine_unix_call" ); + void **p__wine_unix_call_dispatcher = (void **)GetProcAddress( module, "__wine_unix_call_dispatcher" ); - if (!proc) return STATUS_DLL_NOT_FOUND; + if (!p__wine_unix_call_dispatcher) return STATUS_DLL_NOT_FOUND; status = NtQueryVirtualMemory( GetCurrentProcess(), image_base(), MemoryWineUnixFuncs, &__wine_unixlib_handle, sizeof(__wine_unixlib_handle), NULL ); - if (!status) __wine_unix_call_ptr = proc; + if (!status) __wine_unix_call_dispatcher = *p__wine_unix_call_dispatcher; return status; } diff --git a/dlls/winevulkan/loader.c b/dlls/winevulkan/loader.c index f168e824ae8..6e20565179d 100644 --- a/dlls/winevulkan/loader.c +++ b/dlls/winevulkan/loader.c @@ -236,7 +236,7 @@ static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context) { NTSTATUS status = __wine_init_unix_call(); - p_vk_direct_unix_call = __wine_unix_call_ptr; + p_vk_direct_unix_call = __wine_unix_call_dispatcher; if (status) return FALSE; return !vk_unix_call(unix_init, &p_vk_direct_unix_call); } diff --git a/include/wine/unixlib.h b/include/wine/unixlib.h index 977dabc77f3..f8360f1549e 100644 --- a/include/wine/unixlib.h +++ b/include/wine/unixlib.h @@ -268,10 +268,10 @@ static inline ULONG ntdll_wcstoul( const WCHAR *s, WCHAR **end, int base ) #else /* WINE_UNIX_LIB */ extern unixlib_handle_t __wine_unixlib_handle DECLSPEC_HIDDEN; -extern NTSTATUS (WINAPI *__wine_unix_call_ptr)( unixlib_handle_t, unsigned int, void * ) DECLSPEC_HIDDEN; +extern NTSTATUS (WINAPI *__wine_unix_call_dispatcher)( unixlib_handle_t, unsigned int, void * ) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI __wine_init_unix_call(void) DECLSPEC_HIDDEN; -#define WINE_UNIX_CALL(code,args) __wine_unix_call_ptr( __wine_unixlib_handle, (code), (args) ) +#define WINE_UNIX_CALL(code,args) __wine_unix_call_dispatcher( __wine_unixlib_handle, (code), (args) ) #endif /* WINE_UNIX_LIB */
1
0
0
0
Alexandre Julliard : opengl32: Fix calling convention of Unix call entry points.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: 0f67dbb50e3b871ffe00af5ab2a4ab6f57555bfd URL:
https://gitlab.winehq.org/wine/wine/-/commit/0f67dbb50e3b871ffe00af5ab2a4ab…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Thu Dec 1 11:30:23 2022 +0100 opengl32: Fix calling convention of Unix call entry points. --- dlls/opengl32/unix_wgl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/opengl32/unix_wgl.c b/dlls/opengl32/unix_wgl.c index b0874af546e..d1db15404f0 100644 --- a/dlls/opengl32/unix_wgl.c +++ b/dlls/opengl32/unix_wgl.c @@ -1049,13 +1049,13 @@ NTSTATUS ext_wglSetPbufferAttribARB( void *args ) return STATUS_SUCCESS; } -NTSTATUS WINAPI thread_attach( void *args ) +NTSTATUS thread_attach( void *args ) { NtCurrentTeb()->glTable = &null_opengl_funcs; return STATUS_SUCCESS; } -NTSTATUS WINAPI process_detach( void *args ) +NTSTATUS process_detach( void *args ) { return STATUS_SUCCESS; } @@ -1986,7 +1986,7 @@ NTSTATUS wow64_ext_glUnmapNamedBufferEXT( void *args ) return wow64_ext_glUnmapNamedBuffer( args ); } -NTSTATUS WINAPI wow64_process_detach( void *args ) +NTSTATUS wow64_process_detach( void *args ) { NTSTATUS status;
1
0
0
0
Zebediah Figura : wineusb.sys: Do not close the device handle more than once.
by Alexandre Julliard
01 Dec '22
01 Dec '22
Module: wine Branch: master Commit: 5addec396680ea25bdc2f6c2dfce45159ca0364f URL:
https://gitlab.winehq.org/wine/wine/-/commit/5addec396680ea25bdc2f6c2dfce45…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Wed Nov 30 12:22:32 2022 -0600 wineusb.sys: Do not close the device handle more than once. Since multiple interfaces can hold onto it, we need to refcount it. In order to do this just refcount the parent device, and close the handle only when the parent device refcount reaches 0. --- dlls/wineusb.sys/unixlib.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/dlls/wineusb.sys/unixlib.c b/dlls/wineusb.sys/unixlib.c index 278750c37f6..7889270c37d 100644 --- a/dlls/wineusb.sys/unixlib.c +++ b/dlls/wineusb.sys/unixlib.c @@ -45,8 +45,8 @@ struct unix_device struct list entry; libusb_device_handle *handle; - - bool interface; + struct unix_device *parent; + unsigned int refcount; }; static libusb_hotplug_callback_handle hotplug_cb_handle; @@ -128,7 +128,7 @@ static void add_usb_device(libusb_device *libusb_device) free(unix_device); return; } - unix_device->interface = false; + unix_device->refcount = 1; pthread_mutex_lock(&device_mutex); list_add_tail(&device_list, &unix_device->entry); @@ -175,8 +175,10 @@ static void add_usb_device(libusb_device *libusb_device) if (!(unix_iface = calloc(1, sizeof(*unix_iface)))) return; + ++unix_device->refcount; + unix_iface->refcount = 1; unix_iface->handle = unix_device->handle; - unix_iface->interface = true; + unix_iface->parent = unix_device; pthread_mutex_lock(&device_mutex); list_add_tail(&device_list, &unix_iface->entry); pthread_mutex_unlock(&device_mutex); @@ -547,16 +549,33 @@ static NTSTATUS usb_cancel_transfer(void *args) return STATUS_SUCCESS; } -static NTSTATUS usb_destroy_device(void *args) +static void decref_device(struct unix_device *device) { - const struct usb_destroy_device_params *params = args; - struct unix_device *device = params->device; - pthread_mutex_lock(&device_mutex); - libusb_close(device->handle); + + if (--device->refcount) + { + pthread_mutex_unlock(&device_mutex); + return; + } + list_remove(&device->entry); + pthread_mutex_unlock(&device_mutex); + + if (device->parent) + decref_device(device->parent); + else + libusb_close(device->handle); free(device); +} + +static NTSTATUS usb_destroy_device(void *args) +{ + const struct usb_destroy_device_params *params = args; + struct unix_device *device = params->device; + + decref_device(device); return STATUS_SUCCESS; }
1
0
0
0
← Newer
1
...
49
50
51
52
53
54
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Results per page:
10
25
50
100
200