Commit fc7c3b51 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Always inline NtCurrentTeb() on ARM.

parent 6a971e84
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
@ stub NtCreateToken @ stub NtCreateToken
@ stdcall -syscall NtCreateUserProcess(ptr ptr long long ptr ptr long long ptr ptr ptr) @ stdcall -syscall NtCreateUserProcess(ptr ptr long long ptr ptr long long ptr ptr ptr)
# @ stub NtCreateWaitablePort # @ stub NtCreateWaitablePort
@ stdcall -arch=win32,arm64 NtCurrentTeb() @ stdcall -arch=i386,arm64 NtCurrentTeb()
@ stdcall -syscall NtDebugActiveProcess(long long) @ stdcall -syscall NtDebugActiveProcess(long long)
# @ stub NtDebugContinue # @ stub NtDebugContinue
@ stdcall -syscall NtDelayExecution(long ptr) @ stdcall -syscall NtDelayExecution(long ptr)
......
...@@ -304,12 +304,4 @@ __ASM_STDCALL_FUNC( DbgBreakPoint, 0, "bkpt #0; bx lr; nop; nop; nop; nop" ); ...@@ -304,12 +304,4 @@ __ASM_STDCALL_FUNC( DbgBreakPoint, 0, "bkpt #0; bx lr; nop; nop; nop; nop" );
*/ */
__ASM_STDCALL_FUNC( DbgUserBreakPoint, 0, "bkpt #0; bx lr; nop; nop; nop; nop" ); __ASM_STDCALL_FUNC( DbgUserBreakPoint, 0, "bkpt #0; bx lr; nop; nop; nop; nop" );
/**********************************************************************
* NtCurrentTeb (NTDLL.@)
*/
TEB * WINAPI NtCurrentTeb(void)
{
return unix_funcs->NtCurrentTeb();
}
#endif /* __arm__ */ #endif /* __arm__ */
...@@ -1508,7 +1508,9 @@ static double CDECL ntdll_tan( double d ) { return tan( d ); } ...@@ -1508,7 +1508,9 @@ static double CDECL ntdll_tan( double d ) { return tan( d ); }
*/ */
static struct unix_funcs unix_funcs = static struct unix_funcs unix_funcs =
{ {
#ifdef __aarch64__
NtCurrentTeb, NtCurrentTeb,
#endif
DbgUiIssueRemoteBreakin, DbgUiIssueRemoteBreakin,
RtlGetSystemTimePrecise, RtlGetSystemTimePrecise,
RtlWaitOnAddress, RtlWaitOnAddress,
......
...@@ -68,8 +68,6 @@ ...@@ -68,8 +68,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(seh); WINE_DEFAULT_DEBUG_CHANNEL(seh);
static pthread_key_t teb_key;
/*********************************************************************** /***********************************************************************
* signal context platform-specific definitions * signal context platform-specific definitions
...@@ -584,23 +582,21 @@ static void setup_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec ) ...@@ -584,23 +582,21 @@ static void setup_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec )
* call_user_apc_dispatcher * call_user_apc_dispatcher
*/ */
__ASM_GLOBAL_FUNC( call_user_apc_dispatcher, __ASM_GLOBAL_FUNC( call_user_apc_dispatcher,
"mov r4, r0\n\t" /* context_ptr */
"mov r5, r1\n\t" /* ctx */ "mov r5, r1\n\t" /* ctx */
"mov r6, r2\n\t" /* arg1 */ "mov r6, r2\n\t" /* arg1 */
"mov r7, r3\n\t" /* arg2 */ "mov r7, r3\n\t" /* arg2 */
"ldr r8, [sp]\n\t" /* func */ "ldr r8, [sp]\n\t" /* func */
"ldr r9, [sp, #4]\n\t" /* dispatcher */ "ldr r9, [sp, #4]\n\t" /* dispatcher */
"bl " __ASM_NAME("NtCurrentTeb") "\n\t" "mrc p15, 0, r10, c13, c0, 2\n\t" /* NtCurrentTeb() */
"add r10, r0, #0x1d8\n\t" /* arm_thread_data()->syscall_frame */ "cmp r0, #0\n\t" /* context_ptr */
"movs r0, r4\n\t"
"beq 1f\n\t" "beq 1f\n\t"
"ldr r0, [r0, #0x38]\n\t" /* context_ptr->Sp */ "ldr r0, [r0, #0x38]\n\t" /* context_ptr->Sp */
"sub r0, r0, #0x1c8\n\t" /* sizeof(CONTEXT) + offsetof(frame,r4) */ "sub r0, r0, #0x1c8\n\t" /* sizeof(CONTEXT) + offsetof(frame,r4) */
"mov ip, #0\n\t" "mov ip, #0\n\t"
"str ip, [r10]\n\t" "str ip, [r10, #0x1d8]\n\t" /* arm_thread_data()->syscall_frame */
"mov sp, r0\n\t" "mov sp, r0\n\t"
"b 2f\n" "b 2f\n"
"1:\tldr r0, [r10]\n\t" "1:\tldr r0, [r10, #0x1d8]\n\t"
"sub r0, #0x1a0\n\t" "sub r0, #0x1a0\n\t"
"mov sp, r0\n\t" "mov sp, r0\n\t"
"mov r0, #3\n\t" "mov r0, #3\n\t"
...@@ -613,7 +609,7 @@ __ASM_GLOBAL_FUNC( call_user_apc_dispatcher, ...@@ -613,7 +609,7 @@ __ASM_GLOBAL_FUNC( call_user_apc_dispatcher,
"str r0, [sp, #4]\n\t" /* context.R0 = STATUS_USER_APC */ "str r0, [sp, #4]\n\t" /* context.R0 = STATUS_USER_APC */
"mov r0, sp\n\t" "mov r0, sp\n\t"
"mov ip, #0\n\t" "mov ip, #0\n\t"
"str ip, [r10]\n\t" "str ip, [r10, #0x1d8]\n\t"
"2:\tmov r1, r5\n\t" /* ctx */ "2:\tmov r1, r5\n\t" /* ctx */
"mov r2, r6\n\t" /* arg1 */ "mov r2, r6\n\t" /* arg1 */
"mov r3, r7\n\t" /* arg2 */ "mov r3, r7\n\t" /* arg2 */
...@@ -634,17 +630,10 @@ __ASM_GLOBAL_FUNC( call_raise_user_exception_dispatcher, ...@@ -634,17 +630,10 @@ __ASM_GLOBAL_FUNC( call_raise_user_exception_dispatcher,
* call_user_exception_dispatcher * call_user_exception_dispatcher
*/ */
__ASM_GLOBAL_FUNC( call_user_exception_dispatcher, __ASM_GLOBAL_FUNC( call_user_exception_dispatcher,
"mov r4, r0\n\t" "mrc p15, 0, r7, c13, c0, 2\n\t" /* NtCurrentTeb() */
"mov r5, r1\n\t" "ldr r3, [r7, #0x1d8]\n\t" /* arm_thread_data()->syscall_frame */
"mov r6, r2\n\t"
"bl " __ASM_NAME("NtCurrentTeb") "\n\t"
"add r7, r0, #0x1d8\n\t" /* arm_thread_data()->syscall_frame */
"mov r0, r4\n\t"
"mov r1, r5\n\t"
"mov r2, r6\n\t"
"ldr r3, [r7]\n\t"
"mov ip, #0\n\t" "mov ip, #0\n\t"
"str ip, [r7]\n\t" "str ip, [r7, #0x1d8]\n\t"
"add r3, r3, #8\n\t" "add r3, r3, #8\n\t"
"ldm r3, {r5-r11}\n\t" "ldm r3, {r5-r11}\n\t"
"ldr r4, [r3, #32]\n\t" "ldr r4, [r3, #32]\n\t"
...@@ -911,7 +900,6 @@ NTSTATUS WINAPI NtSetLdtEntries( ULONG sel1, LDT_ENTRY entry1, ULONG sel2, LDT_E ...@@ -911,7 +900,6 @@ NTSTATUS WINAPI NtSetLdtEntries( ULONG sel1, LDT_ENTRY entry1, ULONG sel2, LDT_E
*/ */
void signal_init_threading(void) void signal_init_threading(void)
{ {
pthread_key_create( &teb_key, NULL );
} }
...@@ -937,11 +925,7 @@ void signal_free_thread( TEB *teb ) ...@@ -937,11 +925,7 @@ void signal_free_thread( TEB *teb )
*/ */
void signal_init_thread( TEB *teb ) void signal_init_thread( TEB *teb )
{ {
#if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_8A__)
/* Win32/ARM applications expect the TEB pointer to be in the TPIDRURW register. */
__asm__ __volatile__( "mcr p15, 0, %0, c13, c0, 2" : : "r" (teb) ); __asm__ __volatile__( "mcr p15, 0, %0, c13, c0, 2" : : "r" (teb) );
#endif
pthread_setspecific( teb_key, teb );
} }
...@@ -1057,13 +1041,4 @@ void signal_exit_thread( int status, void (*func)(int) ) ...@@ -1057,13 +1041,4 @@ void signal_exit_thread( int status, void (*func)(int) )
call_thread_exit_func( status, func, NtCurrentTeb() ); call_thread_exit_func( status, func, NtCurrentTeb() );
} }
/**********************************************************************
* NtCurrentTeb (NTDLL.@)
*/
TEB * WINAPI NtCurrentTeb(void)
{
return pthread_getspecific( teb_key );
}
#endif /* __arm__ */ #endif /* __arm__ */
...@@ -27,12 +27,14 @@ ...@@ -27,12 +27,14 @@
struct _DISPATCHER_CONTEXT; struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */ /* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 106 #define NTDLL_UNIXLIB_VERSION 107
struct unix_funcs struct unix_funcs
{ {
/* Nt* functions */ /* Nt* functions */
#ifdef __aarch64__
TEB * (WINAPI *NtCurrentTeb)(void); TEB * (WINAPI *NtCurrentTeb)(void);
#endif
/* other Win32 API functions */ /* other Win32 API functions */
NTSTATUS (WINAPI *DbgUiIssueRemoteBreakin)( HANDLE process ); NTSTATUS (WINAPI *DbgUiIssueRemoteBreakin)( HANDLE process );
......
...@@ -2801,7 +2801,7 @@ static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void) ...@@ -2801,7 +2801,7 @@ static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
{ {
return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self)); return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self));
} }
#elif defined(__arm__) && defined(__MINGW32__) #elif defined(__arm__) && defined(__GNUC__)
static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void) static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
{ {
struct _TEB *teb; struct _TEB *teb;
......
...@@ -1577,10 +1577,8 @@ void output_syscalls( DLLSPEC *spec ) ...@@ -1577,10 +1577,8 @@ void output_syscalls( DLLSPEC *spec )
output( "\tcmp r4, r5\n" ); output( "\tcmp r4, r5\n" );
output( "\tbcs 5f\n" ); output( "\tbcs 5f\n" );
output( "\tsub sp, sp, #8\n" ); output( "\tsub sp, sp, #8\n" );
output( "\tpush {r0-r3}\n" ); output( "\tmrc p15, 0, r7, c13, c0, 2\n" ); /* NtCurrentTeb() */
output( "\tbl %s\n", asm_name("NtCurrentTeb") ); output( "\tadd r7, #0x1d8\n" ); /* arm_thread_data()->syscall_frame */
output( "\tadd r7, r0, #0x1d8\n" ); /* arm_thread_data()->syscall_frame */
output( "\tpop {r0-r3}\n" );
output( "\tmrs ip, CPSR\n" ); output( "\tmrs ip, CPSR\n" );
output( "\tstr ip, [sp, #4]\n" ); output( "\tstr ip, [sp, #4]\n" );
output( "\tstr sp, [r7]\n" ); /* syscall frame */ output( "\tstr sp, [r7]\n" ); /* syscall frame */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment