X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/6d2010ae8f7a6078e10b361c6962983bab233e0f..eee3565979933af707c711411001ba11fe406a3c:/libsyscall/custom/custom.s?ds=inline diff --git a/libsyscall/custom/custom.s b/libsyscall/custom/custom.s index b9d46ba13..56a95cf5b 100644 --- a/libsyscall/custom/custom.s +++ b/libsyscall/custom/custom.s @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2007 Apple Inc. All rights reserved. + * Copyright (c) 1999-2015 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -32,19 +32,29 @@ #if defined(__i386__) - .globl _errno - -LABEL(cerror) - REG_TO_EXTERN(%eax, _errno) - mov %esp,%edx - andl $0xfffffff0,%esp - subl $16,%esp - movl %edx,4(%esp) - movl %eax,(%esp) - CALL_EXTERN(_cthread_set_errno_self) - movl 4(%esp),%esp - movl $-1,%eax - movl $-1,%edx /* in case a 64-bit value is returned */ +/* + * i386 needs custom assembly to transform the return from syscalls + * into a proper stack for a function call out to cerror{,_nocancel}. + */ + +LABEL(tramp_cerror) + mov %esp, %edx + andl $0xfffffff0, %esp + subl $16, %esp + movl %edx, 4(%esp) + movl %eax, (%esp) + CALL_EXTERN(_cerror) + movl 4(%esp), %esp + ret + +LABEL(tramp_cerror_nocancel) + mov %esp, %edx + andl $0xfffffff0, %esp + subl $16, %esp + movl %edx, 4(%esp) + movl %eax, (%esp) + CALL_EXTERN(_cerror_nocancel) + movl 4(%esp), %esp ret LABEL(__sysenter_trap) @@ -52,39 +62,45 @@ LABEL(__sysenter_trap) movl %esp, %ecx sysenter -#elif defined(__x86_64__) + .globl _i386_get_ldt + ALIGN +_i386_get_ldt: + movl $6,%eax + MACHDEP_SYSCALL_TRAP + jnb 2f + jmp tramp_cerror +2: ret - .globl _errno - -LABEL(cerror) - PICIFY(_errno) /* address -> %r11 */ - movl %eax,(%r11) - mov %rsp,%rdx - andq $-16,%rsp - subq $16,%rsp - // Preserve the original stack - movq %rdx,(%rsp) - movq %rax,%rdi - CALL_EXTERN(_cthread_set_errno_self) - // Restore the original stack - movq (%rsp),%rsp - movq $-1,%rax - movq $-1,%rdx /* in case a 128-bit value is returned */ - ret -#else -#error Unsupported architecture -#endif + .globl _i386_set_ldt + ALIGN +_i386_set_ldt: + movl $5,%eax + MACHDEP_SYSCALL_TRAP + jnb 2f + jmp tramp_cerror +2: ret + + ALIGN + .globl __thread_set_tsd_base +__thread_set_tsd_base: + pushl 4(%esp) + pushl $0 + movl $3,%eax + MACHDEP_SYSCALL_TRAP + addl $8,%esp + ret -#if defined(__i386__) || defined(__x86_64__) +#elif defined(__x86_64__) .globl _i386_get_ldt ALIGN _i386_get_ldt: movl $6,%eax MACHDEP_SYSCALL_TRAP - jnb 2f - jmp cerror + jnb 2f + movq %rax, %rdi + jmp _cerror 2: ret @@ -93,8 +109,21 @@ _i386_get_ldt: _i386_set_ldt: movl $5,%eax MACHDEP_SYSCALL_TRAP - jnb 2f - jmp cerror + jnb 2f + movq %rax, %rdi + jmp _cerror 2: ret + ALIGN + .globl __thread_set_tsd_base +__thread_set_tsd_base: + movl $0, %esi // 0 as the second argument + movl $ SYSCALL_CONSTRUCT_MDEP(3), %eax // Machine-dependent syscall number 3 + MACHDEP_SYSCALL_TRAP + ret + +#else +#error unknown architecture #endif + +.subsections_via_symbols