diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-01-31 05:15:05 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-01-31 05:15:05 +0000 |
commit | 58d1d4b705b45fc72b7ca4d7726f4ed9a9f5d113 (patch) | |
tree | b5a5355086a5c0be017d5dd904ca1e95b85cf07e /sys/arch/vax | |
parent | ec8fd6f84c6d5d6b450d4b8198253ec4795ceb0c (diff) |
from ragge;
save usp when trapping from userspace
change register save structs according to this
handle old init register passing convention
Diffstat (limited to 'sys/arch/vax')
-rw-r--r-- | sys/arch/vax/vax/intvec.s | 40 | ||||
-rw-r--r-- | sys/arch/vax/vax/machdep.c | 118 | ||||
-rw-r--r-- | sys/arch/vax/vax/subr.s | 6 | ||||
-rw-r--r-- | sys/arch/vax/vax/vm_machdep.c | 45 |
4 files changed, 97 insertions, 112 deletions
diff --git a/sys/arch/vax/vax/intvec.s b/sys/arch/vax/vax/intvec.s index 4dc2c181fb8..1e740e0d41e 100644 --- a/sys/arch/vax/vax/intvec.s +++ b/sys/arch/vax/vax/intvec.s @@ -1,4 +1,4 @@ -/* $NetBSD: intvec.s,v 1.12 1995/11/10 19:05:46 ragge Exp $ */ +/* $NetBSD: intvec.s,v 1.13 1996/01/28 12:22:55 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -56,7 +56,7 @@ .long label+stack; .text - .globl _kernbase,_rpb + .globl _kernbase, _rpb _kernbase: _rpb: /* @@ -212,15 +212,17 @@ ptelen: movl $T_PTELEN, (sp) # PTE must expand (or send segv) syscall: pushl $T_SYSCALL pushr $0xfff + mfpr $PR_USP, -(sp) pushl ap pushl fp pushl sp # pointer to syscall frame; defined in trap.h - calls $1,_syscall - movl (sp)+,fp - movl (sp)+,ap + calls $1, _syscall + movl (sp)+, fp + movl (sp)+, ap + mtpr (sp)+, $PR_USP popr $0xfff - addl2 $8,sp - mtpr $0x1f,$PR_IPL # Be sure we can REI + addl2 $8, sp + mtpr $0x1f, $PR_IPL # Be sure we can REI rei STRAY(0, 44) @@ -259,7 +261,7 @@ syscall: STRAY(0, B4) STRAY(0, B8) - TRAPCALL(ddbtrap,T_KDBTRAP) + TRAPCALL(ddbtrap, T_KDBTRAP) .align 2 .globl hardclock @@ -293,16 +295,26 @@ hardclock: mtpr $0xc1,$PR_ICCS # Reset interrupt flag FASTINTR(consrint, gencnrint) FASTINTR(constint, gencntint) +/* + * Main routine for traps; all go through this. + * Note that we put USP on the frame here, which sometimes should + * be KSP to be correct, but because we only alters it when we are + * called from user space it doesn't care. + * _sret is used in cpu_set_kpc to jump out to user space first time. + */ + .globl _sret trap: pushr $0xfff + mfpr $PR_USP, -(sp) pushl ap pushl fp pushl sp - calls $1,_arithflt - movl (sp)+,fp - movl (sp)+,ap - popr $0xfff - addl2 $8,sp - mtpr $0x1f,$PR_IPL # Be sure we can REI + calls $1, _arithflt +_sret: movl (sp)+, fp + movl (sp)+, ap + mtpr (sp)+, $PR_USP + popr $0xfff + addl2 $8, sp + mtpr $0x1f, $PR_IPL # Be sure we can REI rei #if VAX630 || VAX650 diff --git a/sys/arch/vax/vax/machdep.c b/sys/arch/vax/vax/machdep.c index f17365ff4c6..c88115b7b7d 100644 --- a/sys/arch/vax/vax/machdep.c +++ b/sys/arch/vax/vax/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.22 1996/01/04 22:22:58 jtc Exp $ */ +/* $NetBSD: machdep.c,v 1.23 1996/01/28 12:22:54 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -350,8 +350,12 @@ setstatclockrate(hzrate) consinit() { #ifdef DDB - db_machine_init(); +/* db_machine_init(); */ ddb_init(); +#ifdef donotworkbyunknownreason + if (boothowto & RB_KDB) + Debugger(); +#endif #endif } @@ -385,19 +389,19 @@ sys_sigreturn(p, v, retval) scf->fp = cntx->sc_fp; scf->ap = cntx->sc_ap; scf->pc = cntx->sc_pc; + scf->sp = cntx->sc_sp; scf->psl = cntx->sc_ps; - mtpr(cntx->sc_sp, PR_USP); return (EJUSTRETURN); } struct trampframe { - u_int sig; /* Signal number */ - u_int code; /* Info code */ - u_int scp; /* Pointer to struct sigcontext */ - u_int r0, r1, r2, r3, r4, r5; /* Registers saved when + unsigned sig; /* Signal number */ + unsigned code; /* Info code */ + unsigned scp; /* Pointer to struct sigcontext */ + unsigned r0, r1, r2, r3, r4, r5; /* Registers saved when * interrupt */ - u_int pc; /* Address of signal handler */ - u_int arg; /* Pointer to first (and only) sigreturn + unsigned pc; /* Address of signal handler */ + unsigned arg; /* Pointer to first (and only) sigreturn * argument */ }; @@ -407,14 +411,14 @@ sendsig(catcher, sig, mask, code) int sig, mask; u_long code; { - struct proc *p = curproc; - struct sigacts *psp = p->p_sigacts; - struct trapframe *syscf; - struct sigcontext *sigctx; - struct trampframe *trampf; - u_int *cursp; - int oonstack; - extern char sigcode[], esigcode[]; + struct proc *p = curproc; + struct sigacts *psp = p->p_sigacts; + struct trapframe *syscf; + struct sigcontext *sigctx; + struct trampframe *trampf; + unsigned cursp; + int oonstack; + extern char sigcode[], esigcode[]; /* * Allocate and validate space for the signal handler context. Note * that if the stack is in P0 space, the call to grow() is a nop, and @@ -422,26 +426,26 @@ sendsig(catcher, sig, mask, code) * allocated the space with a `brk'. We shall allocate space on the * stack for both struct sigcontext and struct calls... */ + syscf = p->p_addr->u_pcb.framep; + /* First check what stack to work on */ if ((psp->ps_flags & SAS_ALTSTACK) && !oonstack && (psp->ps_sigonstack & sigmask(sig))) { - cursp = (u_int *) (psp->ps_sigstk.ss_sp + - psp->ps_sigstk.ss_size); + cursp = (int)(psp->ps_sigstk.ss_sp + psp->ps_sigstk.ss_size); psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else - cursp = (u_int *) mfpr(PR_USP); - if ((u_int) cursp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) - (void) grow(p, (u_int) cursp); + cursp = syscf->sp; + if (cursp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) + (void) grow(p, cursp); /* Set up positions for structs on stack */ - sigctx = (struct sigcontext *) ((u_int) cursp - - sizeof(struct sigcontext)); - trampf = (struct trampframe *) ((u_int) sigctx - + sigctx = (struct sigcontext *) (cursp - sizeof(struct sigcontext)); + trampf = (struct trampframe *) ((unsigned)sigctx - sizeof(struct trampframe)); - cursp = (u_int *) sigctx - 2; /* Place for pointer to arg list in - * sigreturn */ - syscf = p->p_addr->u_pcb.framep; + /* Place for pointer to arg list in sigreturn */ + cursp = (unsigned)sigctx - 8; + if (useracc((caddr_t) cursp, sizeof(struct sigcontext) + sizeof(struct trampframe), B_WRITE) == 0) { /* @@ -458,7 +462,7 @@ sendsig(catcher, sig, mask, code) } /* Set up pointers for sigreturn args */ trampf->arg = (int) sigctx; - trampf->pc = (u_int) catcher; + trampf->pc = (unsigned) catcher; trampf->scp = (int) sigctx; trampf->code = code; trampf->sig = sig; @@ -468,14 +472,14 @@ sendsig(catcher, sig, mask, code) sigctx->sc_ps = syscf->psl; sigctx->sc_ap = syscf->ap; sigctx->sc_fp = syscf->fp; - sigctx->sc_sp = mfpr(PR_USP); + sigctx->sc_sp = syscf->sp; sigctx->sc_onstack = oonstack; sigctx->sc_mask = mask; - syscf->pc = (u_int) (((char *) PS_STRINGS) - (esigcode - sigcode)); + syscf->pc = (unsigned) (((char *) PS_STRINGS) - (esigcode - sigcode)); syscf->psl = PSL_U | PSL_PREVU; - syscf->ap = (u_int) cursp; - mtpr(cursp, PR_USP); + syscf->ap = cursp; + syscf->sp = cursp; } int waittime = -1; @@ -616,21 +620,10 @@ process_read_regs(p, regs) { struct trapframe *tf = p->p_addr->u_pcb.framep; - regs->r0 = tf->r0; - regs->r1 = tf->r1; - regs->r2 = tf->r2; - regs->r3 = tf->r3; - regs->r4 = tf->r4; - regs->r5 = tf->r5; - regs->r6 = tf->r6; - regs->r7 = tf->r7; - regs->r8 = tf->r8; - regs->r9 = tf->r9; - regs->r10 = tf->r10; - regs->r11 = tf->r11; + bcopy(&tf->r0, ®s->r0, 12 * sizeof(int)); regs->ap = tf->ap; regs->fp = tf->fp; - regs->sp = mfpr(PR_USP); + regs->sp = tf->sp; regs->pc = tf->pc; regs->psl = tf->psl; return 0; @@ -643,21 +636,10 @@ process_write_regs(p, regs) { struct trapframe *tf = p->p_addr->u_pcb.framep; - tf->r0 = regs->r0; - tf->r1 = regs->r1; - tf->r2 = regs->r2; - tf->r3 = regs->r3; - tf->r4 = regs->r4; - tf->r5 = regs->r5; - tf->r6 = regs->r6; - tf->r7 = regs->r7; - tf->r8 = regs->r8; - tf->r9 = regs->r9; - tf->r10 = regs->r10; - tf->r11 = regs->r11; + bcopy(®s->r0, &tf->r0, 12 * sizeof(int)); tf->ap = regs->ap; tf->fp = regs->fp; - mtpr(regs->sp, PR_USP); + tf->sp = regs->sp; tf->pc = regs->pc; tf->psl = regs->psl; return 0; @@ -665,11 +647,11 @@ process_write_regs(p, regs) int process_set_pc(p, addr) - struct proc *p; - caddr_t addr; + struct proc *p; + caddr_t addr; { - void *ptr; - struct trapframe *tf; + struct trapframe *tf; + void *ptr; if ((p->p_flag & P_INMEM) == 0) return (EIO); @@ -677,7 +659,7 @@ process_set_pc(p, addr) ptr = (char *) p->p_addr->u_pcb.framep; tf = ptr; - tf->pc = (u_int) addr; + tf->pc = (unsigned) addr; return (0); } @@ -703,12 +685,6 @@ process_sstep(p, sstep) return (0); } -#undef setsoftnet -setsoftnet() -{ - panic("setsoftnet"); -} - ns_cksum() { panic("ns_cksum"); @@ -716,8 +692,10 @@ ns_cksum() cmrerr() { +#if 0 switch (cpunumber) { case VAX_750: ka750_memerr(); } +#endif } diff --git a/sys/arch/vax/vax/subr.s b/sys/arch/vax/vax/subr.s index 34692c377f8..f0a6e60b84b 100644 --- a/sys/arch/vax/vax/subr.s +++ b/sys/arch/vax/vax/subr.s @@ -1,4 +1,4 @@ -/* $NetBSD: subr.s,v 1.12 1995/11/10 19:08:59 ragge Exp $ */ +/* $NetBSD: subr.s,v 1.13 1996/01/28 12:22:52 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. @@ -211,12 +211,12 @@ cs: ret ret -_loswtch: .globl _loswtch,_rei +_loswtch: .globl _loswtch mtpr _curpcb,$PR_PCBB svpctx mtpr _nypcb,$PR_PCBB ldpctx -_rei: rei + rei .data diff --git a/sys/arch/vax/vax/vm_machdep.c b/sys/arch/vax/vax/vm_machdep.c index b49bcddc6f7..8a39aab0def 100644 --- a/sys/arch/vax/vax/vm_machdep.c +++ b/sys/arch/vax/vax/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.18 1995/12/13 18:47:59 ragge Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.19 1996/01/28 12:22:49 ragge Exp $ */ #undef SWDEBUG /* @@ -51,6 +51,7 @@ #include "machine/macros.h" #include "machine/trap.h" #include "machine/pcb.h" +#include "machine/frame.h" #include <sys/syscallargs.h> @@ -126,7 +127,6 @@ cpu_fork(p1, p2) nyproc->P0LR = AST_PCB; nyproc->P1LR = 0x200000; #endif - nyproc->USP = mfpr(PR_USP); nyproc->iftrap = NULL; nyproc->KSP = (u_int)p2->p_addr + USPACE; @@ -135,6 +135,7 @@ cpu_fork(p1, p2) bcopy(&tf->r2,&nyproc->R[2],10*sizeof(int)); nyproc->AP = tf->ap; nyproc->FP = tf->fp; + nyproc->USP = tf->sp; nyproc->PC = tf->pc; nyproc->PSL = tf->psl & ~PSL_C; nyproc->R[0] = p1->p_pid; /* parent pid. (shouldn't be needed) */ @@ -158,30 +159,25 @@ cpu_set_kpc(p, pc) { struct pcb *nyproc; struct { - u_int chand; - u_int mask; - u_int ap; - u_int fp; - u_int pc; - u_int nargs; - u_int pp; - u_int rpc; - u_int rpsl; + struct callsframe cf; + struct trapframe tf; } *kc; - extern int rei; - - kc = (void *)p->p_addr + USPACE - sizeof(*kc); - kc->chand = 0; - kc->mask = 0x20000000; - kc->pc = (u_int)&rei; - kc->nargs = 1; - kc->pp = (u_int)p; - kc->rpsl = 0x3c00000; + extern int sret, boothowto; nyproc = &p->p_addr->u_pcb; - nyproc->framep = (void *)p->p_addr + USPACE - sizeof(struct trapframe); - nyproc->AP = (u_int)&kc->nargs; - nyproc->FP = nyproc->KSP = (u_int)kc; + (unsigned)kc = nyproc->FP = nyproc->KSP = + (unsigned)p->p_addr + USPACE - sizeof(*kc); + kc->cf.ca_cond = 0; + kc->cf.ca_maskpsw = 0x20000000; + kc->cf.ca_pc = (unsigned)&sret; + kc->cf.ca_argno = 1; + kc->cf.ca_arg1 = (unsigned)p; + kc->tf.r11 = boothowto; /* If we have old init */ + kc->tf.psl = 0x3c00000; + + nyproc->framep = (void *)&kc->tf; + nyproc->AP = (unsigned)&kc->cf.ca_argno; + nyproc->FP = nyproc->KSP = (unsigned)kc; nyproc->PC = pc + 2; } @@ -453,7 +449,6 @@ cpu_coredump(p, vp, cred, chdr) chdr->c_cpusize = sizeof(struct md_coredump); bcopy(tf, &state, sizeof(struct md_coredump)); - state.md_tf.code = mfpr(PR_USP); /* XXX */ CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_VAX, CORE_CPU); cseg.c_addr = 0; @@ -506,7 +501,7 @@ cpu_swapin(p) uarea = (u_int)p->p_addr; - for(i = uarea;i < uarea + USPACE;i += PAGE_SIZE) { + for (i = uarea;i < uarea + USPACE;i += PAGE_SIZE) { j = (u_int *)kvtopte(i); if ((*j & PG_V) == 0) { rv = vm_fault(kernel_map, i, |