Module Name: src
Committed By: matt
Date: Sun Jul 3 02:18:21 UTC 2011
Modified Files:
src/sys/arch/vax/include: db_machdep.h pcb.h proc.h trap.h userret.h
src/sys/arch/vax/vax: compat_13_machdep.c compat_16_machdep.c
core_machdep.c db_machdep.c locore.c machdep.c sig_machdep.c
syscall.c trap.c vm_machdep.c
Log Message:
Cleanup trapframe handling. Instead of keeping a trapframe pointer in the
pcb, put in the mdlwp instead. We had a dummy field so it didn't grow in
size. This also follows the practice that mips and powerpc follow that a
pointer to the user trapframe is in l->l_md.md_utf. Make trapframe members
start with tf_
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/vax/include/db_machdep.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/vax/include/pcb.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/vax/include/proc.h
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/vax/include/trap.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/vax/include/userret.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/vax/vax/compat_13_machdep.c \
src/sys/arch/vax/vax/compat_16_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/vax/vax/core_machdep.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/vax/vax/db_machdep.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/vax/vax/locore.c
cvs rdiff -u -r1.181 -r1.182 src/sys/arch/vax/vax/machdep.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/vax/vax/sig_machdep.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/vax/vax/syscall.c
cvs rdiff -u -r1.127 -r1.128 src/sys/arch/vax/vax/trap.c
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/vax/vax/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/vax/include/db_machdep.h
diff -u src/sys/arch/vax/include/db_machdep.h:1.18 src/sys/arch/vax/include/db_machdep.h:1.19
--- src/sys/arch/vax/include/db_machdep.h:1.18 Thu May 26 15:34:14 2011
+++ src/sys/arch/vax/include/db_machdep.h Sun Jul 3 02:18:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.18 2011/05/26 15:34:14 joerg Exp $ */
+/* $NetBSD: db_machdep.h,v 1.19 2011/07/03 02:18:20 matt Exp $ */
/*
* Mach Operating System
@@ -47,17 +47,17 @@
extern db_regs_t ddb_regs; /* register state */
#define DDB_REGS (&ddb_regs)
-#define PC_REGS(regs) (*(db_addr_t *)&(regs)->pc)
+#define PC_REGS(regs) (*(db_addr_t *)&(regs)->tf_pc)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0x03 /* breakpoint instruction */
#define BKPT_SIZE (1) /* size of breakpoint inst */
#define BKPT_SET(inst, addr) (BKPT_INST)
-#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->pc -= BKPT_SIZE)
+#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_pc -= BKPT_SIZE)
-#define db_clear_single_step(regs) ((regs)->psl &= ~PSL_T)
-#define db_set_single_step(regs) ((regs)->psl |= PSL_T)
+#define db_clear_single_step(regs) ((regs)->tf_psl &= ~PSL_T)
+#define db_set_single_step(regs) ((regs)->tf_psl |= PSL_T)
#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)
#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_TRCTRAP)
Index: src/sys/arch/vax/include/pcb.h
diff -u src/sys/arch/vax/include/pcb.h:1.13 src/sys/arch/vax/include/pcb.h:1.14
--- src/sys/arch/vax/include/pcb.h:1.13 Sat Mar 20 23:31:30 2010
+++ src/sys/arch/vax/include/pcb.h Sun Jul 3 02:18:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pcb.h,v 1.13 2010/03/20 23:31:30 chs Exp $ */
+/* $NetBSD: pcb.h,v 1.14 2011/07/03 02:18:20 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -56,7 +56,6 @@
long P1LR; /* Page 1 Length Register */
/* Software registers, only used by kernel software */
- void *framep; /* Pointer to syscall frame */
void *pcb_onfault; /* Tells whether fault copy */
paddr_t pcb_paddr; /* physical address of PCB */
struct pmap *pcb_pm; /* owning pmap */
Index: src/sys/arch/vax/include/proc.h
diff -u src/sys/arch/vax/include/proc.h:1.14 src/sys/arch/vax/include/proc.h:1.15
--- src/sys/arch/vax/include/proc.h:1.14 Fri Jan 14 02:06:33 2011
+++ src/sys/arch/vax/include/proc.h Sun Jul 3 02:18:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.14 2011/01/14 02:06:33 rmind Exp $ */
+/* $NetBSD: proc.h,v 1.15 2011/07/03 02:18:20 matt Exp $ */
/*
* Copyright (c) 1991 Regents of the University of California.
@@ -38,7 +38,7 @@
* Machine-dependent lwp struct for vax,
*/
struct mdlwp {
- int md_dummy; /* Must be at least one field */
+ struct trapframe *md_utf; /* pointer to user trapframe */
};
struct trapframe;
Index: src/sys/arch/vax/include/trap.h
diff -u src/sys/arch/vax/include/trap.h:1.23 src/sys/arch/vax/include/trap.h:1.24
--- src/sys/arch/vax/include/trap.h:1.23 Sat Nov 13 02:23:27 2010
+++ src/sys/arch/vax/include/trap.h Sun Jul 3 02:18:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.h,v 1.23 2010/11/13 02:23:27 matt Exp $ */
+/* $NetBSD: trap.h,v 1.24 2011/07/03 02:18:20 matt Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -81,25 +81,25 @@
#ifndef _LOCORE
struct trapframe {
- long fp; /* Stack frame pointer */
- long ap; /* Argument pointer on user stack */
- long sp; /* Stack pointer */
- long r0; /* General registers saved upon trap/syscall */
- long r1;
- long r2;
- long r3;
- long r4;
- long r5;
- long r6;
- long r7;
- long r8;
- long r9;
- long r10;
- long r11;
- long trap; /* Type of trap */
- long code; /* Trap specific code */
- long pc; /* User pc */
- long psl; /* User psl */
+ long tf_fp; /* Stack frame pointer */
+ long tf_ap; /* Argument pointer on user stack */
+ long tf_sp; /* Stack pointer */
+ long tf_r0; /* General registers saved upon trap/syscall */
+ long tf_r1;
+ long tf_r2;
+ long tf_r3;
+ long tf_r4;
+ long tf_r5;
+ long tf_r6;
+ long tf_r7;
+ long tf_r8;
+ long tf_r9;
+ long tf_r10;
+ long tf_r11;
+ long tf_trap; /* Type of trap */
+ long tf_code; /* Trap specific code */
+ long tf_pc; /* User pc */
+ long tf_psl; /* User psl */
};
#endif /* _LOCORE */
Index: src/sys/arch/vax/include/userret.h
diff -u src/sys/arch/vax/include/userret.h:1.12 src/sys/arch/vax/include/userret.h:1.13
--- src/sys/arch/vax/include/userret.h:1.12 Sat Feb 27 22:12:32 2010
+++ src/sys/arch/vax/include/userret.h Sun Jul 3 02:18:20 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: userret.h,v 1.12 2010/02/27 22:12:32 snj Exp $ */
+/* $NetBSD: userret.h,v 1.13 2011/07/03 02:18:20 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -37,9 +37,9 @@
* return to usermode.
*/
static __inline void
-userret(struct lwp *l, struct trapframe *frame, u_quad_t oticks)
+userret(struct lwp *l, struct trapframe *tf, u_quad_t oticks)
{
- struct proc *p = l->l_proc;
+ struct proc * const p = l->l_proc;
mi_userret(l);
@@ -49,7 +49,7 @@
if ((p->p_stflag & PST_PROFIL) != 0) {
extern int psratio;
- addupc_task(l, frame->pc,
+ addupc_task(l, tf->tf_pc,
(int)(p->p_sticks - oticks) * psratio);
}
}
Index: src/sys/arch/vax/vax/compat_13_machdep.c
diff -u src/sys/arch/vax/vax/compat_13_machdep.c:1.3 src/sys/arch/vax/vax/compat_13_machdep.c:1.4
--- src/sys/arch/vax/vax/compat_13_machdep.c:1.3 Tue Dec 14 23:44:49 2010
+++ src/sys/arch/vax/vax/compat_13_machdep.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_13_machdep.c,v 1.3 2010/12/14 23:44:49 matt Exp $ */
+/* $NetBSD: compat_13_machdep.c,v 1.4 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.3 2010/12/14 23:44:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.4 2011/07/03 02:18:21 matt Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -123,14 +123,12 @@
/* {
syscallarg(struct sigcontext13 *) sigcntxp;
} */
- struct proc *p = l->l_proc;
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *scf;
+ struct proc * const p = l->l_proc;
+ struct trapframe * const tf = l->l_md.md_utf;
struct sigcontext13 *ucntx;
struct sigcontext13 ksc;
sigset_t mask;
- scf = pcb->framep;
ucntx = SCARG(uap, sigcntxp);
if (copyin((void *)ucntx, (void *)&ksc, sizeof(struct sigcontext)))
return EINVAL;
@@ -152,11 +150,11 @@
(void) sigprocmask1(l, SIG_SETMASK, &mask, 0);
mutex_exit(p->p_lock);
- scf->fp = ksc.sc_fp;
- scf->ap = ksc.sc_ap;
- scf->pc = ksc.sc_pc;
- scf->sp = ksc.sc_sp;
- scf->psl = ksc.sc_ps;
+ tf->tf_fp = ksc.sc_fp;
+ tf->tf_ap = ksc.sc_ap;
+ tf->tf_pc = ksc.sc_pc;
+ tf->tf_sp = ksc.sc_sp;
+ tf->tf_psl = ksc.sc_ps;
return (EJUSTRETURN);
}
@@ -167,14 +165,14 @@
{
struct sigcontext sigctx;
struct otrampframe tramp;
- struct proc *p = l->l_proc;
+ struct proc * const p = l->l_proc;
bool error;
- sigctx.sc_pc = tf->pc;
- sigctx.sc_ps = tf->psl;
- sigctx.sc_ap = tf->ap;
- sigctx.sc_fp = tf->fp;
- sigctx.sc_sp = tf->sp;
+ sigctx.sc_pc = tf->tf_pc;
+ sigctx.sc_ps = tf->tf_psl;
+ sigctx.sc_ap = tf->tf_ap;
+ sigctx.sc_fp = tf->tf_fp;
+ sigctx.sc_sp = tf->tf_sp;
sigctx.sc_onstack = onstack ? SS_ONSTACK : 0;
sigctx.sc_mask = *mask;
sp -= sizeof(struct sigcontext);
Index: src/sys/arch/vax/vax/compat_16_machdep.c
diff -u src/sys/arch/vax/vax/compat_16_machdep.c:1.3 src/sys/arch/vax/vax/compat_16_machdep.c:1.4
--- src/sys/arch/vax/vax/compat_16_machdep.c:1.3 Tue Dec 14 23:44:49 2010
+++ src/sys/arch/vax/vax/compat_16_machdep.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_16_machdep.c,v 1.3 2010/12/14 23:44:49 matt Exp $ */
+/* $NetBSD: compat_16_machdep.c,v 1.4 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.3 2010/12/14 23:44:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.4 2011/07/03 02:18:21 matt Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -120,14 +120,11 @@
/* {
syscallarg(struct sigcontext *) sigcntxp;
} */
- struct proc *p = l->l_proc;
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *scf;
- struct sigcontext *ucntx;
+ struct proc * const p = l->l_proc;
+ struct trapframe * const tf = l->l_md.md_utf;
+ struct sigcontext * const ucntx = SCARG(uap, sigcntxp);
struct sigcontext ksc;
- scf = pcb->framep;
- ucntx = SCARG(uap, sigcntxp);
if (copyin((void *)ucntx, (void *)&ksc, sizeof(struct sigcontext)))
return EINVAL;
@@ -143,15 +140,16 @@
l->l_sigstk.ss_flags |= SS_ONSTACK;
else
l->l_sigstk.ss_flags &= ~SS_ONSTACK;
+
/* Restore signal mask. */
(void) sigprocmask1(l, SIG_SETMASK, &ksc.sc_mask, 0);
mutex_exit(p->p_lock);
- scf->fp = ksc.sc_fp;
- scf->ap = ksc.sc_ap;
- scf->pc = ksc.sc_pc;
- scf->sp = ksc.sc_sp;
- scf->psl = ksc.sc_ps;
+ tf->tf_fp = ksc.sc_fp;
+ tf->tf_ap = ksc.sc_ap;
+ tf->tf_pc = ksc.sc_pc;
+ tf->tf_sp = ksc.sc_sp;
+ tf->tf_psl = ksc.sc_ps;
return (EJUSTRETURN);
}
@@ -177,15 +175,15 @@
{
struct trampoline2 tramp;
struct sigcontext sigctx;
- struct proc *p = l->l_proc;
+ struct proc * const p = l->l_proc;
bool error;
/* The sigcontext struct will be passed back to sigreturn(). */
- sigctx.sc_pc = tf->pc;
- sigctx.sc_ps = tf->psl;
- sigctx.sc_ap = tf->ap;
- sigctx.sc_fp = tf->fp;
- sigctx.sc_sp = tf->sp;
+ sigctx.sc_pc = tf->tf_pc;
+ sigctx.sc_ps = tf->tf_psl;
+ sigctx.sc_ap = tf->tf_ap;
+ sigctx.sc_fp = tf->tf_fp;
+ sigctx.sc_sp = tf->tf_sp;
sigctx.sc_onstack = onstack ? SS_ONSTACK : 0;
sigctx.sc_mask = *mask;
sp -= sizeof(struct sigcontext);
@@ -200,7 +198,7 @@
mutex_exit(p->p_lock);
/* Store the handler in the trapframe. */
- tf->fp = handler;
+ tf->tf_fp = handler;
/* Copy out the sigcontext and trampoline. */
error = (copyout(&sigctx, (char *)tramp.scp, sizeof(sigctx)) != 0 ||
Index: src/sys/arch/vax/vax/core_machdep.c
diff -u src/sys/arch/vax/vax/core_machdep.c:1.4 src/sys/arch/vax/vax/core_machdep.c:1.5
--- src/sys/arch/vax/vax/core_machdep.c:1.4 Tue Dec 14 23:44:49 2010
+++ src/sys/arch/vax/vax/core_machdep.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: core_machdep.c,v 1.4 2010/12/14 23:44:49 matt Exp $ */
+/* $NetBSD: core_machdep.c,v 1.5 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.4 2010/12/14 23:44:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.5 2011/07/03 02:18:21 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,7 +54,6 @@
{
struct md_coredump md_core;
struct coreseg cseg;
- struct pcb *pcb;
int error;
if (iocookie == NULL) {
@@ -66,8 +65,7 @@
return 0;
}
- pcb = lwp_getpcb(l);
- md_core.md_tf = *(struct trapframe *)pcb->framep; /*XXX*/
+ md_core.md_tf = *l->l_md.md_utf; /*XXX*/
CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_MACHINE, CORE_CPU);
cseg.c_addr = 0;
Index: src/sys/arch/vax/vax/db_machdep.c
diff -u src/sys/arch/vax/vax/db_machdep.c:1.57 src/sys/arch/vax/vax/db_machdep.c:1.58
--- src/sys/arch/vax/vax/db_machdep.c:1.57 Tue Dec 14 23:44:49 2010
+++ src/sys/arch/vax/vax/db_machdep.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.c,v 1.57 2010/12/14 23:44:49 matt Exp $ */
+/* $NetBSD: db_machdep.c,v 1.58 2011/07/03 02:18:21 matt Exp $ */
/*
* :set tabs=4
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.57 2010/12/14 23:44:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.58 2011/07/03 02:18:21 matt Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -142,14 +142,14 @@
* contain the registers when panic was called. (easy to debug).
*/
void
-kdb_trap(struct trapframe *frame)
+kdb_trap(struct trapframe *tf)
{
int s;
#ifdef MULTIPROCESSOR
struct cpu_info *ci = curcpu();
#endif
- switch (frame->trap) {
+ switch (tf->tf_trap) {
case T_BPTFLT: /* breakpoint */
case T_TRCTRAP: /* single_step */
break;
@@ -160,16 +160,16 @@
if (panicstr) {
struct callsframe *pf, *df;
- df = (void *)frame->fp; /* start of debug's calls */
+ df = (void *)tf->tf_fp; /* start of debug's calls */
pf = (void *)df->ca_fp; /* start of panic's calls */
- memcpy(&ddb_regs.r0, &pf->ca_argno, sizeof(int) * 12);
- ddb_regs.fp = pf->ca_fp;
- ddb_regs.pc = pf->ca_pc;
- ddb_regs.ap = pf->ca_ap;
- ddb_regs.sp = (unsigned)pf;
- ddb_regs.psl = frame->psl & ~0x1fffe0;
- ddb_regs.psl |= pf->ca_maskpsw & 0xffe0;
- ddb_regs.psl |= (splsave << 16);
+ memcpy(&ddb_regs.tf_r0, &pf->ca_argno, sizeof(int) * 12);
+ ddb_regs.tf_fp = pf->ca_fp;
+ ddb_regs.tf_pc = pf->ca_pc;
+ ddb_regs.tf_ap = pf->ca_ap;
+ ddb_regs.tf_sp = (unsigned)pf;
+ ddb_regs.tf_psl = tf->tf_psl & ~0x1fffe0;
+ ddb_regs.tf_psl |= pf->ca_maskpsw & 0xffe0;
+ ddb_regs.tf_psl |= (splsave << 16);
}
#endif
break;
@@ -178,7 +178,7 @@
if ((boothowto & RB_KDB) == 0)
return;
- kdbprinttrap(frame->trap, frame->code);
+ kdbprinttrap(tf->tf_trap, tf->tf_code);
if (db_recover != 0) {
db_error("Faulted in DDB; continuing...\n");
/*NOTREACHED*/
@@ -186,13 +186,13 @@
}
#ifdef MULTIPROCESSOR
- ci->ci_ddb_regs = frame;
+ ci->ci_ddb_regs = tf;
if (pause_cpus())
return;
#endif
#ifndef MULTIPROCESSOR
if (!panicstr)
- memcpy(&ddb_regs, frame, sizeof(struct trapframe));
+ memcpy(&ddb_regs, tf, sizeof(struct trapframe));
#else
memcpy(&ddb_regs, stopcpu->ci_ddb_regs, sizeof(struct trapframe));
printf("stopped on CPU %d\n", stopcpu->ci_cpuid);
@@ -203,18 +203,18 @@
s = splhigh();
db_active++;
cnpollc(true);
- db_trap(frame->trap, frame->code);
+ db_trap(tf->tf_trap, tf->tf_code);
cnpollc(false);
db_active--;
splx(s);
#ifndef MULTIPROCESSOR
if (!panicstr)
- memcpy(frame, &ddb_regs, sizeof(struct trapframe));
+ memcpy(tf, &ddb_regs, sizeof(struct trapframe));
#else
memcpy(stopcpu->ci_ddb_regs, &ddb_regs, sizeof(struct trapframe));
#endif
- frame->sp = mfpr(PR_USP);
+ tf->tf_sp = mfpr(PR_USP);
#ifdef MULTIPROCESSOR
rpb.wait = 0;
resume_cpus();
@@ -268,25 +268,25 @@
* Machine register set.
*/
const struct db_variable db_regs[] = {
- {"r0", &ddb_regs.r0, FCN_NULL},
- {"r1", &ddb_regs.r1, FCN_NULL},
- {"r2", &ddb_regs.r2, FCN_NULL},
- {"r3", &ddb_regs.r3, FCN_NULL},
- {"r4", &ddb_regs.r4, FCN_NULL},
- {"r5", &ddb_regs.r5, FCN_NULL},
- {"r6", &ddb_regs.r6, FCN_NULL},
- {"r7", &ddb_regs.r7, FCN_NULL},
- {"r8", &ddb_regs.r8, FCN_NULL},
- {"r9", &ddb_regs.r9, FCN_NULL},
- {"r10", &ddb_regs.r10, FCN_NULL},
- {"r11", &ddb_regs.r11, FCN_NULL},
- {"ap", &ddb_regs.ap, FCN_NULL},
- {"fp", &ddb_regs.fp, FCN_NULL},
- {"sp", &ddb_regs.sp, FCN_NULL},
- {"pc", &ddb_regs.pc, FCN_NULL},
- {"psl", &ddb_regs.psl, FCN_NULL},
+ {"r0", &ddb_regs.tf_r0, FCN_NULL},
+ {"r1", &ddb_regs.tf_r1, FCN_NULL},
+ {"r2", &ddb_regs.tf_r2, FCN_NULL},
+ {"r3", &ddb_regs.tf_r3, FCN_NULL},
+ {"r4", &ddb_regs.tf_r4, FCN_NULL},
+ {"r5", &ddb_regs.tf_r5, FCN_NULL},
+ {"r6", &ddb_regs.tf_r6, FCN_NULL},
+ {"r7", &ddb_regs.tf_r7, FCN_NULL},
+ {"r8", &ddb_regs.tf_r8, FCN_NULL},
+ {"r9", &ddb_regs.tf_r9, FCN_NULL},
+ {"r10", &ddb_regs.tf_r10, FCN_NULL},
+ {"r11", &ddb_regs.tf_r11, FCN_NULL},
+ {"ap", &ddb_regs.tf_ap, FCN_NULL},
+ {"fp", &ddb_regs.tf_fp, FCN_NULL},
+ {"sp", &ddb_regs.tf_sp, FCN_NULL},
+ {"pc", &ddb_regs.tf_pc, FCN_NULL},
+ {"psl", &ddb_regs.tf_psl, FCN_NULL},
};
-const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+const struct db_variable * const db_eregs = db_regs + __arraycount(db_regs);
#define IN_USERLAND(x) (((u_int)(x) & 0x80000000) == 0)
@@ -347,8 +347,9 @@
}
tf = (struct trapframe *) &fp->vax_args[arg_base + 2];
(*pr)("0x%lx: trap type=0x%lx code=0x%lx pc=0x%lx psl=0x%lx\n",
- tf, tf->trap, tf->code, tf->pc, tf->psl);
- pc = tf->pc;
+ tf, tf->tf_trap, tf->tf_code,
+ tf->tf_pc, tf->tf_psl);
+ pc = tf->tf_pc;
}
diff = INT_MAX;
@@ -425,9 +426,9 @@
(*pr)("panic: %s\n", panicstr);
/* xxx ? where did we panic and whose stack are we using? */
#ifdef MULTIPROCESSOR
- db_dump_stack((VAX_CALLFRAME *)(ddb_regs.fp), ddb_regs.ap, pr);
+ db_dump_stack((VAX_CALLFRAME *)(ddb_regs.tf_fp), ddb_regs.tf_ap, pr);
#else
- db_dump_stack((VAX_CALLFRAME *)(ddb_regs.sp), ddb_regs.ap, pr);
+ db_dump_stack((VAX_CALLFRAME *)(ddb_regs.tf_sp), ddb_regs.tf_ap, pr);
#endif
return;
}
@@ -504,7 +505,7 @@
(*pr)(" FP = 0x%x\n", (unsigned int)(pcb->FP));
(*pr)(" PC = 0x%x\n", (unsigned int)(pcb->PC));
(*pr)(" PSL = 0x%x\n", (unsigned int)(pcb->PSL));
- (*pr)(" Trap frame pointer: 0x%x\n", (unsigned int)(pcb->framep));
+ (*pr)(" Trap frame pointer: %o\n", l->l_md.md_utf);
db_dump_stack((VAX_CALLFRAME *)(pcb->FP), (u_int)pcb->KSP, pr);
return;
#if 0
Index: src/sys/arch/vax/vax/locore.c
diff -u src/sys/arch/vax/vax/locore.c:1.79 src/sys/arch/vax/vax/locore.c:1.80
--- src/sys/arch/vax/vax/locore.c:1.79 Tue Dec 14 23:44:49 2010
+++ src/sys/arch/vax/vax/locore.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.c,v 1.79 2010/12/14 23:44:49 matt Exp $ */
+/* $NetBSD: locore.c,v 1.80 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -32,7 +32,7 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.c,v 1.79 2010/12/14 23:44:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.c,v 1.80 2011/07/03 02:18:21 matt Exp $");
#include "opt_compat_netbsd.h"
@@ -92,7 +92,6 @@
_start(struct rpb *prpb)
{
extern uintptr_t scratch;
- struct pcb *pcb0;
struct pte *pt;
vaddr_t uv;
@@ -340,8 +339,7 @@
pt = kvtopte(uv);
pt->pg_v = 0;
- pcb0 = lwp_getpcb(&lwp0);
- pcb0->framep = (void *)scratch;
+ lwp0.l_md.md_utf = (void *)scratch;
/*
* Change mode down to userspace is done by faking a stack
Index: src/sys/arch/vax/vax/machdep.c
diff -u src/sys/arch/vax/vax/machdep.c:1.181 src/sys/arch/vax/vax/machdep.c:1.182
--- src/sys/arch/vax/vax/machdep.c:1.181 Sun Jun 12 03:35:49 2011
+++ src/sys/arch/vax/vax/machdep.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.181 2011/06/12 03:35:49 rmind Exp $ */
+/* $NetBSD: machdep.c,v 1.182 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.181 2011/06/12 03:35:49 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.182 2011/07/03 02:18:21 matt Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -460,30 +460,28 @@
int
process_read_regs(struct lwp *l, struct reg *regs)
{
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *tf = pcb->framep;
+ struct trapframe * const tf = l->l_md.md_utf;
- memcpy(®s->r0, &tf->r0, 12 * sizeof(int));
- regs->ap = tf->ap;
- regs->fp = tf->fp;
- regs->sp = tf->sp;
- regs->pc = tf->pc;
- regs->psl = tf->psl;
+ memcpy(®s->r0, &tf->tf_r0, 12 * sizeof(int));
+ regs->ap = tf->tf_ap;
+ regs->fp = tf->tf_fp;
+ regs->sp = tf->tf_sp;
+ regs->pc = tf->tf_pc;
+ regs->psl = tf->tf_psl;
return 0;
}
int
process_write_regs(struct lwp *l, const struct reg *regs)
{
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *tf = pcb->framep;
+ struct trapframe * const tf = l->l_md.md_utf;
- memcpy(&tf->r0, ®s->r0, 12 * sizeof(int));
- tf->ap = regs->ap;
- tf->fp = regs->fp;
- tf->sp = regs->sp;
- tf->pc = regs->pc;
- tf->psl = (regs->psl|PSL_U|PSL_PREVU) &
+ memcpy(&tf->tf_r0, ®s->r0, 12 * sizeof(int));
+ tf->tf_ap = regs->ap;
+ tf->tf_fp = regs->fp;
+ tf->tf_sp = regs->sp;
+ tf->tf_pc = regs->pc;
+ tf->tf_psl = (regs->psl|PSL_U|PSL_PREVU) &
~(PSL_MBZ|PSL_IS|PSL_IPL1F|PSL_CM); /* Allow compat mode? */
return 0;
}
@@ -491,14 +489,7 @@
int
process_set_pc(struct lwp *l, void *addr)
{
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *tf;
- void *ptr;
-
- ptr = (char *)pcb->framep;
- tf = ptr;
-
- tf->pc = (unsigned) addr;
+ l->l_md.md_utf->tf_pc = (uintptr_t) addr;
return (0);
}
@@ -506,17 +497,12 @@
int
process_sstep(struct lwp *l, int sstep)
{
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *tf;
- void *ptr;
-
- ptr = pcb->framep;
- tf = ptr;
+ struct trapframe * const tf = l->l_md.md_utf;
if (sstep)
- tf->psl |= PSL_T;
+ tf->tf_psl |= PSL_T;
else
- tf->psl &= ~PSL_T;
+ tf->tf_psl &= ~PSL_T;
return (0);
}
@@ -639,8 +625,7 @@
cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted,
void *sas, void *ap, void *sp, sa_upcall_t upcall)
{
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *tf = pcb->framep;
+ struct trapframe * const tf = l->l_md.md_utf;
uint32_t saframe[11], *fp = saframe;
sp = (void *)((uintptr_t)sp - sizeof(saframe));
@@ -675,45 +660,43 @@
/* NOTREACHED */
}
- tf->ap = (uintptr_t) sp + 20;
- tf->sp = (long) sp;
- tf->fp = (long) sp;
- tf->pc = (long) upcall + 2;
- tf->psl = (long) PSL_U | PSL_PREVU;
+ tf->tf_ap = (uintptr_t) sp + 20;
+ tf->tf_sp = (long) sp;
+ tf->tf_fp = (long) sp;
+ tf->tf_pc = (long) upcall + 2;
+ tf->tf_psl = (long) PSL_U | PSL_PREVU;
}
void
cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags)
{
- const struct pcb *pcb = lwp_getpcb(l);
- const struct trapframe *tf = pcb->framep;
+ const struct trapframe * const tf = l->l_md.md_utf;
__greg_t *gr = mcp->__gregs;
- gr[_REG_R0] = tf->r0;
- gr[_REG_R1] = tf->r1;
- gr[_REG_R2] = tf->r2;
- gr[_REG_R3] = tf->r3;
- gr[_REG_R4] = tf->r4;
- gr[_REG_R5] = tf->r5;
- gr[_REG_R6] = tf->r6;
- gr[_REG_R7] = tf->r7;
- gr[_REG_R8] = tf->r8;
- gr[_REG_R9] = tf->r9;
- gr[_REG_R10] = tf->r10;
- gr[_REG_R11] = tf->r11;
- gr[_REG_AP] = tf->ap;
- gr[_REG_FP] = tf->fp;
- gr[_REG_SP] = tf->sp;
- gr[_REG_PC] = tf->pc;
- gr[_REG_PSL] = tf->psl;
+ gr[_REG_R0] = tf->tf_r0;
+ gr[_REG_R1] = tf->tf_r1;
+ gr[_REG_R2] = tf->tf_r2;
+ gr[_REG_R3] = tf->tf_r3;
+ gr[_REG_R4] = tf->tf_r4;
+ gr[_REG_R5] = tf->tf_r5;
+ gr[_REG_R6] = tf->tf_r6;
+ gr[_REG_R7] = tf->tf_r7;
+ gr[_REG_R8] = tf->tf_r8;
+ gr[_REG_R9] = tf->tf_r9;
+ gr[_REG_R10] = tf->tf_r10;
+ gr[_REG_R11] = tf->tf_r11;
+ gr[_REG_AP] = tf->tf_ap;
+ gr[_REG_FP] = tf->tf_fp;
+ gr[_REG_SP] = tf->tf_sp;
+ gr[_REG_PC] = tf->tf_pc;
+ gr[_REG_PSL] = tf->tf_psl;
*flags |= _UC_CPU;
}
int
cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags)
{
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *tf = pcb->framep;
+ struct trapframe * const tf = l->l_md.md_utf;
const __greg_t *gr = mcp->__gregs;
if ((flags & _UC_CPU) == 0)
@@ -724,23 +707,23 @@
(gr[_REG_PSL] & PSL_CM))
return (EINVAL);
- tf->r0 = gr[_REG_R0];
- tf->r1 = gr[_REG_R1];
- tf->r2 = gr[_REG_R2];
- tf->r3 = gr[_REG_R3];
- tf->r4 = gr[_REG_R4];
- tf->r5 = gr[_REG_R5];
- tf->r6 = gr[_REG_R6];
- tf->r7 = gr[_REG_R7];
- tf->r8 = gr[_REG_R8];
- tf->r9 = gr[_REG_R9];
- tf->r10 = gr[_REG_R10];
- tf->r11 = gr[_REG_R11];
- tf->ap = gr[_REG_AP];
- tf->fp = gr[_REG_FP];
- tf->sp = gr[_REG_SP];
- tf->pc = gr[_REG_PC];
- tf->psl = gr[_REG_PSL];
+ tf->tf_r0 = gr[_REG_R0];
+ tf->tf_r1 = gr[_REG_R1];
+ tf->tf_r2 = gr[_REG_R2];
+ tf->tf_r3 = gr[_REG_R3];
+ tf->tf_r4 = gr[_REG_R4];
+ tf->tf_r5 = gr[_REG_R5];
+ tf->tf_r6 = gr[_REG_R6];
+ tf->tf_r7 = gr[_REG_R7];
+ tf->tf_r8 = gr[_REG_R8];
+ tf->tf_r9 = gr[_REG_R9];
+ tf->tf_r10 = gr[_REG_R10];
+ tf->tf_r11 = gr[_REG_R11];
+ tf->tf_ap = gr[_REG_AP];
+ tf->tf_fp = gr[_REG_FP];
+ tf->tf_sp = gr[_REG_SP];
+ tf->tf_pc = gr[_REG_PC];
+ tf->tf_psl = gr[_REG_PSL];
return 0;
}
Index: src/sys/arch/vax/vax/sig_machdep.c
diff -u src/sys/arch/vax/vax/sig_machdep.c:1.20 src/sys/arch/vax/vax/sig_machdep.c:1.21
--- src/sys/arch/vax/vax/sig_machdep.c:1.20 Tue Dec 14 23:44:50 2010
+++ src/sys/arch/vax/vax/sig_machdep.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: sig_machdep.c,v 1.20 2010/12/14 23:44:50 matt Exp $ */
+/* $NetBSD: sig_machdep.c,v 1.21 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.20 2010/12/14 23:44:50 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.21 2011/07/03 02:18:21 matt Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -157,7 +157,7 @@
vaddr_t handler)
{
struct trampoline3 tramp;
- struct proc *p = l->l_proc;
+ struct proc * const p = l->l_proc;
ucontext_t uc;
bool error;
@@ -179,7 +179,7 @@
mutex_exit(p->p_lock);
cpu_getmcontext(l, &uc.uc_mcontext, &uc.uc_flags);
- tf->fp = handler;
+ tf->tf_fp = handler;
/* Copy the context to the stack. */
error = (copyout(&uc, (char *)tramp.ucp, sizeof(uc)) != 0 ||
@@ -196,12 +196,11 @@
void
sendsig_sighelper(const ksiginfo_t *ksi, const sigset_t *mask)
{
- struct lwp *l = curlwp;
- struct proc *p = l->l_proc;
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *tf = pcb->framep;
- struct sigaltstack *ss = &l->l_sigstk;
- const struct sigact_sigdesc *sd =
+ struct lwp * const l = curlwp;
+ struct proc * const p = l->l_proc;
+ struct trapframe * const tf = l->l_md.md_utf;
+ struct sigaltstack * const ss = &l->l_sigstk;
+ const struct sigact_sigdesc * const sd =
&p->p_sigacts->sa_sigdesc[ksi->ksi_signo];
vaddr_t sp;
int onstack;
@@ -210,7 +209,7 @@
/* Figure what stack we are running on. */
onstack = (ss->ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
(sd->sd_sigact.sa_flags & SA_ONSTACK) != 0;
- sp = onstack ? ((vaddr_t)ss->ss_sp + ss->ss_size) : tf->sp;
+ sp = onstack ? ((vaddr_t)ss->ss_sp + ss->ss_size) : tf->tf_sp;
if (sd->sd_vers > 3 || (setup = sig_setupstacks[sd->sd_vers]) == NULL)
goto nosupport;
@@ -221,13 +220,13 @@
goto nosupport;
if (sd->sd_vers == 0)
- tf->pc = (register_t)p->p_sigctx.ps_sigcode;
+ tf->tf_pc = (register_t)p->p_sigctx.ps_sigcode;
else
- tf->pc = (register_t)sd->sd_tramp;
+ tf->tf_pc = (register_t)sd->sd_tramp;
- tf->psl = PSL_U | PSL_PREVU;
- tf->sp = sp;
- tf->ap = sp;
+ tf->tf_psl = PSL_U | PSL_PREVU;
+ tf->tf_sp = sp;
+ tf->tf_ap = sp;
if (onstack)
ss->ss_flags |= SS_ONSTACK;
Index: src/sys/arch/vax/vax/syscall.c
diff -u src/sys/arch/vax/vax/syscall.c:1.18 src/sys/arch/vax/vax/syscall.c:1.19
--- src/sys/arch/vax/vax/syscall.c:1.18 Mon Dec 20 00:25:45 2010
+++ src/sys/arch/vax/vax/syscall.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.18 2010/12/20 00:25:45 matt Exp $ */
+/* $NetBSD: syscall.c,v 1.19 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -33,7 +33,7 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.18 2010/12/20 00:25:45 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.19 2011/07/03 02:18:21 matt Exp $");
#include "opt_multiprocessor.h"
#include "opt_sa.h"
@@ -67,39 +67,37 @@
}
void
-syscall(struct trapframe *frame)
+syscall(struct trapframe *tf)
{
int error;
int rval[2];
int args[2+SYS_MAXSYSARGS]; /* add two for SYS___syscall + padding */
- struct trapframe * const exptr = frame;
struct lwp * const l = curlwp;
struct proc * const p = l->l_proc;
- struct pcb *pcb = lwp_getpcb(l);
const struct emul * const emul = p->p_emul;
const struct sysent *callp = emul->e_sysent;
const u_quad_t oticks = p->p_sticks;
TDB(("trap syscall %s pc %lx, psl %lx, sp %lx, pid %d, frame %p\n",
- syscallnames[frame->code], frame->pc, frame->psl,frame->sp,
+ syscallnames[tf->tf_code], tf->tf_pc, tf->tf_psl,tf->tf_sp,
p->p_pid,frame));
curcpu()->ci_data.cpu_nsyscall++;
LWP_CACHE_CREDS(l, p);
- pcb->framep = frame;
+ l->l_md.md_utf = tf;
- if ((unsigned long) frame->code >= emul->e_nsysent)
+ if ((unsigned long) tf->tf_code >= emul->e_nsysent)
callp += emul->e_nosys;
else
- callp += frame->code;
+ callp += tf->tf_code;
rval[0] = 0;
- rval[1] = frame->r1;
+ rval[1] = tf->tf_r1;
if (callp->sy_narg) {
- error = copyin((char*)frame->ap + 4, args, callp->sy_argsize);
+ error = copyin((char*)tf->tf_ap + 4, args, callp->sy_argsize);
if (error)
goto bad;
}
@@ -116,20 +114,19 @@
*/
if (__predict_true(!p->p_trace_enabled)
|| __predict_false(callp->sy_flags & SYCALL_INDIRECT)
- || (error = trace_enter(frame->code, args, callp->sy_narg)) == 0) {
+ || (error = trace_enter(tf->tf_code, args, callp->sy_narg)) == 0) {
error = sy_call(callp, curlwp, args, rval);
}
- KASSERT(exptr == pcb->framep);
TDB(("return %s pc %lx, psl %lx, sp %lx, pid %d, err %d r0 %d, r1 %d, "
- "frame %p\n", syscallnames[exptr->code], exptr->pc, exptr->psl,
- exptr->sp, p->p_pid, error, rval[0], rval[1], exptr));
+ "tf %p\n", syscallnames[tf->tf_code], tf->tf_pc, tf->tf_psl,
+ tf->tf_sp, p->p_pid, error, rval[0], rval[1], exptr));
bad:
switch (error) {
case 0:
- exptr->r1 = rval[1];
- exptr->r0 = rval[0];
- exptr->psl &= ~PSL_C;
+ tf->tf_r1 = rval[1];
+ tf->tf_r0 = rval[0];
+ tf->tf_psl &= ~PSL_C;
break;
case EJUSTRETURN:
@@ -137,28 +134,27 @@
case ERESTART:
/* assumes CHMK $n was used */
- exptr->pc -= (exptr->code > 63 ? 4 : 2);
+ tf->tf_pc -= (tf->tf_code > 63 ? 4 : 2);
break;
default:
- exptr->r0 = error;
- exptr->psl |= PSL_C;
+ tf->tf_r0 = error;
+ tf->tf_psl |= PSL_C;
break;
}
if (__predict_false(p->p_trace_enabled)
&& __predict_true(!(callp->sy_flags & SYCALL_INDIRECT)))
- trace_exit(frame->code, rval, error);
+ trace_exit(tf->tf_code, rval, error);
- userret(l, frame, oticks);
+ userret(l, tf, oticks);
}
void
child_return(void *arg)
{
struct lwp *l = arg;
- struct pcb *pcb = lwp_getpcb(l);
- userret(l, pcb->framep, 0);
+ userret(l, l->l_md.md_utf, 0);
ktrsysret(SYS_fork, 0, 0);
}
Index: src/sys/arch/vax/vax/trap.c
diff -u src/sys/arch/vax/vax/trap.c:1.127 src/sys/arch/vax/vax/trap.c:1.128
--- src/sys/arch/vax/vax/trap.c:1.127 Fri Mar 4 22:25:30 2011
+++ src/sys/arch/vax/vax/trap.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.127 2011/03/04 22:25:30 joerg Exp $ */
+/* $NetBSD: trap.c,v 1.128 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -33,7 +33,7 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.127 2011/03/04 22:25:30 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.128 2011/07/03 02:18:21 matt Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -90,35 +90,30 @@
};
int no_traps = 18;
-#define USERMODE_P(framep) ((((framep)->psl) & (PSL_U)) == PSL_U)
+#define USERMODE_P(tf) ((((tf)->tf_psl) & (PSL_U)) == PSL_U)
void
-trap(struct trapframe *frame)
+trap(struct trapframe *tf)
{
- u_int sig = 0, type = frame->trap, code = 0;
+ u_int sig = 0, type = tf->tf_trap, code = 0;
u_int rv, addr;
bool trapsig = true;
- const bool usermode = USERMODE_P(frame);
- struct lwp *l;
- struct proc *p;
- struct pcb *pcb;
+ const bool usermode = USERMODE_P(tf);
+ struct lwp * const l = curlwp;
+ struct proc * const p = l->l_proc;
+ struct pcb * const pcb = lwp_getpcb(l);
u_quad_t oticks = 0;
struct vmspace *vm;
struct vm_map *map;
vm_prot_t ftype;
- void *onfault;
+ void *onfault = pcb->pcb_onfault;
- l = curlwp;
- KASSERT(l != NULL);
- pcb = lwp_getpcb(l);
- onfault = pcb->pcb_onfault;
- p = l->l_proc;
KASSERT(p != NULL);
curcpu()->ci_data.cpu_ntrap++;
if (usermode) {
type |= T_USER;
oticks = p->p_sticks;
- pcb->framep = frame;
+ l->l_md.md_utf = tf;
LWP_CACHE_CREDS(l, p);
}
@@ -126,26 +121,26 @@
#ifdef TRAPDEBUG
-if(frame->trap==7) goto fram;
+if(tf->tf_trap==7) goto fram;
if(faultdebug)printf("Trap: type %lx, code %lx, pc %lx, psl %lx\n",
- frame->trap, frame->code, frame->pc, frame->psl);
+ tf->tf_trap, tf->tf_code, tf->tf_pc, tf->tf_psl);
fram:
#endif
switch (type) {
default:
#ifdef DDB
- kdb_trap(frame);
+ kdb_trap(tf);
#endif
panic("trap: type %x, code %x, pc %x, psl %x",
- (u_int)frame->trap, (u_int)frame->code,
- (u_int)frame->pc, (u_int)frame->psl);
+ (u_int)tf->tf_trap, (u_int)tf->tf_code,
+ (u_int)tf->tf_pc, (u_int)tf->tf_psl);
case T_KSPNOTVAL:
panic("%d.%d (%s): KSP invalid %#x@%#x pcb %p fp %#x psl %#x)",
p->p_pid, l->l_lid, l->l_name ? l->l_name : "??",
- mfpr(PR_KSP), (u_int)frame->pc, pcb,
- (u_int)frame->fp, (u_int)frame->psl);
+ mfpr(PR_KSP), (u_int)tf->tf_pc, pcb,
+ (u_int)tf->tf_fp, (u_int)tf->tf_psl);
case T_TRANSFLT|T_USER:
case T_TRANSFLT:
@@ -165,7 +160,7 @@
case T_PTELEN|T_USER: /* Page table length exceeded */
case T_ACCFLT|T_USER:
- if (frame->code < 0) { /* Check for kernel space */
+ if (tf->tf_code < 0) { /* Check for kernel space */
sig = SIGSEGV;
code = SEGV_ACCERR;
break;
@@ -181,10 +176,10 @@
*/
{
extern const uint8_t cas32_ras_start[], cas32_ras_end[];
- if (frame->code == CASMAGIC
- && frame->pc >= (uintptr_t) cas32_ras_start
- && frame->pc < (uintptr_t) cas32_ras_end) {
- frame->pc = (uintptr_t) cas32_ras_start;
+ if (tf->tf_code == CASMAGIC
+ && tf->tf_pc >= (uintptr_t) cas32_ras_start
+ && tf->tf_pc < (uintptr_t) cas32_ras_end) {
+ tf->tf_pc = (uintptr_t) cas32_ras_start;
trapsig = false;
break;
}
@@ -194,13 +189,13 @@
case T_ACCFLT:
#ifdef TRAPDEBUG
if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
- frame->trap, frame->code, frame->pc, frame->psl);
+ tf->tf_trap, tf->tf_code, tf->tf_pc, tf->tf_psl);
#endif
#ifdef DIAGNOSTIC
if (p == 0)
panic("trap: access fault: addr %lx code %lx",
- frame->pc, frame->code);
- if (frame->psl & PSL_IS)
+ tf->tf_pc, tf->tf_code);
+ if (tf->tf_psl & PSL_IS)
panic("trap: pflt on IS");
#endif
@@ -211,8 +206,8 @@
* because we must check for PTE pages anyway we don't
* bother doing it here.
*/
- addr = trunc_page(frame->code);
- if (!usermode && (frame->code < 0)) {
+ addr = trunc_page(tf->tf_code);
+ if (!usermode && (tf->tf_code < 0)) {
vm = NULL;
map = kernel_map;
@@ -221,13 +216,13 @@
map = &vm->vm_map;
}
- if (frame->trap & T_WRITE)
+ if (tf->tf_trap & T_WRITE)
ftype = VM_PROT_WRITE;
else
ftype = VM_PROT_READ;
if ((usermode) && (l->l_flag & LW_SA)) {
- l->l_savp->savp_faultaddr = (vaddr_t)frame->code;
+ l->l_savp->savp_faultaddr = (vaddr_t)tf->tf_code;
l->l_pflag |= LP_SA_PAGEFAULT;
}
@@ -237,13 +232,14 @@
if (rv != 0) {
if (!usermode) {
if (onfault) {
- frame->pc = (unsigned)onfault;
- frame->psl &= ~PSL_FPD;
- frame->r0 = rv;
+ pcb->pcb_onfault = NULL;
+ tf->tf_pc = (unsigned)onfault;
+ tf->tf_psl &= ~PSL_FPD;
+ tf->tf_r0 = rv;
return;
}
- panic("Segv in kernel mode: pc %x addr %x",
- (u_int)frame->pc, (u_int)frame->code);
+ panic("Segv in kernel mode: pc %#lx addr %#lx",
+ tf->tf_pc, tf->tf_code);
}
code = SEGV_ACCERR;
if (rv == ENOMEM) {
@@ -276,7 +272,7 @@
case T_TRCTRAP|T_USER:
sig = SIGTRAP;
code = TRAP_TRACE;
- frame->psl &= ~PSL_T;
+ tf->tf_psl &= ~PSL_T;
break;
case T_PRIVINFLT|T_USER:
@@ -298,7 +294,7 @@
case T_ARITHFLT|T_USER:
sig = SIGFPE;
- switch (frame->code) {
+ switch (tf->tf_code) {
case ATRP_INTOVF: code = FPE_INTOVF; break;
case ATRP_INTDIV: code = FPE_INTDIV; break;
case ATRP_FLTOVF: code = FPE_FLTOVF; break;
@@ -325,7 +321,7 @@
case T_KDBTRAP:
case T_KDBTRAP|T_USER:
case T_TRCTRAP:
- kdb_trap(frame);
+ kdb_trap(tf);
return;
#endif
}
@@ -333,12 +329,12 @@
ksiginfo_t ksi;
if ((sig == SIGSEGV || sig == SIGILL) && cpu_printfataltraps)
printf("pid %d.%d (%s): sig %d: type %lx, code %lx, pc %lx, psl %lx\n",
- p->p_pid, l->l_lid, p->p_comm, sig, frame->trap,
- frame->code, frame->pc, frame->psl);
+ p->p_pid, l->l_lid, p->p_comm, sig, tf->tf_trap,
+ tf->tf_code, tf->tf_pc, tf->tf_psl);
KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = sig;
- ksi.ksi_trap = frame->trap;
- ksi.ksi_addr = (void *)frame->code;
+ ksi.ksi_trap = tf->tf_trap;
+ ksi.ksi_addr = (void *)tf->tf_code;
ksi.ksi_code = code;
/*
@@ -352,8 +348,8 @@
*
* XXX this is gross -- miod
*/
- if (type == (T_ARITHFLT | T_USER) && (frame->code & 8))
- frame->pc = skip_opcode(frame->pc);
+ if (type == (T_ARITHFLT | T_USER) && (tf->tf_code & 8))
+ tf->tf_pc = skip_opcode(tf->tf_pc);
trapsignal(l, &ksi);
}
@@ -361,23 +357,20 @@
if (!usermode)
return;
- userret(l, frame, oticks);
+ userret(l, tf, oticks);
}
void
setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack)
{
- struct trapframe *exptr;
- struct pcb *pcb;
+ struct trapframe * const tf = l->l_md.md_utf;
- pcb = lwp_getpcb(l);
- exptr = pcb->framep;
- exptr->pc = pack->ep_entry + 2;
- exptr->sp = stack;
- exptr->r6 = stack; /* for ELF */
- exptr->r7 = 0; /* for ELF */
- exptr->r8 = 0; /* for ELF */
- exptr->r9 = l->l_proc->p_psstrp; /* for ELF */
+ tf->tf_pc = pack->ep_entry + 2;
+ tf->tf_sp = stack;
+ tf->tf_r6 = stack; /* for ELF */
+ tf->tf_r7 = 0; /* for ELF */
+ tf->tf_r8 = 0; /* for ELF */
+ tf->tf_r9 = l->l_proc->p_psstrp; /* for ELF */
}
@@ -387,9 +380,8 @@
void
startlwp(void *arg)
{
- ucontext_t *uc = arg;
- lwp_t *l = curlwp;
- struct pcb *pcb;
+ ucontext_t * const uc = arg;
+ lwp_t * const l = curlwp;
int error;
error = cpu_setmcontext(l, &uc->uc_mcontext, uc->uc_flags);
@@ -397,17 +389,14 @@
kmem_free(uc, sizeof(ucontext_t));
/* XXX - profiling spoiled here */
- pcb = lwp_getpcb(l);
- userret(l, pcb->framep, l->l_proc->p_sticks);
+ userret(l, l->l_md.md_utf, l->l_proc->p_sticks);
}
void
upcallret(struct lwp *l)
{
- struct pcb *pcb;
/* XXX - profiling */
- pcb = lwp_getpcb(l);
- userret(l, pcb->framep, l->l_proc->p_sticks);
+ userret(l, l->l_md.md_utf, l->l_proc->p_sticks);
}
Index: src/sys/arch/vax/vax/vm_machdep.c
diff -u src/sys/arch/vax/vax/vm_machdep.c:1.115 src/sys/arch/vax/vax/vm_machdep.c:1.116
--- src/sys/arch/vax/vax/vm_machdep.c:1.115 Thu Apr 14 08:17:27 2011
+++ src/sys/arch/vax/vax/vm_machdep.c Sun Jul 3 02:18:21 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.115 2011/04/14 08:17:27 matt Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.116 2011/07/03 02:18:21 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.115 2011/04/14 08:17:27 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.116 2011/07/03 02:18:21 matt Exp $");
#include "opt_execfmt.h"
#include "opt_compat_ultrix.h"
@@ -84,14 +84,10 @@
cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
void (*func)(void *), void *arg)
{
- struct pcb *pcb1, *pcb2;
- struct trapframe *tf;
struct callsframe *cf;
- vaddr_t uv;
extern int sret; /* Return address in trap routine */
- pcb1 = lwp_getpcb(l1);
- pcb2 = lwp_getpcb(l2);
+ struct pcb * const pcb2 = lwp_getpcb(l2);
#ifdef DIAGNOSTIC
/*
@@ -109,10 +105,10 @@
/*
* Copy the trap frame.
*/
- uv = uvm_lwp_getuarea(l2);
- tf = (struct trapframe *)(uv + USPACE) - 1;
- pcb2->framep = tf;
- *tf = *(struct trapframe *)pcb1->framep;
+ const vaddr_t uv = uvm_lwp_getuarea(l2);
+ struct trapframe * const tf = (struct trapframe *)(uv + USPACE) - 1;
+ l2->l_md.md_utf = tf;
+ *tf = *l1->l_md.md_utf;
/*
* Activate address space for the new process. The PTEs have
@@ -161,45 +157,43 @@
* If specified, give the child a different stack.
*/
if (stack != NULL)
- tf->sp = (uintptr_t)stack + stacksize;
+ tf->tf_sp = (uintptr_t)stack + stacksize;
/*
* Set the last return information after fork().
* This is only interesting if the child will return to userspace,
* but doesn't hurt otherwise.
*/
- tf->r0 = l1->l_proc->p_pid; /* parent pid. (shouldn't be needed) */
- tf->r1 = 1;
- tf->psl = PSL_U|PSL_PREVU;
+ tf->tf_r0 = l1->l_proc->p_pid; /* parent pid. (shouldn't be needed) */
+ tf->tf_r1 = 1;
+ tf->tf_psl = PSL_U|PSL_PREVU;
}
vaddr_t
cpu_lwp_pc(struct lwp *l)
{
- struct pcb * const pcb = lwp_getpcb(l);
- return pcb->PC;
+ return l->l_md.md_utf->tf_pc;
}
#if KERN_SA > 0
void
cpu_setfunc(struct lwp *l, void (*func)(void *), void *arg)
{
- struct pcb *pcb = lwp_getpcb(l);
- struct trapframe *tf;
+ struct trapframe * const tf = l->l_md.md_utf;
struct callsframe *cf;
extern int sret;
panic("cpu_setfunc() called\n");
- tf = (struct trapframe *)(uvm_lwp_getuarea(l) + USPACE) - 1;
cf = (struct callsframe *)tf - 1;
cf->ca_cond = 0;
- cf->ca_maskpsw = 0x20000000;
+ cf->ca_maskpsw = 0x20000000; /* CALLS, no saved registers */
cf->ca_pc = (unsigned)&sret;
cf->ca_argno = 1;
cf->ca_arg1 = (long)arg;
- pcb->framep = tf;
+ struct pcb * const pcb = lwp_getpcb(l);
+
pcb->KSP = (long)cf;
pcb->FP = (long)cf;
pcb->AP = (long)&cf->ca_argno;