From b7c628e4a8ff1c8e4f738ef450eb1527e94e3ee5 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 18 Jun 2003 18:30:13 +0000 Subject: [PATCH] thread stage 4: remove curpcb, use td_pcb reference instead. Move the pcb to the end of the thread stack, and note that a pcb will always exist because a thread context will always exist. Also note that vm86 replaces td_pcb temporarily and we really need to rip that out and instead make a copy on the stack, because assumptions are made in regards to the pcb's location. --- sys/ddb/db_ps.c | 4 +- sys/emulation/linux/i386/linux_ptrace.c | 6 +- sys/emulation/svr4/i386/svr4_machdep.c | 4 +- sys/i386/i386/db_trace.c | 4 +- sys/i386/i386/genassym.c | 6 +- sys/i386/i386/globals.s | 8 +-- sys/i386/i386/locore.s | 14 +++-- sys/i386/i386/machdep.c | 62 ++++++++++-------- sys/i386/i386/math_emu.h | 4 +- sys/i386/i386/math_emulate.c | 7 +-- sys/i386/i386/pmap.c | 7 ++- sys/i386/i386/support.s | 83 ++++++++++++++++--------- sys/i386/i386/swtch.s | 23 ++++--- sys/i386/i386/sys_machdep.c | 22 +++---- sys/i386/i386/trap.c | 20 +++--- sys/i386/i386/vm86.c | 12 ++-- sys/i386/i386/vm86bios.s | 20 +++--- sys/i386/i386/vm_machdep.c | 23 ++++--- sys/i386/include/asnames.h | 3 +- sys/i386/include/globaldata.h | 3 +- sys/i386/include/globals.h | 9 +-- sys/i386/include/pcb.h | 6 +- sys/i386/isa/npx.c | 18 +++--- sys/kern/init_main.c | 14 ++--- sys/kern/kern_exit.c | 4 +- sys/kern/kern_fork.c | 3 +- sys/platform/pc32/i386/db_trace.c | 4 +- sys/platform/pc32/i386/genassym.c | 6 +- sys/platform/pc32/i386/globals.s | 8 +-- sys/platform/pc32/i386/locore.s | 14 +++-- sys/platform/pc32/i386/machdep.c | 62 ++++++++++-------- sys/platform/pc32/i386/math_emu.h | 4 +- sys/platform/pc32/i386/math_emulate.c | 7 +-- sys/platform/pc32/i386/pmap.c | 7 ++- sys/platform/pc32/i386/support.s | 83 ++++++++++++++++--------- sys/platform/pc32/i386/swtch.s | 23 ++++--- sys/platform/pc32/i386/sys_machdep.c | 22 +++---- sys/platform/pc32/i386/trap.c | 20 +++--- sys/platform/pc32/i386/vm86.c | 12 ++-- sys/platform/pc32/i386/vm86bios.s | 20 +++--- sys/platform/pc32/i386/vm_machdep.c | 23 ++++--- sys/platform/pc32/include/asnames.h | 3 +- sys/platform/pc32/include/globaldata.h | 3 +- sys/platform/pc32/include/globals.h | 9 +-- sys/platform/pc32/include/pcb.h | 6 +- sys/platform/pc32/isa/npx.c | 18 +++--- sys/platform/vkernel/i386/genassym.c | 6 +- sys/sys/proc.h | 3 +- sys/sys/user.h | 3 +- sys/vm/vm_glue.c | 3 +- 50 files changed, 418 insertions(+), 340 deletions(-) diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c index e8c503f670..3f990c2b0a 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.2 2003/06/17 04:28:20 dillon Exp $ + * $DragonFly: src/sys/ddb/db_ps.c,v 1.3 2003/06/18 18:29:53 dillon Exp $ */ #include #include @@ -93,7 +93,7 @@ db_ps(dummy1, dummy2, dummy3, dummy4) pp = p; db_printf("%5d %8p %8p %4d %5d %5d %06x %d", - p->p_pid, (volatile void *)p, (void *)p->p_addr, + p->p_pid, (volatile void *)p, (void *)p->p_thread->td_pcb, p->p_cred ? p->p_cred->p_ruid : 0, pp->p_pid, p->p_pgrp ? p->p_pgrp->pg_id : 0, p->p_flag, p->p_stat); if (p->p_wchan) { diff --git a/sys/emulation/linux/i386/linux_ptrace.c b/sys/emulation/linux/i386/linux_ptrace.c index 67852eb1eb..6fafef8e74 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.2 2003/06/17 04:28:38 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linux_ptrace.c,v 1.3 2003/06/18 18:30:03 dillon Exp $ */ #include "opt_cpu.h" @@ -225,7 +225,7 @@ linux_proc_read_fpxregs(struct proc *p, struct linux_pt_fpxreg *fpxregs) if (cpu_fxsr == 0 || (p->p_flag & P_INMEM) == 0) error = EIO; else - bcopy(&p->p_addr->u_pcb.pcb_save.sv_xmm, + bcopy(&p->p_thread->td_pcb->pcb_save.sv_xmm, fpxregs, sizeof(*fpxregs)); return (error); } @@ -239,7 +239,7 @@ linux_proc_write_fpxregs(struct proc *p, struct linux_pt_fpxreg *fpxregs) if (cpu_fxsr == 0 || (p->p_flag & P_INMEM) == 0) error = EIO; else - bcopy(fpxregs, &p->p_addr->u_pcb.pcb_save.sv_xmm, + bcopy(fpxregs, &p->p_thread->td_pcb->pcb_save.sv_xmm, sizeof(*fpxregs)); return (error); } diff --git a/sys/emulation/svr4/i386/svr4_machdep.c b/sys/emulation/svr4/i386/svr4_machdep.c index 88c4069659..370fc7afa5 100644 --- a/sys/emulation/svr4/i386/svr4_machdep.c +++ b/sys/emulation/svr4/i386/svr4_machdep.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/svr4/svr4_machdep.c,v 1.13.2.1 2002/01/12 11:03:30 bde Exp $ - * $DragonFly: src/sys/emulation/svr4/i386/Attic/svr4_machdep.c,v 1.2 2003/06/17 04:28:39 dillon Exp $ + * $DragonFly: src/sys/emulation/svr4/i386/Attic/svr4_machdep.c,v 1.3 2003/06/18 18:30:06 dillon Exp $ */ #include @@ -81,7 +81,7 @@ svr4_setregs(p, epp, stack) struct exec_package *epp; u_long stack; { - register struct pcb *pcb = &p->p_addr->u_pcb; + register struct pcb *pcb = p->p_thread->td_pcb; pcb->pcb_savefpu.sv_env.en_cw = __SVR4_NPXCW__; setregs(p, epp, stack, 0UL); diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 4d1de1cc13..ae9233b5f2 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.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/db_trace.c,v 1.3 2003/06/18 18:29:55 dillon Exp $ */ #include @@ -317,7 +317,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) db_printf("pid %d swapped out\n", pid); return; } - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; frame = (struct i386_frame *)pcb->pcb_ebp; if (frame == NULL) frame = (struct i386_frame *) diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 6def56bdde..c64d184487 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.5 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.6 2003/06/18 18:29:55 dillon Exp $ */ #include "opt_user_ldt.h" @@ -83,6 +83,7 @@ ASSYM(P_WCHAN, offsetof(struct proc, p_wchan)); ASSYM(P_THREAD, offsetof(struct proc, p_thread)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); +ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); #ifdef SMP ASSYM(P_ONCPU, offsetof(struct proc, p_oncpu)); @@ -141,9 +142,7 @@ ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu)); ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87)); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); -#ifdef SMP ASSYM(PCB_SIZE, sizeof(struct pcb)); -#endif ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno)); ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); @@ -176,7 +175,6 @@ ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_SIZEOF, sizeof(struct globaldata)); ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread)); -ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); ASSYM(GD_SWITCHTICKS, offsetof(struct globaldata, gd_switchticks)); diff --git a/sys/i386/i386/globals.s b/sys/i386/i386/globals.s index 29cac9a239..8f1b185bdb 100644 --- a/sys/i386/i386/globals.s +++ b/sys/i386/i386/globals.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/globals.s,v 1.13.2.1 2000/05/16 06:58:06 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/globals.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/globals.s,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ #include "opt_user_ldt.h" @@ -64,12 +64,11 @@ globaldata: #else .set globaldata,0 #endif - .globl gd_curthread, gd_curpcb, gd_npxthread, gd_astpending + .globl gd_curthread, gd_npxthread, gd_astpending .globl gd_common_tss, gd_switchtime, gd_switchticks, gd_idlethread .set gd_curthread,globaldata + GD_CURTHREAD .set gd_idlethread,globaldata + GD_IDLETHREAD .set gd_astpending,globaldata + GD_ASTPENDING - .set gd_curpcb,globaldata + GD_CURPCB .set gd_npxthread,globaldata + GD_NPXTHREAD .set gd_common_tss,globaldata + GD_COMMON_TSS .set gd_switchtime,globaldata + GD_SWITCHTIME @@ -85,12 +84,11 @@ globaldata: #endif #ifndef SMP - .globl _curthread, _curpcb, _npxthread, _astpending + .globl _curthread, _npxthread, _astpending .globl _common_tss, _switchtime, _switchticks, _idlethread .set _curthread,globaldata + GD_CURTHREAD .set _idlethread,globaldata + GD_IDLETHREAD .set _astpending,globaldata + GD_ASTPENDING - .set _curpcb,globaldata + GD_CURPCB .set _npxthread,globaldata + GD_NPXTHREAD .set _common_tss,globaldata + GD_COMMON_TSS .set _switchtime,globaldata + GD_SWITCHTIME diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index 9d9dec4d63..8c68ed43a3 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -35,7 +35,7 @@ * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/locore.s,v 1.132.2.10 2003/02/03 20:54:49 jhb Exp $ - * $DragonFly: src/sys/i386/i386/Attic/locore.s,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/locore.s,v 1.3 2003/06/18 18:29:55 dillon Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -355,14 +355,18 @@ NON_GPROF_ENTRY(btext) /* now running relocated at KERNBASE where the system is linked to run */ begin: + /* + * set up the bootstrap stack. The pcb sits at the end of the + * bootstrap stack. + */ /* set up bootstrap stack */ movl _proc0paddr,%esp /* location of in-kernel pages */ - addl $UPAGES*PAGE_SIZE,%esp /* bootstrap stack end location */ - xorl %eax,%eax /* mark end of frames */ + addl $UPAGES*PAGE_SIZE-PCB_SIZE,%esp + xorl %eax,%eax /* mark end of frames */ movl %eax,%ebp - movl _proc0paddr,%eax + /*movl _proc0paddr,%eax*/ movl _IdlePTD, %esi - movl %esi,PCB_CR3(%eax) + movl %esi,PCB_CR3(%esp) testl $CPUID_PGE, R(_cpu_feature) jz 1f diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 83e820df06..2d1d372b47 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.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.4 2003/06/18 18:29:55 dillon Exp $ */ #include "apm.h" @@ -569,7 +569,7 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) */ if (regs->tf_eflags & PSL_VM) { struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs; sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs; @@ -676,7 +676,7 @@ sendsig(catcher, sig, mask, code) */ if (regs->tf_eflags & PSL_VM) { struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs; sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs; @@ -757,9 +757,9 @@ osigreturn(p, uap) * if pcb_ext == 0 or vm86_inited == 0, the user hasn't * set up the vm86 area, and we can't enter vm86 mode. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (p->p_thread->td_pcb->pcb_ext == 0) return (EINVAL); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_inited == 0) return (EINVAL); @@ -877,9 +877,9 @@ sigreturn(p, uap) * if pcb_ext == 0 or vm86_inited == 0, the user hasn't * set up the vm86 area, and we can't enter vm86 mode. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (p->p_thread->td_pcb->pcb_ext == 0) return (EINVAL); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_inited == 0) return (EINVAL); @@ -1009,7 +1009,7 @@ setregs(p, entry, stack, ps_strings) u_long ps_strings; { struct trapframe *regs = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = p->p_thread->td_pcb; /* Reset pc->pcb_gs and %gs before possibly invalidating it. */ pcb->pcb_gs = _udatasel; @@ -1044,7 +1044,7 @@ setregs(p, entry, stack, ps_strings) pcb->pcb_dr3 = 0; pcb->pcb_dr6 = 0; pcb->pcb_dr7 = 0; - if (pcb == curpcb) { + if (pcb == curthread->td_pcb) { /* * Clear the debug registers on the running * CPU, otherwise they will end up affecting @@ -1062,7 +1062,7 @@ setregs(p, entry, stack, 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_addr->u_pcb.pcb_flags &= ~FP_SOFTFP; + p->p_thread->td_pcb->pcb_flags &= ~FP_SOFTFP; /* * Arrange to trap the next npx or `fwait' instruction (see npx.c @@ -1865,6 +1865,10 @@ init386(first) safepri = cpl; proc0.p_addr = proc0paddr; + proc0.p_thread = &thread0; + thread0.td_proc = &proc0; + thread0.td_pcb = (struct pcb *) + ((char *)proc0paddr + UPAGES*PAGE_SIZE - sizeof(struct pcb)); atdevbase = ISA_HOLE_START + KERNBASE; @@ -1997,8 +2001,11 @@ init386(first) setidt(13, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); initializecpu(); /* Initialize CPU registers */ - /* make an initial tss so cpu can get interrupt stack on syscall! */ - common_tss.tss_esp0 = (int) proc0.p_addr + UPAGES*PAGE_SIZE - 16; + /* + * make an initial tss so cpu can get interrupt stack on syscall! + * The 16 bytes is to save room for a VM86 context. + */ + common_tss.tss_esp0 = (int) thread0.td_pcb - 16; common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ; gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); private_tss = 0; @@ -2054,12 +2061,12 @@ init386(first) _udatasel = LSEL(LUDATA_SEL, SEL_UPL); /* setup proc 0's pcb */ - proc0.p_addr->u_pcb.pcb_flags = 0; - proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD; + thread0.td_pcb->pcb_flags = 0; + thread0.td_pcb->pcb_cr3 = (int)IdlePTD; /* should already be setup */ #ifdef SMP - proc0.p_addr->u_pcb.pcb_mpnest = 1; + thread0.td_pcb->pcb_mpnest = 1; #endif - proc0.p_addr->u_pcb.pcb_ext = 0; + thread0.td_pcb->pcb_ext = 0; proc0.p_md.md_regs = &proc0_tf; } @@ -2163,7 +2170,12 @@ int ptrace_write_u(p, off, data) *(int*)((char *)p->p_addr + off) = data; return (0); } - min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_save); + + /* + * 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); @@ -2195,7 +2207,7 @@ fill_regs(p, regs) regs->r_eflags = tp->tf_eflags; regs->r_esp = tp->tf_esp; regs->r_ss = tp->tf_ss; - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; regs->r_gs = pcb->pcb_gs; return (0); } @@ -2227,7 +2239,7 @@ set_regs(p, regs) tp->tf_eflags = regs->r_eflags; tp->tf_esp = regs->r_esp; tp->tf_ss = regs->r_ss; - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; pcb->pcb_gs = regs->r_gs; return (0); } @@ -2293,12 +2305,12 @@ fill_fpregs(p, fpregs) { #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { - fill_fpregs_xmm(&p->p_addr->u_pcb.pcb_save.sv_xmm, + fill_fpregs_xmm(&p->p_thread->td_pcb->pcb_save.sv_xmm, (struct save87 *)fpregs); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(&p->p_addr->u_pcb.pcb_save.sv_87, fpregs, sizeof *fpregs); + bcopy(&p->p_thread->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs); return (0); } @@ -2310,11 +2322,11 @@ set_fpregs(p, fpregs) #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { set_fpregs_xmm((struct save87 *)fpregs, - &p->p_addr->u_pcb.pcb_save.sv_xmm); + &p->p_thread->td_pcb->pcb_save.sv_xmm); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(fpregs, &p->p_addr->u_pcb.pcb_save.sv_87, sizeof *fpregs); + bcopy(fpregs, &p->p_thread->td_pcb->pcb_save.sv_87, sizeof *fpregs); return (0); } @@ -2336,7 +2348,7 @@ fill_dbregs(p, dbregs) dbregs->dr7 = rdr7(); } else { - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; dbregs->dr0 = pcb->pcb_dr0; dbregs->dr1 = pcb->pcb_dr1; dbregs->dr2 = pcb->pcb_dr2; @@ -2380,7 +2392,7 @@ set_dbregs(p, dbregs) if ((dbregs->dr7 & mask1) == mask2) return (EINVAL); - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; /* * Don't let a process set a breakpoint that is not within the diff --git a/sys/i386/i386/math_emu.h b/sys/i386/i386/math_emu.h index 1dddca210d..bedf201736 100644 --- a/sys/i386/i386/math_emu.h +++ b/sys/i386/i386/math_emu.h @@ -4,7 +4,7 @@ * (C) 1991 Linus Torvalds * * $FreeBSD: src/sys/i386/i386/math_emu.h,v 1.7.2.1 2001/08/15 01:23:50 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/math_emu.h,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/math_emu.h,v 1.4 2003/06/18 18:29:55 dillon Exp $ */ #ifndef _LINUX_MATH_EMU_H #define _LINUX_MATH_EMU_H @@ -70,7 +70,7 @@ struct i387_struct { int32_t st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ }; -#define I387 (*(struct i387_struct *)&(((struct pcb *)curproc->p_addr)->pcb_save.sv_87)) /* YYY note: pcb will be moved out of UAREA! */ +#define I387 (*(struct i387_struct *)&((curthread->td_pcb)->pcb_save.sv_87)) #define SWD (*(struct swd *) &I387.swd) #define ROUNDING ((I387.cwd >> 10) & 3) #define PRECISION ((I387.cwd >> 8) & 3) diff --git a/sys/i386/i386/math_emulate.c b/sys/i386/i386/math_emulate.c index b11d66f71d..8a318e0424 100644 --- a/sys/i386/i386/math_emulate.c +++ b/sys/i386/i386/math_emulate.c @@ -7,7 +7,7 @@ * * from: 386BSD 0.1 * $FreeBSD: src/sys/i386/i386/math_emulate.c,v 1.35 1999/08/28 00:43:47 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/math_emulate.c,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/math_emulate.c,v 1.4 2003/06/18 18:29:55 dillon Exp $ */ /* @@ -100,9 +100,8 @@ math_emulate(struct trapframe * info) u_int32_t oldeip; /* ever used fp? */ - /* YYY NOTE: pcb will be moved out of uarea! */ - if ((((struct pcb *)curproc->p_addr)->pcb_flags & FP_SOFTFP) == 0) { - ((struct pcb *)curproc->p_addr)->pcb_flags |= FP_SOFTFP; + if ((curthread->td_pcb->pcb_flags & FP_SOFTFP) == 0) { + curthread->td_pcb->pcb_flags |= FP_SOFTFP; I387.cwd = 0x037f; I387.swd = 0x0000; I387.twd = 0x0000; diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 995a6f498f..f2c8655815 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -40,7 +40,7 @@ * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/i386/pmap.c,v 1.250.2.18 2002/03/06 22:48:53 silby Exp $ - * $DragonFly: src/sys/i386/i386/Attic/pmap.c,v 1.4 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/pmap.c,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ /* @@ -850,6 +850,8 @@ pmap_new_thread(struct proc *p) if (p) { p->p_thread = td; td->td_proc = p; + td->td_pcb = (struct pcb *) + ((char *)p->p_addr + UPAGES * PAGE_SIZE) - 1; } return(td); } @@ -3389,7 +3391,8 @@ pmap_activate(struct proc *p) #if defined(SWTCH_OPTIM_STATS) tlb_flush_count++; #endif - load_cr3(p->p_addr->u_pcb.pcb_cr3 = vtophys(pmap->pm_pdir)); + p->p_thread->td_pcb->pcb_cr3 = vtophys(pmap->pm_pdir); + load_cr3(p->p_thread->td_pcb->pcb_cr3); } vm_offset_t diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 152bc17a57..f8d50d0eb4 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/support.s,v 1.67.2.5 2001/08/15 01:23:50 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/support.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/support.s,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ #include "npx.h" @@ -671,7 +671,8 @@ ENTRY(copyout) jmp *_copyout_vector ENTRY(generic_copyout) - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $copyout_fault,PCB_ONFAULT(%eax) pushl %esi pushl %edi @@ -782,7 +783,8 @@ done_copyout: popl %edi popl %esi xorl %eax,%eax - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl %eax,PCB_ONFAULT(%edx) ret @@ -791,7 +793,8 @@ copyout_fault: popl %ebx popl %edi popl %esi - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl $0,PCB_ONFAULT(%edx) movl $EFAULT,%eax ret @@ -801,7 +804,8 @@ ENTRY(i586_copyout) /* * Duplicated from generic_copyout. Could be done a bit better. */ - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $copyout_fault,PCB_ONFAULT(%eax) pushl %esi pushl %edi @@ -858,7 +862,8 @@ ENTRY(copyin) jmp *_copyin_vector ENTRY(generic_copyin) - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $copyin_fault,PCB_ONFAULT(%eax) pushl %esi pushl %edi @@ -896,7 +901,8 @@ done_copyin: popl %edi popl %esi xorl %eax,%eax - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl %eax,PCB_ONFAULT(%edx) ret @@ -904,7 +910,8 @@ done_copyin: copyin_fault: popl %edi popl %esi - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl $0,PCB_ONFAULT(%edx) movl $EFAULT,%eax ret @@ -914,7 +921,8 @@ ENTRY(i586_copyin) /* * Duplicated from generic_copyin. Could be done a bit better. */ - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $copyin_fault,PCB_ONFAULT(%eax) pushl %esi pushl %edi @@ -971,7 +979,8 @@ ENTRY(fastmove) cmpl $0,_npxthread je 6f /* fnsave(&curpcb->pcb_savefpu); */ - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax fnsave PCB_SAVEFPU(%eax) /* npxthread = NULL; */ movl $0,_npxthread @@ -991,7 +1000,8 @@ ENTRY(fastmove) movl %esi,-8(%ebp) movl %edi,-4(%ebp) movl %esp,%edi - movl _curpcb,%esi + movl _curthread,%esi + movl TD_PCB(%esi),%esi addl $PCB_SAVEFPU,%esi cld movl $PCB_SAVE87_SIZE>>2,%ecx @@ -1005,7 +1015,8 @@ ENTRY(fastmove) /* npxthread = curthread; */ movl _curthread,%eax movl %eax,_npxthread - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $fastmove_fault,PCB_ONFAULT(%eax) 4: movl %ecx,-12(%ebp) @@ -1067,7 +1078,8 @@ fastmove_loop: movl %ecx,-12(%ebp) movl %esi,-8(%ebp) movl %edi,-4(%ebp) - movl _curpcb,%edi + movl _curthread,%edi + movl TD_PCB(%edi),%edi addl $PCB_SAVEFPU,%edi movl %esp,%esi cld @@ -1087,7 +1099,8 @@ fastmove_loop: ALIGN_TEXT fastmove_tail: - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $fastmove_tail_fault,PCB_ONFAULT(%eax) movb %cl,%al @@ -1106,7 +1119,8 @@ fastmove_tail: ALIGN_TEXT fastmove_fault: - movl _curpcb,%edi + movl _curthread,%edi + movl TD_PCB(%edi),%edi addl $PCB_SAVEFPU,%edi movl %esp,%esi cld @@ -1126,7 +1140,8 @@ fastmove_tail_fault: popl %ebx popl %edi popl %esi - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl $0,PCB_ONFAULT(%edx) movl $EFAULT,%eax ret @@ -1138,7 +1153,8 @@ fastmove_tail_fault: * Fetch a byte (sword, word) from user memory */ ENTRY(fuword) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx /* from */ @@ -1164,7 +1180,8 @@ ENTRY(fuswintr) * fusword - MP SAFE */ ENTRY(fusword) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1179,7 +1196,8 @@ ENTRY(fusword) * fubyte - MP SAFE */ ENTRY(fubyte) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1192,7 +1210,8 @@ ENTRY(fubyte) ALIGN_TEXT fusufault: - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx xorl %eax,%eax movl %eax,PCB_ONFAULT(%ecx) decl %eax @@ -1204,7 +1223,8 @@ fusufault: * Write a byte (word, longword) to user memory */ ENTRY(suword) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1248,7 +1268,8 @@ ENTRY(suword) movl 8(%esp),%eax movl %eax,(%edx) xorl %eax,%eax - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl %eax,PCB_ONFAULT(%ecx) ret @@ -1256,7 +1277,8 @@ ENTRY(suword) * susword - MP SAFE (if not I386_CPU) */ ENTRY(susword) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1300,7 +1322,8 @@ ENTRY(susword) movw 8(%esp),%ax movw %ax,(%edx) xorl %eax,%eax - movl _curpcb,%ecx /* restore trashed register */ + movl _curthread,%ecx /* restore trashed register */ + movl TD_PCB(%ecx),%ecx movl %eax,PCB_ONFAULT(%ecx) ret @@ -1309,7 +1332,8 @@ ENTRY(susword) */ ALTENTRY(suibyte) ENTRY(subyte) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1352,7 +1376,8 @@ ENTRY(subyte) movb 8(%esp),%al movb %al,(%edx) xorl %eax,%eax - movl _curpcb,%ecx /* restore trashed register */ + movl _curthread,%ecx /* restore trashed register */ + movl TD_PCB(%ecx),%ecx movl %eax,PCB_ONFAULT(%ecx) ret @@ -1367,7 +1392,8 @@ ENTRY(subyte) ENTRY(copyinstr) pushl %esi pushl %edi - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $cpystrflt,PCB_ONFAULT(%ecx) movl 12(%esp),%esi /* %esi = from */ @@ -1415,7 +1441,8 @@ cpystrflt: cpystrflt_x: /* set *lencopied and return %eax */ - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $0,PCB_ONFAULT(%ecx) movl 20(%esp),%ecx subl %edx,%ecx diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s index fefc494519..6ce174f9a2 100644 --- a/sys/i386/i386/swtch.s +++ b/sys/i386/i386/swtch.s @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/swtch.s,v 1.89.2.10 2003/01/23 03:36:24 ps Exp $ - * $DragonFly: src/sys/i386/i386/Attic/swtch.s,v 1.5 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/swtch.s,v 1.6 2003/06/18 18:29:55 dillon Exp $ */ #include "npx.h" @@ -300,7 +300,8 @@ ENTRY(cpu_switch) #endif /* SMP */ btrl %eax, VM_PMAP+PM_ACTIVE(%edx) - movl P_ADDR(%ecx),%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl (%esp),%eax /* Hardware registers */ movl %eax,PCB_EIP(%edx) @@ -395,8 +396,8 @@ sw1a: cmpb $SRUN,P_STAT(%ecx) jne badsw2 #endif - - movl P_ADDR(%ecx),%edx + movl P_THREAD(%ecx),%edx + movl TD_PCB(%edx),%edx #if defined(SWTCH_OPTIM_STATS) incl _swtch_optim_stats @@ -425,9 +426,13 @@ sw1a: jmp 2f 1: - /* update common_tss.tss_esp0 pointer */ - movl %edx, %ebx /* pcb */ - addl $(UPAGES * PAGE_SIZE - 16), %ebx + /* + * update common_tss.tss_esp0 pointer. This is the supervisor + * stack pointer on entry from user mode. Since the pcb is + * at the top of the supervisor stack esp0 starts just below it. + * We leave enough space for vm86 (16 bytes). + */ + leal -16(%edx),%ebx movl %ebx, _common_tss + TSS_ESP0 btrl %esi, _private_tss @@ -476,7 +481,6 @@ sw1a: movl _cpuid,%eax movb %al, P_ONCPU(%ecx) #endif /* SMP */ - movl %edx, _curpcb movl P_THREAD(%ecx),%ecx /* ecx = thread */ movl %ecx, _curthread movl TD_PROC(%ecx),%ecx /* YYY does %ecx need to be restored? */ @@ -599,8 +603,7 @@ ENTRY(savectx) je 1f pushl %ecx - movl TD_PROC(%eax),%eax - movl P_ADDR(%eax),%eax + movl TD_PCB(%eax),%eax leal PCB_SAVEFPU(%eax),%eax pushl %eax pushl %eax diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c index fdb7ff158c..7ffe298dfe 100644 --- a/sys/i386/i386/sys_machdep.c +++ b/sys/i386/i386/sys_machdep.c @@ -32,7 +32,7 @@ * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.47.2.3 2002/10/07 17:20:00 jhb Exp $ - * $DragonFly: src/sys/i386/i386/Attic/sys_machdep.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/sys_machdep.c,v 1.3 2003/06/18 18:29:55 dillon Exp $ * */ @@ -137,9 +137,9 @@ i386_extend_pcb(struct proc *p) ext = (struct pcb_ext *)kmem_alloc(kernel_map, ctob(IOPAGES+1)); if (ext == 0) return (ENOMEM); - p->p_addr->u_pcb.pcb_ext = ext; + p->p_thread->td_pcb->pcb_ext = ext; bzero(ext, sizeof(struct pcb_ext)); - ext->ext_tss.tss_esp0 = (unsigned)p->p_addr + ctob(UPAGES) - 16; + ext->ext_tss.tss_esp0 = (unsigned)((char *)p->p_thread->td_pcb - 16); ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); /* * The last byte of the i/o map must be followed by an 0xff byte. @@ -189,10 +189,10 @@ i386_set_ioperm(p, args) * cause confusion. This probably requires a global 'usage registry'. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (p->p_thread->td_pcb->pcb_ext == 0) if ((error = i386_extend_pcb(p)) != 0) return (error); - iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + iomap = (char *)p->p_thread->td_pcb->pcb_ext->ext_iomap; if (ua.start + ua.length > IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); @@ -220,12 +220,12 @@ i386_get_ioperm(p, args) if (ua.start >= IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); - if (p->p_addr->u_pcb.pcb_ext == 0) { + if (p->p_thread->td_pcb->pcb_ext == 0) { ua.length = 0; goto done; } - iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + iomap = (char *)p->p_thread->td_pcb->pcb_ext->ext_iomap; i = ua.start; state = (iomap[i >> 3] >> (i & 7)) & 1; @@ -253,7 +253,7 @@ set_user_ldt(struct pcb *pcb) { struct pcb_ldt *pcb_ldt; - if (pcb != curpcb) + if (pcb != curthread->td_pcb) return; pcb_ldt = pcb->pcb_ldt; @@ -309,7 +309,7 @@ user_ldt_free(struct pcb *pcb) if (pcb_ldt == NULL) return; - if (pcb == curpcb) { + if (pcb == curthread->td_pcb) { lldt(_default_ldt); currentldt = _default_ldt; } @@ -328,7 +328,7 @@ i386_get_ldt(p, args) char *args; { int error = 0; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = p->p_thread->td_pcb; struct pcb_ldt *pcb_ldt = pcb->pcb_ldt; int nldt, num; union descriptor *lp; @@ -378,7 +378,7 @@ i386_set_ldt(p, args) { int error = 0, i, n; int largest_ld; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = p->p_thread->td_pcb; struct pcb_ldt *pcb_ldt = pcb->pcb_ldt; union descriptor *descs; int descs_size, s; diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index ad2dee107c..4539cef047 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.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.3 2003/06/18 18:29:55 dillon Exp $ */ /* @@ -510,7 +510,7 @@ kernel_trap: * a signal. */ if (frame.tf_eip == (int)cpu_switch_load_gs) { - curpcb->pcb_gs = 0; + curthread->td_pcb->pcb_gs = 0; psignal(p, SIGBUS); return; } @@ -522,8 +522,8 @@ kernel_trap: doreti_popl_es_fault); MAYBE_DORETI_FAULT(doreti_popl_fs, doreti_popl_fs_fault); - if (curpcb && curpcb->pcb_onfault) { - frame.tf_eip = (int)curpcb->pcb_onfault; + if (curthread->td_pcb->pcb_onfault) { + frame.tf_eip = (int)curthread->td_pcb->pcb_onfault; return; } } @@ -691,8 +691,8 @@ trap_pfault(frame, usermode, eva) if (p == NULL || (!usermode && va < VM_MAXUSER_ADDRESS && - (intr_nesting_level != 0 || curpcb == NULL || - curpcb->pcb_onfault == NULL))) { + (intr_nesting_level != 0 || + curthread->td_pcb->pcb_onfault == NULL))) { trap_fatal(frame, eva); return (-1); } @@ -754,8 +754,8 @@ trap_pfault(frame, usermode, eva) return (0); nogo: if (!usermode) { - if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { - frame->tf_eip = (int)curpcb->pcb_onfault; + if (intr_nesting_level == 0 && curthread->td_pcb->pcb_onfault) { + frame->tf_eip = (int)curthread->td_pcb->pcb_onfault; return (0); } trap_fatal(frame, eva); @@ -861,8 +861,8 @@ trap_pfault(frame, usermode, eva) return (0); nogo: if (!usermode) { - if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { - frame->tf_eip = (int)curpcb->pcb_onfault; + if (intr_nesting_level == 0 && curthread->td_pcb->pcb_onfault) { + frame->tf_eip = (int)curthread->td_pcb->pcb_onfault; return (0); } trap_fatal(frame, eva); diff --git a/sys/i386/i386/vm86.c b/sys/i386/i386/vm86.c index ad0eceb0ad..105d7d78a7 100644 --- a/sys/i386/i386/vm86.c +++ b/sys/i386/i386/vm86.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/vm86.c,v 1.31.2.2 2001/10/05 06:18:55 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/vm86.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm86.c,v 1.3 2003/06/18 18:29:55 dillon Exp $ */ #include @@ -141,9 +141,9 @@ vm86_emulate(vmf) * the extension is not present. (This check should not be needed, * as we can't enter vm86 mode until we set up an extension area) */ - if (curpcb->pcb_ext == 0) + if (curthread->td_pcb->pcb_ext == 0) return (SIGBUS); - vm86 = &curpcb->pcb_ext->ext_vm86; + vm86 = &curthread->td_pcb->pcb_ext->ext_vm86; if (vmf->vmf_eflags & PSL_T) retcode = SIGTRAP; @@ -503,7 +503,7 @@ static void vm86_initflags(struct vm86frame *vmf) { int eflags = vmf->vmf_eflags; - struct vm86_kernel *vm86 = &curpcb->pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &curthread->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_has_vme) { eflags = (vmf->vmf_eflags & ~VME_USERCHANGE) | @@ -656,10 +656,10 @@ vm86_sysarch(p, args) if ((error = copyin(args, &ua, sizeof(struct i386_vm86_args))) != 0) return (error); - if (p->p_addr->u_pcb.pcb_ext == 0) + if (p->p_thread->td_pcb->pcb_ext == 0) if ((error = i386_extend_pcb(p)) != 0) return (error); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; switch (ua.sub_op) { case VM86_INIT: { diff --git a/sys/i386/i386/vm86bios.s b/sys/i386/i386/vm86bios.s index e0b8619be9..ca873db346 100644 --- a/sys/i386/i386/vm86bios.s +++ b/sys/i386/i386/vm86bios.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/vm86bios.s,v 1.15.2.1 2000/05/16 06:58:07 dillon Exp $ - * $DragonFly: src/sys/i386/i386/Attic/vm86bios.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm86bios.s,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ #include /* miscellaneous asm macros */ @@ -76,8 +76,7 @@ ENTRY(vm86_bioscall) testl %ecx,%ecx je 1f /* no curthread/npxthread */ pushl %edx - movl TD_PROC(%ecx),%ecx - movl P_ADDR(%ecx),%ecx + movl TD_PCB(%ecx),%ecx addl $PCB_SAVEFPU,%ecx pushl %ecx call _npxsave @@ -95,10 +94,14 @@ ENTRY(vm86_bioscall) rep movsl /* copy frame to new stack */ - /* YYY when pcb is in thread vm86_bios will be in its own thread */ - movl _curpcb,%eax + /* + * YYY I really dislike replacing td_pcb, even temporarily. Find + * another way. + */ + movl _curthread,%ebx + movl TD_PCB(%ebx),%eax /* save curpcb */ pushl %eax /* save curpcb */ - movl %edx,_curpcb /* set curpcb to vm86pcb */ + movl %edx,TD_PCB(%ebx) /* set curpcb to vm86pcb */ movl _tss_gdt,%ebx /* entry in GDT */ movl 0(%ebx),%eax @@ -179,8 +182,9 @@ ENTRY(vm86_biosret) movl %eax,4(%ebx) /* restore second word */ movl $GPROC0_SEL*8,%esi /* GSEL(entry, SEL_KPL) */ ltr %si - - popl _curpcb /* restore curpcb/curproc */ + + movl _curthread,%eax + popl TD_PCB(%eax) /* restore curpcb */ movl SCR_ARGFRAME(%edx),%edx /* original stack frame */ movl TF_TRAPNO(%edx),%eax /* return (trapno) */ diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 7a6dc2dc69..524b49ef3b 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.4 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/vm_machdep.c,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ #include "npx.h" @@ -127,7 +127,7 @@ cpu_fork(p1, p2, flags) #ifdef USER_LDT if ((flags & RFMEM) == 0) { /* unshare user LDT */ - struct pcb *pcb1 = &p1->p_addr->u_pcb; + struct pcb *pcb1 = p1->p_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); @@ -143,20 +143,22 @@ cpu_fork(p1, p2, flags) #if NNPX > 0 /* Ensure that p1's pcb is up to date. */ if (npxthread == p1->p_thread) - npxsave(&p1->p_addr->u_pcb.pcb_save); + npxsave(&p1->p_thread->td_pcb->pcb_save); #endif /* Copy p1's pcb. */ - p2->p_addr->u_pcb = p1->p_addr->u_pcb; - pcb2 = &p2->p_addr->u_pcb; + *p2->p_thread->td_pcb = *p1->p_thread->td_pcb; + pcb2 = p2->p_thread->td_pcb; /* * Create a new fresh stack for the new process. * Copy the trap frame for the return to user mode as if from a - * syscall. This copies the user mode register values. + * syscall. This copies the user mode register values. The + * 16 byte offset saves space for vm86, and must match + * common_tss.esp0 (kernel stack pointer on entry from user mode) */ p2->p_md.md_regs = (struct trapframe *) - ((int)p2->p_addr + UPAGES * PAGE_SIZE - 16) - 1; + ((char *)p2->p_thread->td_pcb - 16) - 1; bcopy(p1->p_md.md_regs, p2->p_md.md_regs, sizeof(*p2->p_md.md_regs)); /* @@ -224,15 +226,15 @@ cpu_set_fork_handler(p, func, arg) * Note that the trap frame follows the args, so the function * is really called like this: func(arg, frame); */ - p->p_addr->u_pcb.pcb_esi = (int) func; /* function */ - p->p_addr->u_pcb.pcb_ebx = (int) arg; /* first arg */ + p->p_thread->td_pcb->pcb_esi = (int) func; /* function */ + p->p_thread->td_pcb->pcb_ebx = (int) arg; /* first arg */ } void cpu_exit(p) register struct proc *p; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = p->p_thread->td_pcb; #if NNPX > 0 npxexit(p); @@ -291,6 +293,7 @@ cpu_coredump(p, vp, cred) bcopy(p->p_md.md_regs, tempuser + ((caddr_t) p->p_md.md_regs - (caddr_t) p->p_addr), sizeof(struct trapframe)); + bcopy(p->p_thread->td_pcb, tempuser + ((char *)p->p_thread->td_pcb - (char *)p->p_addr), sizeof(struct pcb)); error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, ctob(UPAGES), (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p); diff --git a/sys/i386/include/asnames.h b/sys/i386/include/asnames.h index cbd4cbb516..34534c9679 100644 --- a/sys/i386/include/asnames.h +++ b/sys/i386/include/asnames.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/asnames.h,v 1.44.2.8 2003/01/22 20:14:53 jhb Exp $ - * $DragonFly: src/sys/i386/include/Attic/asnames.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/asnames.h,v 1.5 2003/06/18 18:29:58 dillon Exp $ */ #ifndef _MACHINE_ASNAMES_H_ @@ -342,7 +342,6 @@ #define _common_tssd FS(common_tssd) #define _cpuid FS(cpuid) #define _cpu_lockid FS(cpu_lockid) -#define _curpcb FS(curpcb) #define _curthread FS(curthread) #define _idlethread FS(idlethread) #define _astpending FS(astpending) diff --git a/sys/i386/include/globaldata.h b/sys/i386/include/globaldata.h index bfb8b5c2f6..15c86248b5 100644 --- a/sys/i386/include/globaldata.h +++ b/sys/i386/include/globaldata.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/i386/include/Attic/globaldata.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/globaldata.h,v 1.5 2003/06/18 18:29:58 dillon Exp $ */ /* @@ -43,7 +43,6 @@ struct globaldata { struct privatespace *gd_prvspace; /* self-reference */ struct thread *gd_curthread; struct thread *gd_npxthread; - struct pcb *gd_curpcb; struct timeval gd_switchtime; struct i386tss gd_common_tss; int gd_switchticks; diff --git a/sys/i386/include/globals.h b/sys/i386/include/globals.h index 6cc72adf32..c90f3bf739 100644 --- a/sys/i386/include/globals.h +++ b/sys/i386/include/globals.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globals.h,v 1.5.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/i386/include/Attic/globals.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/globals.h,v 1.5 2003/06/18 18:29:58 dillon Exp $ */ #ifndef _MACHINE_GLOBALS_H_ @@ -84,7 +84,6 @@ */ #define curthread GLOBAL_RVALUE_NV(curthread, struct thread *) #define idlethread GLOBAL_RVALUE_NV(idlethread, struct thread) -#define curpcb GLOBAL_RVALUE_NV(curpcb, struct pcb *) #define npxthread GLOBAL_LVALUE(npxthread, struct thread *) #define common_tss GLOBAL_LVALUE(common_tss, struct i386tss) #define switchtime GLOBAL_LVALUE(switchtime, struct timeval) @@ -125,16 +124,14 @@ extern struct timeval switchtime; /* Uptime at last context switch */ #endif /* - * note: curthread is never NULL, but curproc can be. curpcb is a separate - * entity in other BSDs. In Turtle it is integrated into the thread - * structure. + * note: curthread is never NULL, but curproc can be. Also note that + * in Turtle, the current pcb is stored in the thread structure. */ #define curproc (curthread->td_proc) GLOBAL_FUNC(curthread) GLOBAL_FUNC(idlethread) GLOBAL_FUNC(astpending) -GLOBAL_FUNC(curpcb) GLOBAL_FUNC(npxthread) GLOBAL_FUNC(common_tss) GLOBAL_FUNC(switchtime) diff --git a/sys/i386/include/pcb.h b/sys/i386/include/pcb.h index e1db9990bf..5aa3ba4623 100644 --- a/sys/i386/include/pcb.h +++ b/sys/i386/include/pcb.h @@ -35,7 +35,7 @@ * * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/include/pcb.h,v 1.32.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/pcb.h,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/pcb.h,v 1.3 2003/06/18 18:29:58 dillon Exp $ */ #ifndef _I386_PCB_H_ @@ -92,10 +92,6 @@ struct md_coredump { #ifdef _KERNEL -#ifndef curpcb -extern struct pcb *curpcb; /* our current running pcb */ -#endif - void savectx __P((struct pcb *)); #endif diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c index da3677d549..58472d4421 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.4 2003/06/18 16:30:11 dillon Exp $ + * $DragonFly: src/sys/i386/isa/Attic/npx.c,v 1.5 2003/06/18 18:30:01 dillon Exp $ */ #include "opt_cpu.h" @@ -513,8 +513,7 @@ npxinit(control) fninit(); #endif fldcw(&control); - if (curpcb != NULL) - fpusave(&curpcb->pcb_save); + fpusave(&curthread->td_pcb->pcb_save); start_emulating(); } @@ -527,13 +526,14 @@ npxexit(p) { if (p->p_thread == npxthread) - npxsave(&curpcb->pcb_save); + npxsave(&curthread->td_pcb->pcb_save); #ifdef NPX_DEBUG if (npx_exists) { u_int masked_exceptions; - masked_exceptions = curpcb->pcb_save.sv_87.sv_env.en_cw - & curpcb->pcb_save.sv_87.sv_env.en_sw & 0x7f; + masked_exceptions = + curthread->td_pcb->pcb_save.sv_87.sv_env.en_cw + & curthread->td_pcb->pcb_save.sv_87.sv_env.en_sw & 0x7f; /* * Log exceptions that would have trapped with the old * control word (overflow, divide by 0, and invalid operand). @@ -754,7 +754,7 @@ npx_intr(dummy) panic("npxintr from non-current process"); } - exstat = GET_FPU_EXSW_PTR(curpcb); + exstat = GET_FPU_EXSW_PTR(curthread->td_pcb); outb(0xf0, 0); fnstsw(exstat); fnstcw(&control); @@ -827,7 +827,7 @@ npxdna() * Record new context early in case frstor causes an IRQ13. */ npxthread = curthread; - exstat = GET_FPU_EXSW_PTR(curpcb); + exstat = GET_FPU_EXSW_PTR(curthread->td_pcb); *exstat = 0; /* * The following frstor may cause an IRQ13 when the state being @@ -841,7 +841,7 @@ npxdna() * fnsave are broken, so our treatment breaks fnclex if it is the * first FPU instruction after a context switch. */ - fpurstor(&curpcb->pcb_save); + fpurstor(&curthread->td_pcb->pcb_save); return (1); } diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index f3a2794fdc..2da952f2d1 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.4 2003/06/18 16:30:14 dillon Exp $ + * $DragonFly: src/sys/kern/init_main.c,v 1.5 2003/06/18 18:30:08 dillon Exp $ */ #include "opt_init_path.h" @@ -80,14 +80,14 @@ void mi_startup(void); /* Should be elsewhere */ /* Components of the first process -- never freed. */ static struct session session0; static struct pgrp pgrp0; -struct proc proc0; -static struct thread thread0; static struct pcred cred0; static struct procsig procsig0; static struct filedesc0 filedesc0; static struct plimit limit0; static struct vmspace vmspace0; -struct proc *initproc; +struct proc *initproc; +struct proc proc0; +struct thread thread0; int cmask = CMASK; extern struct user *proc0paddr; @@ -256,12 +256,10 @@ static void proc0_init(void *dummy __unused) { register struct proc *p; - register struct thread *td; register struct filedesc0 *fdp; register unsigned i; p = &proc0; - td = &thread0; /* * Initialize process and pgrp structures. @@ -355,9 +353,7 @@ proc0_init(void *dummy __unused) vm_map_init(&vmspace0.vm_map, round_page(VM_MIN_ADDRESS), trunc_page(VM_MAXUSER_ADDRESS)); vmspace0.vm_map.pmap = vmspace_pmap(&vmspace0); - p->p_addr = proc0paddr; /* XXX */ - p->p_thread = td; - td->td_proc = p; + /*p->p_addr = proc0paddr; */ /* XXX */ /* * We continue to place resource usage info and signal diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index a600a8163b..281890927f 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.3 2003/06/18 06:33:37 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exit.c,v 1.4 2003/06/18 18:30:08 dillon Exp $ */ #include "opt_compat.h" @@ -358,7 +358,7 @@ exit1(p, rv) wakeup((caddr_t)p->p_pptr); #if defined(tahoe) /* move this to cpu_exit */ - p->p_addr->u_pcb.pcb_savacc.faddr = (float *)NULL; + p->p_thread->td_pcb->pcb_saveacc.faddr = (float *)NULL; #endif /* * Clear curproc after we've done all operations diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index ec9cb69624..4e419a4cb0 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.13 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/kern_fork.c,v 1.4 2003/06/18 16:30:14 dillon Exp $ + * $DragonFly: src/sys/kern/kern_fork.c,v 1.5 2003/06/18 18:30:08 dillon Exp $ */ #include "opt_ktrace.h" @@ -260,7 +260,6 @@ fork1(p1, flags, procp) /* Allocate new proc. */ newproc = zalloc(proc_zone); - (void)pmap_new_thread(newproc); /* * Setup linkage for kernel based threading diff --git a/sys/platform/pc32/i386/db_trace.c b/sys/platform/pc32/i386/db_trace.c index 03ce3bbe6b..432b4f7c9b 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.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/db_trace.c,v 1.3 2003/06/18 18:29:55 dillon Exp $ */ #include @@ -317,7 +317,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) db_printf("pid %d swapped out\n", pid); return; } - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; frame = (struct i386_frame *)pcb->pcb_ebp; if (frame == NULL) frame = (struct i386_frame *) diff --git a/sys/platform/pc32/i386/genassym.c b/sys/platform/pc32/i386/genassym.c index ff4a2ef475..7a649691ce 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.5 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.6 2003/06/18 18:29:55 dillon Exp $ */ #include "opt_user_ldt.h" @@ -83,6 +83,7 @@ ASSYM(P_WCHAN, offsetof(struct proc, p_wchan)); ASSYM(P_THREAD, offsetof(struct proc, p_thread)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); +ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); #ifdef SMP ASSYM(P_ONCPU, offsetof(struct proc, p_oncpu)); @@ -141,9 +142,7 @@ ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu)); ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87)); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); -#ifdef SMP ASSYM(PCB_SIZE, sizeof(struct pcb)); -#endif ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno)); ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); @@ -176,7 +175,6 @@ ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_SIZEOF, sizeof(struct globaldata)); ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread)); -ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); ASSYM(GD_SWITCHTICKS, offsetof(struct globaldata, gd_switchticks)); diff --git a/sys/platform/pc32/i386/globals.s b/sys/platform/pc32/i386/globals.s index 347a068aef..a6b69fa4cf 100644 --- a/sys/platform/pc32/i386/globals.s +++ b/sys/platform/pc32/i386/globals.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/globals.s,v 1.13.2.1 2000/05/16 06:58:06 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/globals.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/globals.s,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ #include "opt_user_ldt.h" @@ -64,12 +64,11 @@ globaldata: #else .set globaldata,0 #endif - .globl gd_curthread, gd_curpcb, gd_npxthread, gd_astpending + .globl gd_curthread, gd_npxthread, gd_astpending .globl gd_common_tss, gd_switchtime, gd_switchticks, gd_idlethread .set gd_curthread,globaldata + GD_CURTHREAD .set gd_idlethread,globaldata + GD_IDLETHREAD .set gd_astpending,globaldata + GD_ASTPENDING - .set gd_curpcb,globaldata + GD_CURPCB .set gd_npxthread,globaldata + GD_NPXTHREAD .set gd_common_tss,globaldata + GD_COMMON_TSS .set gd_switchtime,globaldata + GD_SWITCHTIME @@ -85,12 +84,11 @@ globaldata: #endif #ifndef SMP - .globl _curthread, _curpcb, _npxthread, _astpending + .globl _curthread, _npxthread, _astpending .globl _common_tss, _switchtime, _switchticks, _idlethread .set _curthread,globaldata + GD_CURTHREAD .set _idlethread,globaldata + GD_IDLETHREAD .set _astpending,globaldata + GD_ASTPENDING - .set _curpcb,globaldata + GD_CURPCB .set _npxthread,globaldata + GD_NPXTHREAD .set _common_tss,globaldata + GD_COMMON_TSS .set _switchtime,globaldata + GD_SWITCHTIME diff --git a/sys/platform/pc32/i386/locore.s b/sys/platform/pc32/i386/locore.s index ca026aed4d..fdb3c6826f 100644 --- a/sys/platform/pc32/i386/locore.s +++ b/sys/platform/pc32/i386/locore.s @@ -35,7 +35,7 @@ * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/locore.s,v 1.132.2.10 2003/02/03 20:54:49 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/i386/locore.s,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/locore.s,v 1.3 2003/06/18 18:29:55 dillon Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -355,14 +355,18 @@ NON_GPROF_ENTRY(btext) /* now running relocated at KERNBASE where the system is linked to run */ begin: + /* + * set up the bootstrap stack. The pcb sits at the end of the + * bootstrap stack. + */ /* set up bootstrap stack */ movl _proc0paddr,%esp /* location of in-kernel pages */ - addl $UPAGES*PAGE_SIZE,%esp /* bootstrap stack end location */ - xorl %eax,%eax /* mark end of frames */ + addl $UPAGES*PAGE_SIZE-PCB_SIZE,%esp + xorl %eax,%eax /* mark end of frames */ movl %eax,%ebp - movl _proc0paddr,%eax + /*movl _proc0paddr,%eax*/ movl _IdlePTD, %esi - movl %esi,PCB_CR3(%eax) + movl %esi,PCB_CR3(%esp) testl $CPUID_PGE, R(_cpu_feature) jz 1f diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index abf643f121..3c16990133 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.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.4 2003/06/18 18:29:55 dillon Exp $ */ #include "apm.h" @@ -569,7 +569,7 @@ osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) */ if (regs->tf_eflags & PSL_VM) { struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs; sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs; @@ -676,7 +676,7 @@ sendsig(catcher, sig, mask, code) */ if (regs->tf_eflags & PSL_VM) { struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs; sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs; @@ -757,9 +757,9 @@ osigreturn(p, uap) * if pcb_ext == 0 or vm86_inited == 0, the user hasn't * set up the vm86 area, and we can't enter vm86 mode. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (p->p_thread->td_pcb->pcb_ext == 0) return (EINVAL); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_inited == 0) return (EINVAL); @@ -877,9 +877,9 @@ sigreturn(p, uap) * if pcb_ext == 0 or vm86_inited == 0, the user hasn't * set up the vm86 area, and we can't enter vm86 mode. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (p->p_thread->td_pcb->pcb_ext == 0) return (EINVAL); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_inited == 0) return (EINVAL); @@ -1009,7 +1009,7 @@ setregs(p, entry, stack, ps_strings) u_long ps_strings; { struct trapframe *regs = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = p->p_thread->td_pcb; /* Reset pc->pcb_gs and %gs before possibly invalidating it. */ pcb->pcb_gs = _udatasel; @@ -1044,7 +1044,7 @@ setregs(p, entry, stack, ps_strings) pcb->pcb_dr3 = 0; pcb->pcb_dr6 = 0; pcb->pcb_dr7 = 0; - if (pcb == curpcb) { + if (pcb == curthread->td_pcb) { /* * Clear the debug registers on the running * CPU, otherwise they will end up affecting @@ -1062,7 +1062,7 @@ setregs(p, entry, stack, 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_addr->u_pcb.pcb_flags &= ~FP_SOFTFP; + p->p_thread->td_pcb->pcb_flags &= ~FP_SOFTFP; /* * Arrange to trap the next npx or `fwait' instruction (see npx.c @@ -1865,6 +1865,10 @@ init386(first) safepri = cpl; proc0.p_addr = proc0paddr; + proc0.p_thread = &thread0; + thread0.td_proc = &proc0; + thread0.td_pcb = (struct pcb *) + ((char *)proc0paddr + UPAGES*PAGE_SIZE - sizeof(struct pcb)); atdevbase = ISA_HOLE_START + KERNBASE; @@ -1997,8 +2001,11 @@ init386(first) setidt(13, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); initializecpu(); /* Initialize CPU registers */ - /* make an initial tss so cpu can get interrupt stack on syscall! */ - common_tss.tss_esp0 = (int) proc0.p_addr + UPAGES*PAGE_SIZE - 16; + /* + * make an initial tss so cpu can get interrupt stack on syscall! + * The 16 bytes is to save room for a VM86 context. + */ + common_tss.tss_esp0 = (int) thread0.td_pcb - 16; common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ; gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); private_tss = 0; @@ -2054,12 +2061,12 @@ init386(first) _udatasel = LSEL(LUDATA_SEL, SEL_UPL); /* setup proc 0's pcb */ - proc0.p_addr->u_pcb.pcb_flags = 0; - proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD; + thread0.td_pcb->pcb_flags = 0; + thread0.td_pcb->pcb_cr3 = (int)IdlePTD; /* should already be setup */ #ifdef SMP - proc0.p_addr->u_pcb.pcb_mpnest = 1; + thread0.td_pcb->pcb_mpnest = 1; #endif - proc0.p_addr->u_pcb.pcb_ext = 0; + thread0.td_pcb->pcb_ext = 0; proc0.p_md.md_regs = &proc0_tf; } @@ -2163,7 +2170,12 @@ int ptrace_write_u(p, off, data) *(int*)((char *)p->p_addr + off) = data; return (0); } - min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_save); + + /* + * 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); @@ -2195,7 +2207,7 @@ fill_regs(p, regs) regs->r_eflags = tp->tf_eflags; regs->r_esp = tp->tf_esp; regs->r_ss = tp->tf_ss; - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; regs->r_gs = pcb->pcb_gs; return (0); } @@ -2227,7 +2239,7 @@ set_regs(p, regs) tp->tf_eflags = regs->r_eflags; tp->tf_esp = regs->r_esp; tp->tf_ss = regs->r_ss; - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; pcb->pcb_gs = regs->r_gs; return (0); } @@ -2293,12 +2305,12 @@ fill_fpregs(p, fpregs) { #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { - fill_fpregs_xmm(&p->p_addr->u_pcb.pcb_save.sv_xmm, + fill_fpregs_xmm(&p->p_thread->td_pcb->pcb_save.sv_xmm, (struct save87 *)fpregs); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(&p->p_addr->u_pcb.pcb_save.sv_87, fpregs, sizeof *fpregs); + bcopy(&p->p_thread->td_pcb->pcb_save.sv_87, fpregs, sizeof *fpregs); return (0); } @@ -2310,11 +2322,11 @@ set_fpregs(p, fpregs) #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { set_fpregs_xmm((struct save87 *)fpregs, - &p->p_addr->u_pcb.pcb_save.sv_xmm); + &p->p_thread->td_pcb->pcb_save.sv_xmm); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(fpregs, &p->p_addr->u_pcb.pcb_save.sv_87, sizeof *fpregs); + bcopy(fpregs, &p->p_thread->td_pcb->pcb_save.sv_87, sizeof *fpregs); return (0); } @@ -2336,7 +2348,7 @@ fill_dbregs(p, dbregs) dbregs->dr7 = rdr7(); } else { - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; dbregs->dr0 = pcb->pcb_dr0; dbregs->dr1 = pcb->pcb_dr1; dbregs->dr2 = pcb->pcb_dr2; @@ -2380,7 +2392,7 @@ set_dbregs(p, dbregs) if ((dbregs->dr7 & mask1) == mask2) return (EINVAL); - pcb = &p->p_addr->u_pcb; + pcb = p->p_thread->td_pcb; /* * Don't let a process set a breakpoint that is not within the diff --git a/sys/platform/pc32/i386/math_emu.h b/sys/platform/pc32/i386/math_emu.h index 6d730f881c..615d7acd06 100644 --- a/sys/platform/pc32/i386/math_emu.h +++ b/sys/platform/pc32/i386/math_emu.h @@ -4,7 +4,7 @@ * (C) 1991 Linus Torvalds * * $FreeBSD: src/sys/i386/i386/math_emu.h,v 1.7.2.1 2001/08/15 01:23:50 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/math_emu.h,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/math_emu.h,v 1.4 2003/06/18 18:29:55 dillon Exp $ */ #ifndef _LINUX_MATH_EMU_H #define _LINUX_MATH_EMU_H @@ -70,7 +70,7 @@ struct i387_struct { int32_t st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ }; -#define I387 (*(struct i387_struct *)&(((struct pcb *)curproc->p_addr)->pcb_save.sv_87)) /* YYY note: pcb will be moved out of UAREA! */ +#define I387 (*(struct i387_struct *)&((curthread->td_pcb)->pcb_save.sv_87)) #define SWD (*(struct swd *) &I387.swd) #define ROUNDING ((I387.cwd >> 10) & 3) #define PRECISION ((I387.cwd >> 8) & 3) diff --git a/sys/platform/pc32/i386/math_emulate.c b/sys/platform/pc32/i386/math_emulate.c index 327efe173d..19503db1d4 100644 --- a/sys/platform/pc32/i386/math_emulate.c +++ b/sys/platform/pc32/i386/math_emulate.c @@ -7,7 +7,7 @@ * * from: 386BSD 0.1 * $FreeBSD: src/sys/i386/i386/math_emulate.c,v 1.35 1999/08/28 00:43:47 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/math_emulate.c,v 1.3 2003/06/18 06:33:24 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/math_emulate.c,v 1.4 2003/06/18 18:29:55 dillon Exp $ */ /* @@ -100,9 +100,8 @@ math_emulate(struct trapframe * info) u_int32_t oldeip; /* ever used fp? */ - /* YYY NOTE: pcb will be moved out of uarea! */ - if ((((struct pcb *)curproc->p_addr)->pcb_flags & FP_SOFTFP) == 0) { - ((struct pcb *)curproc->p_addr)->pcb_flags |= FP_SOFTFP; + if ((curthread->td_pcb->pcb_flags & FP_SOFTFP) == 0) { + curthread->td_pcb->pcb_flags |= FP_SOFTFP; I387.cwd = 0x037f; I387.swd = 0x0000; I387.twd = 0x0000; diff --git a/sys/platform/pc32/i386/pmap.c b/sys/platform/pc32/i386/pmap.c index a041c79236..7188052061 100644 --- a/sys/platform/pc32/i386/pmap.c +++ b/sys/platform/pc32/i386/pmap.c @@ -40,7 +40,7 @@ * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/i386/pmap.c,v 1.250.2.18 2002/03/06 22:48:53 silby Exp $ - * $DragonFly: src/sys/platform/pc32/i386/pmap.c,v 1.4 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/pmap.c,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ /* @@ -850,6 +850,8 @@ pmap_new_thread(struct proc *p) if (p) { p->p_thread = td; td->td_proc = p; + td->td_pcb = (struct pcb *) + ((char *)p->p_addr + UPAGES * PAGE_SIZE) - 1; } return(td); } @@ -3389,7 +3391,8 @@ pmap_activate(struct proc *p) #if defined(SWTCH_OPTIM_STATS) tlb_flush_count++; #endif - load_cr3(p->p_addr->u_pcb.pcb_cr3 = vtophys(pmap->pm_pdir)); + p->p_thread->td_pcb->pcb_cr3 = vtophys(pmap->pm_pdir); + load_cr3(p->p_thread->td_pcb->pcb_cr3); } vm_offset_t diff --git a/sys/platform/pc32/i386/support.s b/sys/platform/pc32/i386/support.s index 33cfb3222c..22eb2713d4 100644 --- a/sys/platform/pc32/i386/support.s +++ b/sys/platform/pc32/i386/support.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/support.s,v 1.67.2.5 2001/08/15 01:23:50 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/support.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/support.s,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ #include "npx.h" @@ -671,7 +671,8 @@ ENTRY(copyout) jmp *_copyout_vector ENTRY(generic_copyout) - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $copyout_fault,PCB_ONFAULT(%eax) pushl %esi pushl %edi @@ -782,7 +783,8 @@ done_copyout: popl %edi popl %esi xorl %eax,%eax - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl %eax,PCB_ONFAULT(%edx) ret @@ -791,7 +793,8 @@ copyout_fault: popl %ebx popl %edi popl %esi - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl $0,PCB_ONFAULT(%edx) movl $EFAULT,%eax ret @@ -801,7 +804,8 @@ ENTRY(i586_copyout) /* * Duplicated from generic_copyout. Could be done a bit better. */ - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $copyout_fault,PCB_ONFAULT(%eax) pushl %esi pushl %edi @@ -858,7 +862,8 @@ ENTRY(copyin) jmp *_copyin_vector ENTRY(generic_copyin) - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $copyin_fault,PCB_ONFAULT(%eax) pushl %esi pushl %edi @@ -896,7 +901,8 @@ done_copyin: popl %edi popl %esi xorl %eax,%eax - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl %eax,PCB_ONFAULT(%edx) ret @@ -904,7 +910,8 @@ done_copyin: copyin_fault: popl %edi popl %esi - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl $0,PCB_ONFAULT(%edx) movl $EFAULT,%eax ret @@ -914,7 +921,8 @@ ENTRY(i586_copyin) /* * Duplicated from generic_copyin. Could be done a bit better. */ - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $copyin_fault,PCB_ONFAULT(%eax) pushl %esi pushl %edi @@ -971,7 +979,8 @@ ENTRY(fastmove) cmpl $0,_npxthread je 6f /* fnsave(&curpcb->pcb_savefpu); */ - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax fnsave PCB_SAVEFPU(%eax) /* npxthread = NULL; */ movl $0,_npxthread @@ -991,7 +1000,8 @@ ENTRY(fastmove) movl %esi,-8(%ebp) movl %edi,-4(%ebp) movl %esp,%edi - movl _curpcb,%esi + movl _curthread,%esi + movl TD_PCB(%esi),%esi addl $PCB_SAVEFPU,%esi cld movl $PCB_SAVE87_SIZE>>2,%ecx @@ -1005,7 +1015,8 @@ ENTRY(fastmove) /* npxthread = curthread; */ movl _curthread,%eax movl %eax,_npxthread - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $fastmove_fault,PCB_ONFAULT(%eax) 4: movl %ecx,-12(%ebp) @@ -1067,7 +1078,8 @@ fastmove_loop: movl %ecx,-12(%ebp) movl %esi,-8(%ebp) movl %edi,-4(%ebp) - movl _curpcb,%edi + movl _curthread,%edi + movl TD_PCB(%edi),%edi addl $PCB_SAVEFPU,%edi movl %esp,%esi cld @@ -1087,7 +1099,8 @@ fastmove_loop: ALIGN_TEXT fastmove_tail: - movl _curpcb,%eax + movl _curthread,%eax + movl TD_PCB(%eax),%eax movl $fastmove_tail_fault,PCB_ONFAULT(%eax) movb %cl,%al @@ -1106,7 +1119,8 @@ fastmove_tail: ALIGN_TEXT fastmove_fault: - movl _curpcb,%edi + movl _curthread,%edi + movl TD_PCB(%edi),%edi addl $PCB_SAVEFPU,%edi movl %esp,%esi cld @@ -1126,7 +1140,8 @@ fastmove_tail_fault: popl %ebx popl %edi popl %esi - movl _curpcb,%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl $0,PCB_ONFAULT(%edx) movl $EFAULT,%eax ret @@ -1138,7 +1153,8 @@ fastmove_tail_fault: * Fetch a byte (sword, word) from user memory */ ENTRY(fuword) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx /* from */ @@ -1164,7 +1180,8 @@ ENTRY(fuswintr) * fusword - MP SAFE */ ENTRY(fusword) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1179,7 +1196,8 @@ ENTRY(fusword) * fubyte - MP SAFE */ ENTRY(fubyte) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1192,7 +1210,8 @@ ENTRY(fubyte) ALIGN_TEXT fusufault: - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx xorl %eax,%eax movl %eax,PCB_ONFAULT(%ecx) decl %eax @@ -1204,7 +1223,8 @@ fusufault: * Write a byte (word, longword) to user memory */ ENTRY(suword) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1248,7 +1268,8 @@ ENTRY(suword) movl 8(%esp),%eax movl %eax,(%edx) xorl %eax,%eax - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl %eax,PCB_ONFAULT(%ecx) ret @@ -1256,7 +1277,8 @@ ENTRY(suword) * susword - MP SAFE (if not I386_CPU) */ ENTRY(susword) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1300,7 +1322,8 @@ ENTRY(susword) movw 8(%esp),%ax movw %ax,(%edx) xorl %eax,%eax - movl _curpcb,%ecx /* restore trashed register */ + movl _curthread,%ecx /* restore trashed register */ + movl TD_PCB(%ecx),%ecx movl %eax,PCB_ONFAULT(%ecx) ret @@ -1309,7 +1332,8 @@ ENTRY(susword) */ ALTENTRY(suibyte) ENTRY(subyte) - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $fusufault,PCB_ONFAULT(%ecx) movl 4(%esp),%edx @@ -1352,7 +1376,8 @@ ENTRY(subyte) movb 8(%esp),%al movb %al,(%edx) xorl %eax,%eax - movl _curpcb,%ecx /* restore trashed register */ + movl _curthread,%ecx /* restore trashed register */ + movl TD_PCB(%ecx),%ecx movl %eax,PCB_ONFAULT(%ecx) ret @@ -1367,7 +1392,8 @@ ENTRY(subyte) ENTRY(copyinstr) pushl %esi pushl %edi - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $cpystrflt,PCB_ONFAULT(%ecx) movl 12(%esp),%esi /* %esi = from */ @@ -1415,7 +1441,8 @@ cpystrflt: cpystrflt_x: /* set *lencopied and return %eax */ - movl _curpcb,%ecx + movl _curthread,%ecx + movl TD_PCB(%ecx),%ecx movl $0,PCB_ONFAULT(%ecx) movl 20(%esp),%ecx subl %edx,%ecx diff --git a/sys/platform/pc32/i386/swtch.s b/sys/platform/pc32/i386/swtch.s index b5ed63ee31..f25cb9f2ca 100644 --- a/sys/platform/pc32/i386/swtch.s +++ b/sys/platform/pc32/i386/swtch.s @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/swtch.s,v 1.89.2.10 2003/01/23 03:36:24 ps Exp $ - * $DragonFly: src/sys/platform/pc32/i386/swtch.s,v 1.5 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/swtch.s,v 1.6 2003/06/18 18:29:55 dillon Exp $ */ #include "npx.h" @@ -300,7 +300,8 @@ ENTRY(cpu_switch) #endif /* SMP */ btrl %eax, VM_PMAP+PM_ACTIVE(%edx) - movl P_ADDR(%ecx),%edx + movl _curthread,%edx + movl TD_PCB(%edx),%edx movl (%esp),%eax /* Hardware registers */ movl %eax,PCB_EIP(%edx) @@ -395,8 +396,8 @@ sw1a: cmpb $SRUN,P_STAT(%ecx) jne badsw2 #endif - - movl P_ADDR(%ecx),%edx + movl P_THREAD(%ecx),%edx + movl TD_PCB(%edx),%edx #if defined(SWTCH_OPTIM_STATS) incl _swtch_optim_stats @@ -425,9 +426,13 @@ sw1a: jmp 2f 1: - /* update common_tss.tss_esp0 pointer */ - movl %edx, %ebx /* pcb */ - addl $(UPAGES * PAGE_SIZE - 16), %ebx + /* + * update common_tss.tss_esp0 pointer. This is the supervisor + * stack pointer on entry from user mode. Since the pcb is + * at the top of the supervisor stack esp0 starts just below it. + * We leave enough space for vm86 (16 bytes). + */ + leal -16(%edx),%ebx movl %ebx, _common_tss + TSS_ESP0 btrl %esi, _private_tss @@ -476,7 +481,6 @@ sw1a: movl _cpuid,%eax movb %al, P_ONCPU(%ecx) #endif /* SMP */ - movl %edx, _curpcb movl P_THREAD(%ecx),%ecx /* ecx = thread */ movl %ecx, _curthread movl TD_PROC(%ecx),%ecx /* YYY does %ecx need to be restored? */ @@ -599,8 +603,7 @@ ENTRY(savectx) je 1f pushl %ecx - movl TD_PROC(%eax),%eax - movl P_ADDR(%eax),%eax + movl TD_PCB(%eax),%eax leal PCB_SAVEFPU(%eax),%eax pushl %eax pushl %eax diff --git a/sys/platform/pc32/i386/sys_machdep.c b/sys/platform/pc32/i386/sys_machdep.c index dd46e3a0ce..46e8144bd8 100644 --- a/sys/platform/pc32/i386/sys_machdep.c +++ b/sys/platform/pc32/i386/sys_machdep.c @@ -32,7 +32,7 @@ * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.47.2.3 2002/10/07 17:20:00 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/i386/sys_machdep.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/sys_machdep.c,v 1.3 2003/06/18 18:29:55 dillon Exp $ * */ @@ -137,9 +137,9 @@ i386_extend_pcb(struct proc *p) ext = (struct pcb_ext *)kmem_alloc(kernel_map, ctob(IOPAGES+1)); if (ext == 0) return (ENOMEM); - p->p_addr->u_pcb.pcb_ext = ext; + p->p_thread->td_pcb->pcb_ext = ext; bzero(ext, sizeof(struct pcb_ext)); - ext->ext_tss.tss_esp0 = (unsigned)p->p_addr + ctob(UPAGES) - 16; + ext->ext_tss.tss_esp0 = (unsigned)((char *)p->p_thread->td_pcb - 16); ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); /* * The last byte of the i/o map must be followed by an 0xff byte. @@ -189,10 +189,10 @@ i386_set_ioperm(p, args) * cause confusion. This probably requires a global 'usage registry'. */ - if (p->p_addr->u_pcb.pcb_ext == 0) + if (p->p_thread->td_pcb->pcb_ext == 0) if ((error = i386_extend_pcb(p)) != 0) return (error); - iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + iomap = (char *)p->p_thread->td_pcb->pcb_ext->ext_iomap; if (ua.start + ua.length > IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); @@ -220,12 +220,12 @@ i386_get_ioperm(p, args) if (ua.start >= IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); - if (p->p_addr->u_pcb.pcb_ext == 0) { + if (p->p_thread->td_pcb->pcb_ext == 0) { ua.length = 0; goto done; } - iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + iomap = (char *)p->p_thread->td_pcb->pcb_ext->ext_iomap; i = ua.start; state = (iomap[i >> 3] >> (i & 7)) & 1; @@ -253,7 +253,7 @@ set_user_ldt(struct pcb *pcb) { struct pcb_ldt *pcb_ldt; - if (pcb != curpcb) + if (pcb != curthread->td_pcb) return; pcb_ldt = pcb->pcb_ldt; @@ -309,7 +309,7 @@ user_ldt_free(struct pcb *pcb) if (pcb_ldt == NULL) return; - if (pcb == curpcb) { + if (pcb == curthread->td_pcb) { lldt(_default_ldt); currentldt = _default_ldt; } @@ -328,7 +328,7 @@ i386_get_ldt(p, args) char *args; { int error = 0; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = p->p_thread->td_pcb; struct pcb_ldt *pcb_ldt = pcb->pcb_ldt; int nldt, num; union descriptor *lp; @@ -378,7 +378,7 @@ i386_set_ldt(p, args) { int error = 0, i, n; int largest_ld; - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = p->p_thread->td_pcb; struct pcb_ldt *pcb_ldt = pcb->pcb_ldt; union descriptor *descs; int descs_size, s; diff --git a/sys/platform/pc32/i386/trap.c b/sys/platform/pc32/i386/trap.c index edf30a739c..095edcbfc5 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.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.3 2003/06/18 18:29:55 dillon Exp $ */ /* @@ -510,7 +510,7 @@ kernel_trap: * a signal. */ if (frame.tf_eip == (int)cpu_switch_load_gs) { - curpcb->pcb_gs = 0; + curthread->td_pcb->pcb_gs = 0; psignal(p, SIGBUS); return; } @@ -522,8 +522,8 @@ kernel_trap: doreti_popl_es_fault); MAYBE_DORETI_FAULT(doreti_popl_fs, doreti_popl_fs_fault); - if (curpcb && curpcb->pcb_onfault) { - frame.tf_eip = (int)curpcb->pcb_onfault; + if (curthread->td_pcb->pcb_onfault) { + frame.tf_eip = (int)curthread->td_pcb->pcb_onfault; return; } } @@ -691,8 +691,8 @@ trap_pfault(frame, usermode, eva) if (p == NULL || (!usermode && va < VM_MAXUSER_ADDRESS && - (intr_nesting_level != 0 || curpcb == NULL || - curpcb->pcb_onfault == NULL))) { + (intr_nesting_level != 0 || + curthread->td_pcb->pcb_onfault == NULL))) { trap_fatal(frame, eva); return (-1); } @@ -754,8 +754,8 @@ trap_pfault(frame, usermode, eva) return (0); nogo: if (!usermode) { - if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { - frame->tf_eip = (int)curpcb->pcb_onfault; + if (intr_nesting_level == 0 && curthread->td_pcb->pcb_onfault) { + frame->tf_eip = (int)curthread->td_pcb->pcb_onfault; return (0); } trap_fatal(frame, eva); @@ -861,8 +861,8 @@ trap_pfault(frame, usermode, eva) return (0); nogo: if (!usermode) { - if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { - frame->tf_eip = (int)curpcb->pcb_onfault; + if (intr_nesting_level == 0 && curthread->td_pcb->pcb_onfault) { + frame->tf_eip = (int)curthread->td_pcb->pcb_onfault; return (0); } trap_fatal(frame, eva); diff --git a/sys/platform/pc32/i386/vm86.c b/sys/platform/pc32/i386/vm86.c index 94ff5c0584..245a02b7b4 100644 --- a/sys/platform/pc32/i386/vm86.c +++ b/sys/platform/pc32/i386/vm86.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/vm86.c,v 1.31.2.2 2001/10/05 06:18:55 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/vm86.c,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm86.c,v 1.3 2003/06/18 18:29:55 dillon Exp $ */ #include @@ -141,9 +141,9 @@ vm86_emulate(vmf) * the extension is not present. (This check should not be needed, * as we can't enter vm86 mode until we set up an extension area) */ - if (curpcb->pcb_ext == 0) + if (curthread->td_pcb->pcb_ext == 0) return (SIGBUS); - vm86 = &curpcb->pcb_ext->ext_vm86; + vm86 = &curthread->td_pcb->pcb_ext->ext_vm86; if (vmf->vmf_eflags & PSL_T) retcode = SIGTRAP; @@ -503,7 +503,7 @@ static void vm86_initflags(struct vm86frame *vmf) { int eflags = vmf->vmf_eflags; - struct vm86_kernel *vm86 = &curpcb->pcb_ext->ext_vm86; + struct vm86_kernel *vm86 = &curthread->td_pcb->pcb_ext->ext_vm86; if (vm86->vm86_has_vme) { eflags = (vmf->vmf_eflags & ~VME_USERCHANGE) | @@ -656,10 +656,10 @@ vm86_sysarch(p, args) if ((error = copyin(args, &ua, sizeof(struct i386_vm86_args))) != 0) return (error); - if (p->p_addr->u_pcb.pcb_ext == 0) + if (p->p_thread->td_pcb->pcb_ext == 0) if ((error = i386_extend_pcb(p)) != 0) return (error); - vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86; + vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; switch (ua.sub_op) { case VM86_INIT: { diff --git a/sys/platform/pc32/i386/vm86bios.s b/sys/platform/pc32/i386/vm86bios.s index 33f77431de..4483bfddbc 100644 --- a/sys/platform/pc32/i386/vm86bios.s +++ b/sys/platform/pc32/i386/vm86bios.s @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/vm86bios.s,v 1.15.2.1 2000/05/16 06:58:07 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/i386/vm86bios.s,v 1.4 2003/06/18 07:04:25 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm86bios.s,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ #include /* miscellaneous asm macros */ @@ -76,8 +76,7 @@ ENTRY(vm86_bioscall) testl %ecx,%ecx je 1f /* no curthread/npxthread */ pushl %edx - movl TD_PROC(%ecx),%ecx - movl P_ADDR(%ecx),%ecx + movl TD_PCB(%ecx),%ecx addl $PCB_SAVEFPU,%ecx pushl %ecx call _npxsave @@ -95,10 +94,14 @@ ENTRY(vm86_bioscall) rep movsl /* copy frame to new stack */ - /* YYY when pcb is in thread vm86_bios will be in its own thread */ - movl _curpcb,%eax + /* + * YYY I really dislike replacing td_pcb, even temporarily. Find + * another way. + */ + movl _curthread,%ebx + movl TD_PCB(%ebx),%eax /* save curpcb */ pushl %eax /* save curpcb */ - movl %edx,_curpcb /* set curpcb to vm86pcb */ + movl %edx,TD_PCB(%ebx) /* set curpcb to vm86pcb */ movl _tss_gdt,%ebx /* entry in GDT */ movl 0(%ebx),%eax @@ -179,8 +182,9 @@ ENTRY(vm86_biosret) movl %eax,4(%ebx) /* restore second word */ movl $GPROC0_SEL*8,%esi /* GSEL(entry, SEL_KPL) */ ltr %si - - popl _curpcb /* restore curpcb/curproc */ + + movl _curthread,%eax + popl TD_PCB(%eax) /* restore curpcb */ movl SCR_ARGFRAME(%edx),%edx /* original stack frame */ movl TF_TRAPNO(%edx),%eax /* return (trapno) */ diff --git a/sys/platform/pc32/i386/vm_machdep.c b/sys/platform/pc32/i386/vm_machdep.c index f94d0a726e..fe738e5ca8 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.4 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/vm_machdep.c,v 1.5 2003/06/18 18:29:55 dillon Exp $ */ #include "npx.h" @@ -127,7 +127,7 @@ cpu_fork(p1, p2, flags) #ifdef USER_LDT if ((flags & RFMEM) == 0) { /* unshare user LDT */ - struct pcb *pcb1 = &p1->p_addr->u_pcb; + struct pcb *pcb1 = p1->p_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); @@ -143,20 +143,22 @@ cpu_fork(p1, p2, flags) #if NNPX > 0 /* Ensure that p1's pcb is up to date. */ if (npxthread == p1->p_thread) - npxsave(&p1->p_addr->u_pcb.pcb_save); + npxsave(&p1->p_thread->td_pcb->pcb_save); #endif /* Copy p1's pcb. */ - p2->p_addr->u_pcb = p1->p_addr->u_pcb; - pcb2 = &p2->p_addr->u_pcb; + *p2->p_thread->td_pcb = *p1->p_thread->td_pcb; + pcb2 = p2->p_thread->td_pcb; /* * Create a new fresh stack for the new process. * Copy the trap frame for the return to user mode as if from a - * syscall. This copies the user mode register values. + * syscall. This copies the user mode register values. The + * 16 byte offset saves space for vm86, and must match + * common_tss.esp0 (kernel stack pointer on entry from user mode) */ p2->p_md.md_regs = (struct trapframe *) - ((int)p2->p_addr + UPAGES * PAGE_SIZE - 16) - 1; + ((char *)p2->p_thread->td_pcb - 16) - 1; bcopy(p1->p_md.md_regs, p2->p_md.md_regs, sizeof(*p2->p_md.md_regs)); /* @@ -224,15 +226,15 @@ cpu_set_fork_handler(p, func, arg) * Note that the trap frame follows the args, so the function * is really called like this: func(arg, frame); */ - p->p_addr->u_pcb.pcb_esi = (int) func; /* function */ - p->p_addr->u_pcb.pcb_ebx = (int) arg; /* first arg */ + p->p_thread->td_pcb->pcb_esi = (int) func; /* function */ + p->p_thread->td_pcb->pcb_ebx = (int) arg; /* first arg */ } void cpu_exit(p) register struct proc *p; { - struct pcb *pcb = &p->p_addr->u_pcb; + struct pcb *pcb = p->p_thread->td_pcb; #if NNPX > 0 npxexit(p); @@ -291,6 +293,7 @@ cpu_coredump(p, vp, cred) bcopy(p->p_md.md_regs, tempuser + ((caddr_t) p->p_md.md_regs - (caddr_t) p->p_addr), sizeof(struct trapframe)); + bcopy(p->p_thread->td_pcb, tempuser + ((char *)p->p_thread->td_pcb - (char *)p->p_addr), sizeof(struct pcb)); error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, ctob(UPAGES), (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, (int *)NULL, p); diff --git a/sys/platform/pc32/include/asnames.h b/sys/platform/pc32/include/asnames.h index c53bb62070..1517901ce5 100644 --- a/sys/platform/pc32/include/asnames.h +++ b/sys/platform/pc32/include/asnames.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/asnames.h,v 1.44.2.8 2003/01/22 20:14:53 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/include/Attic/asnames.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/Attic/asnames.h,v 1.5 2003/06/18 18:29:58 dillon Exp $ */ #ifndef _MACHINE_ASNAMES_H_ @@ -342,7 +342,6 @@ #define _common_tssd FS(common_tssd) #define _cpuid FS(cpuid) #define _cpu_lockid FS(cpu_lockid) -#define _curpcb FS(curpcb) #define _curthread FS(curthread) #define _idlethread FS(idlethread) #define _astpending FS(astpending) diff --git a/sys/platform/pc32/include/globaldata.h b/sys/platform/pc32/include/globaldata.h index 422759a871..7300d8de63 100644 --- a/sys/platform/pc32/include/globaldata.h +++ b/sys/platform/pc32/include/globaldata.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globaldata.h,v 1.11.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/include/globaldata.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/globaldata.h,v 1.5 2003/06/18 18:29:58 dillon Exp $ */ /* @@ -43,7 +43,6 @@ struct globaldata { struct privatespace *gd_prvspace; /* self-reference */ struct thread *gd_curthread; struct thread *gd_npxthread; - struct pcb *gd_curpcb; struct timeval gd_switchtime; struct i386tss gd_common_tss; int gd_switchticks; diff --git a/sys/platform/pc32/include/globals.h b/sys/platform/pc32/include/globals.h index ea0beb4792..f7db4664c9 100644 --- a/sys/platform/pc32/include/globals.h +++ b/sys/platform/pc32/include/globals.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/globals.h,v 1.5.2.1 2000/05/16 06:58:10 dillon Exp $ - * $DragonFly: src/sys/platform/pc32/include/Attic/globals.h,v 1.4 2003/06/18 07:04:28 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/Attic/globals.h,v 1.5 2003/06/18 18:29:58 dillon Exp $ */ #ifndef _MACHINE_GLOBALS_H_ @@ -84,7 +84,6 @@ */ #define curthread GLOBAL_RVALUE_NV(curthread, struct thread *) #define idlethread GLOBAL_RVALUE_NV(idlethread, struct thread) -#define curpcb GLOBAL_RVALUE_NV(curpcb, struct pcb *) #define npxthread GLOBAL_LVALUE(npxthread, struct thread *) #define common_tss GLOBAL_LVALUE(common_tss, struct i386tss) #define switchtime GLOBAL_LVALUE(switchtime, struct timeval) @@ -125,16 +124,14 @@ extern struct timeval switchtime; /* Uptime at last context switch */ #endif /* - * note: curthread is never NULL, but curproc can be. curpcb is a separate - * entity in other BSDs. In Turtle it is integrated into the thread - * structure. + * note: curthread is never NULL, but curproc can be. Also note that + * in Turtle, the current pcb is stored in the thread structure. */ #define curproc (curthread->td_proc) GLOBAL_FUNC(curthread) GLOBAL_FUNC(idlethread) GLOBAL_FUNC(astpending) -GLOBAL_FUNC(curpcb) GLOBAL_FUNC(npxthread) GLOBAL_FUNC(common_tss) GLOBAL_FUNC(switchtime) diff --git a/sys/platform/pc32/include/pcb.h b/sys/platform/pc32/include/pcb.h index 073e6212f2..732881a8cf 100644 --- a/sys/platform/pc32/include/pcb.h +++ b/sys/platform/pc32/include/pcb.h @@ -35,7 +35,7 @@ * * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/include/pcb.h,v 1.32.2.1 2001/08/15 01:23:52 peter Exp $ - * $DragonFly: src/sys/platform/pc32/include/pcb.h,v 1.2 2003/06/17 04:28:35 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/include/pcb.h,v 1.3 2003/06/18 18:29:58 dillon Exp $ */ #ifndef _I386_PCB_H_ @@ -92,10 +92,6 @@ struct md_coredump { #ifdef _KERNEL -#ifndef curpcb -extern struct pcb *curpcb; /* our current running pcb */ -#endif - void savectx __P((struct pcb *)); #endif diff --git a/sys/platform/pc32/isa/npx.c b/sys/platform/pc32/isa/npx.c index 5b2a14dcdf..47431e6778 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.4 2003/06/18 16:30:11 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/isa/npx.c,v 1.5 2003/06/18 18:30:01 dillon Exp $ */ #include "opt_cpu.h" @@ -513,8 +513,7 @@ npxinit(control) fninit(); #endif fldcw(&control); - if (curpcb != NULL) - fpusave(&curpcb->pcb_save); + fpusave(&curthread->td_pcb->pcb_save); start_emulating(); } @@ -527,13 +526,14 @@ npxexit(p) { if (p->p_thread == npxthread) - npxsave(&curpcb->pcb_save); + npxsave(&curthread->td_pcb->pcb_save); #ifdef NPX_DEBUG if (npx_exists) { u_int masked_exceptions; - masked_exceptions = curpcb->pcb_save.sv_87.sv_env.en_cw - & curpcb->pcb_save.sv_87.sv_env.en_sw & 0x7f; + masked_exceptions = + curthread->td_pcb->pcb_save.sv_87.sv_env.en_cw + & curthread->td_pcb->pcb_save.sv_87.sv_env.en_sw & 0x7f; /* * Log exceptions that would have trapped with the old * control word (overflow, divide by 0, and invalid operand). @@ -754,7 +754,7 @@ npx_intr(dummy) panic("npxintr from non-current process"); } - exstat = GET_FPU_EXSW_PTR(curpcb); + exstat = GET_FPU_EXSW_PTR(curthread->td_pcb); outb(0xf0, 0); fnstsw(exstat); fnstcw(&control); @@ -827,7 +827,7 @@ npxdna() * Record new context early in case frstor causes an IRQ13. */ npxthread = curthread; - exstat = GET_FPU_EXSW_PTR(curpcb); + exstat = GET_FPU_EXSW_PTR(curthread->td_pcb); *exstat = 0; /* * The following frstor may cause an IRQ13 when the state being @@ -841,7 +841,7 @@ npxdna() * fnsave are broken, so our treatment breaks fnclex if it is the * first FPU instruction after a context switch. */ - fpurstor(&curpcb->pcb_save); + fpurstor(&curthread->td_pcb->pcb_save); return (1); } diff --git a/sys/platform/vkernel/i386/genassym.c b/sys/platform/vkernel/i386/genassym.c index 5b03063491..3205111d52 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.5 2003/06/18 16:30:09 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.6 2003/06/18 18:29:55 dillon Exp $ */ #include "opt_user_ldt.h" @@ -83,6 +83,7 @@ ASSYM(P_WCHAN, offsetof(struct proc, p_wchan)); ASSYM(P_THREAD, offsetof(struct proc, p_thread)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); +ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); #ifdef SMP ASSYM(P_ONCPU, offsetof(struct proc, p_oncpu)); @@ -141,9 +142,7 @@ ASSYM(PCB_SAVEFPU_SIZE, sizeof(union savefpu)); ASSYM(PCB_SAVE87_SIZE, sizeof(struct save87)); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); -#ifdef SMP ASSYM(PCB_SIZE, sizeof(struct pcb)); -#endif ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno)); ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); @@ -176,7 +175,6 @@ ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend)); ASSYM(GD_SIZEOF, sizeof(struct globaldata)); ASSYM(GD_CURTHREAD, offsetof(struct globaldata, gd_curthread)); ASSYM(GD_NPXTHREAD, offsetof(struct globaldata, gd_npxthread)); -ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb)); ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss)); ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime)); ASSYM(GD_SWITCHTICKS, offsetof(struct globaldata, gd_switchticks)); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index df744e5907..ae9b849553 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.4 2003/06/18 16:30:17 dillon Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.5 2003/06/18 18:30:11 dillon Exp $ */ #ifndef _SYS_PROC_H_ @@ -382,6 +382,7 @@ extern u_long pgrphash; #endif extern struct proc proc0; /* Process slot for swapper. */ +extern struct thread thread0; /* Thread slot for swapper. */ extern int hogticks; /* Limit on kernel cpu hogs. */ extern int nprocs, maxproc; /* Current and max number of procs. */ extern int maxprocperuid; /* Max procs per uid. */ diff --git a/sys/sys/user.h b/sys/sys/user.h index 8a98b1bdf7..e1bb7270e4 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -32,7 +32,7 @@ * * @(#)user.h 8.2 (Berkeley) 9/23/93 * $FreeBSD: src/sys/sys/user.h,v 1.24.2.1 2001/10/11 08:20:18 peter Exp $ - * $DragonFly: src/sys/sys/user.h,v 1.2 2003/06/17 04:28:59 dillon Exp $ + * $DragonFly: src/sys/sys/user.h,v 1.3 2003/06/18 18:30:11 dillon Exp $ */ #ifndef _SYS_USER_H_ @@ -100,7 +100,6 @@ void fill_eproc __P((struct proc *, struct eproc *)); * when the process isn't running (esp. when swapped out). */ struct user { - struct pcb u_pcb; struct sigacts u_sigacts; /* p_sigacts points here (use it!) */ struct pstats u_stats; /* p_stats points here (use it!) */ /* diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index eafc49730f..61031c4b76 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.2 2003/06/17 04:29:00 dillon Exp $ + * $DragonFly: src/sys/vm/vm_glue.c,v 1.3 2003/06/18 18:30:13 dillon Exp $ */ #include "opt_vm.h" @@ -239,6 +239,7 @@ vm_fork(p1, p2, flags) } pmap_new_proc(p2); + pmap_new_thread(p2); up = p2->p_addr; -- 2.41.0