Module Name:    src
Committed By:   skrll
Date:           Tue Mar 16 16:20:19 UTC 2010

Modified Files:
        src/sys/arch/hp700/hp700: genassym.cf locore.S machdep.c
        src/sys/arch/hppa/hppa: fpu.c hppa_machdep.c pmap.c process_machdep.c
            trap.S trap.c vm_machdep.c
        src/sys/arch/hppa/include: frame.h pcb.h reg.h

Log Message:
The FP regs are accessed in both physical and virtual modes.  Make sure
they're allocated in directly mapped memory to avoid aliasing problems
and unnecessary cache flushing.

Fix various names and references. If we ever directly map the uarea and
pcb we can change things at that point.

Significantly helps my J210 (PA7200).

Mostly from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/hp700/hp700/genassym.cf
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/hp700/hp700/locore.S
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/hp700/hp700/machdep.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/hppa/hppa/fpu.c \
    src/sys/arch/hppa/hppa/hppa_machdep.c
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/hppa/hppa/pmap.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hppa/hppa/process_machdep.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/hppa/hppa/trap.S
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/hppa/hppa/trap.c
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/hppa/hppa/vm_machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hppa/include/frame.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hppa/include/pcb.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hppa/include/reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hp700/hp700/genassym.cf
diff -u src/sys/arch/hp700/hp700/genassym.cf:1.20 src/sys/arch/hp700/hp700/genassym.cf:1.21
--- src/sys/arch/hp700/hp700/genassym.cf:1.20	Thu Dec 10 05:10:01 2009
+++ src/sys/arch/hp700/hp700/genassym.cf	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.20 2009/12/10 05:10:01 rmind Exp $
+#	$NetBSD: genassym.cf,v 1.21 2010/03/16 16:20:19 skrll Exp $
 
 #	$OpenBSD: genassym.cf,v 1.18 2001/09/20 18:31:14 mickey Exp $
 
@@ -189,7 +189,6 @@
 member	PCB_FPREGS	pcb_fpregs
 member	PCB_ONFAULT	pcb_onfault
 member	PCB_SPACE	pcb_space
-member	PCB_UVA		pcb_uva
 member	PCB_KSP		pcb_ksp
 
 # system calls

Index: src/sys/arch/hp700/hp700/locore.S
diff -u src/sys/arch/hp700/hp700/locore.S:1.43 src/sys/arch/hp700/hp700/locore.S:1.44
--- src/sys/arch/hp700/hp700/locore.S:1.43	Mon Mar  8 07:42:47 2010
+++ src/sys/arch/hp700/hp700/locore.S	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.43 2010/03/08 07:42:47 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.44 2010/03/16 16:20:19 skrll Exp $	*/
 /*	$OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $	*/
 
 /*
@@ -230,12 +230,11 @@
 	 * kernel stack starts a page and a trapframe above uarea address.
 	 */
 	ldo	NBPG+TRAPFRAME_SIZEOF(%t3), %sp
-	mtctl	%t3, CR_UPADDR
+	mtctl	%t3, CR_FPPADDR
 
 	/* initialize the pcb */
 	stw	%r0, PCB_ONFAULT(%t3)
 	stw	%r0, PCB_SPACE(%t3)	/* XXX HPPA_SID_KERNEL == 0 */
-	stw	%t3, PCB_UVA(%t3)
 
 	/*
 	 * Setup various pointers.
@@ -857,7 +856,7 @@
 	mtctl	%t3, %pidr2			/* pmap_activate? */
 #endif
 	ldw	TF_CR30(%t1), %t2		/* pmap_activate? */
-	mtctl	%t2, CR_UPADDR			/* pmap_activate? */
+	mtctl	%t2, CR_FPPADDR			/* pmap_activate? */
 
 	mtctl	%arg1, CR_CURLWP
 
@@ -930,7 +929,7 @@
 	 */
 	ldil	L%fpu_cur_uspace, %t1
 	mfctl	%ccr, %r1
