From 7db093553a2a3beb79052f58945fed9a39fb4fe4 Mon Sep 17 00:00:00 2001 From: skrll Date: Thu, 12 Jul 2007 14:15:36 +0000 Subject: [PATCH] Like I said - don't futz with the trapframe in pmap_activate. Instead update the trapframe space and protection register in cpu_lwp_fork and setregs. --- sys/arch/hp700/hp700/machdep.c | 17 +++++++++++++++-- sys/arch/hppa/hppa/pmap.c | 19 ++----------------- sys/arch/hppa/hppa/vm_machdep.c | 9 ++++----- sys/arch/hppa/include/pmap.h | 3 +-- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/sys/arch/hp700/hp700/machdep.c b/sys/arch/hp700/hp700/machdep.c index 6b708a169faa..50735c6196b3 100644 --- a/sys/arch/hp700/hp700/machdep.c +++ b/sys/arch/hp700/hp700/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.37 2007/03/07 11:29:46 skrll Exp $ */ +/* $NetBSD: machdep.c,v 1.38 2007/07/12 14:15:36 skrll Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.37 2007/03/07 11:29:46 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38 2007/07/12 14:15:36 skrll Exp $"); #include "opt_cputype.h" #include "opt_ddb.h" @@ -1691,6 +1691,8 @@ setregs(struct lwp *l, struct exec_package *pack, u_long stack) { struct proc *p = l->l_proc; struct trapframe *tf = l->l_md.md_regs; + pmap_t pmap = p->p_vmspace->vm_map.pmap; + pa_space_t space = pmap->pmap_space; struct pcb *pcb = &l->l_addr->u_pcb; tf->tf_flags = TFF_SYS|TFF_LAST; @@ -1700,6 +1702,17 @@ setregs(struct lwp *l, struct exec_package *pack, u_long stack) tf->tf_arg0 = (u_long)p->p_psstr; tf->tf_arg1 = tf->tf_arg2 = 0; /* XXX dynload stuff */ + tf->tf_sr7 = HPPA_SID_KERNEL; + + /* Load all of the user's space registers. */ + tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr2 = tf->tf_sr3 = + tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 = space; + + tf->tf_iisq_head = tf->tf_iisq_tail = space; + + /* Load the protection regsiters. */ + tf->tf_pidr1 = tf->tf_pidr2 = pmap->pmap_pid; + /* reset any of the pending FPU exceptions */ hppa_fpu_flush(l); pcb->pcb_fpregs[0] = ((uint64_t)HPPA_FPU_INIT) << 32; diff --git a/sys/arch/hppa/hppa/pmap.c b/sys/arch/hppa/hppa/pmap.c index ba43ebd3a1f5..08f67bcd588a 100644 --- a/sys/arch/hppa/hppa/pmap.c +++ b/sys/arch/hppa/hppa/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.36 2007/05/18 09:10:50 skrll Exp $ */ +/* $NetBSD: pmap.c,v 1.37 2007/07/12 14:15:37 skrll Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -171,7 +171,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.36 2007/05/18 09:10:50 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.37 2007/07/12 14:15:37 skrll Exp $"); #include #include @@ -1242,7 +1242,6 @@ pmap_pinit(pmap_t pmap) pmap->pmap_refcnt = 1; pmap->pmap_stats.resident_count = 0; pmap->pmap_stats.wired_count = 0; - pmap->pmap_vmspace = NULL; splx(s); } @@ -1334,20 +1333,6 @@ pmap_activate(struct lwp *l) /* space is cached for the copy{in,out}'s pleasure */ pcb->pcb_space = space; - if (pmap->pmap_vmspace != l->l_proc->p_vmspace) { - struct trapframe *tf = l->l_md.md_regs; - - pmap->pmap_vmspace = l->l_proc->p_vmspace; - - /* Load all of the user's space registers. */ - tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr2 = tf->tf_sr3 = - tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 = space; - tf->tf_iisq_head = tf->tf_iisq_tail = space; - - /* Load the protection registers. */ - tf->tf_pidr1 = tf->tf_pidr2 = pmap->pmap_pid; - } - if (p == curproc) mtctl(pmap->pmap_pid, CR_PIDR2); } diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c index 1c156096ef10..f7f1fc7f39ba 100644 --- a/sys/arch/hppa/hppa/vm_machdep.c +++ b/sys/arch/hppa/hppa/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.26 2007/05/18 09:10:50 skrll Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.27 2007/07/12 14:15:38 skrll Exp $ */ /* $OpenBSD: vm_machdep.c,v 1.25 2001/09/19 20:50:56 mickey Exp $ */ @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.26 2007/05/18 09:10:50 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.27 2007/07/12 14:15:38 skrll Exp $"); #include #include @@ -164,10 +164,9 @@ cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize, tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr3 = tf->tf_sr2 = tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 = space; tf->tf_iisq_head = tf->tf_iisq_tail = space; - tf->tf_pidr1 = tf->tf_pidr2 = pmap->pmap_pid; - /* record the vmspace just in case it changes underneath us. */ - pmap->pmap_vmspace = p->p_vmspace; + /* Load the protection registers */ + tf->tf_pidr1 = tf->tf_pidr2 = pmap->pmap_pid; /* * theoretically these could be inherited from the father, diff --git a/sys/arch/hppa/include/pmap.h b/sys/arch/hppa/include/pmap.h index cbb9307dfa19..baf1847a363b 100644 --- a/sys/arch/hppa/include/pmap.h +++ b/sys/arch/hppa/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.13 2007/05/18 09:10:50 skrll Exp $ */ +/* $NetBSD: pmap.h,v 1.14 2007/07/12 14:15:38 skrll Exp $ */ /* $OpenBSD: pmap.h,v 1.14 2001/05/09 15:31:24 art Exp $ */ @@ -92,7 +92,6 @@ struct pmap { pa_space_t pmap_space; /* space for this pmap */ u_int pmap_pid; /* protection id for pmap */ struct pmap_statistics pmap_stats; /* statistics */ - struct vmspace *pmap_vmspace; /* last vmspace */ } *pmap_t; extern pmap_t kernel_pmap; /* The kernel's map */