runrun => want_resched; add proc arg to psig, trapsignal
SCCS-vsn: sys/hp300/hp300/trap.c 7.10
*
* from: Utah $Hdr: trap.c 1.28 89/09/25$
*
*
* from: Utah $Hdr: trap.c 1.28 89/09/25$
*
- * @(#)trap.c 7.9 (Berkeley) %G%
+ * @(#)trap.c 7.10 (Berkeley) %G%
+#include "param.h"
+#include "systm.h"
+#include "proc.h"
+#include "seg.h"
+#include "acct.h"
+#include "kernel.h"
+#include "signalvar.h"
+#include "resourcevar.h"
+#include "syslog.h"
+#include "user.h"
+#ifdef KTRACE
+#include "ktrace.h"
+#endif
+
+#include "../include/trap.h"
#include "../include/cpu.h"
#include "../include/psl.h"
#include "../include/reg.h"
#include "../include/mtpr.h"
#include "../include/cpu.h"
#include "../include/psl.h"
#include "../include/reg.h"
#include "../include/mtpr.h"
-#include "sys/param.h"
-#include "sys/systm.h"
-#include "sys/user.h"
-#include "sys/proc.h"
-#include "sys/seg.h"
-#include "../include/trap.h"
-#include "sys/acct.h"
-#include "sys/kernel.h"
-#include "sys/syslog.h"
-#ifdef KTRACE
-#include "sys/ktrace.h"
-#endif
-
-#include "vm/vm_param.h"
-#include "vm/vm_map.h"
-#include "sys/vmmeter.h"
#ifdef HPUXCOMPAT
#include "../hpux/hpux.h"
#ifdef HPUXCOMPAT
#include "../hpux/hpux.h"
{
register int i;
unsigned ucode = 0;
{
register int i;
unsigned ucode = 0;
- register struct proc *p = u.u_procp;
+ register struct proc *p = curproc;
struct timeval syst;
unsigned ncode;
cnt.v_trap++;
struct timeval syst;
unsigned ncode;
cnt.v_trap++;
- syst = u.u_ru.ru_stime;
if (USERMODE(frame.f_sr)) {
type |= USER;
if (USERMODE(frame.f_sr)) {
type |= USER;
- u.u_ar0 = frame.f_regs;
+ p->p_regs = frame.f_regs;
}
switch (type) {
default:
dopanic:
}
switch (type) {
default:
dopanic:
-#ifdef KGDB
- if (!panicstr && kgdb_trap(type, code, v, &frame))
- return;
-#endif
printf("trap type %d, code = %x, v = %x\n", type, code, v);
regdump(frame.f_regs, 128);
type &= ~USER;
printf("trap type %d, code = %x, v = %x\n", type, code, v);
regdump(frame.f_regs, 128);
type &= ~USER;
* in the stack frame of a signal handler.
*/
type |= USER;
* in the stack frame of a signal handler.
*/
type |= USER;
- printf("pid %d: kernel %s exception\n", u.u_procp->p_pid,
+ printf("pid %d: kernel %s exception\n", p->p_pid,
type==T_COPERR ? "coprocessor" : "format");
type==T_COPERR ? "coprocessor" : "format");
- u.u_signal[SIGILL] = SIG_DFL;
+ p->p_sigacts->ps_sigact[SIGILL] = SIG_DFL;
i = sigmask(SIGILL);
p->p_sigignore &= ~i;
p->p_sigcatch &= ~i;
i = sigmask(SIGILL);
p->p_sigignore &= ~i;
p->p_sigcatch &= ~i;
case T_ILLINST+USER: /* illegal instruction fault */
#ifdef HPUXCOMPAT
case T_ILLINST+USER: /* illegal instruction fault */
#ifdef HPUXCOMPAT
- if (u.u_procp->p_flag & SHPUX) {
+ if (p->p_flag & SHPUX) {
ucode = HPUX_ILL_ILLINST_TRAP;
i = SIGILL;
break;
ucode = HPUX_ILL_ILLINST_TRAP;
i = SIGILL;
break;
#endif
case T_PRIVINST+USER: /* privileged instruction fault */
#ifdef HPUXCOMPAT
#endif
case T_PRIVINST+USER: /* privileged instruction fault */
#ifdef HPUXCOMPAT
- if (u.u_procp->p_flag & SHPUX)
ucode = HPUX_ILL_PRIV_TRAP;
else
#endif
ucode = HPUX_ILL_PRIV_TRAP;
else
#endif
case T_ZERODIV+USER: /* Divide by zero */
#ifdef HPUXCOMPAT
case T_ZERODIV+USER: /* Divide by zero */
#ifdef HPUXCOMPAT
- if (u.u_procp->p_flag & SHPUX)
ucode = HPUX_FPE_INTDIV_TRAP;
else
#endif
ucode = HPUX_FPE_INTDIV_TRAP;
else
#endif
case T_CHKINST+USER: /* CHK instruction trap */
#ifdef HPUXCOMPAT
case T_CHKINST+USER: /* CHK instruction trap */
#ifdef HPUXCOMPAT
- if (u.u_procp->p_flag & SHPUX) {
+ if (p->p_flag & SHPUX) {
/* handled differently under hp-ux */
i = SIGILL;
ucode = HPUX_ILL_CHK_TRAP;
/* handled differently under hp-ux */
i = SIGILL;
ucode = HPUX_ILL_CHK_TRAP;
case T_TRAPVINST+USER: /* TRAPV instruction trap */
#ifdef HPUXCOMPAT
case T_TRAPVINST+USER: /* TRAPV instruction trap */
#ifdef HPUXCOMPAT
- if (u.u_procp->p_flag & SHPUX) {
+ if (p->p_flag & SHPUX) {
/* handled differently under hp-ux */
i = SIGILL;
ucode = HPUX_ILL_TRAPV_TRAP;
/* handled differently under hp-ux */
i = SIGILL;
ucode = HPUX_ILL_TRAPV_TRAP;
* HP-UX uses trap #1 for breakpoints,
* HPBSD uses trap #2,
* SUN 3.x uses trap #15,
* HP-UX uses trap #1 for breakpoints,
* HPBSD uses trap #2,
* SUN 3.x uses trap #15,
- * KGDB uses trap #15 (for kernel breakpoints).
+ * KGDB uses trap #15 (for kernel breakpoints; handled elsewhere).
*
* HPBSD and HP-UX traps both get mapped by locore.s into T_TRACE.
* SUN 3.x traps get passed through as T_TRAP15 and are not really
*
* HPBSD and HP-UX traps both get mapped by locore.s into T_TRACE.
* SUN 3.x traps get passed through as T_TRAP15 and are not really
- * supported yet. KGDB traps are also passed through as T_TRAP15
- * and are not used yet.
*/
case T_TRACE: /* kernel trace trap */
*/
case T_TRACE: /* kernel trace trap */
- case T_TRAP15: /* SUN (or KGDB) kernel trace trap */
-#ifdef KGDB
- if (kgdb_trap(type, code, v, &frame))
- return;
-#endif
+ case T_TRAP15: /* SUN trace trap */
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
break;
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
break;
}
spl0();
#ifndef PROFTIMER
}
spl0();
#ifndef PROFTIMER
- if ((u.u_procp->p_flag&SOWEUPC) && u.u_prof.pr_scale) {
- addupc(frame.f_pc, &u.u_prof, 1);
- u.u_procp->p_flag &= ~SOWEUPC;
+ if ((p->p_flag&SOWEUPC) && p->p_stats->p_prof.pr_scale) {
+ addupc(frame.f_pc, &p->p_stats->p_prof, 1);
+ p->p_flag &= ~SOWEUPC;
case T_MMUFLT+USER: /* page fault */
{
register vm_offset_t va;
case T_MMUFLT+USER: /* page fault */
{
register vm_offset_t va;
+ register struct vmspace *vm = p->p_vmspace;
register vm_map_t map;
int rv;
vm_prot_t ftype;
register vm_map_t map;
int rv;
vm_prot_t ftype;
(code & (SSW_DF|FC_SUPERD)) == (SSW_DF|FC_SUPERD)))
map = kernel_map;
else
(code & (SSW_DF|FC_SUPERD)) == (SSW_DF|FC_SUPERD)))
map = kernel_map;
else
- map = u.u_procp->p_map;
if ((code & (SSW_DF|SSW_RW)) == SSW_DF) /* what about RMW? */
ftype = VM_PROT_READ | VM_PROT_WRITE;
else
if ((code & (SSW_DF|SSW_RW)) == SSW_DF) /* what about RMW? */
ftype = VM_PROT_READ | VM_PROT_WRITE;
else
* XXX: rude hack to make stack limits "work"
*/
nss = 0;
* XXX: rude hack to make stack limits "work"
*/
nss = 0;
- if ((caddr_t)va >= u.u_maxsaddr && map != kernel_map) {
+ if ((caddr_t)va >= vm->vm_maxsaddr && map != kernel_map) {
nss = clrnd(btoc(USRSTACK-(unsigned)va));
nss = clrnd(btoc(USRSTACK-(unsigned)va));
- if (nss > btoc(u.u_rlimit[RLIMIT_STACK].rlim_cur)) {
+ if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) {
rv = KERN_FAILURE;
goto nogo;
}
rv = KERN_FAILURE;
goto nogo;
}
/*
* XXX: continuation of rude stack hack
*/
/*
* XXX: continuation of rude stack hack
*/
- if (nss > u.u_ssize)
- u.u_ssize = nss;
+ if (nss > vm->vm_ssize)
+ vm->vm_ssize = nss;
if (type == T_MMUFLT)
return;
goto out;
if (type == T_MMUFLT)
return;
goto out;
type, code);
goto dopanic;
}
type, code);
goto dopanic;
}
i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
break;
}
}
i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
break;
}
}
+ trapsignal(p, i, ucode);
if ((type & USER) == 0)
return;
out:
if ((type & USER) == 0)
return;
out:
- p = u.u_procp;
- if (i = CURSIG(p))
psig(i);
p->p_pri = p->p_usrpri;
psig(i);
p->p_pri = p->p_usrpri;
- * Since we are u.u_procp, clock will normally just change
+ * Since we are curproc, clock will normally just change
* our priority without moving us from one queue to another
* (since the running process is not on a queue.)
* If that happened after we setrq ourselves but before we
* our priority without moving us from one queue to another
* (since the running process is not on a queue.)
* If that happened after we setrq ourselves but before we
*/
(void) splclock();
setrq(p);
*/
(void) splclock();
setrq(p);
+ p->p_stats->p_ru.ru_nivcsw++;
- if (u.u_prof.pr_scale) {
+ if (p->p_stats->p_prof.pr_scale) {
- struct timeval *tv = &u.u_ru.ru_stime;
+ struct timeval *tv = &p->p_stime;
ticks = ((tv->tv_sec - syst.tv_sec) * 1000 +
(tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000);
if (ticks) {
#ifdef PROFTIMER
extern int profscale;
ticks = ((tv->tv_sec - syst.tv_sec) * 1000 +
(tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000);
if (ticks) {
#ifdef PROFTIMER
extern int profscale;
- addupc(frame.f_pc, &u.u_prof, ticks * profscale);
+ addupc(frame.f_pc, &p->p_stats->p_prof,
+ ticks * profscale);
- addupc(frame.f_pc, &u.u_prof, ticks);
+ addupc(frame.f_pc, &p->p_stats->p_prof, ticks);
register caddr_t params;
register int i;
register struct sysent *callp;
register caddr_t params;
register int i;
register struct sysent *callp;
- register struct proc *p = u.u_procp;
+ register struct proc *p = curproc;
int error, opc, numsys;
struct args {
int i[8];
int error, opc, numsys;
struct args {
int i[8];
- syst = u.u_ru.ru_stime;
if (!USERMODE(frame.f_sr))
panic("syscall");
if (!USERMODE(frame.f_sr))
panic("syscall");
- u.u_ar0 = frame.f_regs;
+ p->p_regs = frame.f_regs;
opc = frame.f_pc - 2;
systab = sysent;
numsys = nsysent;
opc = frame.f_pc - 2;
systab = sysent;
numsys = nsysent;
#ifdef HPUXCOMPAT
/* debug kludge */
if (callp->sy_call == notimp)
#ifdef HPUXCOMPAT
/* debug kludge */
if (callp->sy_call == notimp)
- error = notimp(u.u_procp, args.i, rval, code, callp->sy_narg);
+ error = notimp(p, args.i, rval, code, callp->sy_narg);
- error = (*callp->sy_call)(u.u_procp, &args, rval);
+ error = (*callp->sy_call)(p, &args, rval);
if (error == ERESTART)
frame.f_pc = opc;
else if (error != EJUSTRETURN) {
if (error == ERESTART)
frame.f_pc = opc;
else if (error != EJUSTRETURN) {
* Reinitialize proc pointer `p' as it may be different
* if this is a child returning from fork syscall.
*/
* Reinitialize proc pointer `p' as it may be different
* if this is a child returning from fork syscall.
*/
/*
* XXX the check for sigreturn ensures that we don't
* attempt to set up a call to a signal handler (sendsig) before
/*
* XXX the check for sigreturn ensures that we don't
* attempt to set up a call to a signal handler (sendsig) before
* so that this is not a problem.
*/
#include "sys/syscall.h"
* so that this is not a problem.
*/
#include "sys/syscall.h"
- if (code != SYS_sigreturn && (i = CURSIG(p)))
- psig(i);
+ if (code != SYS_sigreturn)
+ while (i = CURSIG(p))
+ psig(i);
- * Since we are u.u_procp, clock will normally just change
+ * Since we are curproc, clock will normally just change
* our priority without moving us from one queue to another
* (since the running process is not on a queue.)
* If that happened after we setrq ourselves but before we
* our priority without moving us from one queue to another
* (since the running process is not on a queue.)
* If that happened after we setrq ourselves but before we
*/
(void) splclock();
setrq(p);
*/
(void) splclock();
setrq(p);
+ p->p_stats->p_ru.ru_nivcsw++;
- if (code != SYS_sigreturn && (i = CURSIG(p)))
- psig(i);
+ if (code != SYS_sigreturn)
+ while (i = CURSIG(p))
+ psig(i);
- if (u.u_prof.pr_scale) {
+ if (p->p_stats->p_prof.pr_scale) {
- struct timeval *tv = &u.u_ru.ru_stime;
+ struct timeval *tv = &p->p_stime;
ticks = ((tv->tv_sec - syst.tv_sec) * 1000 +
(tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000);
if (ticks) {
#ifdef PROFTIMER
extern int profscale;
ticks = ((tv->tv_sec - syst.tv_sec) * 1000 +
(tv->tv_usec - syst.tv_usec) / 1000) / (tick / 1000);
if (ticks) {
#ifdef PROFTIMER
extern int profscale;
- addupc(frame.f_pc, &u.u_prof, ticks * profscale);
+ addupc(frame.f_pc, &p->p_stats->p_prof,
+ ticks * profscale);
- addupc(frame.f_pc, &u.u_prof, ticks);
+ addupc(frame.f_pc, &p->p_stats->p_prof, ticks);