summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/alpha/trap.c61
-rw-r--r--sys/arch/alpha/include/cpu.h7
-rw-r--r--sys/arch/amd64/include/cpu.h7
-rw-r--r--sys/arch/arm/arm/ast.c32
-rw-r--r--sys/arch/arm/arm/fault.c6
-rw-r--r--sys/arch/arm/arm/syscall.c20
-rw-r--r--sys/arch/arm/arm/undefined.c54
-rw-r--r--sys/arch/arm/include/cpu.h4
-rw-r--r--sys/arch/i386/i386/trap.c37
-rw-r--r--sys/arch/i386/include/cpu.h7
-rw-r--r--sys/arch/m88k/include/cpu.h12
-rw-r--r--sys/arch/m88k/include/db_machdep.h11
-rw-r--r--sys/arch/m88k/m88k/trap.c48
-rw-r--r--sys/arch/mips64/include/cpu.h7
-rw-r--r--sys/arch/mips64/mips64/interrupt.c28
-rw-r--r--sys/arch/mips64/mips64/trap.c60
-rw-r--r--sys/arch/solbourne/solbourne/trap.c50
-rw-r--r--sys/arch/sparc/include/cpu.h7
-rw-r--r--sys/arch/sparc/sparc/trap.c54
-rw-r--r--sys/arch/sparc64/include/cpu.h7
-rw-r--r--sys/arch/sparc64/sparc64/trap.c64
-rw-r--r--sys/arch/vax/include/cpu.h10
-rw-r--r--sys/arch/vax/vax/trap.c35
23 files changed, 170 insertions, 458 deletions
diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c
index 9a7c1bcb91e..99172106797 100644
--- a/sys/arch/alpha/alpha/trap.c
+++ b/sys/arch/alpha/alpha/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.51 2006/06/19 20:23:53 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.52 2006/12/24 20:30:33 miod Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */
/*-
@@ -126,7 +126,7 @@
#include <compat/osf1/osf1_syscall.h>
#endif
-void userret(struct proc *, u_int64_t, u_quad_t);
+void userret(struct proc *);
#ifndef SMALL_KERNEL
@@ -184,13 +184,9 @@ trap_init()
* trap and syscall.
*/
void
-userret(p, pc, oticks)
- register struct proc *p;
- u_int64_t pc;
- u_quad_t oticks;
+userret(struct proc *p)
{
int sig;
- struct cpu_info *ci = curcpu();
/* Do any deferred user pmap operations. */
PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));
@@ -198,30 +194,8 @@ userret(p, pc, oticks)
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
- p->p_priority = p->p_usrpri;
- if (ci->ci_want_resched) {
- /*
- * We are being preempted.
- */
- preempt(NULL);
-
- ci = curcpu();
-
- PMAP_USERRET(vm_map_pmap(&p->p_vmspace->vm_map));
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
-
- /*
- * If profiling, charge recent system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
- addupc_task(p, pc, (int)(p->p_sticks - oticks) * psratio);
- }
-
- curpriority = p->p_priority;
+ curpriority = p->p_priority = p->p_usrpri;
}
#ifdef DEBUG
@@ -292,7 +266,6 @@ trap(a0, a1, a2, entry, framep)
struct proc *p;
int i;
u_int64_t ucode;
- u_quad_t sticks;
int user;
#if defined(DDB)
int call_debugger = 1;
@@ -308,7 +281,6 @@ trap(a0, a1, a2, entry, framep)
ucode = 0;
user = (framep->tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) != 0;
if (user) {
- sticks = p->p_sticks;
p->p_md.md_tf = framep;
#if 0
/* This is to catch some weird stuff on the UDB (mj) */
@@ -318,8 +290,6 @@ trap(a0, a1, a2, entry, framep)
printtrap(a0, a1, a2, entry, framep, 1, user);
}
#endif
- } else {
- sticks = 0; /* XXX bogus -Wuninitialized warning */
}
switch (entry) {
@@ -552,7 +522,7 @@ do_fault:
trapsignal(p, i, ucode, typ, sv);
out:
if (user)
- userret(p, framep->tf_regs[FRAME_PC], sticks);
+ userret(p);
return;
dopanic:
@@ -595,7 +565,6 @@ syscall(code, framep)
struct proc *p;
int error, numsys;
u_int64_t opc;
- u_quad_t sticks;
u_long rval[2];
u_long args[10]; /* XXX */
u_int hidden, nargs;
@@ -603,15 +572,10 @@ syscall(code, framep)
extern struct emul emul_osf1;
#endif
-#if notdef /* can't happen, ever. */
- if ((framep->tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) == 0)
- panic("syscall");
-#endif
uvmexp.syscalls++;
p = curproc;
p->p_md.md_tf = framep;
opc = framep->tf_regs[FRAME_PC] - 4;
- sticks = p->p_sticks;
callp = p->p_emul->e_sysent;
numsys = p->p_emul->e_nsysent;
@@ -711,7 +675,7 @@ syscall(code, framep)
#ifdef SYSCALL_DEBUG
scdebug_ret(p, code, error, rval);
#endif
- userret(p, framep->tf_regs[FRAME_PC], sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p, code, error, rval[0]);
@@ -735,7 +699,7 @@ child_return(arg)
framep->tf_regs[FRAME_A4] = 0;
framep->tf_regs[FRAME_A3] = 0;
- userret(p, framep->tf_regs[FRAME_PC], 0);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p,
@@ -789,17 +753,17 @@ void
ast(framep)
struct trapframe *framep;
{
- register struct proc *p;
- u_quad_t sticks;
+ struct proc *p;
curcpu()->ci_astpending = 0;
p = curproc;
- sticks = p->p_sticks;
p->p_md.md_tf = framep;
+#ifdef DIAGNOSTIC
if ((framep->tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) == 0)
panic("ast and not user");
+#endif
uvmexp.softs++;
@@ -808,7 +772,10 @@ ast(framep)
ADDUPROF(p);
}
- userret(p, framep->tf_regs[FRAME_PC], sticks);
+ if (curcpu()->ci_want_resched)
+ preempt(NULL);
+
+ userret(p);
}
/*
diff --git a/sys/arch/alpha/include/cpu.h b/sys/arch/alpha/include/cpu.h
index c793d217035..ef4b6b09503 100644
--- a/sys/arch/alpha/include/cpu.h
+++ b/sys/arch/alpha/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.25 2004/06/13 21:49:12 niklas Exp $ */
+/* $OpenBSD: cpu.h,v 1.26 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: cpu.h,v 1.45 2000/08/21 02:03:12 thorpej Exp $ */
/*-
@@ -266,6 +266,11 @@ struct clockframe {
#define CLKF_INTR(framep) (curcpu()->ci_intrdepth)
/*
+ * This is used during profiling to integrate system time.
+ */
+#define PROC_PC(p) ((p)->p_md.md_tf->tf_regs[FRAME_PC])
+
+/*
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
*/
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index af11a651b00..cf4f6ced4a6 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.22 2006/12/20 22:48:29 gwk Exp $ */
+/* $OpenBSD: cpu.h,v 1.23 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -218,6 +218,11 @@ extern u_int32_t cpus_attached;
#define CLKF_INTR(frame) (curcpu()->ci_idepth > 1)
/*
+ * This is used during profiling to integrate system time.
+ */
+#define PROC_PC(p) ((p)->p_md.md_regs->tf_rip)
+
+/*
* Give a profiling tick to the current process when the user profiling
* buffer pages are invalid. On the i386, request an ast to send us
* through trap(), marking the proc as needing a profiling tick.
diff --git a/sys/arch/arm/arm/ast.c b/sys/arch/arm/arm/ast.c
index 3e2ca77e181..8ba315e3687 100644
--- a/sys/arch/arm/arm/ast.c
+++ b/sys/arch/arm/arm/ast.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ast.c,v 1.5 2005/11/19 01:59:36 aaron Exp $ */
+/* $OpenBSD: ast.c,v 1.6 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: ast.c,v 1.6 2003/10/31 16:44:34 cl Exp $ */
/*
@@ -66,13 +66,13 @@
/*
* Prototypes
*/
-void ast (struct trapframe *);
+void ast(struct trapframe *);
-int want_resched = 0;
+int want_resched;
extern int astpending;
void
-userret(struct proc *p, u_int32_t pc, quad_t oticks)
+userret(struct proc *p)
{
int sig;
@@ -80,27 +80,7 @@ userret(struct proc *p, u_int32_t pc, quad_t oticks)
while ((sig = (CURSIG(p))) != 0)
postsig(sig);
- p->p_priority = p->p_usrpri;
-
- if (want_resched) {
- /*
- * We're being preempted.
- */
- preempt(NULL);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
-
- /*
- * If profiling, charge recent system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, pc, (int)(p->p_sticks - oticks) * psratio);
- }
-
- curpriority = p->p_priority;
+ curpriority = p->p_priority = p->p_usrpri;
}
@@ -142,7 +122,7 @@ ast(struct trapframe *tf)
if (want_resched)
preempt(NULL);
- userret(p, tf->tf_pc, p->p_sticks); /* XXX */
+ userret(p);
}
/* End of ast.c */
diff --git a/sys/arch/arm/arm/fault.c b/sys/arch/arm/arm/fault.c
index 0ffaf4b4699..c2c51aa3f15 100644
--- a/sys/arch/arm/arm/fault.c
+++ b/sys/arch/arm/arm/fault.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fault.c,v 1.8 2006/05/26 17:06:39 miod Exp $ */
+/* $OpenBSD: fault.c,v 1.9 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: fault.c,v 1.46 2004/01/21 15:39:21 skrll Exp $ */
/*
@@ -440,7 +440,7 @@ do_trapsignal:
out:
/* If returning to user mode, make sure to invoke userret() */
if (user)
- userret(p, tf->tf_pc, p->p_sticks);
+ userret(p);
}
/*
@@ -767,7 +767,7 @@ prefetch_abort_handler(trapframe_t *tf)
trapsignal(p, SIGSEGV, 0, SEGV_MAPERR, sv);
out:
- userret(p, tf->tf_pc, p->p_sticks);
+ userret(p);
}
/*
diff --git a/sys/arch/arm/arm/syscall.c b/sys/arch/arm/arm/syscall.c
index 8a4903d1d69..bcbde5ed403 100644
--- a/sys/arch/arm/arm/syscall.c
+++ b/sys/arch/arm/arm/syscall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.c,v 1.6 2005/09/15 21:16:33 miod Exp $ */
+/* $OpenBSD: syscall.c,v 1.7 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: syscall.c,v 1.24 2003/11/14 19:03:17 scw Exp $ */
/*-
@@ -115,14 +115,12 @@ swi_handler(trapframe_t *frame)
struct proc *p = curproc;
u_int32_t insn;
union sigval sv;
- u_quad_t sticks;
/*
* Enable interrupts if they were enabled before the exception.
* Since all syscalls *should* come from user mode it will always
* be safe to enable them, but check anyway.
*/
- sticks = p->p_sticks;
#ifdef acorn26
if ((frame->tf_r15 & R15_IRQ_DISABLE) == 0)
int_on();
@@ -135,6 +133,8 @@ swi_handler(trapframe_t *frame)
frame->tf_pc += INSN_SIZE;
#endif
+ p->p_addr->u_pcb.pcb_tf = frame;
+
/*
* Make sure the program counter is correctly aligned so we
* don't take an alignment fault trying to read the opcode.
@@ -143,7 +143,7 @@ swi_handler(trapframe_t *frame)
/* Give the user an illegal instruction signal. */
sv.sival_ptr = (u_int32_t *)(u_int32_t)(frame->tf_pc-INSN_SIZE);
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
- userret(p, frame->tf_pc, p->p_sticks);
+ userret(p);
return;
}
@@ -154,8 +154,6 @@ swi_handler(trapframe_t *frame)
insn = *(u_int32_t *)((frame->tf_r15 & R15_PC) - INSN_SIZE);
#endif
- p->p_addr->u_pcb.pcb_tf = frame;
-
#ifdef CPU_ARM7
/*
* This code is only needed if we are including support for the ARM7
@@ -176,7 +174,7 @@ swi_handler(trapframe_t *frame)
if ((insn & 0x0f000000) != 0x0f000000) {
frame->tf_pc -= INSN_SIZE;
curcpu()->ci_arm700bugcount.ev_count++;
- userret(l, frame->tf_pc, p->p_sticks);
+ userret(p);
return;
}
#endif /* CPU_ARM7 */
@@ -213,7 +211,7 @@ syscall(struct trapframe *frame, struct proc *p, u_int32_t insn)
break;
}
- userret(p, frame->tf_pc, p->p_sticks);
+ userret(p);
return;
case 0x000000: /* Old unofficial NetBSD range. */
case SWI_OS_NETBSD: /* New official NetBSD range. */
@@ -223,7 +221,7 @@ syscall(struct trapframe *frame, struct proc *p, u_int32_t insn)
/* Undefined so illegal instruction */
sv.sival_ptr = (u_int32_t *)(frame->tf_pc - INSN_SIZE);
trapsignal(p, SIGILL, 0, ILL_ILLOPN, sv);
- userret(p, frame->tf_pc, p->p_sticks);
+ userret(p);
return;
}
@@ -316,7 +314,7 @@ syscall(struct trapframe *frame, struct proc *p, u_int32_t insn)
#ifdef SYSCALL_DEBUG
scdebug_ret(p, code, orig_error, rval);
#endif
- userret(p, frame->tf_pc, p->p_sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p, code, orig_error, rval[0]);
@@ -337,7 +335,7 @@ child_return(arg)
frame->tf_r15 &= ~R15_FLAG_C; /* carry bit */
#endif
- userret(p, frame->tf_pc, 0);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
diff --git a/sys/arch/arm/arm/undefined.c b/sys/arch/arm/arm/undefined.c
index 4a7bd500c9d..f93ea2c4844 100644
--- a/sys/arch/arm/arm/undefined.c
+++ b/sys/arch/arm/arm/undefined.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: undefined.c,v 1.2 2004/02/23 19:09:57 drahn Exp $ */
+/* $OpenBSD: undefined.c,v 1.3 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: undefined.c,v 1.22 2003/11/29 22:21:29 bjh21 Exp $ */
/*
@@ -45,8 +45,6 @@
* Created : 06/01/95
*/
-#define FAST_FPE
-
#include <sys/param.h>
#include <sys/malloc.h>
@@ -58,9 +56,6 @@
#include <sys/user.h>
#include <sys/syslog.h>
#include <sys/vmmeter.h>
-#ifdef FAST_FPE
-#include <sys/acct.h>
-#endif
#include <uvm/uvm_extern.h>
@@ -76,10 +71,6 @@
static int gdb_trapper(u_int, u_int, struct trapframe *, int);
-#ifdef FAST_FPE
-extern int want_resched;
-#endif
-
LIST_HEAD(, undefined_handler) undefined_handlers[MAX_COPROCS];
@@ -196,7 +187,7 @@ undefinedinstruction(trapframe_t *frame)
/* Give the user an illegal instruction signal. */
sv.sival_int = (u_int32_t) fault_pc;
trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv);
- userret(p, fault_pc, p->p_sticks);
+ userret(p);
return;
}
@@ -227,11 +218,6 @@ undefinedinstruction(trapframe_t *frame)
else
coprocessor = 0;
- /* Get the current proc structure or proc0 if there is none. */
-
- if ((p = curproc) == 0)
- p = &proc0;
-
#ifdef __PROG26
if ((frame->tf_r15 & R15_MODE) == R15_MODE_USR)
#else
@@ -291,41 +277,5 @@ undefinedinstruction(trapframe_t *frame)
if ((fault_code & FAULT_USER) == 0)
return;
-#ifdef FAST_FPE
- /* Optimised exit code */
- {
- int sig;
-
- /* take pending signals */
-
- while ((sig = (CURSIG(p))) != 0) {
- postsig(sig);
- }
-
- p->p_priority = p->p_usrpri;
-
- /*
- * Check for reschedule request, at the moment there is only
- * 1 ast so this code should always be run
- */
-
- if (want_resched) {
- /*
- * We are being preempted.
- */
- preempt(NULL);
- while ((sig = (CURSIG(p))) != 0) {
- postsig(sig);
- }
- }
-
- /* XXX
- curcpu()->ci_schedstate.spc_curpriority = p->p_priority;
- */
- }
-
-#else
userret(p);
- userret(p, frame->tf_pc, p->p_sticks);
-#endif
}
diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h
index d19b13c39e4..a7c423c420c 100644
--- a/sys/arch/arm/include/cpu.h
+++ b/sys/arch/arm/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.12 2006/01/17 20:30:12 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.13 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */
/*
@@ -287,7 +287,7 @@ struct pcb;
void savectx (struct pcb *pcb);
/* ast.c */
-void userret (register struct proc *p, u_int32_t pc, quad_t ticks);
+void userret (struct proc *p);
/* machdep.h */
void bootsync (int);
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c
index 1a293e75e86..f4f84c0a2f4 100644
--- a/sys/arch/i386/i386/trap.c
+++ b/sys/arch/i386/i386/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.79 2006/12/24 20:29:19 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.80 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
@@ -97,7 +97,7 @@ extern struct emul emul_aout;
#include "npx.h"
-static __inline void userret(struct proc *, int, u_quad_t);
+static __inline void userret(struct proc *);
void trap(struct trapframe);
int trapwrite(unsigned);
void syscall(struct trapframe);
@@ -107,31 +107,13 @@ void syscall(struct trapframe);
* trap and syscall.
*/
static __inline void
-userret(struct proc *p, int pc, u_quad_t oticks)
+userret(struct proc *p)
{
int sig;
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
- p->p_priority = p->p_usrpri;
- if (want_resched) {
- /*
- * We're being preempted.
- */
- preempt(NULL);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
-
- /*
- * If profiling, charge recent system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, pc, (int)(p->p_sticks - oticks) * psratio);
- }
p->p_cpu->ci_schedstate.spc_curpriority = p->p_priority;
}
@@ -179,7 +161,6 @@ trap(struct trapframe frame)
{
struct proc *p = curproc;
int type = frame.tf_trapno;
- u_quad_t sticks;
struct pcb *pcb = NULL;
extern char resume_iret[], resume_pop_ds[], resume_pop_es[],
resume_pop_fs[], resume_pop_gs[];
@@ -210,10 +191,8 @@ trap(struct trapframe frame)
if (!KERNELMODE(frame.tf_cs, frame.tf_eflags)) {
type |= T_USER;
- sticks = p->p_sticks;
p->p_md.md_regs = &frame;
- } else
- sticks = 0;
+ }
switch (type) {
@@ -586,7 +565,7 @@ trap(struct trapframe frame)
if ((type & T_USER) == 0)
return;
out:
- userret(p, frame.tf_eip, sticks);
+ userret(p);
}
/*
@@ -629,7 +608,6 @@ syscall(struct trapframe frame)
int orig_error, error, opc, nsys;
size_t argsize;
register_t code, args[8], rval[2];
- u_quad_t sticks;
#ifdef DIAGNOSTIC
int ocpl = lapic_tpr;
#endif
@@ -640,7 +618,6 @@ syscall(struct trapframe frame)
panic("syscall");
#endif
p = curproc;
- sticks = p->p_sticks;
p->p_md.md_regs = &frame;
opc = frame.tf_eip;
code = frame.tf_eax;
@@ -797,7 +774,7 @@ syscall(struct trapframe frame)
scdebug_ret(p, code, orig_error, rval);
KERNEL_PROC_UNLOCK(p);
#endif
- userret(p, frame.tf_eip, sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_PROC_LOCK(p);
@@ -826,7 +803,7 @@ child_return(void *arg)
KERNEL_PROC_UNLOCK(p);
- userret(p, tf->tf_eip, 0);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_PROC_LOCK(p);
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index 9cd4923d30f..b9ac96eca8a 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.85 2006/12/20 17:50:40 gwk Exp $ */
+/* $OpenBSD: cpu.h,v 1.86 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -215,6 +215,11 @@ extern void need_resched(struct cpu_info *);
#define CLKF_INTR(frame) (IDXSEL((frame)->if_cs) == GICODE_SEL)
/*
+ * This is used during profiling to integrate system time.
+ */
+#define PROC_PC(p) ((p)->p_md.md_regs->tf_eip)
+
+/*
* Give a profiling tick to the current process when the user profiling
* buffer pages are invalid. On the i386, request an ast to send us
* through trap(), marking the proc as needing a profiling tick.
diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h
index da423c0d2dd..3b7e7d57b6f 100644
--- a/sys/arch/m88k/include/cpu.h
+++ b/sys/arch/m88k/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.16 2006/11/29 12:26:13 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.17 2006/12/24 20:30:35 miod Exp $ */
/*
* Copyright (c) 1996 Nivas Madhur
* Copyright (c) 1992, 1993
@@ -202,6 +202,16 @@ extern int ssir;
#define aston(p) ((p)->p_md.md_astpending = 1)
/*
+ * This is used during profiling to integrate system time.
+ */
+#define PC_REGS(regs) \
+ (CPU_IS88110 ? ((regs)->exip & XIP_ADDR) : \
+ ((regs)->sxip & XIP_V ? (regs)->sxip & XIP_ADDR : \
+ ((regs)->snip & NIP_V ? (regs)->snip & NIP_ADDR : \
+ (regs)->sfip & FIP_ADDR)))
+#define PROC_PC(p) PC_REGS((struct reg *)((p)->p_md.md_tf))
+
+/*
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
*/
diff --git a/sys/arch/m88k/include/db_machdep.h b/sys/arch/m88k/include/db_machdep.h
index 1b0d690da46..af7904eabc7 100644
--- a/sys/arch/m88k/include/db_machdep.h
+++ b/sys/arch/m88k/include/db_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_machdep.h,v 1.10 2006/05/08 14:03:34 miod Exp $ */
+/* $OpenBSD: db_machdep.h,v 1.11 2006/12/24 20:30:35 miod Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1991 Carnegie Mellon University
@@ -41,15 +41,6 @@
#include <uvm/uvm_param.h>
-/*
- * Extract the real pc from the exception pipeline.
- */
-#define PC_REGS(regs) \
- (CPU_IS88110 ? ((regs)->exip & XIP_ADDR) : \
- ((regs)->sxip & XIP_V ? (regs)->sxip & XIP_ADDR : \
- ((regs)->snip & NIP_V ? (regs)->snip & NIP_ADDR : \
- (regs)->sfip & FIP_ADDR)))
-
#define SET_PC_REGS(regs, value) \
do { \
(regs)->sxip = (value); \
diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c
index 1eaf55d0c88..df8a7c94d2e 100644
--- a/sys/arch/m88k/m88k/trap.c
+++ b/sys/arch/m88k/m88k/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.36 2006/12/24 20:29:19 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.37 2006/12/24 20:30:35 miod Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
@@ -118,35 +118,15 @@ const char *pbus_exception_type[] = {
#endif
static inline void
-userret(struct proc *p, struct trapframe *frame, u_quad_t oticks)
+userret(struct proc *p)
{
int sig;
- struct cpu_info *cpu = curcpu();
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
- p->p_priority = p->p_usrpri;
- if (cpu->ci_want_resched) {
- /*
- * We're being preempted.
- */
- preempt(NULL);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
-
- /*
- * If profiling, charge recent system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, frame->tf_sxip & XIP_ADDR,
- (int)(p->p_sticks - oticks) * psratio);
- }
- cpu->ci_schedstate.spc_curpriority = p->p_priority;
+ curcpu()->ci_schedstate.spc_curpriority = p->p_priority = p->p_usrpri;
}
__dead void
@@ -198,7 +178,6 @@ void
m88100_trap(unsigned type, struct trapframe *frame)
{
struct proc *p;
- u_quad_t sticks = 0;
struct vm_map *map;
vaddr_t va, pcb_onfault;
vm_prot_t ftype;
@@ -221,7 +200,6 @@ m88100_trap(unsigned type, struct trapframe *frame)
p = &proc0;
if (USERMODE(frame->tf_epsr)) {
- sticks = p->p_sticks;
type += T_USER;
p->p_md.md_tf = frame; /* for ptrace/signals */
}
@@ -589,7 +567,7 @@ user_fault:
frame->tf_ipfsr = frame->tf_dpfsr = 0;
}
- userret(p, frame, sticks);
+ userret(p);
}
#endif /* M88100 */
@@ -598,7 +576,6 @@ void
m88110_trap(unsigned type, struct trapframe *frame)
{
struct proc *p;
- u_quad_t sticks = 0;
struct vm_map *map;
vaddr_t va, pcb_onfault;
vm_prot_t ftype;
@@ -623,7 +600,6 @@ m88110_trap(unsigned type, struct trapframe *frame)
p = &proc0;
if (USERMODE(frame->tf_epsr)) {
- sticks = p->p_sticks;
type += T_USER;
p->p_md.md_tf = frame; /* for ptrace/signals */
}
@@ -1102,7 +1078,7 @@ m88110_user_fault:
KERNEL_PROC_UNLOCK(p);
}
- userret(p, frame, sticks);
+ userret(p);
}
#endif /* M88110 */
@@ -1129,7 +1105,6 @@ m88100_syscall(register_t code, struct trapframe *tf)
struct proc *p;
int error;
register_t args[8], rval[2], *ap;
- u_quad_t sticks;
uvmexp.syscalls++;
@@ -1138,7 +1113,6 @@ m88100_syscall(register_t code, struct trapframe *tf)
callp = p->p_emul->e_sysent;
nsys = p->p_emul->e_nsysent;
- sticks = p->p_sticks;
p->p_md.md_tf = tf;
/*
@@ -1261,7 +1235,7 @@ bad:
scdebug_ret(p, code, error, rval);
KERNEL_PROC_UNLOCK(p);
#endif
- userret(p, tf, sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_PROC_LOCK(p);
@@ -1282,7 +1256,6 @@ m88110_syscall(register_t code, struct trapframe *tf)
struct proc *p;
int error;
register_t args[8], rval[2], *ap;
- u_quad_t sticks;
uvmexp.syscalls++;
@@ -1291,7 +1264,6 @@ m88110_syscall(register_t code, struct trapframe *tf)
callp = p->p_emul->e_sysent;
nsys = p->p_emul->e_nsysent;
- sticks = p->p_sticks;
p->p_md.md_tf = tf;
/*
@@ -1425,7 +1397,7 @@ bad:
scdebug_ret(p, code, error, rval);
KERNEL_PROC_UNLOCK(p);
#endif
- userret(p, tf, sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
KERNEL_PROC_LOCK(p);
@@ -1469,7 +1441,7 @@ child_return(arg)
#endif
KERNEL_PROC_UNLOCK(p);
- userret(p, tf, p->p_sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
@@ -1795,12 +1767,10 @@ cache_flush(struct trapframe *tf)
{
struct proc *p;
struct pmap *pmap;
- u_quad_t sticks;
if ((p = curproc) == NULL)
p = &proc0;
- sticks = p->p_sticks;
p->p_md.md_tf = tf;
pmap = vm_map_pmap(&p->p_vmspace->vm_map);
@@ -1809,5 +1779,5 @@ cache_flush(struct trapframe *tf)
tf->tf_snip = tf->tf_snip & ~NIP_E;
tf->tf_sfip = tf->tf_sfip & ~FIP_E;
- userret(p, tf, sticks);
+ userret(p);
}
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h
index 30a30fa6899..def5c9e20c4 100644
--- a/sys/arch/mips64/include/cpu.h
+++ b/sys/arch/mips64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.13 2006/11/29 12:26:13 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.14 2006/12/24 20:30:35 miod Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -334,6 +334,11 @@ extern int int_nest_cntr;
#define CLKF_INTR(framep) (int_nest_cntr > 0)
/*
+ * This is used during profiling to integrate system time.
+ */
+#define PROC_PC(p) ((p)->p_md.md_regs->pc)
+
+/*
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
*/
diff --git a/sys/arch/mips64/mips64/interrupt.c b/sys/arch/mips64/mips64/interrupt.c
index b7c92014fc9..59d1aed120d 100644
--- a/sys/arch/mips64/mips64/interrupt.c
+++ b/sys/arch/mips64/mips64/interrupt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interrupt.c,v 1.21 2006/05/11 19:57:45 miod Exp $ */
+/* $OpenBSD: interrupt.c,v 1.22 2006/12/24 20:30:35 miod Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -124,8 +124,8 @@ int netisr;
* CPU is done. Instead a fixed mask is set and used throughout.
*/
-void interrupt (struct trap_frame *);
-void softintr (void);
+void interrupt(struct trap_frame *);
+void softintr(void);
/*
* Handle an interrupt. Both kernel and user mode is handled here.
@@ -256,7 +256,6 @@ set_intr(int pri, intrmask_t mask,
/*
* This is called from MipsUserIntr() if astpending is set.
- * This is very similar to the tail of trap().
*/
void
softintr()
@@ -265,26 +264,21 @@ softintr()
int sig;
uvmexp.softs++;
- /* take pending signals */
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- p->p_priority = p->p_usrpri;
+
astpending = 0;
if (p->p_flag & P_OWEUPC) {
p->p_flag &= ~P_OWEUPC;
ADDUPROF(p);
}
- if (want_resched) {
- /*
- * We're being preempted.
- */
+ if (want_resched)
preempt(NULL);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
- curpriority = p->p_priority;
-}
+ /* inline userret(p) */
+
+ while ((sig = CURSIG(p)) != 0) /* take pending signals */
+ postsig(sig);
+ curpriority = p->p_priority = p->p_usrpri;
+}
intrmask_t intem = 0x0;
diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c
index aeefc98c6a3..cb812d565e8 100644
--- a/sys/arch/mips64/mips64/trap.c
+++ b/sys/arch/mips64/mips64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.30 2006/05/31 20:19:39 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.31 2006/12/24 20:30:35 miod Exp $ */
/* tracked to 1.23 */
/*
@@ -157,6 +157,18 @@ int cpu_singlestep(struct proc *);
#endif
u_long MipsEmulateBranch(struct trap_frame *, long, int, u_int);
+static __inline__ void
+userret(struct proc *p)
+{
+ int sig;
+
+ /* take pending signals */
+ while ((sig = CURSIG(p)) != 0)
+ postsig(sig);
+
+ curpriority = p->p_priority = p->p_usrpri;
+}
+
/*
* Handle an exception.
* In the case of a kernel trap, we return the pc where to resume if
@@ -169,7 +181,6 @@ trap(trapframe)
int type, i;
unsigned ucode = 0;
struct proc *p = curproc;
- u_quad_t sticks;
vm_prot_t ftype;
extern vaddr_t onfault_table[];
int onfault;
@@ -181,7 +192,6 @@ trap(trapframe)
type = (trapframe->cause & CR_EXC_CODE) >> CR_EXC_CODE_SHIFT;
if (USERMODE(trapframe->sr)) {
type |= T_USER;
- sticks = p->p_sticks;
}
/*
@@ -793,27 +803,7 @@ out:
/*
* Note: we should only get here if returning to user mode.
*/
- /* take pending signals */
- while ((i = CURSIG(p)) != 0)
- postsig(i);
- p->p_priority = p->p_usrpri;
- astpending = 0;
- if (want_resched) {
- preempt(NULL);
- while ((i = CURSIG(p)) != 0)
- postsig(i);
- }
-
- /*
- * If profiling, charge system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, trapframe->pc, (int)(p->p_sticks - sticks) * psratio);
- }
-
- curpriority = p->p_priority;
+ userret(p);
return (trapframe->pc);
}
@@ -823,33 +813,13 @@ child_return(arg)
{
struct proc *p = arg;
struct trap_frame *trapframe;
- int i;
trapframe = p->p_md.md_regs;
trapframe->v0 = 0;
trapframe->v1 = 1;
trapframe->a3 = 0;
- /* take pending signals */
- while ((i = CURSIG(p)) != 0)
- postsig(i);
- p->p_priority = p->p_usrpri;
- astpending = 0;
- if (want_resched) {
- preempt(NULL);
- while ((i = CURSIG(p)) != 0)
- postsig(i);
- }
-
-#if 0 /* Need sticks */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, trapframe->pc, (int)(p->p_sticks - sticks) * psratio);
- }
-#endif
-
- curpriority = p->p_priority;
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
diff --git a/sys/arch/solbourne/solbourne/trap.c b/sys/arch/solbourne/solbourne/trap.c
index 61ff9bb4643..e2ac576e8ad 100644
--- a/sys/arch/solbourne/solbourne/trap.c
+++ b/sys/arch/solbourne/solbourne/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.7 2006/12/24 20:29:19 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.8 2006/12/24 20:30:35 miod Exp $ */
/* OpenBSD: trap.c,v 1.42 2004/12/06 20:12:25 miod Exp */
/*
@@ -202,7 +202,7 @@ const char *trap_type[] = {
#define N_TRAP_TYPES (sizeof trap_type / sizeof *trap_type)
-static __inline void userret(struct proc *, int, u_quad_t);
+static __inline void userret(struct proc *);
void trap(unsigned, int, int, struct trapframe *);
static __inline void share_fpu(struct proc *, struct trapframe *);
void mem_access_fault(unsigned, int, u_int, int, int, struct trapframe *);
@@ -217,43 +217,15 @@ int want_ast = 0;
* trap, mem_access_fault, and syscall.
*/
static __inline void
-userret(p, pc, oticks)
- struct proc *p;
- int pc;
- u_quad_t oticks;
+userret(struct proc *p)
{
int sig;
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
- p->p_priority = p->p_usrpri;
- if (want_ast) {
- want_ast = 0;
- if (p->p_flag & P_OWEUPC) {
- p->p_flag &= ~P_OWEUPC;
- ADDUPROF(p);
- }
- }
- if (want_resched) {
- /*
- * We're being preempted.
- */
- preempt(NULL);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
-
- /*
- * If profiling, charge recent system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, pc, (int)(p->p_sticks - oticks) * psratio);
- }
- curpriority = p->p_priority;
+ curpriority = p->p_priority = p->p_usrpri;
}
/*
@@ -283,7 +255,6 @@ trap(type, psr, pc, tf)
struct proc *p;
struct pcb *pcb;
int n;
- u_quad_t sticks;
union sigval sv;
sv.sival_int = pc; /* XXX fix for parm five of trapsignal() */
@@ -337,7 +308,6 @@ trap(type, psr, pc, tf)
}
if ((p = curproc) == NULL)
p = &proc0;
- sticks = p->p_sticks;
pcb = &p->p_addr->u_pcb;
p->p_md.md_tf = tf; /* for ptrace/signals */
@@ -582,7 +552,7 @@ badtrap:
trapsignal(p, SIGFPE, FPE_INTOVF_TRAP, FPE_INTOVF, sv);
break;
}
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
#undef ADVANCE
}
@@ -672,14 +642,12 @@ mem_access_fault(type, ser, v, pc, psr, tf)
int rv;
vm_prot_t ftype;
int onfault;
- u_quad_t sticks;
union sigval sv;
u_int isr;
uvmexp.traps++;
if ((p = curproc) == NULL) /* safety check */
p = &proc0;
- sticks = p->p_sticks;
if (type == T_DATAFAULT && (ser & FCR_EXTERNAL) != 0) {
/*
@@ -811,7 +779,7 @@ kfault:
}
out:
if ((psr & PSR_PS) == 0) {
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
}
}
@@ -850,7 +818,6 @@ syscall(code, tf, pc)
register_t i[8];
} args;
register_t rval[2];
- u_quad_t sticks;
#ifdef DIAGNOSTIC
extern struct pcb *cpcb;
#endif
@@ -865,7 +832,6 @@ syscall(code, tf, pc)
if (tf != (struct trapframe *)((caddr_t)cpcb + USPACE) - 1)
panic("syscall trapframe");
#endif
- sticks = p->p_sticks;
p->p_md.md_tf = tf;
new = code & (SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
code &= ~(SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
@@ -975,7 +941,7 @@ syscall(code, tf, pc)
break;
}
- userret(p, pc, sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p, code, error, rval[0]);
@@ -1000,7 +966,7 @@ child_return(arg)
tf->tf_out[1] = 0;
tf->tf_psr &= ~PSR_C;
- userret(p, tf->tf_pc, 0);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p,
diff --git a/sys/arch/sparc/include/cpu.h b/sys/arch/sparc/include/cpu.h
index 2f157be7e14..6cab3d88eab 100644
--- a/sys/arch/sparc/include/cpu.h
+++ b/sys/arch/sparc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.26 2006/11/29 12:26:14 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.27 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: cpu.h,v 1.24 1997/03/15 22:25:15 pk Exp $ */
/*
@@ -132,6 +132,11 @@ extern int want_resched; /* resched() was called */
extern int want_ast;
/*
+ * This is used during profiling to integrate system time.
+ */
+#define PROC_PC(p) ((p)->p_md.md_tf->tf_pc)
+
+/*
* Give a profiling tick to the current process when the user profiling
* buffer pages are invalid. On the sparc, request an ast to send us
* through trap(), marking the proc as needing a profiling tick.
diff --git a/sys/arch/sparc/sparc/trap.c b/sys/arch/sparc/sparc/trap.c
index 6799a7a6bd7..7ea961d5ecb 100644
--- a/sys/arch/sparc/sparc/trap.c
+++ b/sys/arch/sparc/sparc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.49 2006/12/24 20:29:19 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.50 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: trap.c,v 1.58 1997/09/12 08:55:01 pk Exp $ */
/*
@@ -199,7 +199,7 @@ const char *trap_type[] = {
#define N_TRAP_TYPES (sizeof trap_type / sizeof *trap_type)
-static __inline void userret(struct proc *, int, u_quad_t);
+static __inline void userret(struct proc *);
void trap(unsigned, int, int, struct trapframe *);
static __inline void share_fpu(struct proc *, struct trapframe *);
void mem_access_fault(unsigned, int, u_int, int, int, struct trapframe *);
@@ -214,43 +214,15 @@ int want_ast = 0;
* trap, mem_access_fault, and syscall.
*/
static __inline void
-userret(p, pc, oticks)
- struct proc *p;
- int pc;
- u_quad_t oticks;
+userret(struct proc *p)
{
int sig;
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
- p->p_priority = p->p_usrpri;
- if (want_ast) {
- want_ast = 0;
- if (p->p_flag & P_OWEUPC) {
- p->p_flag &= ~P_OWEUPC;
- ADDUPROF(p);
- }
- }
- if (want_resched) {
- /*
- * We're being preempted.
- */
- preempt(NULL);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
-
- /*
- * If profiling, charge recent system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, pc, (int)(p->p_sticks - oticks) * psratio);
- }
- curpriority = p->p_priority;
+ curpriority = p->p_priority = p->p_usrpri;
}
/*
@@ -280,7 +252,6 @@ trap(type, psr, pc, tf)
struct proc *p;
struct pcb *pcb;
int n;
- u_quad_t sticks;
union sigval sv;
sv.sival_int = pc; /* XXX fix for parm five of trapsignal() */
@@ -330,7 +301,6 @@ trap(type, psr, pc, tf)
}
if ((p = curproc) == NULL)
p = &proc0;
- sticks = p->p_sticks;
pcb = &p->p_addr->u_pcb;
p->p_md.md_tf = tf; /* for ptrace/signals */
@@ -575,7 +545,7 @@ badtrap:
trapsignal(p, SIGFPE, FPE_INTOVF_TRAP, FPE_INTOVF, sv);
break;
}
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
#undef ADVANCE
}
@@ -666,13 +636,11 @@ mem_access_fault(type, ser, v, pc, psr, tf)
int rv;
vm_prot_t ftype;
int onfault;
- u_quad_t sticks;
union sigval sv;
uvmexp.traps++;
if ((p = curproc) == NULL) /* safety check */
p = &proc0;
- sticks = p->p_sticks;
/*
* Figure out what to pass the VM code, and ignore the sva register
@@ -786,7 +754,7 @@ kfault:
}
out:
if ((psr & PSR_PS) == 0) {
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
}
#endif /* Sun4/Sun4C */
@@ -814,13 +782,11 @@ mem_access_fault4m(type, sfsr, sfva, tf)
int rv;
vm_prot_t ftype;
int onfault;
- u_quad_t sticks;
union sigval sv;
uvmexp.traps++;
if ((p = curproc) == NULL) /* safety check */
p = &proc0;
- sticks = p->p_sticks;
pc = tf->tf_pc; /* These are needed below */
psr = tf->tf_psr;
@@ -1004,7 +970,7 @@ kfault:
}
out:
if ((psr & PSR_PS) == 0) {
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
}
}
@@ -1032,7 +998,6 @@ syscall(code, tf, pc)
register_t i[8];
} args;
register_t rval[2];
- u_quad_t sticks;
#ifdef DIAGNOSTIC
extern struct pcb *cpcb;
#endif
@@ -1047,7 +1012,6 @@ syscall(code, tf, pc)
if (tf != (struct trapframe *)((caddr_t)cpcb + USPACE) - 1)
panic("syscall trapframe");
#endif
- sticks = p->p_sticks;
p->p_md.md_tf = tf;
new = code & (SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
code &= ~(SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
@@ -1157,7 +1121,7 @@ syscall(code, tf, pc)
break;
}
- userret(p, pc, sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p, code, error, rval[0]);
@@ -1182,7 +1146,7 @@ child_return(arg)
tf->tf_out[1] = 0;
tf->tf_psr &= ~PSR_C;
- userret(p, tf->tf_pc, 0);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p,
diff --git a/sys/arch/sparc64/include/cpu.h b/sys/arch/sparc64/include/cpu.h
index f657a981b2a..66d66500796 100644
--- a/sys/arch/sparc64/include/cpu.h
+++ b/sys/arch/sparc64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.36 2006/11/29 12:26:14 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.37 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: cpu.h,v 1.28 2001/06/14 22:56:58 thorpej Exp $ */
/*
@@ -165,6 +165,11 @@ extern int want_resched; /* resched() was called */
#define need_resched(ci) (want_resched = 1, want_ast = 1)
/*
+ * This is used during profiling to integrate system time.
+ */
+#define PROC_PC(p) ((p)->p_md.md_tf->tf_pc)
+
+/*
* Give a profiling tick to the current process when the user profiling
* buffer pages are invalid. On the sparc, request an ast to send us
* through trap(), marking the proc as needing a profiling tick.
diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c
index 57820d5d2b2..98dc2c6a14d 100644
--- a/sys/arch/sparc64/sparc64/trap.c
+++ b/sys/arch/sparc64/sparc64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.44 2006/12/24 20:29:19 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.45 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */
/*
@@ -320,7 +320,7 @@ const char *trap_type[] = {
#define N_TRAP_TYPES (sizeof trap_type / sizeof *trap_type)
-static __inline void userret(struct proc *, int, u_quad_t);
+static __inline void userret(struct proc *);
static __inline void share_fpu(struct proc *, struct trapframe64 *);
void trap(struct trapframe64 *tf, unsigned type, vaddr_t pc, long tstate);
@@ -339,46 +339,18 @@ void syscall(struct trapframe64 *, register_t code, register_t pc);
* trap, mem_access_fault, and syscall.
*/
static __inline void
-userret(p, pc, oticks)
- struct proc *p;
- int pc;
- u_quad_t oticks;
+userret(struct proc *p)
{
int sig;
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
- p->p_priority = p->p_usrpri;
- if (want_ast) {
- want_ast = 0;
- if (p->p_flag & P_OWEUPC) {
- p->p_flag &= ~P_OWEUPC;
- ADDUPROF(p);
- }
- }
- if (want_resched) {
- /*
- * We are being preempted.
- */
- preempt(NULL);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
-
- /*
- * If profiling, charge recent system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, pc, (int)(p->p_sticks - oticks) * psratio);
- }
#ifdef notyet
- curcpu()->ci_schedstate.spc_curpriority = p->p_priority;
+ curcpu()->ci_schedstate.spc_curpriority = p->p_priority = p->p_usrpri;
#else
- curpriority = p->p_priority;
+ curpriority = p->p_priority = p->p_usrpri;
#endif
}
@@ -414,7 +386,6 @@ trap(tf, type, pc, tstate)
struct pcb *pcb;
int pstate = (tstate>>TSTATE_PSTATE_SHIFT);
int64_t n;
- u_quad_t sticks;
union sigval sv;
sv.sival_ptr = (void *)pc;
@@ -482,7 +453,6 @@ trap(tf, type, pc, tstate)
}
if ((p = curproc) == NULL)
p = &proc0;
- sticks = p->p_sticks;
pcb = &p->p_addr->u_pcb;
p->p_md.md_tf = tf; /* for ptrace/signals */
@@ -750,7 +720,7 @@ badtrap:
trapsignal(p, SIGFPE, FPE_INTOVF_TRAP, FPE_INTOVF, sv);
break;
}
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
#undef ADVANCE
}
@@ -843,7 +813,6 @@ data_access_fault(tf, type, pc, addr, sfva, sfsr)
int rv;
vm_prot_t access_type;
vaddr_t onfault;
- u_quad_t sticks;
union sigval sv;
sv.sival_ptr = (void *)addr;
@@ -851,7 +820,6 @@ data_access_fault(tf, type, pc, addr, sfva, sfsr)
uvmexp.traps++;
if ((p = curproc) == NULL) /* safety check */
p = &proc0;
- sticks = p->p_sticks;
tstate = tf->tf_tstate;
@@ -954,7 +922,7 @@ kfault:
}
}
if ((tstate & TSTATE_PRIV) == 0) {
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
}
}
@@ -979,13 +947,11 @@ data_access_error(tf, type, afva, afsr, sfva, sfsr)
u_int64_t tstate;
struct proc *p;
vaddr_t onfault;
- u_quad_t sticks;
union sigval sv;
uvmexp.traps++;
if ((p = curproc) == NULL) /* safety check */
p = &proc0;
- sticks = p->p_sticks;
pc = tf->tf_pc;
tstate = tf->tf_tstate;
@@ -1031,7 +997,7 @@ data_access_error(tf, type, afva, afsr, sfva, sfsr)
trapsignal(p, SIGSEGV, VM_PROT_READ|VM_PROT_WRITE, SEGV_MAPERR, sv);
out:
if ((tstate & TSTATE_PRIV) == 0) {
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
}
}
@@ -1053,7 +1019,6 @@ text_access_fault(tf, type, pc, sfsr)
vaddr_t va;
int rv;
vm_prot_t access_type;
- u_quad_t sticks;
union sigval sv;
sv.sival_ptr = (void *)pc;
@@ -1061,7 +1026,6 @@ text_access_fault(tf, type, pc, sfsr)
uvmexp.traps++;
if ((p = curproc) == NULL) /* safety check */
panic("text_access_fault: no curproc");
- sticks = p->p_sticks;
tstate = tf->tf_tstate;
@@ -1113,7 +1077,7 @@ text_access_fault(tf, type, pc, sfsr)
trapsignal(p, SIGSEGV, access_type, SEGV_MAPERR, sv);
}
if ((tstate & TSTATE_PRIV) == 0) {
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
}
}
@@ -1141,14 +1105,12 @@ text_access_error(tf, type, pc, sfsr, afva, afsr)
vaddr_t va;
int rv;
vm_prot_t access_type;
- u_quad_t sticks;
union sigval sv;
sv.sival_ptr = (void *)pc;
uvmexp.traps++;
if ((p = curproc) == NULL) /* safety check */
p = &proc0;
- sticks = p->p_sticks;
tstate = tf->tf_tstate;
@@ -1221,7 +1183,7 @@ text_access_error(tf, type, pc, sfsr, afva, afsr)
}
out:
if ((tstate & TSTATE_PRIV) == 0) {
- userret(p, pc, sticks);
+ userret(p);
share_fpu(p, tf);
}
}
@@ -1268,7 +1230,6 @@ syscall(tf, code, pc)
int error = 0, new;
register_t args[8];
register_t rval[2];
- u_quad_t sticks;
#ifdef DIAGNOSTIC
extern struct pcb *cpcb;
#endif
@@ -1283,7 +1244,6 @@ syscall(tf, code, pc)
if (tf != (struct trapframe64 *)((caddr_t)cpcb + USPACE) - 1)
panic("syscall: trapframe");
#endif
- sticks = p->p_sticks;
p->p_md.md_tf = tf;
new = code & (SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
code &= ~(SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
@@ -1412,7 +1372,7 @@ syscall(tf, code, pc)
#ifdef SYSCALL_DEBUG
scdebug_ret(p, code, error, rval);
#endif
- userret(p, pc, sticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p, code, error, rval[0]);
@@ -1437,7 +1397,7 @@ child_return(arg)
tf->tf_out[1] = 0;
tf->tf_tstate &= ~(((int64_t)(ICC_C|XCC_C))<<TSTATE_CCR_SHIFT);
- userret(p, tf->tf_pc, 0);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p,
diff --git a/sys/arch/vax/include/cpu.h b/sys/arch/vax/include/cpu.h
index a798fb98972..0191390c8cf 100644
--- a/sys/arch/vax/include/cpu.h
+++ b/sys/arch/vax/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.21 2006/11/29 12:26:14 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.22 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: cpu.h,v 1.41 1999/10/21 20:01:36 ragge Exp $ */
/*
@@ -44,6 +44,7 @@
#include <machine/pcb.h>
#include <machine/uvax.h>
#include <machine/psl.h>
+#include <machine/trap.h>
#define cpu_wait(p)
#define cpu_number() 0
@@ -102,8 +103,13 @@ extern int bootdev;
extern int want_resched; /* resched() was called */
/*
+ * This is used during profiling to integrate system time.
+ */
+#define PROC_PC(p) (((struct trapframe *)((p)->p_addr->u_pcb.framep))->pc)
+
+/*
* Give a profiling tick to the current process when the user profiling
- * buffer pages are invalid. On the hp300, request an ast to send us
+ * buffer pages are invalid. On the vax, request an ast to send us
* through trap, marking the proc as needing a profiling tick.
*/
#define need_proftick(p) {(p)->p_flag |= P_OWEUPC; mtpr(AST_OK,PR_ASTLVL); }
diff --git a/sys/arch/vax/vax/trap.c b/sys/arch/vax/vax/trap.c
index 857143ae859..37f901282f6 100644
--- a/sys/arch/vax/vax/trap.c
+++ b/sys/arch/vax/vax/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.35 2006/12/24 20:29:19 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.36 2006/12/24 20:30:35 miod Exp $ */
/* $NetBSD: trap.c,v 1.47 1999/08/21 19:26:20 matt Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -64,7 +64,7 @@
volatile int startsysc = 0, faultdebug = 0;
#endif
-static __inline void userret(struct proc *, struct trapframe *, u_quad_t);
+static __inline void userret(struct proc *);
void arithflt(struct trapframe *);
void syscall(struct trapframe *);
@@ -108,36 +108,15 @@ int no_traps = 18;
* return to usermode.
*/
static __inline void
-userret(p, frame, oticks)
- struct proc *p;
- struct trapframe *frame;
- u_quad_t oticks;
+userret(struct proc *p)
{
int sig;
/* Take pending signals. */
while ((sig = CURSIG(p)) !=0)
postsig(sig);
- p->p_priority = p->p_usrpri;
- if (want_resched) {
- /*
- * We're being preempted.
- */
- preempt(NULL);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
- /*
- * If profiling, charge system time to the trapped pc.
- */
- if (p->p_flag & P_PROFIL) {
- extern int psratio;
-
- addupc_task(p, frame->pc,
- (int)(p->p_sticks - oticks) * psratio);
- }
- curpriority = p->p_priority;
+ curpriority = p->p_priority = p->p_usrpri;
}
void
@@ -353,7 +332,7 @@ if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
if (umode == 0)
return;
- userret(p, frame, oticks);
+ userret(p);
}
void
@@ -465,7 +444,7 @@ bad:
break;
}
- userret(p, frame, oticks);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
@@ -484,7 +463,7 @@ child_return(arg)
frame->r1 = frame->r0 = 0;
frame->psl &= ~PSL_C;
- userret(p, frame, 0);
+ userret(p);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))