diff options
author | 2012-06-21 00:56:59 +0000 | |
---|---|---|
committer | 2012-06-21 00:56:59 +0000 | |
commit | 16b62b6a0b93be6a70f097edd49f4c661f85cd4f (patch) | |
tree | b60ec958758bfe01ad491979d73feeea25c66228 /lib | |
parent | fix strlcpy truncation check. from carsten at debian org, ok markus (diff) | |
download | wireguard-openbsd-16b62b6a0b93be6a70f097edd49f4c661f85cd4f.tar.xz wireguard-openbsd-16b62b6a0b93be6a70f097edd49f4c661f85cd4f.zip |
__tfork() needs to set the stack address of the new thread in the kernel,
so that it can't get a signal while still running on the parent thread's
stack. Also, pass in sizeof(struct __tfork) to provide forward compat
when more members are added. This is an ABI change, so switch syscall
numbers and bump lib majors this time.
ok deraadt@ matthew@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/arch/alpha/sys/tfork_thread.S | 9 | ||||
-rw-r--r-- | lib/libc/arch/amd64/sys/tfork_thread.S | 9 | ||||
-rw-r--r-- | lib/libc/arch/arm/sys/tfork_thread.S | 17 | ||||
-rw-r--r-- | lib/libc/arch/hppa/sys/tfork_thread.S | 18 | ||||
-rw-r--r-- | lib/libc/arch/hppa64/sys/tfork_thread.S | 11 | ||||
-rw-r--r-- | lib/libc/arch/i386/sys/tfork_thread.S | 44 | ||||
-rw-r--r-- | lib/libc/arch/m68k/sys/tfork_thread.S | 13 | ||||
-rw-r--r-- | lib/libc/arch/m88k/sys/tfork_thread.S | 8 | ||||
-rw-r--r-- | lib/libc/arch/mips64/sys/tfork_thread.S | 14 | ||||
-rw-r--r-- | lib/libc/arch/powerpc/sys/tfork_thread.S | 8 | ||||
-rw-r--r-- | lib/libc/arch/sh/sys/tfork_thread.S | 7 | ||||
-rw-r--r-- | lib/libc/arch/sparc/sys/tfork_thread.S | 12 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/sys/tfork_thread.S | 11 | ||||
-rw-r--r-- | lib/libc/arch/vax/sys/tfork_thread.S | 16 | ||||
-rw-r--r-- | lib/libc/shlib_version | 4 | ||||
-rw-r--r-- | lib/librthread/rthread.c | 10 | ||||
-rw-r--r-- | lib/librthread/shlib_version | 4 |
17 files changed, 80 insertions, 135 deletions
diff --git a/lib/libc/arch/alpha/sys/tfork_thread.S b/lib/libc/arch/alpha/sys/tfork_thread.S index 10fac103287..9b84cd0158a 100644 --- a/lib/libc/arch/alpha/sys/tfork_thread.S +++ b/lib/libc/arch/alpha/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:55 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -28,10 +28,10 @@ #include "SYS.h" /* - * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); */ LEAF(__tfork_thread,0) - /* a0 = flags, a1 = stack, a2 = func, a3 = arg */ + /* a0 = flags, a1 = psize, a2 = func, a3 = arg */ mov a3, a5 CALLSYS_ERROR(__tfork) @@ -44,9 +44,8 @@ LEAF(__tfork_thread,0) 1: /* - * In child process: switch stack, invoke function, then exit. + * In child process: invoke function, then exit. */ - mov a1, sp /* stack */ mov a5, a0 /* arg */ mov a2, pv /* func */ jsr ra, (pv) diff --git a/lib/libc/arch/amd64/sys/tfork_thread.S b/lib/libc/arch/amd64/sys/tfork_thread.S index 41a42d79972..9eb4f0631fe 100644 --- a/lib/libc/arch/amd64/sys/tfork_thread.S +++ b/lib/libc/arch/amd64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:55 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /*- * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org> * Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu> @@ -38,11 +38,11 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/amd64/gen/rfork_thread.S,v 1.1 #include "SYS.h" /* - * %rdi %rsi %rdx %rcx - * __tfork_thread(param, stack_addr, start_fnc, start_arg); + * %rdi %rsi %rdx %rcx + * __tfork_thread(param, psize, start_fnc, start_arg); * * param: Argument to pass to the actual kernel call. - * stack_addr: Top of stack for thread. + * psize: Other argument to pass to the actual kernel call. * start_fnc: Address of thread function to call in child. * start_arg: Argument to pass to the thread function in child. */ @@ -71,7 +71,6 @@ ENTRY(__tfork_thread) * returns, then call __threxit. */ 1: - movq %rsi, %rsp movq %r9, %rdi call *%r8 diff --git a/lib/libc/arch/arm/sys/tfork_thread.S b/lib/libc/arch/arm/sys/tfork_thread.S index 0ece8d15d2a..4115477f28d 100644 --- a/lib/libc/arch/arm/sys/tfork_thread.S +++ b/lib/libc/arch/arm/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:55 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005 Dale Rahn <drahn@openbsd.org> * @@ -19,30 +19,23 @@ #include "SYS.h" /* - * r0 r1 r2 r3 - * __tfork_thread(param, stack_addr, start_fnc, start_arg); + * r0 r1 r2 r3 + * __tfork_thread(param, psize, start_fnc, start_arg); */ ENTRY(__tfork_thread) - stmdb sp!, {r4} - mov r4, r1 - - SYSTRAP(__tfork) - bcs 1f + bcs 1f /* XXX can this be PIC_SYM(CERROR, PLT) ? */ /* check if we are parent or child */ cmp r0, #0 - ldmneia sp!, {r4} movne pc, lr /* child */ - mov sp, r4 mov r0, r3 mov lr, pc mov pc, r2 nop SYSTRAP(__threxit) 1: - ldmia sp!, {r4} - b PIC_SYM(CERROR, PLT) + b PIC_SYM(CERROR, PLT) diff --git a/lib/libc/arch/hppa/sys/tfork_thread.S b/lib/libc/arch/hppa/sys/tfork_thread.S index 5a77bd3bbea..65a8af3c514 100644 --- a/lib/libc/arch/hppa/sys/tfork_thread.S +++ b/lib/libc/arch/hppa/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:55 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -28,7 +28,7 @@ #include "SYS.h" /* - * int __tfork_thread(param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(param, size_t psize, void (*func)(void *), void *arg); */ ENTRY(__tfork_thread, 0) SYSCALL(__tfork) @@ -36,20 +36,8 @@ ENTRY(__tfork_thread, 0) nop /* - * In child process: switch stack, invoke function, then exit. + * In child process: invoke function, then exit. */ - - /* - * PIC code expects 32 bytes of room available below sp. - * Then the regular procedure invocation requires us to allocate - * 64 bytes as well. - */ - copy arg1, sp - ldo 0(sp), r3 - stw,ma r0, HPPA_FRAME_SIZE(sp) - stw r0, HPPA_FRAME_CRP(sp) - stw r0, HPPA_FRAME_PSP(sp) - copy arg3, arg0 /* arg */ copy arg2, t1 bl $$dyncall, r31 diff --git a/lib/libc/arch/hppa64/sys/tfork_thread.S b/lib/libc/arch/hppa64/sys/tfork_thread.S index 96a8e4a72f6..4fd2cb67700 100644 --- a/lib/libc/arch/hppa64/sys/tfork_thread.S +++ b/lib/libc/arch/hppa64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/04/11 12:27:08 jsing Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat * @@ -27,7 +27,7 @@ #include "SYS.h" /* - * int __tfork_thread(param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(param, size_t psize, void (*func)(void *), void *arg); */ ENTRY(__tfork_thread, 0) SYSCALL(__tfork) @@ -35,13 +35,8 @@ ENTRY(__tfork_thread, 0) nop /* - * In child process: switch stack, invoke function, then exit. + * In child process: invoke function, then exit. */ - copy %arg1, %sp - ldo 0(%sp), %r3 - std,ma %r0, HPPA_FRAME_SIZE(%sp) - std %r0, HPPA_FRAME_PSP(%sp) - copy %arg3, %arg0 /* arg */ copy %arg2, %t1 b,l $$dyncall, %r31 diff --git a/lib/libc/arch/i386/sys/tfork_thread.S b/lib/libc/arch/i386/sys/tfork_thread.S index 4b7de1b030c..57a7339eed3 100644 --- a/lib/libc/arch/i386/sys/tfork_thread.S +++ b/lib/libc/arch/i386/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.2 2012/04/11 18:36:57 kettenis Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.3 2012/06/21 00:56:59 guenther Exp $ */ /*- * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org> * All rights reserved. @@ -37,11 +37,11 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/i386/gen/rfork_thread.S,v 1.5 2 #include "SYS.h" /* - * 8 12 16 20 - * __tfork_thread(param, stack_addr, start_fnc, start_arg); + * 8 12 16 20 + * __tfork_thread(param, psize, start_fnc, start_arg); * * param: Arguments to actual system call. - * stack_addr: Top of stack for thread. + * psize: Other argument to pass to the actual kernel call. * start_fnc: Address of thread function to call in child. * start_arg: Argument to pass to the thread function in child. */ @@ -50,25 +50,20 @@ ENTRY(__tfork_thread) pushl %ebp movl %esp, %ebp pushl %esi + pushl %edi /* - * Push thread info onto the new thread's stack + * Save the thread info in esi and ebx */ - movl 12(%ebp), %esi # get stack addr - - subl $4, %esi - movl 20(%ebp), %eax # get start argument - movl %eax, (%esi) - - subl $4, %esi - movl 16(%ebp), %eax # get start thread address - movl %eax, (%esi) + movl 16(%ebp), %esi # get start thread address + movl 20(%ebp), %edi # get start argument /* * Prepare and execute the thread creation syscall */ - pushl 8(%ebp) - pushl $0 + pushl 12(%ebp) # push psize + pushl 8(%ebp) # push param + pushl $0 # slot for return address, ignored by kernel movl $SYS___tfork, %eax int $0x80 jb 2f @@ -78,7 +73,8 @@ ENTRY(__tfork_thread) */ cmpl $0, %edx jnz 1f - addl $8, %esp + addl $12, %esp + popl %edi popl %esi movl %ebp, %esp popl %ebp @@ -88,20 +84,19 @@ ENTRY(__tfork_thread) /* * If we are in the child (new thread), then * set-up the call to the internal subroutine. If it - * returns, then call __exit. + * returns, then call __threxit. */ 1: xorl %ebp, %ebp # mark outermost frame - movl %esi, %esp - popl %eax - call *%eax + pushl %edi # push start argument + call *%esi addl $4, %esp /* * Exit system call */ - pushl %eax - pushl $0 + pushl $0 # NULL pointer argument to __threxit + pushl $0 # slot for return address, ignored by kernel movl $SYS___threxit, %eax int $0x80 @@ -109,7 +104,8 @@ ENTRY(__tfork_thread) * Branch here if the thread creation fails: */ 2: - addl $8, %esp + addl $12, %esp + popl %edi popl %esi movl %ebp, %esp popl %ebp diff --git a/lib/libc/arch/m68k/sys/tfork_thread.S b/lib/libc/arch/m68k/sys/tfork_thread.S index 2d6d791ae42..b44442f2bcb 100644 --- a/lib/libc/arch/m68k/sys/tfork_thread.S +++ b/lib/libc/arch/m68k/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:55 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -28,14 +28,13 @@ #include "SYS.h" /* - * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); */ ENTRY(__tfork_thread) /* - * Set up the new thread's stack. + * Move info for the new thread into registers. */ - movl sp@(8), a0 /* stack */ - movl sp@(16), a0@- /* arg */ + movl sp@(16), a0 /* arg */ movl sp@(12), a1 /* func */ /* @@ -55,9 +54,9 @@ ENTRY(__tfork_thread) 1: /* - * child process: switch stacks, invoke function, then exit. + * child process: invoke function, then exit. */ - movl a0, sp /* stack with arg pushed on it */ + movl a0, sp@- /* stack with arg pushed on it */ jsr a1@ /* func */ addq #4, sp diff --git a/lib/libc/arch/m88k/sys/tfork_thread.S b/lib/libc/arch/m88k/sys/tfork_thread.S index 351d93151da..df901bba981 100644 --- a/lib/libc/arch/m88k/sys/tfork_thread.S +++ b/lib/libc/arch/m88k/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:55 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -28,10 +28,9 @@ #include "SYS.h" /* - * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); */ ENTRY(__tfork_thread) - or r6, r3, r0 /* save stack */ or r13, r0, __SYSCALLNAME(SYS_,__tfork) tb0 0, r0, 128 /* corrupts r2 and r3 in the child */ br __cerror @@ -45,9 +44,8 @@ ENTRY(__tfork_thread) 1: /* - * In child process: switch stack, invoke function, then exit. + * In child process: invoke function, then exit. */ - or r31, r6, r0 /* stack */ jsr.n r4 /* func */ or r2, r5, r0 /* arg */ diff --git a/lib/libc/arch/mips64/sys/tfork_thread.S b/lib/libc/arch/mips64/sys/tfork_thread.S index aaedba7df17..b0cf318553a 100644 --- a/lib/libc/arch/mips64/sys/tfork_thread.S +++ b/lib/libc/arch/mips64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:55 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -28,27 +28,26 @@ #include "SYS.h" /* - * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); */ FRAMESZ=4*REGSZ GPOFF=FRAMESZ-2*REGSZ LEAF(__tfork_thread, FRAMESZ) - /* a0 = param, a1 = stack, a2 = func, a3 = arg */ + /* a0 = param, a1 = psize, a2 = func, a3 = arg */ PTR_SUBU sp, FRAMESZ SETUP_GP64(GPOFF, _C_LABEL(__tfork_thread)) .set reorder - move t0, a1 /* stack */ move t1, a3 /* arg */ __DO_SYSCALL(__tfork) bnez a3, 9f + beqz v0, 1f + RESTORE_GP64 PTR_ADDU sp, FRAMESZ - beqz v0, 1f - /* * In parent process: just return. */ @@ -56,10 +55,9 @@ LEAF(__tfork_thread, FRAMESZ) 1: /* - * In child process: switch stack, invoke function, then exit. + * In child process: invoke function, then exit. */ - move sp, t0 /* stack */ move t9, a2 /* func */ move a0, t1 /* arg */ move v0, zero diff --git a/lib/libc/arch/powerpc/sys/tfork_thread.S b/lib/libc/arch/powerpc/sys/tfork_thread.S index 2e9a46a7664..aa5f59c966d 100644 --- a/lib/libc/arch/powerpc/sys/tfork_thread.S +++ b/lib/libc/arch/powerpc/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:56 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005 Tim Wiess <tim@nop.cx> @@ -21,13 +21,9 @@ ENTRY(__tfork_thread) /* sanity check */ - cmpwi %r4, 0 - beq 1f cmpwi %r5, 0 beq 1f - mr %r7,%r4 - /* call __tfork */ li %r0, SYS___tfork sc @@ -41,7 +37,7 @@ ENTRY(__tfork_thread) /* child */ mtlr %r5 /* fp */ mr %r3, %r6 /* arg */ - subi %r1, %r7, 16 /* fixup sp to get headroom */ + subi %r1, %r1, 16 /* fixup sp to get headroom */ blrl /* child returned, call _exit */ diff --git a/lib/libc/arch/sh/sys/tfork_thread.S b/lib/libc/arch/sh/sys/tfork_thread.S index bfca155e1d0..49235c0b829 100644 --- a/lib/libc/arch/sh/sys/tfork_thread.S +++ b/lib/libc/arch/sh/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:56 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2007 Miodrag Vallat. @@ -20,7 +20,7 @@ #include "SYS.h" /* - * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); * r4 r5 r6 r7 */ ENTRY(__tfork_thread) @@ -39,9 +39,8 @@ ENTRY(__tfork_thread) 1: /* - * In child process: switch stack, invoke function, then exit. + * In child process: invoke function, then exit. */ - mov r5, sp jsr @r6 mov r7, r4 diff --git a/lib/libc/arch/sparc/sys/tfork_thread.S b/lib/libc/arch/sparc/sys/tfork_thread.S index 882a07f7234..09bf0083810 100644 --- a/lib/libc/arch/sparc/sys/tfork_thread.S +++ b/lib/libc/arch/sparc/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:56 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -28,11 +28,9 @@ #include "SYS.h" /* - * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); */ ENTRY(__tfork_thread) - mov %o1, %o4 /* save stack */ - /* * We can not invoke __tfork as a G2-style system call since we want * different return paths. @@ -54,12 +52,8 @@ ENTRY(__tfork_thread) 1: /* - * In child process: switch stack, invoke function, then exit. - * Don't forget to allocate room for a window save on the new - * stack! + * In child process: invoke function, then exit. */ - sub %g0, %g0, %fp - sub %o4, 96, %sp /* stack */ call %o2 /* func */ mov %o3, %o0 /* arg */ diff --git a/lib/libc/arch/sparc64/sys/tfork_thread.S b/lib/libc/arch/sparc64/sys/tfork_thread.S index d22aba43a55..cf70b25d401 100644 --- a/lib/libc/arch/sparc64/sys/tfork_thread.S +++ b/lib/libc/arch/sparc64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:56 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -28,11 +28,9 @@ #include "SYS.h" /* - * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); */ ENTRY(__tfork_thread) - mov %o1, %o4 /* save stack */ - /* * We can not invoke __tfork as a G2-style system call since we want * different return paths. @@ -54,11 +52,8 @@ ENTRY(__tfork_thread) 1: /* - * In child process: switch stack, invoke function, then exit. + * In child process: invoke function, then exit. */ - - mov %g0, %fp /* clear frame pointer */ - sub %o4, (BIAS + CC64FSZ), %sp /* stack */ call %o2 /* func */ mov %o3, %o0 /* arg */ diff --git a/lib/libc/arch/vax/sys/tfork_thread.S b/lib/libc/arch/vax/sys/tfork_thread.S index 1d22f1e924b..123c4a83641 100644 --- a/lib/libc/arch/vax/sys/tfork_thread.S +++ b/lib/libc/arch/vax/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.1 2012/03/22 00:44:56 guenther Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.2 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -28,15 +28,14 @@ #include "SYS.h" /* - * int __tfork_thread(const struct __tfork *param, void *stack, void (*func)(void *), void *arg); + * int __tfork_thread(const struct __tfork *param, size_t psize, void (*func)(void *), void *arg); */ -ENTRY(__tfork_thread, R2|R3|R4) +ENTRY(__tfork_thread, R2|R3) /* * Save thread creation arguments into registers. */ - movl 8(ap), r2 /* stack */ - movl 12(ap), r3 /* func */ - movl 16(ap), r4 /* arg */ + movl 12(ap), r2 /* func */ + movl 16(ap), r3 /* arg */ __DO_SYSCALL(__tfork) jcs 9f @@ -55,9 +54,8 @@ ENTRY(__tfork_thread, R2|R3|R4) * Note that since we can not pass a register to calls, we need * to waste 4 bytes of stack in every thread. */ - movl r2, sp /* stack */ - pushl r3 /* func */ - pushl r4 /* arg */ + pushl r2 /* func */ + pushl r3 /* arg */ calls $1, *4(sp) /* func */ __DO_SYSCALL(__threxit) diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version index 56a8145c9df..bb49a127eb9 100644 --- a/lib/libc/shlib_version +++ b/lib/libc/shlib_version @@ -1,4 +1,4 @@ -major=64 -minor=2 +major=65 +minor=0 # note: If changes were made to include/thread_private.h or if system # calls were added/changed then libpthread must also be updated. diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c index f8f6605e726..27a9b6dbf72 100644 --- a/lib/librthread/rthread.c +++ b/lib/librthread/rthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.c,v 1.61 2012/04/10 21:10:45 guenther Exp $ */ +/* $OpenBSD: rthread.c,v 1.62 2012/06/21 00:56:59 guenther Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org> * All Rights Reserved. @@ -48,8 +48,6 @@ static _spinlock_lock_t _thread_gc_lock = _SPINLOCK_UNLOCKED; struct pthread _initial_thread; struct thread_control_block _initial_thread_tcb; -int __tfork_thread(const struct __tfork *, void *, void (*)(void *), void *); - struct pthread_attr _rthread_attr_default = { #ifndef lint .stack_addr = NULL, @@ -86,7 +84,7 @@ _spinunlock(_spinlock_lock_t *lock) /* * This sets up the thread base for the initial thread so that it * references the errno location provided by libc. For other threads - * this is handled by the block in _rthread_start(). + * this is handled by __tfork_thread() */ void _rthread_initlib(void) __attribute__((constructor)); void _rthread_initlib(void) @@ -415,7 +413,7 @@ pthread_create(pthread_t *threadp, const pthread_attr_t *attr, param.tf_tcb = tcb; param.tf_tid = &thread->tid; - param.tf_flags = 0; + param.tf_stack = thread->stack->sp; _spinlock(&_thread_lock); LIST_INSERT_HEAD(&_thread_list, thread, threads); @@ -423,7 +421,7 @@ pthread_create(pthread_t *threadp, const pthread_attr_t *attr, /* we're going to be multi-threaded real soon now */ __isthreaded = 1; - rc = __tfork_thread(¶m, thread->stack->sp, _rthread_start, thread); + rc = __tfork_thread(¶m, sizeof(param), _rthread_start, thread); if (rc != -1) { /* success */ *threadp = thread; diff --git a/lib/librthread/shlib_version b/lib/librthread/shlib_version index 998729533f3..84e2c2920d7 100644 --- a/lib/librthread/shlib_version +++ b/lib/librthread/shlib_version @@ -1,2 +1,2 @@ -major=15 -minor=2 +major=16 +minor=0 |