-	mfctl	CR_UPADDR, %t2
+	mfctl	CR_FPPADDR, %t2
 	ldw	R%fpu_cur_uspace(%t1), %t1
 	depi	0, 25, 2, %r1		; disables the FPU
 	comb,<>,n %t1, %t2, 0		; nullify if LWPs different

Index: src/sys/arch/hp700/hp700/machdep.c
diff -u src/sys/arch/hp700/hp700/machdep.c:1.79 src/sys/arch/hp700/hp700/machdep.c:1.80
--- src/sys/arch/hp700/hp700/machdep.c:1.79	Tue Feb 16 16:56:29 2010
+++ src/sys/arch/hp700/hp700/machdep.c	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.79 2010/02/16 16:56:29 skrll Exp $	*/
+/*	$NetBSD: machdep.c,v 1.80 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.79 2010/02/16 16:56:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.80 2010/03/16 16:20:19 skrll Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -107,6 +107,7 @@
 #include <machine/autoconf.h>
 #include <machine/bootinfo.h>
 #include <machine/kcore.h>
+#include <machine/pcb.h>
 
 #ifdef	KGDB
 #include "com.h"
@@ -244,6 +245,9 @@
 struct extent *hp700_io_extent;
 static long hp700_io_extent_store[EXTENT_FIXED_STORAGE_SIZE(64) / sizeof(long)];
 
+struct pool hppa_fppl;
+struct fpreg lwp0_fpregs;
+
 /* Virtual page frame for /dev/mem (see mem.c) */
 vaddr_t vmmap;
 
@@ -397,6 +401,7 @@
 	struct btlb_slot *btlb_slot;
 	int btlb_slot_i;
 	struct btinfo_symtab *bi_sym;
+	struct pcb *pcb0;
 
 #ifdef KGDB
 	boothowto |= RB_KDB;	/* go to kgdb early if compiled in. */
@@ -575,6 +580,13 @@
 	/* We will shortly go virtual. */
 	pagezero_mapped = 0;
 	fcacheall();
+
+	pcb0 = lwp_getpcb(&lwp0);
+	pcb0->pcb_fpregs = &lwp0_fpregs;
+	memset(&lwp0_fpregs, 0, sizeof(struct fpreg));
+
+	pool_init(&hppa_fppl, sizeof(struct fpreg), 16, 0, 0, "fppl", NULL,
+	    IPL_NONE);
 }
 
 void
@@ -1856,11 +1868,10 @@
 
 	/* reset any of the pending FPU exceptions */
 	hppa_fpu_flush(l);
-	pcb->pcb_fpregs[0] = ((uint64_t)HPPA_FPU_INIT) << 32;
-	pcb->pcb_fpregs[1] = 0;
-	pcb->pcb_fpregs[2] = 0;
-	pcb->pcb_fpregs[3] = 0;
-	fdcache(HPPA_SID_KERNEL, (vaddr_t)pcb->pcb_fpregs, 8 * 4);
+	pcb->pcb_fpregs->fpr_regs[0] = ((uint64_t)HPPA_FPU_INIT) << 32;
+	pcb->pcb_fpregs->fpr_regs[1] = 0;
+	pcb->pcb_fpregs->fpr_regs[2] = 0;
+	pcb->pcb_fpregs->fpr_regs[3] = 0;
 
 	/* setup terminal stack frame */
 	stack = (u_long)STACK_ALIGN(stack, 63);

Index: src/sys/arch/hppa/hppa/fpu.c
diff -u src/sys/arch/hppa/hppa/fpu.c:1.19 src/sys/arch/hppa/hppa/fpu.c:1.20
--- src/sys/arch/hppa/hppa/fpu.c:1.19	Sat Nov 21 15:36:33 2009
+++ src/sys/arch/hppa/hppa/fpu.c	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu.c,v 1.19 2009/11/21 15:36:33 rmind Exp $	*/
+/*	$NetBSD: fpu.c,v 1.20 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.19 2009/11/21 15:36:33 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.20 2010/03/16 16:20:19 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -81,7 +81,8 @@
 paddr_t fpu_cur_uspace;
 
 /* In locore.S, this swaps states in and out of the FPU. */
