cpu_setfunc() can not use lwp_trampoline, as that has additional lwp startup

semantics. Use a simpler setfunc_trampoline instead.
This commit is contained in:
martin 2009-05-30 16:52:32 +00:00
parent 9bae1e8ed5
commit 7f65d1375e
3 changed files with 23 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.85 2009/05/16 19:15:34 nakayama Exp $ */
/* $NetBSD: cpu.h,v 1.86 2009/05/30 16:52:32 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@ -338,7 +338,6 @@ int probeset(paddr_t, int, int, uint64_t);
#define write_all_windows() __asm volatile("flushw" : : )
#define write_user_windows() __asm volatile("flushw" : : )
void lwp_trampoline(void);
struct pcb;
void snapshot(struct pcb *);
struct frame *getfp(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.290 2009/05/18 11:42:30 nakayama Exp $ */
/* $NetBSD: locore.s,v 1.291 2009/05/30 16:52:32 martin Exp $ */
/*
* Copyright (c) 1996-2002 Eduardo Horvath
@ -6851,6 +6851,16 @@ ENTRY(lwp_trampoline)
ba,a,pt %icc, return_from_trap
nop
/*
* Like lwp_trampoline, but for cpu_setfunc(), i.e. without newlwp
* arguement and will not call lwp_startup.
*/
ENTRY(setfunc_trampoline)
call %l0 ! re-use current frame
mov %l1, %o0
ba,a,pt %icc, return_from_trap
nop
/*
* {fu,su}{,i}{byte,word}
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.88 2009/05/21 13:24:38 martin Exp $ */
/* $NetBSD: vm_machdep.c,v 1.89 2009/05/30 16:52:32 martin Exp $ */
/*
* Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved.
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.88 2009/05/21 13:24:38 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.89 2009/05/30 16:52:32 martin Exp $");
#include "opt_multiprocessor.h"
@ -157,6 +157,7 @@ cpu_proc_fork(struct proc *p1, struct proc *p2)
char cpu_forkname[] = "cpu_lwp_fork()";
#endif
void setfunc_trampoline(void);
inline void
cpu_setfunc(struct lwp *l, void (*func)(void *), void *arg)
{
@ -166,9 +167,8 @@ cpu_setfunc(struct lwp *l, void (*func)(void *), void *arg)
rp = (struct rwindow *)((u_long)npcb + TOPFRAMEOFF);
rp->rw_local[0] = (long)func; /* Function to call */
rp->rw_local[1] = (long)arg; /* and its argument */
rp->rw_local[2] = (long)l; /* new lwp */
npcb->pcb_pc = (long)lwp_trampoline - 8;
npcb->pcb_pc = (long)setfunc_trampoline - 8;
npcb->pcb_sp = (long)rp - STACK_OFFSET;
}
@ -190,6 +190,7 @@ cpu_setfunc(struct lwp *l, void (*func)(void *), void *arg)
* in both the stack and stacksize args), set up the user stack pointer
* accordingly.
*/
void lwp_trampoline(void);
void
cpu_lwp_fork(register struct lwp *l1, register struct lwp *l2, void *stack, size_t stacksize, void (*func)(void *), void *arg)
{
@ -274,7 +275,12 @@ cpu_lwp_fork(register struct lwp *l1, register struct lwp *l2, void *stack, size
rp = (struct rwindow *)((u_long)npcb + TOPFRAMEOFF);
*rp = *(struct rwindow *)((u_long)opcb + TOPFRAMEOFF);
cpu_setfunc(l2, func, arg);
rp->rw_local[0] = (long)func; /* Function to call */
rp->rw_local[1] = (long)arg; /* and its argument */
rp->rw_local[2] = (long)l2; /* new lwp */
npcb->pcb_pc = (long)lwp_trampoline - 8;
npcb->pcb_sp = (long)rp - STACK_OFFSET;
}
static inline void