From bb3cd9518721986ad148e543a0f97d97ab5a5c9f Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Tue, 19 Sep 2006 11:47:36 +0000 Subject: [PATCH] 1:1 Userland threading stage 2.9/4: Push out p_thread a little bit more --- sys/amd64/amd64/genassym.c | 3 +- sys/cpu/i386/include/cpu.h | 6 +-- sys/cpu/i386/include/npx.h | 4 +- sys/cpu/i386/include/reg.h | 4 +- sys/ddb/db_ps.c | 9 ++-- sys/emulation/linux/i386/linux_ptrace.c | 21 ++++---- sys/i386/i386/db_trace.c | 15 ++++-- sys/i386/i386/genassym.c | 3 +- sys/i386/i386/machdep.c | 65 ++----------------------- sys/i386/i386/trap.c | 12 ++--- sys/i386/i386/vm_machdep.c | 51 ++++++++++--------- sys/i386/include/cpu.h | 6 +-- sys/i386/include/npx.h | 4 +- sys/i386/include/ptrace.h | 14 +----- sys/i386/include/reg.h | 4 +- sys/i386/isa/npx.c | 8 +-- sys/kern/imgact_resident.c | 6 +-- sys/kern/init_main.c | 6 ++- sys/kern/kern_descrip.c | 11 +++-- sys/kern/kern_event.c | 6 ++- sys/kern/kern_exec.c | 4 +- sys/kern/kern_exit.c | 23 +++++---- sys/kern/kern_fork.c | 6 +-- sys/kern/kern_sig.c | 7 +-- sys/kern/sys_process.c | 4 +- sys/kern/tty.c | 11 +++-- sys/kern/vfs_aio.c | 7 +-- sys/kern/vfs_subr.c | 6 +-- sys/netproto/smb/smb_subr.c | 7 ++- sys/platform/pc32/i386/db_trace.c | 15 ++++-- sys/platform/pc32/i386/genassym.c | 3 +- sys/platform/pc32/i386/machdep.c | 65 ++----------------------- sys/platform/pc32/i386/trap.c | 12 ++--- sys/platform/pc32/i386/vm_machdep.c | 51 ++++++++++--------- sys/platform/pc32/include/ptrace.h | 14 +----- sys/platform/pc32/isa/npx.c | 8 +-- sys/platform/vkernel/i386/genassym.c | 3 +- sys/sys/proc.h | 6 +-- sys/sys/ptrace.h | 3 +- sys/vm/vm_extern.h | 4 +- sys/vm/vm_glue.c | 9 ++-- 41 files changed, 204 insertions(+), 322 deletions(-) diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index 72b6dd6112..23390559ec 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/amd64/amd64/Attic/genassym.c,v 1.11 2006/06/04 21:09:44 dillon Exp $ + * $DragonFly: src/sys/amd64/amd64/Attic/genassym.c,v 1.12 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -75,7 +75,6 @@ ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); ASSYM(P_ADDR, offsetof(struct proc, p_addr)); ASSYM(P_STAT, offsetof(struct proc, p_stat)); -ASSYM(P_THREAD, offsetof(struct proc, p_thread)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); diff --git a/sys/cpu/i386/include/cpu.h b/sys/cpu/i386/include/cpu.h index b590a63b47..9c95cd36b3 100644 --- a/sys/cpu/i386/include/cpu.h +++ b/sys/cpu/i386/include/cpu.h @@ -35,7 +35,7 @@ * * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/include/cpu.h,v 1.43.2.2 2001/06/15 09:37:57 scottl Exp $ - * $DragonFly: src/sys/cpu/i386/include/cpu.h,v 1.17 2006/09/10 01:26:39 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/cpu.h,v 1.18 2006/09/19 11:47:35 corecode Exp $ */ #ifndef _MACHINE_CPU_H_ @@ -122,13 +122,13 @@ #ifdef _KERNEL -struct proc; +struct lwp; extern char btext[]; extern char etext[]; void fork_trampoline (void); -void fork_return (struct proc *, struct trapframe); +void fork_return (struct lwp *, struct trapframe); #endif diff --git a/sys/cpu/i386/include/npx.h b/sys/cpu/i386/include/npx.h index 12c576e138..ce77adfd72 100644 --- a/sys/cpu/i386/include/npx.h +++ b/sys/cpu/i386/include/npx.h @@ -35,7 +35,7 @@ * * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 * $FreeBSD: src/sys/i386/include/npx.h,v 1.18.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/cpu/i386/include/npx.h,v 1.8 2006/05/20 02:42:06 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/npx.h,v 1.9 2006/09/19 11:47:35 corecode Exp $ */ /* @@ -150,7 +150,7 @@ union savefpu { struct proc; int npxdna (void); -void npxexit (struct proc *p); +void npxexit (void); void npxinit (u_short control); void npxsave (union savefpu *addr); #endif diff --git a/sys/cpu/i386/include/reg.h b/sys/cpu/i386/include/reg.h index 39101d5002..5a5bf4c144 100644 --- a/sys/cpu/i386/include/reg.h +++ b/sys/cpu/i386/include/reg.h @@ -35,7 +35,7 @@ * * from: @(#)reg.h 5.5 (Berkeley) 1/18/91 * $FreeBSD: src/sys/i386/include/reg.h,v 1.22.2.2 2002/11/07 22:47:55 alfred Exp $ - * $DragonFly: src/sys/cpu/i386/include/reg.h,v 1.5 2006/05/20 02:42:06 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/reg.h,v 1.6 2006/09/19 11:47:35 corecode Exp $ */ #ifndef _MACHINE_REG_H_ @@ -154,7 +154,7 @@ struct lwp; */ int set_fpregs (struct lwp *, struct fpreg *); int set_regs (struct lwp *lp, struct reg *regs); -void setregs (struct proc *, u_long, u_long, u_long); +void setregs (struct lwp *, u_long, u_long, u_long); int set_dbregs (struct lwp *lp, struct dbreg *dbregs); #endif diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c index 65343de3fe..864170637f 100644 --- a/sys/ddb/db_ps.c +++ b/sys/ddb/db_ps.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ddb/db_ps.c,v 1.20 1999/08/28 00:41:09 peter Exp $ - * $DragonFly: src/sys/ddb/db_ps.c,v 1.18 2006/05/29 03:57:18 dillon Exp $ + * $DragonFly: src/sys/ddb/db_ps.c,v 1.19 2006/09/19 11:47:35 corecode Exp $ */ #include #include @@ -59,7 +59,7 @@ db_ps(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4) if (db_more(&nl) < 0) return; - db_printf(" pid proc addr uid ppid pgrp flag stat wmesg wchan cmd\n"); + db_printf(" pid proc uid ppid pgrp flag stat wmesg wchan cmd\n"); while (--np >= 0) { /* * XXX just take 20 for now... @@ -74,8 +74,8 @@ db_ps(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4) if (pp == NULL) pp = p; - db_printf("%5d %8p %8p %4d %5d %5d %06x %d", - p->p_pid, (volatile void *)p, (void *)p->p_thread->td_pcb, + db_printf("%5d %8p %4d %5d %5d %06x %d", + p->p_pid, (volatile void *)p, p->p_ucred ? p->p_ucred->cr_ruid : 0, pp->p_pid, p->p_pgrp ? p->p_pgrp->pg_id : 0, p->p_flag, p->p_stat); if (p->p_wchan) { @@ -84,7 +84,6 @@ db_ps(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4) db_printf(" "); } db_printf(" %s\n", p->p_comm ? p->p_comm : ""); - db_dump_td_tokens(p->p_thread); p = p->p_list.le_next; if (p == NULL && np > 0) diff --git a/sys/emulation/linux/i386/linux_ptrace.c b/sys/emulation/linux/i386/linux_ptrace.c index fe19d5fe7c..eae9f0371c 100644 --- a/sys/emulation/linux/i386/linux_ptrace.c +++ b/sys/emulation/linux/i386/linux_ptrace.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/linux/linux_ptrace.c,v 1.7.4.3 2003/01/03 17:13:23 kan Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linux_ptrace.c,v 1.10 2006/06/05 07:26:10 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linux_ptrace.c,v 1.11 2006/09/19 11:47:35 corecode Exp $ */ #include "opt_cpu.h" @@ -217,29 +217,29 @@ struct linux_pt_fpxreg { #ifndef CPU_DISABLE_SSE static int -linux_proc_read_fpxregs(struct proc *p, struct linux_pt_fpxreg *fpxregs) +linux_proc_read_fpxregs(struct thread *td, struct linux_pt_fpxreg *fpxregs) { int error; error = 0; - if (cpu_fxsr == 0 || (p->p_flag & P_SWAPPEDOUT)) + if (cpu_fxsr == 0) error = EIO; else - bcopy(&p->p_thread->td_pcb->pcb_save.sv_xmm, + bcopy(&td->td_pcb->pcb_save.sv_xmm, fpxregs, sizeof(*fpxregs)); return (error); } static int -linux_proc_write_fpxregs(struct proc *p, struct linux_pt_fpxreg *fpxregs) +linux_proc_write_fpxregs(struct thread *td, struct linux_pt_fpxreg *fpxregs) { int error; error = 0; - if (cpu_fxsr == 0 || (p->p_flag & P_SWAPPEDOUT)) + if (cpu_fxsr == 0) error = EIO; else - bcopy(fpxregs, &p->p_thread->td_pcb->pcb_save.sv_xmm, + bcopy(fpxregs, &td->td_pcb->pcb_save.sv_xmm, sizeof(*fpxregs)); return (error); } @@ -248,7 +248,8 @@ linux_proc_write_fpxregs(struct proc *p, struct linux_pt_fpxreg *fpxregs) int sys_linux_ptrace(struct linux_ptrace_args *uap) { - struct proc *curp = curproc; + struct thread *td = curthread; + struct proc *curp = td->td_proc; union { struct linux_pt_reg reg; struct linux_pt_fpreg fpreg; @@ -396,7 +397,7 @@ sys_linux_ptrace(struct linux_ptrace_args *uap) if (req == PTRACE_GETFPXREGS) { PHOLD(p); - error = linux_proc_read_fpxregs(p, &r.fpxreg); + error = linux_proc_read_fpxregs(td, &r.fpxreg); PRELE(p); if (error == 0) error = copyout(&r.fpxreg, (caddr_t)uap->data, @@ -405,7 +406,7 @@ sys_linux_ptrace(struct linux_ptrace_args *uap) /* clear dangerous bits exactly as Linux does*/ r.fpxreg.mxcsr &= 0xffbf; PHOLD(p); - error = linux_proc_write_fpxregs(p, &r.fpxreg); + error = linux_proc_write_fpxregs(td, &r.fpxreg); PRELE(p); } break; diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 6e5c0bce1f..3e7a7f6b43 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -24,7 +24,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/i386/i386/db_trace.c,v 1.35.2.3 2002/02/21 22:31:25 silby Exp $ - * $DragonFly: src/sys/i386/i386/Attic/db_trace.c,v 1.14 2006/09/03 17:55:34 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/db_trace.c,v 1.15 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -265,9 +265,6 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, int *argp; db_addr_t callpc; boolean_t first; - struct pcb *pcb; - struct proc *p; - pid_t pid; int i; if (count == -1) @@ -279,6 +276,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, frame = (struct i386_frame *)(SP_REGS(&ddb_regs) - 4); callpc = PC_REGS(&ddb_regs); } else if (!INKERNEL(addr)) { +#if needswork pid = (addr % 16) + ((addr >> 4) % 16) * 10 + ((addr >> 8) % 16) * 100 + ((addr >> 12) % 16) * 1000 + ((addr >> 16) % 16) * 10000; @@ -293,6 +291,10 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, (SP_REGS(&ddb_regs) - 4); callpc = PC_REGS(&ddb_regs); } else { + pid_t pid; + struct proc *p; + struct pcb *pcb; + p = pfind(pid); if (p == NULL) { db_printf("pid %d not found\n", pid); @@ -309,6 +311,11 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, (pcb->pcb_esp - 4); callpc = (db_addr_t)pcb->pcb_eip; } +#else + /* XXX */ + db_printf("no kernel stack address\n"); + return; +#endif } else { /* * Look for something that might be a frame pointer, just as diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index fca111f981..8eaa7122e2 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.50 2006/06/04 21:09:50 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.51 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -78,7 +78,6 @@ ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); ASSYM(P_ADDR, offsetof(struct proc, p_addr)); ASSYM(P_STAT, offsetof(struct proc, p_stat)); -ASSYM(P_THREAD, offsetof(struct proc, p_thread)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index af08a0787d..cc54428e95 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.97 2006/09/13 18:45:12 swildner Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.98 2006/09/19 11:47:35 corecode Exp $ */ #include "use_apm.h" @@ -877,10 +877,10 @@ cpu_idle(void) * Clear registers on exec */ void -setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) +setregs(struct lwp *lp, u_long entry, u_long stack, u_long ps_strings) { - struct trapframe *regs = p->p_md.md_regs; - struct pcb *pcb = p->p_thread->td_pcb; + struct trapframe *regs = lp->lwp_md.md_regs; + struct pcb *pcb = lp->lwp_thread->td_pcb; /* Reset pc->pcb_gs and %gs before possibly invalidating it. */ pcb->pcb_gs = _udatasel; @@ -931,7 +931,7 @@ setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) * traps to the emulator (if it is done at all) mainly because * emulators don't provide an entry point for initialization. */ - p->p_thread->td_pcb->pcb_flags &= ~FP_SOFTFP; + lp->lwp_thread->td_pcb->pcb_flags &= ~FP_SOFTFP; /* * note: do not set CR0_TS here. npxinit() must do it after clearing @@ -2103,61 +2103,6 @@ ptrace_single_step(struct lwp *lp) return (0); } -int -ptrace_read_u_check(struct proc *p, vm_offset_t addr, size_t len) -{ - vm_offset_t gap; - - if ((vm_offset_t) (addr + len) < addr) - return EPERM; - if ((vm_offset_t) (addr + len) <= sizeof(struct user)) - return 0; - - gap = (char *) p->p_md.md_regs - (char *) p->p_addr; - - if ((vm_offset_t) addr < gap) - return EPERM; - if ((vm_offset_t) (addr + len) <= - (vm_offset_t) (gap + sizeof(struct trapframe))) - return 0; - return EPERM; -} - -int -ptrace_write_u(struct proc *p, vm_offset_t off, long data) -{ - struct trapframe frame_copy; - vm_offset_t min; - struct trapframe *tp; - - /* - * Privileged kernel state is scattered all over the user area. - * Only allow write access to parts of regs and to fpregs. - */ - min = (char *)p->p_md.md_regs - (char *)p->p_addr; - if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) { - tp = p->p_md.md_regs; - frame_copy = *tp; - *(int *)((char *)&frame_copy + (off - min)) = data; - if (!EFL_SECURE(frame_copy.tf_eflags, tp->tf_eflags) || - !CS_SECURE(frame_copy.tf_cs)) - return (EINVAL); - *(int*)((char *)p->p_addr + off) = data; - return (0); - } - - /* - * The PCB is at the end of the user area YYY - */ - min = (char *)p->p_thread->td_pcb - (char *)p->p_addr; - min += offsetof(struct pcb, pcb_save); - if (off >= min && off <= min + sizeof(union savefpu) - sizeof(int)) { - *(int*)((char *)p->p_addr + off) = data; - return (0); - } - return (EFAULT); -} - int fill_regs(struct lwp *lp, struct reg *regs) { diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 9ea6913b1f..551fb7d5fa 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.80 2006/09/13 18:45:12 swildner Exp $ + * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.81 2006/09/19 11:47:35 corecode Exp $ */ /* @@ -242,7 +242,7 @@ userret(struct lwp *lp, struct trapframe *frame, int sticks) */ if (p->p_flag & P_PROFIL) { addupc_task(p, frame->tf_eip, - (u_int)((int)p->p_thread->td_sticks - sticks)); + (u_int)((int)lp->lwp_thread->td_sticks - sticks)); } recheck: @@ -1480,13 +1480,9 @@ bad: * trampoline code which then runs doreti. */ void -fork_return(struct proc *p, struct trapframe frame) +fork_return(struct lwp *lp, struct trapframe frame) { - struct lwp *lp; - - KKASSERT(p->p_nthreads == 1); - - lp = LIST_FIRST(&p->p_lwps); + struct proc *p = lp->lwp_proc; frame.tf_eax = 0; /* Child returns zero */ frame.tf_eflags &= ~PSL_C; /* success */ diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index c5342ad020..fb2b9e4dfe 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -39,7 +39,7 @@ * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.45 2006/09/13 18:45:12 swildner Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.46 2006/09/19 11:47:35 corecode Exp $ */ #include "use_npx.h" @@ -91,19 +91,19 @@ extern int _ucodesel, _udatasel; /* - * Finish a fork operation, with process p2 nearly set up. + * Finish a fork operation, with lwp lp2 nearly set up. * Copy and update the pcb, set up the stack so that the child * ready to run and return to user mode. */ void -cpu_fork(struct proc *p1, struct proc *p2, int flags) +cpu_fork(struct lwp *lp1, struct lwp *lp2, int flags) { struct pcb *pcb2; if ((flags & RFPROC) == 0) { if ((flags & RFMEM) == 0) { /* unshare user LDT */ - struct pcb *pcb1 = p1->p_thread->td_pcb; + struct pcb *pcb1 = lp1->lwp_thread->td_pcb; struct pcb_ldt *pcb_ldt = pcb1->pcb_ldt; if (pcb_ldt && pcb_ldt->ldt_refcnt > 1) { pcb_ldt = user_ldt_alloc(pcb1,pcb_ldt->ldt_len); @@ -116,19 +116,19 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) } #if NNPX > 0 - /* Ensure that p1's pcb is up to date. */ - if (mdcpu->gd_npxthread == p1->p_thread) - npxsave(p1->p_thread->td_savefpu); + /* Ensure that lp1's pcb is up to date. */ + if (mdcpu->gd_npxthread == lp1->lwp_thread) + npxsave(lp1->lwp_thread->td_savefpu); #endif /* - * Copy p1's PCB. This really only applies to the + * Copy lp1's PCB. This really only applies to the * debug registers and FP state, but its faster to just copy the * whole thing. Because we only save the PCB at switchout time, * the register state (including pcb_gs) may not be current. */ - pcb2 = p2->p_thread->td_pcb; - *pcb2 = *p1->p_thread->td_pcb; + pcb2 = lp2->lwp_thread->td_pcb; + *pcb2 = *lp1->lwp_thread->td_pcb; /* * Create a new fresh stack for the new process. @@ -149,24 +149,24 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) * to use the LWKT restore function directly so we can get rid of * all the extra crap we are setting up. */ - p2->p_md.md_regs = (struct trapframe *)((char *)pcb2 - 16) - 1; - bcopy(p1->p_md.md_regs, p2->p_md.md_regs, sizeof(*p2->p_md.md_regs)); + lp2->lwp_md.md_regs = (struct trapframe *)((char *)pcb2 - 16) - 1; + bcopy(lp1->lwp_md.md_regs, lp2->lwp_md.md_regs, sizeof(*lp2->lwp_md.md_regs)); /* * Set registers for trampoline to user mode. Leave space for the * return address on stack. These are the kernel mode register values. */ - pcb2->pcb_cr3 = vtophys(vmspace_pmap(p2->p_vmspace)->pm_pdir); + pcb2->pcb_cr3 = vtophys(vmspace_pmap(lp2->lwp_proc->p_vmspace)->pm_pdir); pcb2->pcb_edi = 0; pcb2->pcb_esi = (int)fork_return; /* fork_trampoline argument */ pcb2->pcb_ebp = 0; - pcb2->pcb_esp = (int)p2->p_md.md_regs - sizeof(void *); - pcb2->pcb_ebx = (int)p2; /* fork_trampoline argument */ + pcb2->pcb_esp = (int)lp2->lwp_md.md_regs - sizeof(void *); + pcb2->pcb_ebx = (int)lp2; /* fork_trampoline argument */ pcb2->pcb_eip = (int)fork_trampoline; - p2->p_thread->td_sp = (char *)(pcb2->pcb_esp - sizeof(void *)); - *(u_int32_t *)p2->p_thread->td_sp = PSL_USER; - p2->p_thread->td_sp -= sizeof(void *); - *(void **)p2->p_thread->td_sp = (void *)cpu_heavy_restore; + lp2->lwp_thread->td_sp = (char *)(pcb2->pcb_esp - sizeof(void *)); + *(u_int32_t *)lp2->lwp_thread->td_sp = PSL_USER; + lp2->lwp_thread->td_sp -= sizeof(void *); + *(void **)lp2->lwp_thread->td_sp = (void *)cpu_heavy_restore; /* * Segment registers. @@ -194,8 +194,8 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) pcb2->pcb_ldt->ldt_len); } } - bcopy(&p1->p_thread->td_tls, &p2->p_thread->td_tls, - sizeof(p2->p_thread->td_tls)); + bcopy(&lp1->lwp_thread->td_tls, &lp2->lwp_thread->td_tls, + sizeof(lp2->lwp_thread->td_tls)); /* * Now, cpu_switch() can schedule the new process. * pcb_esp is loaded pointing to the cpu_switch() stack frame @@ -214,14 +214,14 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) * This is needed to make kernel threads stay in kernel mode. */ void -cpu_set_fork_handler(struct proc *p, void (*func)(void *), void *arg) +cpu_set_fork_handler(struct lwp *lp, void (*func)(void *), void *arg) { /* * Note that the trap frame follows the args, so the function * is really called like this: func(arg, frame); */ - p->p_thread->td_pcb->pcb_esi = (int) func; /* function */ - p->p_thread->td_pcb->pcb_ebx = (int) arg; /* first arg */ + lp->lwp_thread->td_pcb->pcb_esi = (int) func; /* function */ + lp->lwp_thread->td_pcb->pcb_ebx = (int) arg; /* first arg */ } void @@ -244,8 +244,7 @@ cpu_proc_exit(void) struct pcb_ext *ext; #if NNPX > 0 - KKASSERT(td->td_proc); - npxexit(td->td_proc); + npxexit(); #endif /* NNPX */ /* diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h index 5ef95fc19f..1ab06c2bc8 100644 --- a/sys/i386/include/cpu.h +++ b/sys/i386/include/cpu.h @@ -35,7 +35,7 @@ * * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/include/cpu.h,v 1.43.2.2 2001/06/15 09:37:57 scottl Exp $ - * $DragonFly: src/sys/i386/include/Attic/cpu.h,v 1.17 2006/09/10 01:26:39 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/cpu.h,v 1.18 2006/09/19 11:47:35 corecode Exp $ */ #ifndef _MACHINE_CPU_H_ @@ -122,13 +122,13 @@ #ifdef _KERNEL -struct proc; +struct lwp; extern char btext[]; extern char etext[]; void fork_trampoline (void); -void fork_return (struct proc *, struct trapframe); +void fork_return (struct lwp *, struct trapframe); #endif diff --git a/sys/i386/include/npx.h b/sys/i386/include/npx.h index 7b69ae43cb..3102c669ff 100644 --- a/sys/i386/include/npx.h +++ b/sys/i386/include/npx.h @@ -35,7 +35,7 @@ * * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 * $FreeBSD: src/sys/i386/include/npx.h,v 1.18.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/npx.h,v 1.8 2006/05/20 02:42:06 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/npx.h,v 1.9 2006/09/19 11:47:35 corecode Exp $ */ /* @@ -150,7 +150,7 @@ union savefpu { struct proc; int npxdna (void); -void npxexit (struct proc *p); +void npxexit (void); void npxinit (u_short control); void npxsave (union savefpu *addr); #endif diff --git a/sys/i386/include/ptrace.h b/sys/i386/include/ptrace.h index 48af45abaf..b5b315f28a 100644 --- a/sys/i386/include/ptrace.h +++ b/sys/i386/include/ptrace.h @@ -32,7 +32,7 @@ * * @(#)ptrace.h 8.1 (Berkeley) 6/11/93 * $FreeBSD: src/sys/i386/include/ptrace.h,v 1.9 1999/12/29 04:33:06 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/ptrace.h,v 1.4 2006/05/20 02:42:06 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/ptrace.h,v 1.5 2006/09/19 11:47:35 corecode Exp $ */ #ifndef _MACHINE_PTRACE_H_ @@ -48,17 +48,5 @@ #define PT_GETDBREGS (PT_FIRSTMACH + 5) #define PT_SETDBREGS (PT_FIRSTMACH + 6) -#ifdef _KERNEL - -#ifndef _SYS_TYPES_H_ -#include -#endif - -struct proc; - -int ptrace_read_u_check (struct proc *p, vm_offset_t off, size_t len); - -#endif - #endif diff --git a/sys/i386/include/reg.h b/sys/i386/include/reg.h index ab223e5566..ca49864e93 100644 --- a/sys/i386/include/reg.h +++ b/sys/i386/include/reg.h @@ -35,7 +35,7 @@ * * from: @(#)reg.h 5.5 (Berkeley) 1/18/91 * $FreeBSD: src/sys/i386/include/reg.h,v 1.22.2.2 2002/11/07 22:47:55 alfred Exp $ - * $DragonFly: src/sys/i386/include/Attic/reg.h,v 1.5 2006/05/20 02:42:06 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/reg.h,v 1.6 2006/09/19 11:47:35 corecode Exp $ */ #ifndef _MACHINE_REG_H_ @@ -154,7 +154,7 @@ struct lwp; */ int set_fpregs (struct lwp *, struct fpreg *); int set_regs (struct lwp *lp, struct reg *regs); -void setregs (struct proc *, u_long, u_long, u_long); +void setregs (struct lwp *, u_long, u_long, u_long); int set_dbregs (struct lwp *lp, struct dbreg *dbregs); #endif diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c index 48f4288106..387720bad6 100644 --- a/sys/i386/isa/npx.c +++ b/sys/i386/isa/npx.c @@ -33,7 +33,7 @@ * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/isa/npx.c,v 1.80.2.3 2001/10/20 19:04:38 tegge Exp $ - * $DragonFly: src/sys/i386/isa/Attic/npx.c,v 1.32 2006/09/03 18:29:16 dillon Exp $ + * $DragonFly: src/sys/i386/isa/Attic/npx.c,v 1.33 2006/09/19 11:47:35 corecode Exp $ */ #include "opt_cpu.h" @@ -538,9 +538,9 @@ npxinit(u_short control) * Free coprocessor (if we have it). */ void -npxexit(struct proc *p) +npxexit(void) { - if (p->p_thread == mdcpu->gd_npxthread) + if (curthread == mdcpu->gd_npxthread) npxsave(curthread->td_savefpu); #ifdef NPX_DEBUG if (npx_exists) { @@ -556,7 +556,7 @@ npxexit(struct proc *p) if (masked_exceptions & 0x0d) log(LOG_ERR, "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", - p->p_pid, p->p_comm, masked_exceptions); + curproc->p_pid, curproc->p_comm, masked_exceptions); } #endif } diff --git a/sys/kern/imgact_resident.c b/sys/kern/imgact_resident.c index 9bcd8e4ffa..f923252118 100644 --- a/sys/kern/imgact_resident.c +++ b/sys/kern/imgact_resident.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/kern/imgact_resident.c,v 1.13 2006/09/05 00:55:45 dillon Exp $ + * $DragonFly: src/sys/kern/imgact_resident.c,v 1.14 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -195,7 +195,7 @@ sys_exec_sys_register(struct exec_sys_register_args *uap) int error; p = curproc; - if ((error = suser(p->p_thread)) != 0) + if ((error = suser_cred(p->p_ucred, 0)) != 0) return(error); if ((vp = p->p_textvp) == NULL) return(ENOENT); @@ -234,7 +234,7 @@ sys_exec_sys_unregister(struct exec_sys_unregister_args *uap) int count; p = curproc; - if ((error = suser(p->p_thread)) != 0) + if ((error = suser_cred(p->p_ucred, 0)) != 0) return(error); /* diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index ba72e3555e..fe9dbc74d4 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,7 +40,7 @@ * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/init_main.c,v 1.134.2.8 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/init_main.c,v 1.63 2006/09/11 20:25:01 dillon Exp $ + * $DragonFly: src/sys/kern/init_main.c,v 1.64 2006/09/19 11:47:35 corecode Exp $ */ #include "opt_init_path.h" @@ -582,13 +582,15 @@ static void create_init(const void *udata __unused) { int error; + struct lwp *lp; crit_enter(); error = fork1(&proc0.p_lwp, RFFDG | RFPROC, &initproc); if (error) panic("cannot fork init: %d", error); initproc->p_flag |= P_SYSTEM; - cpu_set_fork_handler(initproc, start_init, NULL); + lp = LIST_FIRST(&initproc->p_lwps); + cpu_set_fork_handler(lp, start_init, NULL); crit_exit(); } SYSINIT(init,SI_SUB_CREATE_INIT, SI_ORDER_FIRST, create_init, NULL) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index fa69c4a8e1..2ff08f1234 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -70,7 +70,7 @@ * * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 * $FreeBSD: src/sys/kern/kern_descrip.c,v 1.81.2.19 2004/02/28 00:43:31 tegge Exp $ - * $DragonFly: src/sys/kern/kern_descrip.c,v 1.73 2006/09/05 03:48:12 dillon Exp $ + * $DragonFly: src/sys/kern/kern_descrip.c,v 1.74 2006/09/19 11:47:35 corecode Exp $ */ #include "opt_compat.h" @@ -1632,7 +1632,8 @@ again: void fdfree(struct proc *p) { - struct thread *td = p->p_thread; + /* Take any thread of p */ + struct thread *td = LIST_FIRST(&p->p_lwps)->lwp_thread; struct filedesc *fdp = p->p_fd; struct fdnode *fdnode; int i; @@ -1879,7 +1880,8 @@ is_unsafe(struct file *fp) void setugidsafety(struct proc *p) { - struct thread *td = p->p_thread; + /* Take any thread of p */ + struct thread *td = LIST_FIRST(&p->p_lwps)->lwp_thread; struct filedesc *fdp = p->p_fd; int i; @@ -1917,7 +1919,8 @@ setugidsafety(struct proc *p) void fdcloseexec(struct proc *p) { - struct thread *td = p->p_thread; + /* Take any thread of p */ + struct thread *td = LIST_FIRST(&p->p_lwps)->lwp_thread; struct filedesc *fdp = p->p_fd; int i; diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 6af0d9e3ab..076472e5b0 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_event.c,v 1.2.2.10 2004/04/04 07:03:14 cperciva Exp $ - * $DragonFly: src/sys/kern/kern_event.c,v 1.29 2006/09/05 00:55:45 dillon Exp $ + * $DragonFly: src/sys/kern/kern_event.c,v 1.30 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -899,8 +899,10 @@ knote_fdclose(struct proc *p, int fd) { struct filedesc *fdp = p->p_fd; struct klist *list = &fdp->fd_knlist[fd]; + /* Take any thread of p */ + struct thread *td = LIST_FIRST(&p->p_lwps)->lwp_thread; - knote_remove(p->p_thread, list); + knote_remove(td, list); } static void diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index e0e6a981e4..8b4164ddb7 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_exec.c,v 1.107.2.15 2002/07/30 15:40:46 nectar Exp $ - * $DragonFly: src/sys/kern/kern_exec.c,v 1.45 2006/09/17 21:07:32 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exec.c,v 1.46 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -444,7 +444,7 @@ interpret: p->p_acflag &= ~AFORK; /* Set values passed into the program in registers. */ - setregs(p, imgp->entry_addr, (u_long)(uintptr_t)stack_base, + setregs(td->td_lwp, imgp->entry_addr, (u_long)(uintptr_t)stack_base, imgp->ps_strings); /* Free any previous argument cache */ diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index f8143de20e..52ad9afb33 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -37,7 +37,7 @@ * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 * $FreeBSD: src/sys/kern/kern_exit.c,v 1.92.2.11 2003/01/13 22:51:16 dillon Exp $ - * $DragonFly: src/sys/kern/kern_exit.c,v 1.62 2006/09/17 21:07:32 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exit.c,v 1.63 2006/09/19 11:47:35 corecode Exp $ */ #include "opt_compat.h" @@ -113,8 +113,9 @@ sys_exit(struct exit_args *uap) void exit1(int rv) { - struct proc *p = curproc; - struct lwp *lp; + struct thread *td = curthread; + struct proc *p = td->td_proc; + struct lwp *lp = td->td_lwp; struct proc *q, *nq; struct vmspace *vm; struct vnode *vtmp; @@ -126,7 +127,7 @@ exit1(int rv) panic("Going nowhere without my init!"); } - lp = &p->p_lwp; /* XXX lwp kill other threads */ + /* XXX lwp kill other threads */ caps_exit(lp->lwp_thread); aio_proc_rundown(p); @@ -162,7 +163,7 @@ exit1(int rv) * XXX what if one of these generates an error? */ TAILQ_FOREACH(ep, &exit_list, next) - (*ep->function)(p->p_thread); + (*ep->function)(td); if (p->p_flag & P_PROFIL) stopprofclock(p); @@ -425,6 +426,7 @@ int kern_wait(pid_t pid, int *status, int options, struct rusage *rusage, int *res) { struct thread *td = curthread; + struct thread *deadtd; struct proc *q = td->td_proc; struct proc *p, *t; int nfound, error; @@ -473,6 +475,9 @@ loop: nfound++; if (p->p_flag & P_ZOMBIE) { + KKASSERT((p->p_nthreads == 1)); + deadtd = LIST_FIRST(&p->p_lwps)->lwp_thread; + /* * Other kernel threads may be in the middle of * accessing the proc. For example, kern/kern_proc.c @@ -484,7 +489,7 @@ loop: while (p->p_lock) tsleep(p, 0, "reap3", hz); } - lwkt_wait_free(p->p_thread); + lwkt_wait_free(deadtd); /* * The process's thread may still be in the middle @@ -497,13 +502,13 @@ loop: * * YYY no wakeup occurs so we depend on the timeout. */ - if ((p->p_thread->td_flags & (TDF_RUNNING|TDF_PREEMPT_LOCK|TDF_EXITING)) != TDF_EXITING) { - tsleep(p->p_thread, 0, "reap2", 1); + if ((deadtd->td_flags & (TDF_RUNNING|TDF_PREEMPT_LOCK|TDF_EXITING)) != TDF_EXITING) { + tsleep(deadtd, 0, "reap2", 1); goto loop; } /* scheduling hook for heuristic */ - p->p_usched->heuristic_exiting(td->td_lwp, &p->p_lwp); + p->p_usched->heuristic_exiting(td->td_lwp, deadtd->td_lwp); /* Take care of our return values. */ *res = p->p_pid; diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index c1bdc58a93..f8e4c03cd6 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -37,7 +37,7 @@ * * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 * $FreeBSD: src/sys/kern/kern_fork.c,v 1.72.2.14 2003/06/26 04:15:10 silby Exp $ - * $DragonFly: src/sys/kern/kern_fork.c,v 1.56 2006/09/17 21:07:32 dillon Exp $ + * $DragonFly: src/sys/kern/kern_fork.c,v 1.57 2006/09/19 11:47:35 corecode Exp $ */ #include "opt_ktrace.h" @@ -175,7 +175,7 @@ fork1(struct lwp *lp1, int flags, struct proc **procp) */ if ((flags & RFPROC) == 0) { - vm_fork(p1, 0, flags); + vm_fork(lp1, 0, flags); /* * Close all file descriptors. @@ -464,7 +464,7 @@ fork1(struct lwp *lp1, int flags, struct proc **procp) * Finish creating the child process. It will return via a different * execution path later. (ie: directly into user mode) */ - vm_fork(p1, p2, flags); + vm_fork(lp1, p2, flags); caps_fork(p1, p2, flags); if (flags == (RFFDG | RFPROC)) { diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index bee286138d..5936bc8b44 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -37,7 +37,7 @@ * * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 * $FreeBSD: src/sys/kern/kern_sig.c,v 1.72.2.17 2003/05/16 16:34:34 obrien Exp $ - * $DragonFly: src/sys/kern/kern_sig.c,v 1.53 2006/09/05 00:55:45 dillon Exp $ + * $DragonFly: src/sys/kern/kern_sig.c,v 1.54 2006/09/19 11:47:35 corecode Exp $ */ #include "opt_ktrace.h" @@ -1432,7 +1432,8 @@ issignal(struct proc *p) void postsig(int sig) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct sigacts *ps = p->p_sigacts; sig_t action; sigset_t returnmask; @@ -1443,7 +1444,7 @@ postsig(int sig) SIGDELSET(p->p_siglist, sig); action = ps->ps_sigact[_SIG_IDX(sig)]; #ifdef KTRACE - if (KTRPOINT(p->p_thread, KTR_PSIG)) + if (KTRPOINT(td, KTR_PSIG)) ktrpsig(p, sig, action, p->p_flag & P_OLDMASK ? &p->p_oldsigmask : &p->p_sigmask, 0); #endif diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 359205be2c..f46c249670 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -29,7 +29,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/sys_process.c,v 1.51.2.6 2003/01/08 03:06:45 kan Exp $ - * $DragonFly: src/sys/kern/sys_process.c,v 1.22 2006/09/11 20:25:01 dillon Exp $ + * $DragonFly: src/sys/kern/sys_process.c,v 1.23 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -318,7 +318,7 @@ kern_ptrace(struct proc *curp, int req, pid_t pid, void *addr, int data, int *re /* not owned by you, has done setuid (unless you're root) */ if ((p->p_ucred->cr_ruid != curp->p_ucred->cr_ruid) || (p->p_flag & P_SUGID)) { - if ((error = suser(curp->p_thread)) != 0) + if ((error = suser_cred(curp->p_ucred, 0)) != 0) return error; } diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 65342d23bd..3f05a21afb 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -37,7 +37,7 @@ * * @(#)tty.c 8.8 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/tty.c,v 1.129.2.5 2002/03/11 01:32:31 dd Exp $ - * $DragonFly: src/sys/kern/tty.c,v 1.30 2006/09/10 01:26:39 dillon Exp $ + * $DragonFly: src/sys/kern/tty.c,v 1.31 2006/09/19 11:47:35 corecode Exp $ */ /*- @@ -2389,6 +2389,8 @@ ttyinfo(tp) crit_enter(); + /* XXX lwp should compare lwps */ + for (pick = NULL; p != 0; p = LIST_NEXT(p, p_pglist)) { if (proc_compare(pick, p)) pick = p; @@ -2398,18 +2400,19 @@ ttyinfo(tp) * Figure out what wait/process-state message, and command * buffer to present */ - if (pick->p_thread == NULL) + if (pick->p_flag & P_WEXIT) str = "exiting"; else if (pick->p_stat == SRUN) str = "running"; + else if (pick->p_stat == SIDL) + str = "spawning"; else if (pick->p_wmesg) /* p_thread must not be NULL */ str = pick->p_wmesg; else str = "iowait"; snprintf(buf, sizeof(buf), "cmd: %s %d [%s]", - (pick->p_thread ? pick->p_comm : "?"), - pick->p_pid, str); + pick->p_comm, pick->p_pid, str); /* * Calculate cpu usage, percent cpu, and cmsz. Note that diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index d2b57abf09..1c93100758 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -14,7 +14,7 @@ * of the author. This software is distributed AS-IS. * * $FreeBSD: src/sys/kern/vfs_aio.c,v 1.70.2.28 2003/05/29 06:15:35 alc Exp $ - * $DragonFly: src/sys/kern/vfs_aio.c,v 1.30 2006/09/03 18:29:16 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_aio.c,v 1.31 2006/09/19 11:47:35 corecode Exp $ */ /* @@ -871,14 +871,15 @@ static int aio_newproc() { int error; - struct lwp *lp; + struct lwp *lp, *nlp; struct proc *np; lp = &proc0.p_lwp; error = fork1(lp, RFPROC|RFMEM|RFNOWAIT, &np); if (error) return error; - cpu_set_fork_handler(np, aio_daemon, curproc); + nlp = LIST_FIRST(&np->p_lwps); + cpu_set_fork_handler(nlp, aio_daemon, curproc); start_forked_proc(lp, np); /* diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 6e0a6c98e6..8d691f56f3 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -37,7 +37,7 @@ * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 * $FreeBSD: src/sys/kern/vfs_subr.c,v 1.249.2.30 2003/04/04 20:35:57 tegge Exp $ - * $DragonFly: src/sys/kern/vfs_subr.c,v 1.98 2006/09/10 01:26:39 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_subr.c,v 1.99 2006/09/19 11:47:36 corecode Exp $ */ /* @@ -1550,12 +1550,8 @@ static int vfs_umountall_callback(struct mount *mp, void *data); void vfs_unmountall(void) { - struct thread *td = curthread; int count; - if (td->td_proc == NULL) - td = initproc->p_thread; /* XXX XXX use proc0 instead? */ - do { count = mountlist_scan(vfs_umountall_callback, NULL, MNTSCAN_REVERSE|MNTSCAN_NOBUSY); diff --git a/sys/netproto/smb/smb_subr.c b/sys/netproto/smb/smb_subr.c index e5b919fe78..4b03582761 100644 --- a/sys/netproto/smb/smb_subr.c +++ b/sys/netproto/smb/smb_subr.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_subr.c,v 1.1.2.2 2001/09/03 08:55:11 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_subr.c,v 1.20 2006/09/05 00:55:49 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_subr.c,v 1.21 2006/09/19 11:47:36 corecode Exp $ */ #include #include @@ -372,6 +372,7 @@ kthread_create2(void (*func)(void *), void *arg, int error; __va_list ap; struct proc *p2; + struct lwp *lp2; if (proc0.p_stats == NULL) panic("kthread_create called too soon"); @@ -388,13 +389,15 @@ kthread_create2(void (*func)(void *), void *arg, p2->p_flag |= P_SYSTEM; p2->p_procsig->ps_flag |= PS_NOCLDWAIT; + lp2 = LIST_FIRST(&p2->p_lwps); + /* set up arg0 for 'ps', et al */ __va_start(ap, fmt); vsnprintf(p2->p_comm, sizeof(p2->p_comm), fmt, ap); __va_end(ap); /* call the processes' main()... */ - cpu_set_fork_handler(p2, func, arg); + cpu_set_fork_handler(lp2, func, arg); start_forked_proc(&proc0.p_lwp, p2); return 0; diff --git a/sys/platform/pc32/i386/db_trace.c b/sys/platform/pc32/i386/db_trace.c index f2671a11e0..17d0673030 100644 --- a/sys/platform/pc32/i386/db_trace.c +++ b/sys/platform/pc32/i386/db_trace.c @@ -24,7 +24,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/i386/i386/db_trace.c,v 1.35.2.3 2002/02/21 22:31:25 silby Exp $ - * $DragonFly: src/sys/platform/pc32/i386/db_trace.c,v 1.14 2006/09/03 17:55:34 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/db_trace.c,v 1.15 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -265,9 +265,6 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, int *argp; db_addr_t callpc; boolean_t first; - struct pcb *pcb; - struct proc *p; - pid_t pid; int i; if (count == -1) @@ -279,6 +276,7 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, frame = (struct i386_frame *)(SP_REGS(&ddb_regs) - 4); callpc = PC_REGS(&ddb_regs); } else if (!INKERNEL(addr)) { +#if needswork pid = (addr % 16) + ((addr >> 4) % 16) * 10 + ((addr >> 8) % 16) * 100 + ((addr >> 12) % 16) * 1000 + ((addr >> 16) % 16) * 10000; @@ -293,6 +291,10 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, (SP_REGS(&ddb_regs) - 4); callpc = PC_REGS(&ddb_regs); } else { + pid_t pid; + struct proc *p; + struct pcb *pcb; + p = pfind(pid); if (p == NULL) { db_printf("pid %d not found\n", pid); @@ -309,6 +311,11 @@ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, (pcb->pcb_esp - 4); callpc = (db_addr_t)pcb->pcb_eip; } +#else + /* XXX */ + db_printf("no kernel stack address\n"); + return; +#endif } else { /* * Look for something that might be a frame pointer, just as diff --git a/sys/platform/pc32/i386/genassym.c b/sys/platform/pc32/i386/genassym.c index 311be7b59f..ae7d411ab0 100644 --- a/sys/platform/pc32/i386/genassym.c +++ b/sys/platform/pc32/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.50 2006/06/04 21:09:50 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.51 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -78,7 +78,6 @@ ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); ASSYM(P_ADDR, offsetof(struct proc, p_addr)); ASSYM(P_STAT, offsetof(struct proc, p_stat)); -ASSYM(P_THREAD, offsetof(struct proc, p_thread)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index bcdbc88ad6..8b81ade18a 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.97 2006/09/13 18:45:12 swildner Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.98 2006/09/19 11:47:35 corecode Exp $ */ #include "use_apm.h" @@ -877,10 +877,10 @@ cpu_idle(void) * Clear registers on exec */ void -setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) +setregs(struct lwp *lp, u_long entry, u_long stack, u_long ps_strings) { - struct trapframe *regs = p->p_md.md_regs; - struct pcb *pcb = p->p_thread->td_pcb; + struct trapframe *regs = lp->lwp_md.md_regs; + struct pcb *pcb = lp->lwp_thread->td_pcb; /* Reset pc->pcb_gs and %gs before possibly invalidating it. */ pcb->pcb_gs = _udatasel; @@ -931,7 +931,7 @@ setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings) * traps to the emulator (if it is done at all) mainly because * emulators don't provide an entry point for initialization. */ - p->p_thread->td_pcb->pcb_flags &= ~FP_SOFTFP; + lp->lwp_thread->td_pcb->pcb_flags &= ~FP_SOFTFP; /* * note: do not set CR0_TS here. npxinit() must do it after clearing @@ -2103,61 +2103,6 @@ ptrace_single_step(struct lwp *lp) return (0); } -int -ptrace_read_u_check(struct proc *p, vm_offset_t addr, size_t len) -{ - vm_offset_t gap; - - if ((vm_offset_t) (addr + len) < addr) - return EPERM; - if ((vm_offset_t) (addr + len) <= sizeof(struct user)) - return 0; - - gap = (char *) p->p_md.md_regs - (char *) p->p_addr; - - if ((vm_offset_t) addr < gap) - return EPERM; - if ((vm_offset_t) (addr + len) <= - (vm_offset_t) (gap + sizeof(struct trapframe))) - return 0; - return EPERM; -} - -int -ptrace_write_u(struct proc *p, vm_offset_t off, long data) -{ - struct trapframe frame_copy; - vm_offset_t min; - struct trapframe *tp; - - /* - * Privileged kernel state is scattered all over the user area. - * Only allow write access to parts of regs and to fpregs. - */ - min = (char *)p->p_md.md_regs - (char *)p->p_addr; - if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) { - tp = p->p_md.md_regs; - frame_copy = *tp; - *(int *)((char *)&frame_copy + (off - min)) = data; - if (!EFL_SECURE(frame_copy.tf_eflags, tp->tf_eflags) || - !CS_SECURE(frame_copy.tf_cs)) - return (EINVAL); - *(int*)((char *)p->p_addr + off) = data; - return (0); - } - - /* - * The PCB is at the end of the user area YYY - */ - min = (char *)p->p_thread->td_pcb - (char *)p->p_addr; - min += offsetof(struct pcb, pcb_save); - if (off >= min && off <= min + sizeof(union savefpu) - sizeof(int)) { - *(int*)((char *)p->p_addr + off) = data; - return (0); - } - return (EFAULT); -} - int fill_regs(struct lwp *lp, struct reg *regs) { diff --git a/sys/platform/pc32/i386/trap.c b/sys/platform/pc32/i386/trap.c index 4db15b7e31..756388ffb6 100644 --- a/sys/platform/pc32/i386/trap.c +++ b/sys/platform/pc32/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.80 2006/09/13 18:45:12 swildner Exp $ + * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.81 2006/09/19 11:47:35 corecode Exp $ */ /* @@ -242,7 +242,7 @@ userret(struct lwp *lp, struct trapframe *frame, int sticks) */ if (p->p_flag & P_PROFIL) { addupc_task(p, frame->tf_eip, - (u_int)((int)p->p_thread->td_sticks - sticks)); + (u_int)((int)lp->lwp_thread->td_sticks - sticks)); } recheck: @@ -1480,13 +1480,9 @@ bad: * trampoline code which then runs doreti. */ void -fork_return(struct proc *p, struct trapframe frame) +fork_return(struct lwp *lp, struct trapframe frame) { - struct lwp *lp; - - KKASSERT(p->p_nthreads == 1); - - lp = LIST_FIRST(&p->p_lwps); + struct proc *p = lp->lwp_proc; frame.tf_eax = 0; /* Child returns zero */ frame.tf_eflags &= ~PSL_C; /* success */ diff --git a/sys/platform/pc32/i386/vm_machdep.c b/sys/platform/pc32/i386/vm_machdep.c index 6105c0012c..1de2bad06c 100644 --- a/sys/platform/pc32/i386/vm_machdep.c +++ b/sys/platform/pc32/i386/vm_machdep.c @@ -39,7 +39,7 @@ * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * $FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.132.2.9 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.45 2006/09/13 18:45:12 swildner Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.46 2006/09/19 11:47:35 corecode Exp $ */ #include "use_npx.h" @@ -91,19 +91,19 @@ extern int _ucodesel, _udatasel; /* - * Finish a fork operation, with process p2 nearly set up. + * Finish a fork operation, with lwp lp2 nearly set up. * Copy and update the pcb, set up the stack so that the child * ready to run and return to user mode. */ void -cpu_fork(struct proc *p1, struct proc *p2, int flags) +cpu_fork(struct lwp *lp1, struct lwp *lp2, int flags) { struct pcb *pcb2; if ((flags & RFPROC) == 0) { if ((flags & RFMEM) == 0) { /* unshare user LDT */ - struct pcb *pcb1 = p1->p_thread->td_pcb; + struct pcb *pcb1 = lp1->lwp_thread->td_pcb; struct pcb_ldt *pcb_ldt = pcb1->pcb_ldt; if (pcb_ldt && pcb_ldt->ldt_refcnt > 1) { pcb_ldt = user_ldt_alloc(pcb1,pcb_ldt->ldt_len); @@ -116,19 +116,19 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) } #if NNPX > 0 - /* Ensure that p1's pcb is up to date. */ - if (mdcpu->gd_npxthread == p1->p_thread) - npxsave(p1->p_thread->td_savefpu); + /* Ensure that lp1's pcb is up to date. */ + if (mdcpu->gd_npxthread == lp1->lwp_thread) + npxsave(lp1->lwp_thread->td_savefpu); #endif /* - * Copy p1's PCB. This really only applies to the + * Copy lp1's PCB. This really only applies to the * debug registers and FP state, but its faster to just copy the * whole thing. Because we only save the PCB at switchout time, * the register state (including pcb_gs) may not be current. */ - pcb2 = p2->p_thread->td_pcb; - *pcb2 = *p1->p_thread->td_pcb; + pcb2 = lp2->lwp_thread->td_pcb; + *pcb2 = *lp1->lwp_thread->td_pcb; /* * Create a new fresh stack for the new process. @@ -149,24 +149,24 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) * to use the LWKT restore function directly so we can get rid of * all the extra crap we are setting up. */ - p2->p_md.md_regs = (struct trapframe *)((char *)pcb2 - 16) - 1; - bcopy(p1->p_md.md_regs, p2->p_md.md_regs, sizeof(*p2->p_md.md_regs)); + lp2->lwp_md.md_regs = (struct trapframe *)((char *)pcb2 - 16) - 1; + bcopy(lp1->lwp_md.md_regs, lp2->lwp_md.md_regs, sizeof(*lp2->lwp_md.md_regs)); /* * Set registers for trampoline to user mode. Leave space for the * return address on stack. These are the kernel mode register values. */ - pcb2->pcb_cr3 = vtophys(vmspace_pmap(p2->p_vmspace)->pm_pdir); + pcb2->pcb_cr3 = vtophys(vmspace_pmap(lp2->lwp_proc->p_vmspace)->pm_pdir); pcb2->pcb_edi = 0; pcb2->pcb_esi = (int)fork_return; /* fork_trampoline argument */ pcb2->pcb_ebp = 0; - pcb2->pcb_esp = (int)p2->p_md.md_regs - sizeof(void *); - pcb2->pcb_ebx = (int)p2; /* fork_trampoline argument */ + pcb2->pcb_esp = (int)lp2->lwp_md.md_regs - sizeof(void *); + pcb2->pcb_ebx = (int)lp2; /* fork_trampoline argument */ pcb2->pcb_eip = (int)fork_trampoline; - p2->p_thread->td_sp = (char *)(pcb2->pcb_esp - sizeof(void *)); - *(u_int32_t *)p2->p_thread->td_sp = PSL_USER; - p2->p_thread->td_sp -= sizeof(void *); - *(void **)p2->p_thread->td_sp = (void *)cpu_heavy_restore; + lp2->lwp_thread->td_sp = (char *)(pcb2->pcb_esp - sizeof(void *)); + *(u_int32_t *)lp2->lwp_thread->td_sp = PSL_USER; + lp2->lwp_thread->td_sp -= sizeof(void *); + *(void **)lp2->lwp_thread->td_sp = (void *)cpu_heavy_restore; /* * Segment registers. @@ -194,8 +194,8 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) pcb2->pcb_ldt->ldt_len); } } - bcopy(&p1->p_thread->td_tls, &p2->p_thread->td_tls, - sizeof(p2->p_thread->td_tls)); + bcopy(&lp1->lwp_thread->td_tls, &lp2->lwp_thread->td_tls, + sizeof(lp2->lwp_thread->td_tls)); /* * Now, cpu_switch() can schedule the new process. * pcb_esp is loaded pointing to the cpu_switch() stack frame @@ -214,14 +214,14 @@ cpu_fork(struct proc *p1, struct proc *p2, int flags) * This is needed to make kernel threads stay in kernel mode. */ void -cpu_set_fork_handler(struct proc *p, void (*func)(void *), void *arg) +cpu_set_fork_handler(struct lwp *lp, void (*func)(void *), void *arg) { /* * Note that the trap frame follows the args, so the function * is really called like this: func(arg, frame); */ - p->p_thread->td_pcb->pcb_esi = (int) func; /* function */ - p->p_thread->td_pcb->pcb_ebx = (int) arg; /* first arg */ + lp->lwp_thread->td_pcb->pcb_esi = (int) func; /* function */ + lp->lwp_thread->td_pcb->pcb_ebx = (int) arg; /* first arg */ } void @@ -244,8 +244,7 @@ cpu_proc_exit(void) struct pcb_ext *ext; #if NNPX > 0 - KKASSERT(td->td_proc); - npxexit(td->td_proc); + npxexit(); #endif /* NNPX */ /* diff --git a/sys/platform/pc32/include/ptrace.h b/sys/platform/pc32/include/ptrace.h index 59dd76694d..66264da7cb 100644 --- a/sys/platform/pc32/include/ptrace.h +++ b/sys/platform/pc32/include/ptrace.h @@ -32,7 +32,7 @@ * * @(#)ptrace.h 8.1 (Berkeley) 6/11/93 * $FreeBSD: src/sys/i386/include/ptrace.h,v 1.9 1999/12/29 04:33:06 peter Exp $ - * $DragonFly: src/sys/platform/pc32/include/ptrace.h,v 1.4 2006/05/20 02:42:06 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/ptrace.h,v 1.5 2006/09/19 11:47:35 corecode Exp $ */ #ifndef _MACHINE_PTRACE_H_ @@ -48,17 +48,5 @@ #define PT_GETDBREGS (PT_FIRSTMACH + 5) #define PT_SETDBREGS (PT_FIRSTMACH + 6) -#ifdef _KERNEL - -#ifndef _SYS_TYPES_H_ -#include -#endif - -struct proc; - -int ptrace_read_u_check (struct proc *p, vm_offset_t off, size_t len); - -#endif - #endif diff --git a/sys/platform/pc32/isa/npx.c b/sys/platform/pc32/isa/npx.c index 67463ce318..d46ac96edb 100644 --- a/sys/platform/pc32/isa/npx.c +++ b/sys/platform/pc32/isa/npx.c @@ -33,7 +33,7 @@ * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/isa/npx.c,v 1.80.2.3 2001/10/20 19:04:38 tegge Exp $ - * $DragonFly: src/sys/platform/pc32/isa/npx.c,v 1.32 2006/09/03 18:29:16 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/isa/npx.c,v 1.33 2006/09/19 11:47:35 corecode Exp $ */ #include "opt_cpu.h" @@ -538,9 +538,9 @@ npxinit(u_short control) * Free coprocessor (if we have it). */ void -npxexit(struct proc *p) +npxexit(void) { - if (p->p_thread == mdcpu->gd_npxthread) + if (curthread == mdcpu->gd_npxthread) npxsave(curthread->td_savefpu); #ifdef NPX_DEBUG if (npx_exists) { @@ -556,7 +556,7 @@ npxexit(struct proc *p) if (masked_exceptions & 0x0d) log(LOG_ERR, "pid %d (%s) exited with masked floating point exceptions 0x%02x\n", - p->p_pid, p->p_comm, masked_exceptions); + curproc->p_pid, curproc->p_comm, masked_exceptions); } #endif } diff --git a/sys/platform/vkernel/i386/genassym.c b/sys/platform/vkernel/i386/genassym.c index 24b7653b59..a9e92c2f2a 100644 --- a/sys/platform/vkernel/i386/genassym.c +++ b/sys/platform/vkernel/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.50 2006/06/04 21:09:50 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.51 2006/09/19 11:47:35 corecode Exp $ */ #include @@ -78,7 +78,6 @@ ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); ASSYM(P_ADDR, offsetof(struct proc, p_addr)); ASSYM(P_STAT, offsetof(struct proc, p_stat)); -ASSYM(P_THREAD, offsetof(struct proc, p_thread)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 0ebb680f59..b55ccf0607 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,7 +37,7 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.84 2006/09/17 21:09:39 dillon Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.85 2006/09/19 11:47:36 corecode Exp $ */ #ifndef _SYS_PROC_H_ @@ -475,8 +475,8 @@ void cpu_lwkt_switch (struct thread *); void cpu_proc_exit (void) __dead2; void cpu_thread_exit (void) __dead2; void exit1 (int) __dead2; -void cpu_fork (struct proc *, struct proc *, int); -void cpu_set_fork_handler (struct proc *, void (*)(void *), void *); +void cpu_fork (struct lwp *, struct lwp *, int); +void cpu_set_fork_handler (struct lwp *, void (*)(void *), void *); void cpu_set_thread_handler(struct thread *td, void (*retfunc)(void), void *func, void *arg); int fork1 (struct lwp *, int, struct proc **); void start_forked_proc (struct lwp *, struct proc *); diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h index 8caa654c63..844cac0bc9 100644 --- a/sys/sys/ptrace.h +++ b/sys/sys/ptrace.h @@ -32,7 +32,7 @@ * * @(#)ptrace.h 8.2 (Berkeley) 1/4/94 * $FreeBSD: src/sys/sys/ptrace.h,v 1.10.2.2 2003/01/02 20:39:13 kan Exp $ - * $DragonFly: src/sys/sys/ptrace.h,v 1.7 2006/05/20 02:42:13 dillon Exp $ + * $DragonFly: src/sys/sys/ptrace.h,v 1.8 2006/09/19 11:47:36 corecode Exp $ */ #ifndef _SYS_PTRACE_H_ @@ -86,7 +86,6 @@ struct lwp; void proc_reparent (struct proc *child, struct proc *newparent); int ptrace_set_pc (struct proc *p, unsigned long addr); int ptrace_single_step (struct lwp *lp); -int ptrace_write_u (struct proc *p, vm_offset_t off, long data); int kern_ptrace (struct proc *p, int req, pid_t pid, void *addr, int data, int *res); diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index 30b2033bc5..ad06e28af1 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -32,7 +32,7 @@ * * @(#)vm_extern.h 8.2 (Berkeley) 1/12/94 * $FreeBSD: src/sys/vm/vm_extern.h,v 1.46.2.3 2003/01/13 22:51:17 dillon Exp $ - * $DragonFly: src/sys/vm/vm_extern.h,v 1.18 2006/09/17 21:09:40 dillon Exp $ + * $DragonFly: src/sys/vm/vm_extern.h,v 1.19 2006/09/19 11:47:36 corecode Exp $ */ #ifndef _VM_VM_EXTERN_H_ @@ -93,7 +93,7 @@ int vm_fault (vm_map_t, vm_offset_t, vm_prot_t, int); void vm_fault_copy_entry (vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t); void vm_fault_unwire (vm_map_t, vm_map_entry_t); int vm_fault_wire (vm_map_t, vm_map_entry_t, boolean_t); -void vm_fork (struct proc *, struct proc *, int); +void vm_fork (struct lwp *, struct proc *, int); void vm_fault_ratecheck(void); void vm_waitproc (struct proc *); int vm_mmap (vm_map_t, vm_offset_t *, vm_size_t, vm_prot_t, vm_prot_t, int, void *, vm_ooffset_t); diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 9726319d41..74d7dfbb5a 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -60,7 +60,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_glue.c,v 1.94.2.4 2003/01/13 22:51:17 dillon Exp $ - * $DragonFly: src/sys/vm/vm_glue.c,v 1.43 2006/09/16 03:32:44 dillon Exp $ + * $DragonFly: src/sys/vm/vm_glue.c,v 1.44 2006/09/19 11:47:36 corecode Exp $ */ #include "opt_vm.h" @@ -224,9 +224,10 @@ vsunlock(caddr_t addr, u_int len) * to user mode to avoid stack copying and relocation problems. */ void -vm_fork(struct proc *p1, struct proc *p2, int flags) +vm_fork(struct lwp *lp1, struct proc *p2, int flags) { struct user *up; + struct proc *p1 = lp1->lwp_proc; struct thread *td2; if ((flags & RFPROC) == 0) { @@ -240,7 +241,7 @@ vm_fork(struct proc *p1, struct proc *p2, int flags) vmspace_unshare(p1); } } - cpu_fork(p1, p2, flags); + cpu_fork(lp1, NULL, flags); return; } @@ -291,7 +292,7 @@ vm_fork(struct proc *p1, struct proc *p2, int flags) * cpu_fork will copy and update the pcb, set up the kernel stack, * and make the child ready to run. */ - cpu_fork(p1, p2, flags); + cpu_fork(lp1, td2->td_lwp, flags); } /* -- 2.41.0