-void hppa_fpu_swap(struct pcb *, struct pcb *);
+void hppa_fpu_swapout(struct pcb *);
+void hppa_fpu_swap(struct fpreg *, struct fpreg *);
 
 #ifdef FPEMUL
 /*
@@ -228,7 +229,7 @@
 		return;
 	}
 
-	hppa_fpu_swap(pcb, NULL);
+	hppa_fpu_swapout(pcb);
 	fpu_cur_uspace = 0;
 }
 
@@ -339,7 +340,6 @@
 	error = (inst & OPCODE_STORE) ?
 		copyout(fpreg, (void *) offset, 1 << log2size) :
 		copyin((const void *) offset, fpreg, 1 << log2size);
-	fdcache(HPPA_SID_KERNEL, (vaddr_t)fpreg, sizeof(pcb->pcb_fpregs));
 	return error;
 }
 
@@ -445,7 +445,6 @@
 		ksi.ksi_addr = (void *)frame->tf_iioq_head;
 		trapsignal(l, &ksi);
 	}
-	fdcache(HPPA_SID_KERNEL, (vaddr_t)fpregs, sizeof(pcb->pcb_fpregs));
 }
 
 #endif /* FPEMUL */
Index: src/sys/arch/hppa/hppa/hppa_machdep.c
diff -u src/sys/arch/hppa/hppa/hppa_machdep.c:1.19 src/sys/arch/hppa/hppa/hppa_machdep.c:1.20
--- src/sys/arch/hppa/hppa/hppa_machdep.c:1.19	Sat Jan 16 13:29:47 2010
+++ src/sys/arch/hppa/hppa/hppa_machdep.c	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: hppa_machdep.c,v 1.19 2010/01/16 13:29:47 skrll Exp $	*/
+/*	$NetBSD: hppa_machdep.c,v 1.20 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.19 2010/01/16 13:29:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.20 2010/03/16 16:20:19 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -208,8 +208,6 @@
 
 	hppa_fpu_flush(l);
 	memcpy(&mcp->__fpregs, pcb->pcb_fpregs, sizeof(mcp->__fpregs));
-	fdcache(HPPA_SID_KERNEL, (vaddr_t)pcb->pcb_fpregs,
-	    sizeof(pcb->pcb_fpregs));
 	*flags |= _UC_FPU;
 }
 
@@ -320,8 +318,6 @@
 
 		hppa_fpu_flush(l);
 		memcpy(pcb->pcb_fpregs, &mcp->__fpregs, sizeof(mcp->__fpregs));
-		fdcache(HPPA_SID_KERNEL, (vaddr_t)pcb->pcb_fpregs,
-		    sizeof(pcb->pcb_fpregs));
 	}
 
 	mutex_enter(p->p_lock);

Index: src/sys/arch/hppa/hppa/pmap.c
diff -u src/sys/arch/hppa/hppa/pmap.c:1.71 src/sys/arch/hppa/hppa/pmap.c:1.72
--- src/sys/arch/hppa/hppa/pmap.c:1.71	Sat Mar 13 16:17:59 2010
+++ src/sys/arch/hppa/hppa/pmap.c	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.71 2010/03/13 16:17:59 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.72 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.71 2010/03/13 16:17:59 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.72 2010/03/16 16:20:19 skrll Exp $");
 
 #include "opt_cputype.h"
 
@@ -1685,8 +1685,6 @@
 	pa_space_t space = pmap->pm_space;
 	struct pcb *pcb = lwp_getpcb(l);
 
-	KASSERT(pcb->pcb_uva == uvm_lwp_getuarea(l));
-
 	/* space is cached for the copy{in,out}'s pleasure */
 	pcb->pcb_space = space;
 	fdcache(HPPA_SID_KERNEL, (vaddr_t)pcb, sizeof(struct pcb));

