Module Name: src
Committed By: matt
Date: Wed Jun 9 14:20:00 UTC 2010
Modified Files:
src/sys/arch/mips/include [matt-nb5-mips64]: cpu.h proc.h
src/sys/arch/mips/mips [matt-nb5-mips64]: mips_machdep.c vm_machdep.c
Log Message:
Add support for setting/clearing PK_32 on _LP64 kernels. Make cpu_proc_fork
a real function and add it to vm_machdep.c and let it copy PK_32 on fork.
Properly clear/set PK_32 depending on ABI in setregs. Lack of PX_32 use
tracked down by Cliff Neighbors. [Ya! ps now works!]
To generate a diff of this commit:
cvs rdiff -u -r1.90.16.28 -r1.90.16.29 src/sys/arch/mips/include/cpu.h
cvs rdiff -u -r1.21.36.8 -r1.21.36.9 src/sys/arch/mips/include/proc.h
cvs rdiff -u -r1.205.4.1.2.1.2.46 -r1.205.4.1.2.1.2.47 \
src/sys/arch/mips/mips/mips_machdep.c
cvs rdiff -u -r1.121.6.1.2.14 -r1.121.6.1.2.15 \
src/sys/arch/mips/mips/vm_machdep.c
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/mips/include/cpu.h
diff -u src/sys/arch/mips/include/cpu.h:1.90.16.28 src/sys/arch/mips/include/cpu.h:1.90.16.29
--- src/sys/arch/mips/include/cpu.h:1.90.16.28 Sun Mar 21 18:17:21 2010
+++ src/sys/arch/mips/include/cpu.h Wed Jun 9 14:20:00 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.90.16.28 2010/03/21 18:17:21 cliff Exp $ */
+/* $NetBSD: cpu.h,v 1.90.16.29 2010/06/09 14:20:00 matt Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -197,7 +197,6 @@
#else
#define cpu_number() (0L)
#endif
-#define cpu_proc_fork(p1, p2) ((void)((p2)->p_md.md_abi = (p1)->p_md.md_abi))
/* XXX simonb
* Should the following be in a cpu_info type structure?
Index: src/sys/arch/mips/include/proc.h
diff -u src/sys/arch/mips/include/proc.h:1.21.36.8 src/sys/arch/mips/include/proc.h:1.21.36.9
--- src/sys/arch/mips/include/proc.h:1.21.36.8 Sat May 15 20:27:48 2010
+++ src/sys/arch/mips/include/proc.h Wed Jun 9 14:20:00 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.21.36.8 2010/05/15 20:27:48 matt Exp $ */
+/* $NetBSD: proc.h,v 1.21.36.9 2010/06/09 14:20:00 matt Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -70,8 +70,11 @@
#define MDP_FPUSED 0x0001 /* floating point coprocessor used */
#ifdef _KERNEL
+struct lwp;
+struct proc;
/* kernel single-step emulation */
-int mips_singlestep(struct lwp *l);
+int mips_singlestep(struct lwp *);
+void cpu_proc_fork(struct proc *, struct proc *);
#define LWP0_CPU_INFO &cpu_info_store /* staticly set in lwp0 */
#endif /* _KERNEL */
Index: src/sys/arch/mips/mips/mips_machdep.c
diff -u src/sys/arch/mips/mips/mips_machdep.c:1.205.4.1.2.1.2.46 src/sys/arch/mips/mips/mips_machdep.c:1.205.4.1.2.1.2.47
--- src/sys/arch/mips/mips/mips_machdep.c:1.205.4.1.2.1.2.46 Fri May 28 21:24:47 2010
+++ src/sys/arch/mips/mips/mips_machdep.c Wed Jun 9 14:20:00 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mips_machdep.c,v 1.205.4.1.2.1.2.46 2010/05/28 21:24:47 matt Exp $ */
+/* $NetBSD: mips_machdep.c,v 1.205.4.1.2.1.2.47 2010/06/09 14:20:00 matt Exp $ */
/*
* Copyright 2002 Wasabi Systems, Inc.
@@ -112,7 +112,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.205.4.1.2.1.2.46 2010/05/28 21:24:47 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.205.4.1.2.1.2.47 2010/06/09 14:20:00 matt Exp $");
#define __INTR_PRIVATE
@@ -1228,7 +1228,8 @@
void
setregs(struct lwp *l, struct exec_package *pack, u_long stack)
{
- struct trapframe *tf = l->l_md.md_utf;
+ struct trapframe * const tf = l->l_md.md_utf;
+ struct proc * const p = l->l_proc;
memset(tf, 0, sizeof(struct trapframe));
tf->tf_regs[_R_SP] = (int)stack;
@@ -1239,14 +1240,26 @@
/*
* allow 64bit ops in userland for non-O32 ABIs
*/
- if (l->l_proc->p_md.md_abi == _MIPS_BSD_API_N32 && CPUISMIPS64) {
+ if (p->p_md.md_abi == _MIPS_BSD_API_N32 && CPUISMIPS64) {
tf->tf_regs[_R_SR] |= MIPS_SR_PX;
- } else if (l->l_proc->p_md.md_abi != _MIPS_BSD_API_O32) {
+ } else if (p->p_md.md_abi != _MIPS_BSD_API_O32) {
tf->tf_regs[_R_SR] |= MIPS_SR_UX;
}
- if (_MIPS_SIM_NEWABI_P(l->l_proc->p_md.md_abi))
+ if (_MIPS_SIM_NEWABI_P(p->p_md.md_abi))
tf->tf_regs[_R_SR] |= MIPS3_SR_FR;
#endif
+#ifdef _LP64
+ /*
+ * If we are using a 32-bit ABI on a 64-bit kernel, mark the process
+ * that way. If we aren't, clear it.
+ */
+ if (p->p_md.md_abi == _MIPS_BSD_API_N32
+ || p->p_md.md_abi == _MIPS_BSD_API_O32) {
+ p->p_flag |= PK_32;
+ } else {
+ p->p_flag &= ~PK_32;
+ }
+#endif
/*
* Set up arguments for _start():
* _start(stack, obj, cleanup, ps_strings);
@@ -1259,7 +1272,7 @@
tf->tf_regs[_R_A0] = (intptr_t)stack;
tf->tf_regs[_R_A1] = 0;
tf->tf_regs[_R_A2] = 0;
- tf->tf_regs[_R_A3] = (intptr_t)l->l_proc->p_psstr;
+ tf->tf_regs[_R_A3] = (intptr_t)p->p_psstr;
if (l->l_md.md_flags & MDP_FPUSED)
fpudiscard_lwp(l);
@@ -1662,7 +1675,9 @@
lwp0.l_md.md_utf = (struct trapframe *)(v + USPACE) - 1;
#ifdef _LP64
lwp0.l_md.md_utf->tf_regs[_R_SR] = MIPS_SR_KX;
- lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] = MIPS_SR_KX | MIPS_SR_INT_IE;
+ lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] =
+ (ipl_sr_map.sr_bits[IPL_SCHED] ^ MIPS_INT_MASK)
+ | MIPS_SR_KX | MIPS_SR_INT_IE;
#else
lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] = MIPS_SR_INT_IE;
#endif
Index: src/sys/arch/mips/mips/vm_machdep.c
diff -u src/sys/arch/mips/mips/vm_machdep.c:1.121.6.1.2.14 src/sys/arch/mips/mips/vm_machdep.c:1.121.6.1.2.15
--- src/sys/arch/mips/mips/vm_machdep.c:1.121.6.1.2.14 Mon Mar 1 19:27:21 2010
+++ src/sys/arch/mips/mips/vm_machdep.c Wed Jun 9 14:20:00 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.121.6.1.2.14 2010/03/01 19:27:21 matt Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.121.6.1.2.15 2010/06/09 14:20:00 matt Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -80,7 +80,7 @@
#include "opt_coredump.h"
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.121.6.1.2.14 2010/03/01 19:27:21 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.121.6.1.2.15 2010/06/09 14:20:00 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -207,6 +207,19 @@
KASSERT(pcb->pcb_context.val[_L_SR] & MIPS_SR_INT_IE);
}
+/*
+ * Routine to copy MD stuff from proc to proc on a fork.
+ * For mips, this is the ABI and "32 bit process on a 64 bit kernel" flag.
+ */
+void
+cpu_proc_fork(struct proc *p1, struct proc *p2)
+{
+ p2->p_md.md_abi = p1->p_md.md_abi;
+#ifdef _LP64
+ p2->p_flag = p1->p_flag & PK_32;
+#endif
+}
+
static struct evcnt uarea_remapped =
EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "uarea", "remapped");
static struct evcnt uarea_reallocated =