am 8fa5c252
: Merge "Align arm64 stacks to 16 bytes in __bionic_clone."
* commit '8fa5c2528c04df00f9f9a3dc4047ae88d3f13524': Align arm64 stacks to 16 bytes in __bionic_clone.
This commit is contained in:
commit
0db4c69087
@ -35,29 +35,36 @@ ENTRY(__bionic_clone)
|
|||||||
mov x29, sp
|
mov x29, sp
|
||||||
str x8, [sp, #-16]!
|
str x8, [sp, #-16]!
|
||||||
|
|
||||||
/* store thread pointer & args in child stack */
|
# Align 'child_stack' to 16 bytes.
|
||||||
|
and x1, x1, #~0xf
|
||||||
|
|
||||||
|
# Copy 'fn' and 'arg' onto the child stack.
|
||||||
stp x5, x6, [x1, #-16]
|
stp x5, x6, [x1, #-16]
|
||||||
|
|
||||||
/* sys_clone */
|
# Zero out the top 32 bits of 'flags'. (Is this necessary?)
|
||||||
uxtw x0, w0
|
uxtw x0, w0
|
||||||
|
|
||||||
|
# Make the system call.
|
||||||
mov x8, __NR_clone
|
mov x8, __NR_clone
|
||||||
svc #0
|
svc #0
|
||||||
|
|
||||||
/* check for child/parent */
|
# Are we the child?
|
||||||
cbz x0,1f
|
cbz x0, .L_bc_child
|
||||||
|
|
||||||
ldr x8, [sp], #16
|
ldr x8, [sp], #16
|
||||||
ldp x29, x30, [sp], #16
|
ldp x29, x30, [sp], #16
|
||||||
|
|
||||||
|
# Set errno if something went wrong.
|
||||||
cmn x0, #(MAX_ERRNO + 1)
|
cmn x0, #(MAX_ERRNO + 1)
|
||||||
cneg x0, x0, hi
|
cneg x0, x0, hi
|
||||||
b.hi __set_errno
|
b.hi __set_errno
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
/* thread initialization - set the end of the frame record chain */
|
.L_bc_child:
|
||||||
1:
|
# We're in the child now. Set the end of the frame record chain...
|
||||||
mov x29, xzr
|
mov x29, xzr
|
||||||
|
# ...and call __bionic_clone_entry with the 'fn' and 'arg' we stored on the child stack.
|
||||||
ldp x0, x1, [sp, #-16]
|
ldp x0, x1, [sp, #-16]
|
||||||
b __bionic_clone_entry
|
b __bionic_clone_entry
|
||||||
END(__bionic_clone)
|
END(__bionic_clone)
|
||||||
|
@ -73,7 +73,7 @@ ENTRY(_longjmp)
|
|||||||
ldr w9, .L_setjmp_magic
|
ldr w9, .L_setjmp_magic
|
||||||
ldr w10, [x0, #(_JB_MAGIC * 4)]
|
ldr w10, [x0, #(_JB_MAGIC * 4)]
|
||||||
cmp w9, w10
|
cmp w9, w10
|
||||||
b.ne botch
|
b.ne .L_fail
|
||||||
|
|
||||||
/* restore core registers */
|
/* restore core registers */
|
||||||
ldp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
|
ldp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
|
||||||
@ -93,10 +93,10 @@ ENTRY(_longjmp)
|
|||||||
|
|
||||||
/* validate sp (sp mod 16 = 0) and lr (lr mod 4 = 0) */
|
/* validate sp (sp mod 16 = 0) and lr (lr mod 4 = 0) */
|
||||||
tst x30, #3
|
tst x30, #3
|
||||||
b.ne botch
|
b.ne .L_fail
|
||||||
mov x10, sp
|
mov x10, sp
|
||||||
tst x10, #15
|
tst x10, #15
|
||||||
b.ne botch
|
b.ne .L_fail
|
||||||
|
|
||||||
/* set return value */
|
/* set return value */
|
||||||
cmp w1, wzr
|
cmp w1, wzr
|
||||||
@ -104,7 +104,7 @@ ENTRY(_longjmp)
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
/* validation failed, die die die */
|
/* validation failed, die die die */
|
||||||
botch:
|
.L_fail:
|
||||||
bl PIC_SYM(longjmperror, PLT)
|
bl PIC_SYM(longjmperror, PLT)
|
||||||
bl PIC_SYM(abort, PLT)
|
bl PIC_SYM(abort, PLT)
|
||||||
b . - 8 /* Cannot get here */
|
b . - 8 /* Cannot get here */
|
||||||
|
@ -85,7 +85,7 @@ ENTRY(longjmp)
|
|||||||
ldr w9, .L_setjmp_magic
|
ldr w9, .L_setjmp_magic
|
||||||
ldr w10, [x0, #(_JB_MAGIC * 4)]
|
ldr w10, [x0, #(_JB_MAGIC * 4)]
|
||||||
cmp w9, w10
|
cmp w9, w10
|
||||||
b.ne botch
|
b.ne .L_fail
|
||||||
|
|
||||||
/* restore core registers */
|
/* restore core registers */
|
||||||
ldp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
|
ldp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
|
||||||
@ -105,10 +105,10 @@ ENTRY(longjmp)
|
|||||||
|
|
||||||
/* validate sp (sp mod 16 = 0) and lr (lr mod 4 = 0) */
|
/* validate sp (sp mod 16 = 0) and lr (lr mod 4 = 0) */
|
||||||
tst x30, #3
|
tst x30, #3
|
||||||
b.ne botch
|
b.ne .L_fail
|
||||||
mov x10, sp
|
mov x10, sp
|
||||||
tst x10, #15
|
tst x10, #15
|
||||||
b.ne botch
|
b.ne .L_fail
|
||||||
|
|
||||||
/* set return value */
|
/* set return value */
|
||||||
cmp w1, wzr
|
cmp w1, wzr
|
||||||
@ -116,7 +116,7 @@ ENTRY(longjmp)
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
/* validation failed, die die die */
|
/* validation failed, die die die */
|
||||||
botch:
|
.L_fail:
|
||||||
bl PIC_SYM(longjmperror, PLT)
|
bl PIC_SYM(longjmperror, PLT)
|
||||||
bl PIC_SYM(abort, PLT)
|
bl PIC_SYM(abort, PLT)
|
||||||
b . - 8 /* Cannot get here */
|
b . - 8 /* Cannot get here */
|
||||||
|
@ -6,7 +6,7 @@ ENTRY(__bionic_clone)
|
|||||||
pushl %esi
|
pushl %esi
|
||||||
pushl %edi
|
pushl %edi
|
||||||
|
|
||||||
# Align child stack.
|
# Align 'child_stack' to 16 bytes.
|
||||||
movl 20(%esp), %ecx
|
movl 20(%esp), %ecx
|
||||||
andl $~15, %ecx
|
andl $~15, %ecx
|
||||||
|
|
||||||
@ -28,8 +28,8 @@ ENTRY(__bionic_clone)
|
|||||||
|
|
||||||
# Check result.
|
# Check result.
|
||||||
cmpl $0, %eax
|
cmpl $0, %eax
|
||||||
je bc_child
|
je .L_bc_child
|
||||||
jg bc_parent
|
jg .L_bc_parent
|
||||||
|
|
||||||
# An error occurred, so set errno and return -1.
|
# An error occurred, so set errno and return -1.
|
||||||
negl %eax
|
negl %eax
|
||||||
@ -37,15 +37,15 @@ ENTRY(__bionic_clone)
|
|||||||
call __set_errno
|
call __set_errno
|
||||||
addl $4, %esp
|
addl $4, %esp
|
||||||
orl $-1, %eax
|
orl $-1, %eax
|
||||||
jmp bc_return
|
jmp .L_bc_return
|
||||||
|
|
||||||
bc_child:
|
.L_bc_child:
|
||||||
call __bionic_clone_entry
|
call __bionic_clone_entry
|
||||||
hlt
|
hlt
|
||||||
|
|
||||||
bc_parent:
|
.L_bc_parent:
|
||||||
# we're the parent; nothing to do.
|
# we're the parent; nothing to do.
|
||||||
bc_return:
|
.L_bc_return:
|
||||||
popl %edi
|
popl %edi
|
||||||
popl %esi
|
popl %esi
|
||||||
popl %ebx
|
popl %ebx
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
// pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
|
// pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
|
||||||
ENTRY(__bionic_clone)
|
ENTRY(__bionic_clone)
|
||||||
# Enforce 16-byte alignment for child stack.
|
# Align 'child_stack' to 16 bytes.
|
||||||
andq $~15, %rsi
|
andq $~15, %rsi
|
||||||
|
|
||||||
# Copy 'fn' and 'arg' onto the child stack.
|
# Copy 'fn' and 'arg' onto the child stack.
|
||||||
|
Loading…
Reference in New Issue
Block a user