Index: src/sys/arch/hppa/hppa/process_machdep.c
diff -u src/sys/arch/hppa/hppa/process_machdep.c:1.14 src/sys/arch/hppa/hppa/process_machdep.c:1.15
--- src/sys/arch/hppa/hppa/process_machdep.c:1.14	Sat Nov 21 15:36:33 2009
+++ src/sys/arch/hppa/hppa/process_machdep.c	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.14 2009/11/21 15:36:33 rmind Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.15 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*	$OpenBSD: process_machdep.c,v 1.3 1999/06/18 05:19:52 mickey Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.14 2009/11/21 15:36:33 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.15 2010/03/16 16:20:19 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -113,7 +113,6 @@
 
 	hppa_fpu_flush(l);
 	memcpy(fpregs, pcb->pcb_fpregs, sizeof(*fpregs));
-	fdcache(HPPA_SID_KERNEL, (vaddr_t)&pcb->pcb_fpregs, sizeof(*fpregs));
 	return 0;
 }
 
@@ -178,7 +177,6 @@
 
 	hppa_fpu_flush(l);
 	memcpy(pcb->pcb_fpregs, fpregs, sizeof(*fpregs));
-	fdcache(HPPA_SID_KERNEL, (vaddr_t)&pcb->pcb_fpregs, sizeof(*fpregs));
 	return 0;
 }
 

Index: src/sys/arch/hppa/hppa/trap.S
diff -u src/sys/arch/hppa/hppa/trap.S:1.46 src/sys/arch/hppa/hppa/trap.S:1.47
--- src/sys/arch/hppa/hppa/trap.S:1.46	Thu Mar 11 21:37:52 2010
+++ src/sys/arch/hppa/hppa/trap.S	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.S,v 1.46 2010/03/11 21:37:52 skrll Exp $	*/
+/*	$NetBSD: trap.S,v 1.47 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -510,7 +510,7 @@
 	ldw	TF_CR0(%sr3, %t3), %t1
 	mtctl	%t1, %rctr
 	ldw	TF_CR30(%sr3, %t3), %t1
-	mtctl	%t1, CR_UPADDR
+	mtctl	%t1, CR_FPPADDR
 
 	/*
 	 * Clear the system mask, this puts us back into physical mode.  Reload
@@ -957,7 +957,7 @@
 	/* Call hppa_fpu_swap. */
 	ldil	L%fpu_cur_uspace, %arg0
 	ldw	R%fpu_cur_uspace(%arg0), %arg0
-	mfctl	CR_UPADDR, %arg1
+	mfctl	CR_FPPADDR, %arg1
 	blr	0, %rp
 	b	hppa_fpu_swap
 	nop
@@ -1028,11 +1028,14 @@
 EXIT(TLABEL(emu))
 
 /*
- * void hppa_fpu_swap(paddr_t out, paddr_t in);
- * or
- * void hppa_fpu_swap(struct pcb *out, NULL);
+ * void hppa_fpu_swapout(struct pcb *out);
+ * void hppa_fpu_swap(struct fpreg *out, struct fpreg *in);
  */
-LEAF_ENTRY_NOPROFILE(hppa_fpu_swap)
+LEAF_ENTRY_NOPROFILE(hppa_fpu_swapout)
+	ldw	PCB_FPREGS(%arg0), %arg0
+	copy	%r0, %arg1
+
+ALTENTRY(hppa_fpu_swap)
 
 	/*
 	 * Note that this function must work in physical mode as well as virtual
@@ -1055,7 +1058,6 @@
 	/*
 	 * Swap out the current FPU state.
 	 */
-	ldo	PCB_FPREGS(%arg0), %arg0
 	fstds,ma %fr0 , 8(%arg0)	/* fr0 must be saved first */
 	fstds,ma %fr1 , 8(%arg0)
 	fstds,ma %fr2 , 8(%arg0)
@@ -1121,7 +1123,7 @@
 	/*
 	 * Swap in the new FPU state.
 	 */
-	ldo	PCB_FPREGS+31*8(%arg1), %arg1
+	ldo	31*8(%arg1), %arg1
 	fldds,ma -8(%arg1), %fr31
 	fldds,ma -8(%arg1), %fr30
 	fldds,ma -8(%arg1), %fr29
@@ -1183,7 +1185,7 @@
 	depi	0, 25, 2, %r1
 	b	L$fpu_swap_done
 	mtctl	%r1, %ccr
-EXIT(hppa_fpu_swap)
+EXIT(hppa_fpu_swapout)
 
 	/* Construct the virtual address tag. */
 	/* NB: it is legal for off and t to be the same. */
@@ -1976,10 +1978,10 @@
 	comb,<>	%t1, %t2, L$trap_from_kernel	/* if %t1 != %t2 => kernel */
 	dep	%r0, 31, 6, %sp			/* Assumed stack align step 2 */
 
-	mfctl	CR_UPADDR, %t2
+	mfctl	CR_CURLWP, %t2
 	depi	1, T_USER_POS, 1, %r1
 	depi	1, TFF_LAST_POS, 1, %r1
-	ldw	PCB_UVA(%t2), %sp
+	ldw	L_PCB(%t2), %sp
 #ifdef DIAGNOSTIC
 	b	L$trap_have_stack
 #endif
@@ -2189,7 +2191,7 @@
 	mfctl	%cr28, %t2
 	stw	%t2, TF_CR28(%t3)
 #endif
-	mfctl	CR_UPADDR, %t1
+	mfctl	CR_FPPADDR, %t1
 	stw	%t1, TF_CR30(%t3)
 
 	/*

Index: src/sys/arch/hppa/hppa/trap.c
diff -u src/sys/arch/hppa/hppa/trap.c:1.78 src/sys/arch/hppa/hppa/trap.c:1.79
--- src/sys/arch/hppa/hppa/trap.c:1.78	Thu Mar 11 21:43:15 2010
+++ src/sys/arch/hppa/hppa/trap.c	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.78 2010/03/11 21:43:15 skrll Exp $	*/
+/*	$NetBSD: trap.c,v 1.79 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78 2010/03/11 21:43:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.79 2010/03/16 16:20:19 skrll Exp $");
 
 /* #define INTRDEBUG */
 /* #define TRAPDEBUG */
@@ -423,6 +423,7 @@
 	}						\
 } while (/* CONSTCOND */ 0)
 
+	KASSERT(l != NULL);
 	SANITY((tf->tf_ipsw & kpsw) == kpsw);
 	SANITY((kpsw & PSW_I) == 0 || tf->tf_eiem != 0);
 	if (tf->tf_iisq_head == HPPA_SID_KERNEL) {
@@ -457,17 +458,13 @@
 		maxsp = uv + USPACE + PAGE_SIZE;
 		minsp = uv + PAGE_SIZE;
 
-		SANITY(l != NULL || (tf->tf_sp >= minsp && tf->tf_sp < maxsp));
+		SANITY(tf->tf_sp >= minsp && tf->tf_sp < maxsp);
 	} else {
-		bool ok;
-		paddr_t pa;
-
-		ok = pmap_extract(pmap_kernel(), uvm_lwp_getuarea(l), &pa);
-		KASSERT(ok);
+		struct pcb *pcb = lwp_getpcb(l);
 
 		SANITY(USERMODE(tf->tf_iioq_head));
 		SANITY(USERMODE(tf->tf_iioq_tail));
-		SANITY(l != NULL && tf->tf_cr30 == pa);
+		SANITY(tf->tf_cr30 == (u_int)pcb->pcb_fpregs);
 	}
 #undef SANITY
 out:
@@ -734,7 +731,7 @@
 		int i;
 
 		hppa_fpu_flush(l);
-		fpp = pcb->pcb_fpregs;
+		fpp = (uint64_t *)pcb->pcb_fpregs;
 
 		/* skip the status register */
 		pex = (uint32_t *)&fpp[0];

Index: src/sys/arch/hppa/hppa/vm_machdep.c
diff -u src/sys/arch/hppa/hppa/vm_machdep.c:1.41 src/sys/arch/hppa/hppa/vm_machdep.c:1.42
--- src/sys/arch/hppa/hppa/vm_machdep.c:1.41	Mon Mar  8 14:52:29 2010
+++ src/sys/arch/hppa/hppa/vm_machdep.c	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.41 2010/03/08 14:52:29 skrll Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.42 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*	$OpenBSD: vm_machdep.c,v 1.64 2008/09/30 18:54:26 miod Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.41 2010/03/08 14:52:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.42 2010/03/16 16:20:19 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -41,6 +41,7 @@
 #include <sys/ptrace.h>
 #include <sys/exec.h>
 #include <sys/core.h>
+#include <sys/pool.h>
 
 #include <machine/cpufunc.h>
 #include <machine/pmap.h>
@@ -48,27 +49,25 @@
 
 #include <uvm/uvm.h>
 
+extern struct pool hppa_fppl;
+
 #include <hppa/hppa/machdep.h>
 
 static inline void
 cpu_activate_pcb(struct lwp *l)
 {
 	struct trapframe *tf = l->l_md.md_regs;
-	bool ok;
 	struct pcb *pcb = lwp_getpcb(l);
-	vaddr_t uarea = (vaddr_t)pcb;
 #ifdef DIAGNOSTIC
-	vaddr_t maxsp = (vaddr_t)uarea + USPACE;
+	vaddr_t uarea = (vaddr_t)pcb;
+	vaddr_t maxsp = (vaddr_t)pcb + USPACE;
 #endif
 	KASSERT(tf == (void *)(uarea + PAGE_SIZE));
+
 	/*
-	 * Stash the physical for the pcb of U for later perusal
+	 * Stash the physical address of FP regs for later perusal
 	 */
-	pcb->pcb_uva = uarea;
-	ok = pmap_extract(pmap_kernel(), uarea, (paddr_t *)&tf->tf_cr30);
-	KASSERT(ok);
-
-	fdcache(HPPA_SID_KERNEL, (vaddr_t)pcb, sizeof(struct pcb));
+	tf->tf_cr30 = (u_int)pcb->pcb_fpregs;
 
 #ifdef DIAGNOSTIC
 	/* Create the kernel stack red zone. */
@@ -101,13 +100,16 @@
 
 	/* Now copy the parent PCB into the child. */
 	memcpy(pcb2, pcb1, sizeof(struct pcb));
-	fdcache(HPPA_SID_KERNEL, (vaddr_t)pcb1, sizeof(pcb1->pcb_fpregs));
+
+	pcb2->pcb_fpregs = pool_get(&hppa_fppl, PR_WAITOK);
+	*pcb2->pcb_fpregs = *pcb1->pcb_fpregs;
 
 	/* reset any of the pending FPU exceptions from parent */
-	pcb2->pcb_fpregs[0] = HPPA_FPU_FORK(pcb2->pcb_fpregs[0]);
-	pcb2->pcb_fpregs[1] = 0;
-	pcb2->pcb_fpregs[2] = 0;
-	pcb2->pcb_fpregs[3] = 0;
+	pcb2->pcb_fpregs->fpr_regs[0] =
+	    HPPA_FPU_FORK(pcb2->pcb_fpregs->fpr_regs[0]);
+	pcb2->pcb_fpregs->fpr_regs[1] = 0;
+	pcb2->pcb_fpregs->fpr_regs[2] = 0;
+	pcb2->pcb_fpregs->fpr_regs[3] = 0;
 
 	uv = uvm_lwp_getuarea(l2);
 	sp = (register_t)uv + PAGE_SIZE;
@@ -136,7 +138,6 @@
 	mfctl(CR_EIEM, tf->tf_eiem);
 	tf->tf_ipsw = PSW_C | PSW_Q | PSW_P | PSW_D | PSW_I /* | PSW_L */ |
 	    (kpsw & PSW_O);
-	pcb2->pcb_fpregs[HPPA_NFPREGS] = 0;
 
 	/*
 	 * Set up return value registers as libc:fork() expects
@@ -216,13 +217,15 @@
 void
 cpu_lwp_free(struct lwp *l, int proc)
 {
-
+	struct pcb *pcb = lwp_getpcb(l);
+	
 	/*
 	 * If this thread was using the FPU, disable the FPU and record
 	 * that it's unused.
 	 */
 
 	hppa_fpu_flush(l);
+	pool_put(&hppa_fppl, pcb->pcb_fpregs);
 }
 
 void

Index: src/sys/arch/hppa/include/frame.h
diff -u src/sys/arch/hppa/include/frame.h:1.9 src/sys/arch/hppa/include/frame.h:1.10
--- src/sys/arch/hppa/include/frame.h:1.9	Tue Nov  3 05:07:26 2009
+++ src/sys/arch/hppa/include/frame.h	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: frame.h,v 1.9 2009/11/03 05:07:26 snj Exp $	*/
+/*	$NetBSD: frame.h,v 1.10 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*	$OpenBSD: frame.h,v 1.11 1999/11/25 18:28:06 mickey Exp $	*/
 
@@ -134,7 +134,7 @@
 	u_int	tf_eirr;	/* cr23 - DDB */
 	u_int	tf_vtop;	/* cr25 - DDB */
 	u_int	tf_cr28;	/*      - DDB */
-	u_int	tf_cr30;	/* uaddr */
+	u_int	tf_cr30;	/* fpregs */
 
 	u_int	tf_pad[4];	/* pad to 256 bytes */
 };

Index: src/sys/arch/hppa/include/pcb.h
diff -u src/sys/arch/hppa/include/pcb.h:1.8 src/sys/arch/hppa/include/pcb.h:1.9
--- src/sys/arch/hppa/include/pcb.h:1.8	Tue Nov  3 05:07:26 2009
+++ src/sys/arch/hppa/include/pcb.h	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcb.h,v 1.8 2009/11/03 05:07:26 snj Exp $	*/
+/*	$NetBSD: pcb.h,v 1.9 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*	$OpenBSD: pcb.h,v 1.6 2000/01/12 07:24:35 mickey Exp $	*/
 
@@ -35,11 +35,9 @@
 #include <machine/reg.h>
 
 struct pcb {
-	uint64_t	pcb_fpregs[HPPA_NFPREGS+1];
-					/* not in the trapframe */
+	struct fpreg	*pcb_fpregs;	/* not in the trapframe */
 	u_int		pcb_onfault;	/* SW copy fault handler */
 	pa_space_t	pcb_space;	/* copy pmap_space, for asm's sake */
-	vaddr_t		pcb_uva;	/* KVA for U-area */
 	u_int		pcb_ksp;	/* kernel sp for ctxsw */
 };
 

Index: src/sys/arch/hppa/include/reg.h
diff -u src/sys/arch/hppa/include/reg.h:1.10 src/sys/arch/hppa/include/reg.h:1.11
--- src/sys/arch/hppa/include/reg.h:1.10	Tue Nov  3 05:07:26 2009
+++ src/sys/arch/hppa/include/reg.h	Tue Mar 16 16:20:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: reg.h,v 1.10 2009/11/03 05:07:26 snj Exp $	*/
+/*	$NetBSD: reg.h,v 1.11 2010/03/16 16:20:19 skrll Exp $	*/
 
 /*	$OpenBSD: reg.h,v 1.7 2000/06/15 17:00:37 mickey Exp $	*/
 
@@ -88,7 +88,7 @@
 #define	CR_TLS		27	/* tr3: thread local storage pointer	*/
 #define	CR_HVTP		28	/* tr4: faulted HVT slot ptr on LC cpus */
 #define	CR_TR5		29	/* tr5: emu / TLB_STATS_{PRE,AFT}	*/
-#define	CR_UPADDR	30	/* tr6: paddr of U-area of curlwp	*/
+#define	CR_FPPADDR	30	/* tr6: paddr of FP regs of curlwp	*/
 #define	CR_TR7		31	/* tr7: trap temporary register		*/
 
 /*

Reply via email to