diff options
author | dg <dg@FreeBSD.org> | 1994-01-03 07:55:47 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1994-01-03 07:55:47 +0000 |
commit | 59648ea2fc4d9fa5556db2324cb5f60fac5b3952 (patch) | |
tree | 335a0362d7e0b850b7fde5b1346f528195b5feb7 | |
parent | 17916ffcbb0b38dff696ae09db5821a833224036 (diff) | |
download | FreeBSD-src-59648ea2fc4d9fa5556db2324cb5f60fac5b3952.zip FreeBSD-src-59648ea2fc4d9fa5556db2324cb5f60fac5b3952.tar.gz |
Convert syscall to trapframe. Based on work done by John Brezak.
-rw-r--r-- | sys/amd64/amd64/db_trace.c | 93 | ||||
-rw-r--r-- | sys/amd64/amd64/exception.S | 40 | ||||
-rw-r--r-- | sys/amd64/amd64/exception.s | 40 | ||||
-rw-r--r-- | sys/amd64/amd64/fpu.c | 4 | ||||
-rw-r--r-- | sys/amd64/amd64/machdep.c | 274 | ||||
-rw-r--r-- | sys/amd64/amd64/mem.c | 14 | ||||
-rw-r--r-- | sys/amd64/amd64/trap.c | 61 | ||||
-rw-r--r-- | sys/amd64/include/frame.h | 25 | ||||
-rw-r--r-- | sys/amd64/include/pcb.h | 3 | ||||
-rw-r--r-- | sys/amd64/include/reg.h | 24 | ||||
-rw-r--r-- | sys/amd64/isa/npx.c | 4 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.c | 8 | ||||
-rw-r--r-- | sys/i386/i386/db_trace.c | 93 | ||||
-rw-r--r-- | sys/i386/i386/exception.s | 40 | ||||
-rw-r--r-- | sys/i386/i386/machdep.c | 274 | ||||
-rw-r--r-- | sys/i386/i386/mem.c | 14 | ||||
-rw-r--r-- | sys/i386/i386/trap.c | 61 | ||||
-rw-r--r-- | sys/i386/include/frame.h | 25 | ||||
-rw-r--r-- | sys/i386/include/pcb.h | 3 | ||||
-rw-r--r-- | sys/i386/include/reg.h | 24 | ||||
-rw-r--r-- | sys/i386/isa/npx.c | 4 | ||||
-rw-r--r-- | sys/i386/isa/syscons.c | 8 | ||||
-rw-r--r-- | sys/isa/syscons.c | 8 | ||||
-rw-r--r-- | sys/kern/subr_trap.c | 61 |
24 files changed, 445 insertions, 760 deletions
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index 9e300cf..5e475a4 100644 --- a/sys/amd64/amd64/db_trace.c +++ b/sys/amd64/amd64/db_trace.c @@ -23,7 +23,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: db_trace.c,v 1.2 1993/10/16 14:14:56 rgrimes Exp $ + * $Id: db_trace.c,v 1.3 1993/12/19 00:50:01 wollman Exp $ */ #include "param.h" @@ -73,8 +73,10 @@ struct i386_frame { #define TRAP 1 #define INTERRUPT 2 +#define SYSCALL 3 db_addr_t db_trap_symbol_value = 0; +db_addr_t db_syscall_symbol_value = 0; db_addr_t db_kdintr_symbol_value = 0; boolean_t db_trace_symbols_found = FALSE; @@ -86,6 +88,8 @@ db_find_trace_symbols() db_trap_symbol_value = (db_addr_t) value; if (db_value_of_name("_kdintr", &value)) db_kdintr_symbol_value = (db_addr_t) value; + if (db_value_of_name("_syscall", &value)) + db_syscall_symbol_value = (db_addr_t) value; db_trace_symbols_found = TRUE; } @@ -135,26 +139,43 @@ db_nextframe(fp, ip, argp, is_trap) { struct i386_saved_state *saved_regs; - if (is_trap == 0) { + switch (is_trap) { + case 0: *ip = (db_addr_t) db_get_value((int) &(*fp)->f_retaddr, 4, FALSE); *fp = (struct i386_frame *) db_get_value((int) &(*fp)->f_frame, 4, FALSE); - } else { + break; + case TRAP: + default: /* * We know that trap() has 1 argument and we know that * it is an (int *). */ +#if 0 saved_regs = (struct i386_saved_state *) db_get_value((int)argp, 4, FALSE); +#endif + saved_regs = (struct i386_saved_state *)argp; db_printf("--- trap (number %d) ---\n", saved_regs->tf_trapno & 0xffff); db_printsym(saved_regs->tf_eip, DB_STGY_XTRN); db_printf(":\n"); *fp = (struct i386_frame *)saved_regs->tf_ebp; *ip = (db_addr_t)saved_regs->tf_eip; - } + break; + case SYSCALL: { + struct trapframe *saved_regs = (struct trapframe *)argp; + + db_printf("--- syscall (number %d) ---\n", saved_regs->tf_eax); + db_printsym(saved_regs->tf_eip, DB_STGY_XTRN); + db_printf(":\n"); + *fp = (struct i386_frame *)saved_regs->tf_ebp; + *ip = (db_addr_t)saved_regs->tf_eip; + } + break; + } } void @@ -171,8 +192,10 @@ db_stack_trace_cmd(addr, have_addr, count, modif) boolean_t kernel_only = TRUE; boolean_t trace_thread = FALSE; +#if 0 if (!db_trace_symbols_found) db_find_trace_symbols(); +#endif { register char *cp = modif; @@ -203,38 +226,84 @@ db_stack_trace_cmd(addr, have_addr, count, modif) lastframe = 0; while (count-- && frame != 0) { - register int narg; + int narg; char * name; db_expr_t offset; + db_sym_t sym; +#define MAXNARG 16 + char *argnames[MAXNARG], **argnp = NULL; - if (INKERNEL((int)frame) && callpc == db_trap_symbol_value) { + sym = db_search_symbol(callpc, DB_STGY_ANY, &offset); + db_symbol_values(sym, &name, NULL); + + if (lastframe == 0 && sym == NULL) { + /* Symbol not found, peek at code */ + int instr = db_get_value(callpc, 4, FALSE); + + offset = 1; + if ((instr & 0x00ffffff) == 0x00e58955 || + /* enter: pushl %ebp, movl %esp, %ebp */ + (instr & 0x0000ffff) == 0x0000e589 + /* enter+1: movl %esp, %ebp */ ) { + offset = 0; + } + } +#define STRCMP(s1,s2) ((s1) && (s2) && strcmp((s1), (s2)) == 0) + if (INKERNEL((int)frame) && STRCMP(name, "_trap")) { narg = 1; is_trap = TRAP; } else - if (INKERNEL((int)frame) && callpc == db_kdintr_symbol_value) { + if (INKERNEL((int)frame) && STRCMP(name, "_kdintr")) { is_trap = INTERRUPT; narg = 0; } + else + if (INKERNEL((int)frame) && STRCMP(name, "_syscall")) { + is_trap = SYSCALL; + narg = 0; + } +#undef STRCMP else { is_trap = 0; - narg = db_numargs(frame); + narg = MAXNARG; + if (db_sym_numargs(sym, &narg, argnames)) { + argnp = argnames; + } else { + narg = db_numargs(frame); + } } - db_find_sym_and_offset(callpc, &name, &offset); db_printf("%s(", name); - argp = &frame->f_arg0; + if (lastframe == 0 && offset == 0 && !have_addr) { + /* + * We have a breakpoint before the frame is set up + * Use %esp instead + */ + argp = &((struct i386_frame *)(ddb_regs.tf_esp-4))->f_arg0; + } else + argp = &frame->f_arg0; + while (narg) { + if (argnp) + db_printf("%s=", *argnp++); db_printf("%x", db_get_value((int)argp, 4, FALSE)); argp++; if (--narg != 0) db_printf(","); } db_printf(") at "); - db_printsym(callpc, DB_STGY_XTRN); + db_printsym(callpc, DB_STGY_PROC); db_printf("\n"); + if (lastframe == 0 && offset == 0 && !have_addr) { + /* Frame really belongs to next callpc */ + lastframe = (struct i386_frame *)(ddb_regs.tf_esp-4); + callpc = (db_addr_t)db_get_value((int)&lastframe->f_retaddr, 4, FALSE); + continue; + } + lastframe = frame; db_nextframe(&frame, &callpc, &frame->f_arg0, is_trap); @@ -257,7 +326,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) else { /* in user */ if (frame <= lastframe) { - db_printf("Bad frame pointer: 0x%x\n", frame); + db_printf("Bad user frame pointer: 0x%x\n", frame); break; } } diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S index d6de874..93aed94 100644 --- a/sys/amd64/amd64/exception.S +++ b/sys/amd64/amd64/exception.S @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: exception.s,v 1.1 1993/11/13 02:24:57 davidg Exp $ */ #include "npx.h" /* NNPX */ @@ -181,7 +181,7 @@ calltrap: * Return through doreti to handle ASTs. Have to change trap frame * to interrupt frame. */ - movl $T_ASTFLT,4+4+32(%esp) /* new trap type (err code not used) */ + movl $T_ASTFLT,TF_TRAPNO(%esp) /* new trap type (err code not used) */ pushl _cpl pushl $0 /* dummy unit */ jmp doreti @@ -195,8 +195,8 @@ calltrap: bpttraps: pushal nop - pushl %es pushl %ds + pushl %es movl $KDSEL,%eax movl %ax,%ds movl %ax,%es @@ -211,38 +211,24 @@ bpttraps: */ SUPERALIGN_TEXT IDTVEC(syscall) - pushfl /* only for stupid carry bit and more stupid wait3 cc kludge */ - /* XXX - also for direction flag (bzero, etc. clear it) */ - pushal /* only need eax,ecx,edx - trap resaves others */ + pushfl /* Room for tf_err */ + pushfl /* Room for tf_trapno */ + pushal nop + pushl %ds + pushl %es movl $KDSEL,%eax /* switch to kernel segments */ movl %ax,%ds movl %ax,%es + movl TF_ERR(%esp),%eax /* copy eflags from tf_err to fs_eflags */ + movl %eax,TF_EFLAGS(%esp) + movl $0,TF_ERR(%esp) /* zero tf_err */ incl _cnt+V_SYSCALL call _syscall /* - * Return through doreti to handle ASTs. Have to change syscall frame - * to interrupt frame. - * - * XXX - we should have set up the frame earlier to avoid the - * following popal/pushal (not much can be done to avoid shuffling - * the flags). Consistent frames would simplify things all over. + * Return through doreti to handle ASTs. */ - movl 32+0(%esp),%eax /* old flags, shuffle to above cs:eip */ - movl 32+4(%esp),%ebx /* `int' frame should have been ef, eip, cs */ - movl 32+8(%esp),%ecx - movl %ebx,32+0(%esp) - movl %ecx,32+4(%esp) - movl %eax,32+8(%esp) - popal - nop - pushl $0 /* dummy error code */ - pushl $T_ASTFLT - pushal - nop - movl __udatasel,%eax /* switch back to user segments */ - pushl %eax /* XXX - better to preserve originals? */ - pushl %eax + movl $T_ASTFLT,TF_TRAPNO(%esp) /* new trap type (err code not used) */ pushl _cpl pushl $0 jmp doreti diff --git a/sys/amd64/amd64/exception.s b/sys/amd64/amd64/exception.s index d6de874..93aed94 100644 --- a/sys/amd64/amd64/exception.s +++ b/sys/amd64/amd64/exception.s @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: exception.s,v 1.1 1993/11/13 02:24:57 davidg Exp $ */ #include "npx.h" /* NNPX */ @@ -181,7 +181,7 @@ calltrap: * Return through doreti to handle ASTs. Have to change trap frame * to interrupt frame. */ - movl $T_ASTFLT,4+4+32(%esp) /* new trap type (err code not used) */ + movl $T_ASTFLT,TF_TRAPNO(%esp) /* new trap type (err code not used) */ pushl _cpl pushl $0 /* dummy unit */ jmp doreti @@ -195,8 +195,8 @@ calltrap: bpttraps: pushal nop - pushl %es pushl %ds + pushl %es movl $KDSEL,%eax movl %ax,%ds movl %ax,%es @@ -211,38 +211,24 @@ bpttraps: */ SUPERALIGN_TEXT IDTVEC(syscall) - pushfl /* only for stupid carry bit and more stupid wait3 cc kludge */ - /* XXX - also for direction flag (bzero, etc. clear it) */ - pushal /* only need eax,ecx,edx - trap resaves others */ + pushfl /* Room for tf_err */ + pushfl /* Room for tf_trapno */ + pushal nop + pushl %ds + pushl %es movl $KDSEL,%eax /* switch to kernel segments */ movl %ax,%ds movl %ax,%es + movl TF_ERR(%esp),%eax /* copy eflags from tf_err to fs_eflags */ + movl %eax,TF_EFLAGS(%esp) + movl $0,TF_ERR(%esp) /* zero tf_err */ incl _cnt+V_SYSCALL call _syscall /* - * Return through doreti to handle ASTs. Have to change syscall frame - * to interrupt frame. - * - * XXX - we should have set up the frame earlier to avoid the - * following popal/pushal (not much can be done to avoid shuffling - * the flags). Consistent frames would simplify things all over. + * Return through doreti to handle ASTs. */ - movl 32+0(%esp),%eax /* old flags, shuffle to above cs:eip */ - movl 32+4(%esp),%ebx /* `int' frame should have been ef, eip, cs */ - movl 32+8(%esp),%ecx - movl %ebx,32+0(%esp) - movl %ecx,32+4(%esp) - movl %eax,32+8(%esp) - popal - nop - pushl $0 /* dummy error code */ - pushl $T_ASTFLT - pushal - nop - movl __udatasel,%eax /* switch back to user segments */ - pushl %eax /* XXX - better to preserve originals? */ - pushl %eax + movl $T_ASTFLT,TF_TRAPNO(%esp) /* new trap type (err code not used) */ pushl _cpl pushl $0 jmp doreti diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c index 0e90bff..796dfbb 100644 --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 - * $Id: npx.c,v 1.4 1993/11/03 00:29:19 paul Exp $ + * $Id: npx.c,v 1.5 1993/11/03 23:32:35 paul Exp $ */ #include "npx.h" @@ -439,7 +439,6 @@ npxintr(frame) * just before it is used). */ curproc->p_regs = (int *)&frame.if_es; - curpcb->pcb_flags |= FM_TRAP; /* used by sendsig */ #ifdef notyet /* * Encode the appropriate code for detailed information on @@ -450,7 +449,6 @@ npxintr(frame) code = 0; /* XXX */ #endif trapsignal(curproc, SIGFPE, code); - curpcb->pcb_flags &= ~FM_TRAP; } else { /* * Nested interrupt. These losers occur when: diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 4171474..f47d9e6 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.22 1993/12/19 00:50:03 wollman Exp $ + * $Id: machdep.c,v 1.23 1993/12/22 13:12:04 davidg Exp $ */ #include "npx.h" @@ -418,7 +418,6 @@ sendsig(catcher, sig, mask, code) regs = p->p_regs; oonstack = ps->ps_onstack; - frmtrap = curpcb->pcb_flags & FM_TRAP; /* * Allocate and validate space for the signal handler * context. Note that if the stack is in P0 space, the @@ -431,12 +430,8 @@ sendsig(catcher, sig, mask, code) - sizeof(struct sigframe)); ps->ps_onstack = 1; } else { - if (frmtrap) - fp = (struct sigframe *)(regs[tESP] - - sizeof(struct sigframe)); - else - fp = (struct sigframe *)(regs[sESP] - - sizeof(struct sigframe)); + fp = (struct sigframe *)(regs[tESP] + - sizeof(struct sigframe)); } if (useracc((caddr_t)fp, sizeof (struct sigframe), B_WRITE) == 0) { @@ -463,35 +458,21 @@ sendsig(catcher, sig, mask, code) fp->sf_handler = catcher; /* save scratch registers */ - if(frmtrap) { - fp->sf_eax = regs[tEAX]; - fp->sf_edx = regs[tEDX]; - fp->sf_ecx = regs[tECX]; - } else { - fp->sf_eax = regs[sEAX]; - fp->sf_edx = regs[sEDX]; - fp->sf_ecx = regs[sECX]; - } + fp->sf_eax = regs[tEAX]; + fp->sf_edx = regs[tEDX]; + fp->sf_ecx = regs[tECX]; + /* * Build the signal context to be used by sigreturn. */ fp->sf_sc.sc_onstack = oonstack; fp->sf_sc.sc_mask = mask; - if(frmtrap) { - fp->sf_sc.sc_sp = regs[tESP]; - fp->sf_sc.sc_fp = regs[tEBP]; - fp->sf_sc.sc_pc = regs[tEIP]; - fp->sf_sc.sc_ps = regs[tEFLAGS]; - regs[tESP] = (int)fp; - regs[tEIP] = (int)((struct pcb *)kstack)->pcb_sigc; - } else { - fp->sf_sc.sc_sp = regs[sESP]; - fp->sf_sc.sc_fp = regs[sEBP]; - fp->sf_sc.sc_pc = regs[sEIP]; - fp->sf_sc.sc_ps = regs[sEFLAGS]; - regs[sESP] = (int)fp; - regs[sEIP] = (int)((struct pcb *)kstack)->pcb_sigc; - } + fp->sf_sc.sc_sp = regs[tESP]; + fp->sf_sc.sc_fp = regs[tEBP]; + fp->sf_sc.sc_pc = regs[tEIP]; + fp->sf_sc.sc_ps = regs[tEFLAGS]; + regs[tESP] = (int)fp; + regs[tEIP] = (int)((struct pcb *)kstack)->pcb_sigc; } /* @@ -519,7 +500,7 @@ sigreturn(p, uap, retval) register int *regs = p->p_regs; /* - * (XXX old comment) regs[sESP] points to the return address. + * (XXX old comment) regs[tESP] points to the return address. * The user scp pointer is above that. * The return address is faked in the signal trampoline code * for consistency. @@ -532,9 +513,9 @@ sigreturn(p, uap, retval) return(EINVAL); /* restore scratch registers */ - regs[sEAX] = fp->sf_eax ; - regs[sEDX] = fp->sf_edx ; - regs[sECX] = fp->sf_ecx ; + regs[tEAX] = fp->sf_eax ; + regs[tEDX] = fp->sf_edx ; + regs[tECX] = fp->sf_ecx ; if (useracc((caddr_t)scp, sizeof (*scp), 0) == 0) return(EINVAL); @@ -546,10 +527,10 @@ sigreturn(p, uap, retval) p->p_sigacts->ps_onstack = scp->sc_onstack & 01; p->p_sigmask = scp->sc_mask &~ (sigmask(SIGKILL)|sigmask(SIGCONT)|sigmask(SIGSTOP)); - regs[sEBP] = scp->sc_fp; - regs[sESP] = scp->sc_sp; - regs[sEIP] = scp->sc_pc; - regs[sEFLAGS] = scp->sc_ps; + regs[tEBP] = scp->sc_fp; + regs[tESP] = scp->sc_sp; + regs[tEIP] = scp->sc_pc; + regs[tEFLAGS] = scp->sc_ps; return(EJUSTRETURN); } @@ -762,13 +743,18 @@ initcpu() * Clear registers on exec */ void -setregs(p, entry) +setregs(p, entry, stack) struct proc *p; u_long entry; + u_long stack; { - - p->p_regs[sEBP] = 0; /* bottom of the fp chain */ - p->p_regs[sEIP] = entry; + p->p_regs[tEBP] = 0; /* bottom of the fp chain */ + p->p_regs[tEIP] = entry; + p->p_regs[tESP] = stack; + p->p_regs[tSS] = _udatasel; + p->p_regs[tDS] = _udatasel; + p->p_regs[tES] = _udatasel; + p->p_regs[tCS] = _ucodesel; p->p_addr->u_pcb.pcb_flags = 0; /* no fp at all */ load_cr0(rcr0() | CR0_TS); /* start emulating */ @@ -1153,7 +1139,7 @@ init386(first) x = (int) &IDTVEC(syscall); gdp->gd_looffset = x++; gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL); - gdp->gd_stkcpy = 0; + gdp->gd_stkcpy = 1; /* Leaves room for eflags like a trap */ gdp->gd_type = SDT_SYS386CGT; gdp->gd_dpl = SEL_UPL; gdp->gd_p = 1; @@ -1268,35 +1254,24 @@ _remque(element) int ptrace_set_pc (struct proc *p, unsigned int addr) { - struct pcb *pcb; void *regs = (char*)p->p_addr + ((char*) p->p_regs - (char*) kstack); - pcb = &p->p_addr->u_pcb; - if (pcb->pcb_flags & FM_TRAP) - ((struct trapframe *)regs)->tf_eip = addr; - else - ((struct syscframe *)regs)->sf_eip = addr; + ((struct trapframe *)regs)->tf_eip = addr; return 0; } int ptrace_single_step (struct proc *p) { - struct pcb *pcb; void *regs = (char*)p->p_addr + ((char*) p->p_regs - (char*) kstack); - pcb = &p->p_addr->u_pcb; - if (pcb->pcb_flags & FM_TRAP) - ((struct trapframe *)regs)->tf_eflags |= PSL_T; - else - ((struct syscframe *)regs)->sf_eflags |= PSL_T; + ((struct trapframe *)regs)->tf_eflags |= PSL_T; return 0; } /* - * Copy the registers to user-space. This is tedious because - * we essentially duplicate code for trapframe and syscframe. *sigh* + * Copy the registers to user-space. */ int @@ -1325,50 +1300,24 @@ int fill_regs(struct proc *p, struct regs *regs) { int error; struct trapframe *tp; - struct syscframe *sp; - struct pcb *pcb; void *ptr = (char*)p->p_addr + ((char*) p->p_regs - (char*) kstack); - pcb = &p->p_addr->u_pcb; - if (pcb->pcb_flags & FM_TRAP) { - tp = ptr; - regs->r_es = tp->tf_es; - regs->r_ds = tp->tf_ds; - regs->r_edi = tp->tf_edi; - regs->r_esi = tp->tf_esi; - regs->r_ebp = tp->tf_ebp; - regs->r_ebx = tp->tf_ebx; - regs->r_edx = tp->tf_edx; - regs->r_ecx = tp->tf_ecx; - regs->r_eax = tp->tf_eax; - regs->r_eip = tp->tf_eip; - regs->r_cs = tp->tf_cs; - regs->r_eflags = tp->tf_eflags; - regs->r_esp = tp->tf_esp; - regs->r_ss = tp->tf_ss; - } else { - sp = ptr; - /* - * No sf_es or sf_ds... dunno why. - */ - /* - * regs.r_es = sp->sf_es; - * regs.r_ds = sp->sf_ds; - */ - regs->r_edi = sp->sf_edi; - regs->r_esi = sp->sf_esi; - regs->r_ebp = sp->sf_ebp; - regs->r_ebx = sp->sf_ebx; - regs->r_edx = sp->sf_edx; - regs->r_ecx = sp->sf_ecx; - regs->r_eax = sp->sf_eax; - regs->r_eip = sp->sf_eip; - regs->r_cs = sp->sf_cs; - regs->r_eflags = sp->sf_eflags; - regs->r_esp = sp->sf_esp; - regs->r_ss = sp->sf_ss; - } + tp = ptr; + regs->r_es = tp->tf_es; + regs->r_ds = tp->tf_ds; + regs->r_edi = tp->tf_edi; + regs->r_esi = tp->tf_esi; + regs->r_ebp = tp->tf_ebp; + regs->r_ebx = tp->tf_ebx; + regs->r_edx = tp->tf_edx; + regs->r_ecx = tp->tf_ecx; + regs->r_eax = tp->tf_eax; + regs->r_eip = tp->tf_eip; + regs->r_cs = tp->tf_cs; + regs->r_eflags = tp->tf_eflags; + regs->r_esp = tp->tf_esp; + regs->r_ss = tp->tf_ss; return 0; } @@ -1376,122 +1325,27 @@ int set_regs (struct proc *p, struct regs *regs) { int error; struct trapframe *tp; - struct syscframe *sp; - struct pcb *pcb; void *ptr = (char*)p->p_addr + ((char*) p->p_regs - (char*) kstack); - pcb = &p->p_addr->u_pcb; - if (pcb->pcb_flags & FM_TRAP) { - tp = ptr; - tp->tf_es = regs->r_es; - tp->tf_ds = regs->r_ds; - tp->tf_edi = regs->r_edi; - tp->tf_esi = regs->r_esi; - tp->tf_ebp = regs->r_ebp; - tp->tf_ebx = regs->r_ebx; - tp->tf_edx = regs->r_edx; - tp->tf_ecx = regs->r_ecx; - tp->tf_eax = regs->r_eax; - tp->tf_eip = regs->r_eip; - tp->tf_cs = regs->r_cs; - tp->tf_eflags = regs->r_eflags; - tp->tf_esp = regs->r_esp; - tp->tf_ss = regs->r_ss; - } else { - sp = ptr; - /* - * No sf_es or sf_ds members, dunno why... - */ - /* - * sp->sf_es = regs.r_es; - * sp->sf_ds = regs.r_ds; - */ - sp->sf_edi = regs->r_edi; - sp->sf_esi = regs->r_esi; - sp->sf_ebp = regs->r_ebp; - sp->sf_ebx = regs->r_ebx; - sp->sf_edx = regs->r_edx; - sp->sf_ecx = regs->r_ecx; - sp->sf_eax = regs->r_eax; - sp->sf_eip = regs->r_eip; - sp->sf_cs = regs->r_cs; - sp->sf_eflags = regs->r_eflags; - sp->sf_esp = regs->r_esp; - sp->sf_ss = regs->r_ss; - } + tp = ptr; + tp->tf_es = regs->r_es; + tp->tf_ds = regs->r_ds; + tp->tf_edi = regs->r_edi; + tp->tf_esi = regs->r_esi; + tp->tf_ebp = regs->r_ebp; + tp->tf_ebx = regs->r_ebx; + tp->tf_edx = regs->r_edx; + tp->tf_ecx = regs->r_ecx; + tp->tf_eax = regs->r_eax; + tp->tf_eip = regs->r_eip; + tp->tf_cs = regs->r_cs; + tp->tf_eflags = regs->r_eflags; + tp->tf_esp = regs->r_esp; + tp->tf_ss = regs->r_ss; return 0; } -#ifdef SLOW_OLD_COPYSTRS -vmunaccess() {} - -#if 0 /* assembler versions now in locore.s */ -/* - * Below written in C to allow access to debugging code - */ -copyinstr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *toaddr, *fromaddr; { - int c,tally; - - tally = 0; - while (maxlength--) { - c = fubyte(fromaddr++); - if (c == -1) { - if(lencopied) *lencopied = tally; - return(EFAULT); - } - tally++; - *(char *)toaddr++ = (char) c; - if (c == 0){ - if(lencopied) *lencopied = (u_int)tally; - return(0); - } - } - if(lencopied) *lencopied = (u_int)tally; - return(ENAMETOOLONG); -} - -copyoutstr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *fromaddr, *toaddr; { - int c; - int tally; - - tally = 0; - while (maxlength--) { - c = subyte(toaddr++, *(char *)fromaddr); - if (c == -1) return(EFAULT); - tally++; - if (*(char *)fromaddr++ == 0){ - if(lencopied) *lencopied = tally; - return(0); - } - } - if(lencopied) *lencopied = tally; - return(ENAMETOOLONG); -} - -#endif /* SLOW_OLD_COPYSTRS */ - -copystr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *fromaddr, *toaddr; { - u_int tally; - - tally = 0; - while (maxlength--) { - *(u_char *)toaddr = *(u_char *)fromaddr++; - tally++; - if (*(u_char *)toaddr++ == 0) { - if(lencopied) *lencopied = tally; - return(0); - } - } - if(lencopied) *lencopied = tally; - return(ENAMETOOLONG); -} - -#endif - #include "ddb.h" #if NDDB <= 0 void diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c index b9a912a..c3899a1 100644 --- a/sys/amd64/amd64/mem.c +++ b/sys/amd64/amd64/mem.c @@ -38,7 +38,7 @@ * * from: Utah $Hdr: mem.c 1.13 89/10/08$ * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 - * $Id: mem.c,v 1.5 1993/11/25 01:30:59 wollman Exp $ + * $Id: mem.c,v 1.6 1993/12/19 00:50:06 wollman Exp $ */ /* @@ -70,12 +70,12 @@ mmclose(dev, uio, flags) struct uio *uio; int flags; { - struct syscframe *fp; + struct trapframe *fp; switch (minor(dev)) { case 14: - fp = (struct syscframe *)curproc->p_regs; - fp->sf_eflags &= ~PSL_IOPL; + fp = (struct trapframe *)curproc->p_regs; + fp->tf_eflags &= ~PSL_IOPL; break; default: break; @@ -89,12 +89,12 @@ mmopen(dev, uio, flags) struct uio *uio; int flags; { - struct syscframe *fp; + struct trapframe *fp; switch (minor(dev)) { case 14: - fp = (struct syscframe *)curproc->p_regs; - fp->sf_eflags |= PSL_IOPL; + fp = (struct trapframe *)curproc->p_regs; + fp->tf_eflags |= PSL_IOPL; break; default: break; diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 41370cc..c85ac57 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.11 1993/12/12 12:22:57 davidg Exp $ + * $Id: trap.c,v 1.12 1993/12/19 00:50:09 wollman Exp $ */ /* @@ -179,7 +179,6 @@ copyfault: if (ISPL(frame.tf_cs) == SEL_UPL) { type |= T_USER; p->p_regs = (int *)&frame; - curpcb->pcb_flags |= FM_TRAP; /* used by sendsig */ } ucode=0; @@ -487,7 +486,6 @@ out: } } curpri = p->p_pri; - curpcb->pcb_flags &= ~FM_TRAP; /* used by sendsig */ } /* @@ -575,7 +573,7 @@ int trapwrite(addr) /*ARGSUSED*/ void syscall(frame) - volatile struct syscframe frame; + volatile struct trapframe frame; { register int *locr0 = ((int *)&frame); register caddr_t params; @@ -591,29 +589,30 @@ syscall(frame) r0 = 0; r0 = r0; r1 = 0; r1 = r1; #endif syst = p->p_stime; - if (ISPL(frame.sf_cs) != SEL_UPL) + if (ISPL(frame.tf_cs) != SEL_UPL) panic("syscall"); - code = frame.sf_eax; - curpcb->pcb_flags &= ~FM_TRAP; /* used by sendsig */ + code = frame.tf_eax; p->p_regs = (int *)&frame; - params = (caddr_t)frame.sf_esp + sizeof (int) ; + params = (caddr_t)frame.tf_esp + sizeof (int) ; /* * Reconstruct pc, assuming lcall $X,y is 7 bytes, as it is always. */ - opc = frame.sf_eip - 7; - callp = (code >= nsysent) ? &sysent[63] : &sysent[code]; - if (callp == sysent) { - i = fuword(params); + opc = frame.tf_eip - 7; + if (code == 0) { + code = fuword(params); params += sizeof (int); - callp = (code >= nsysent) ? &sysent[63] : &sysent[code]; } + if (code < 0 || code >= nsysent) + callp = &sysent[0]; + else + callp = &sysent[code]; if ((i = callp->sy_narg * sizeof (int)) && (error = copyin(params, (caddr_t)args, (u_int)i))) { - frame.sf_eax = error; - frame.sf_eflags |= PSL_C; /* carry bit */ + frame.tf_eax = error; + frame.tf_eflags |= PSL_C; /* carry bit */ #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) ktrsyscall(p->p_tracep, code, callp->sy_narg, args); @@ -625,20 +624,20 @@ syscall(frame) ktrsyscall(p->p_tracep, code, callp->sy_narg, args); #endif rval[0] = 0; - rval[1] = frame.sf_edx; + rval[1] = frame.tf_edx; /*pg("%d. s %d\n", p->p_pid, code);*/ error = (*callp->sy_call)(p, args, rval); if (error == ERESTART) - frame.sf_eip = opc; + frame.tf_eip = opc; else if (error != EJUSTRETURN) { if (error) { /*pg("error %d", error);*/ - frame.sf_eax = error; - frame.sf_eflags |= PSL_C; /* carry bit */ + frame.tf_eax = error; + frame.tf_eflags |= PSL_C; /* carry bit */ } else { - frame.sf_eax = rval[0]; - frame.sf_edx = rval[1]; - frame.sf_eflags &= ~PSL_C; /* carry bit */ + frame.tf_eax = rval[0]; + frame.tf_edx = rval[1]; + frame.tf_eflags &= ~PSL_C; /* carry bit */ } } /* else if (error == EJUSTRETURN) */ @@ -679,10 +678,10 @@ done: if (ticks) { #ifdef PROFTIMER extern int profscale; - addupc(frame.sf_eip, &p->p_stats->p_prof, + addupc(frame.tf_eip, &p->p_stats->p_prof, ticks * profscale); #else - addupc(frame.sf_eip, &p->p_stats->p_prof, ticks); + addupc(frame.tf_eip, &p->p_stats->p_prof, ticks); #endif } } @@ -693,13 +692,13 @@ done: #endif #ifdef DIAGNOSTICx { extern int _udatasel, _ucodesel; - if (frame.sf_ss != _udatasel) - printf("ss %x call %d\n", frame.sf_ss, code); - if ((frame.sf_cs&0xffff) != _ucodesel) - printf("cs %x call %d\n", frame.sf_cs, code); - if (frame.sf_eip > VM_MAXUSER_ADDRESS) { - printf("eip %x call %d\n", frame.sf_eip, code); - frame.sf_eip = 0; + if (frame.tf_ss != _udatasel) + printf("ss %x call %d\n", frame.tf_ss, code); + if ((frame.tf_cs&0xffff) != _ucodesel) + printf("cs %x call %d\n", frame.tf_cs, code); + if (frame.tf_eip > VM_MAXUSER_ADDRESS) { + printf("eip %x call %d\n", frame.tf_eip, code); + frame.tf_eip = 0; } } #endif diff --git a/sys/amd64/include/frame.h b/sys/amd64/include/frame.h index c61d179..b36c141 100644 --- a/sys/amd64/include/frame.h +++ b/sys/amd64/include/frame.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 - * $Id: frame.h,v 1.5 1993/12/03 05:10:00 alm Exp $ + * $Id: frame.h,v 1.6 1993/12/19 00:50:15 wollman Exp $ */ #ifndef _MACHINE_FRAME_H_ @@ -113,28 +113,5 @@ struct sigframe { int sf_edx; int sf_ecx; struct sigcontext sf_sc; -} ; - -/* - * Call Gate/System Call Stack Frame - */ - -struct syscframe { - int sf_edi; - int sf_esi; - int sf_ebp; - int :32; /* redundant save of isp */ - int sf_ebx; - int sf_edx; - int sf_ecx; - int sf_eax; - int sf_eflags; - /* below portion defined in 386 hardware */ -/* int sf_args[N];*/ /* if call gate copy args enabled!*/ - int sf_eip; - int sf_cs; - /* below only when transitting rings (e.g. user to kernel) */ - int sf_esp; - int sf_ss; }; #endif /* _MACHINE_FRAME_H_ */ diff --git a/sys/amd64/include/pcb.h b/sys/amd64/include/pcb.h index 1090798..a7a29df 100644 --- a/sys/amd64/include/pcb.h +++ b/sys/amd64/include/pcb.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 - * $Id: pcb.h,v 1.2 1993/10/08 20:51:00 rgrimes Exp $ + * $Id: pcb.h,v 1.3 1993/11/07 17:42:59 wollman Exp $ */ #ifndef _I386_PCB_H_ @@ -72,7 +72,6 @@ struct pcb { #define FP_NEEDSRESTORE 0x04 /* ... that needs restore on next DNA fault */ #endif #define FP_USESEMC 0x08 /* process uses EMC memory-mapped mode */ -#define FM_TRAP 0x10 /* process entered kernel on a trap frame */ #define FP_SOFTFP 0x20 /* process using software fltng pnt emulator */ short pcb_iml; /* interrupt mask level */ caddr_t pcb_onfault; /* copyin/out fault recovery */ diff --git a/sys/amd64/include/reg.h b/sys/amd64/include/reg.h index 969df87..4cefae0 100644 --- a/sys/amd64/include/reg.h +++ b/sys/amd64/include/reg.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)reg.h 5.5 (Berkeley) 1/18/91 - * $Id: reg.h,v 1.4 1993/11/16 09:54:57 davidg Exp $ + * $Id: reg.h,v 1.5 1993/12/03 05:10:08 alm Exp $ */ #ifndef _MACHINE_REG_H_ @@ -68,28 +68,6 @@ #define tESP (15) #define tSS (16) -/* During a system call, registers are at these offsets instead of above. */ - -#define sEDI (0) -#define sESI (1) -#define sEBP (2) - -#define sEBX (4) -#define sEDX (5) -#define sECX (6) -#define sEAX (7) -#define sEFLAGS (8) -#define sEIP (9) -#define sCS (10) -#define sESP (11) -#define sSS (12) - -#define PC sEIP -#define SP sESP -#define PS sEFLAGS -#define R0 sEDX -#define R1 sECX - /* * Registers accessible to ptrace(2) syscall for debugger * The machine-dependent code for PT_{SET,GET}REGS needs to diff --git a/sys/amd64/isa/npx.c b/sys/amd64/isa/npx.c index 0e90bff..796dfbb 100644 --- a/sys/amd64/isa/npx.c +++ b/sys/amd64/isa/npx.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 - * $Id: npx.c,v 1.4 1993/11/03 00:29:19 paul Exp $ + * $Id: npx.c,v 1.5 1993/11/03 23:32:35 paul Exp $ */ #include "npx.h" @@ -439,7 +439,6 @@ npxintr(frame) * just before it is used). */ curproc->p_regs = (int *)&frame.if_es; - curpcb->pcb_flags |= FM_TRAP; /* used by sendsig */ #ifdef notyet /* * Encode the appropriate code for detailed information on @@ -450,7 +449,6 @@ npxintr(frame) code = 0; /* XXX */ #endif trapsignal(curproc, SIGFPE, code); - curpcb->pcb_flags &= ~FM_TRAP; } else { /* * Nested interrupt. These losers occur when: diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index b683ea0..f8c8763 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -35,7 +35,7 @@ * * from: @(#)pccons.c 5.11 (Berkeley) 5/21/91 * from: @(#)syscons.c 1.1 931021 - * $Id: syscons.c,v 1.22 1993/12/21 02:49:13 rich Exp $ + * $Id: syscons.c,v 1.23 1993/12/21 03:27:26 rich Exp $ * * Heavily modified by Søren Schmidt (sos@login.dkuug.dk) to provide: * @@ -526,14 +526,8 @@ pcparam(struct tty *tp, struct termios *t) return(0); } - -#if defined(NetBSD) #define frametype struct trapframe #define eflags tf_eflags -#else -#define frametype struct syscframe -#define eflags sf_eflags -#endif int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 9e300cf..5e475a4 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -23,7 +23,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: db_trace.c,v 1.2 1993/10/16 14:14:56 rgrimes Exp $ + * $Id: db_trace.c,v 1.3 1993/12/19 00:50:01 wollman Exp $ */ #include "param.h" @@ -73,8 +73,10 @@ struct i386_frame { #define TRAP 1 #define INTERRUPT 2 +#define SYSCALL 3 db_addr_t db_trap_symbol_value = 0; +db_addr_t db_syscall_symbol_value = 0; db_addr_t db_kdintr_symbol_value = 0; boolean_t db_trace_symbols_found = FALSE; @@ -86,6 +88,8 @@ db_find_trace_symbols() db_trap_symbol_value = (db_addr_t) value; if (db_value_of_name("_kdintr", &value)) db_kdintr_symbol_value = (db_addr_t) value; + if (db_value_of_name("_syscall", &value)) + db_syscall_symbol_value = (db_addr_t) value; db_trace_symbols_found = TRUE; } @@ -135,26 +139,43 @@ db_nextframe(fp, ip, argp, is_trap) { struct i386_saved_state *saved_regs; - if (is_trap == 0) { + switch (is_trap) { + case 0: *ip = (db_addr_t) db_get_value((int) &(*fp)->f_retaddr, 4, FALSE); *fp = (struct i386_frame *) db_get_value((int) &(*fp)->f_frame, 4, FALSE); - } else { + break; + case TRAP: + default: /* * We know that trap() has 1 argument and we know that * it is an (int *). */ +#if 0 saved_regs = (struct i386_saved_state *) db_get_value((int)argp, 4, FALSE); +#endif + saved_regs = (struct i386_saved_state *)argp; db_printf("--- trap (number %d) ---\n", saved_regs->tf_trapno & 0xffff); db_printsym(saved_regs->tf_eip, DB_STGY_XTRN); db_printf(":\n"); *fp = (struct i386_frame *)saved_regs->tf_ebp; *ip = (db_addr_t)saved_regs->tf_eip; - } + break; + case SYSCALL: { + struct trapframe *saved_regs = (struct trapframe *)argp; + + db_printf("--- syscall (number %d) ---\n", saved_regs->tf_eax); + db_printsym(saved_regs->tf_eip, DB_STGY_XTRN); + db_printf(":\n"); + *fp = (struct i386_frame *)saved_regs->tf_ebp; + *ip = (db_addr_t)saved_regs->tf_eip; + } + break; + } } void @@ -171,8 +192,10 @@ db_stack_trace_cmd(addr, have_addr, count, modif) boolean_t kernel_only = TRUE; boolean_t trace_thread = FALSE; +#if 0 if (!db_trace_symbols_found) db_find_trace_symbols(); +#endif { register char *cp = modif; @@ -203,38 +226,84 @@ db_stack_trace_cmd(addr, have_addr, count, modif) lastframe = 0; while (count-- && frame != 0) { - register int narg; + int narg; char * name; db_expr_t offset; + db_sym_t sym; +#define MAXNARG 16 + char *argnames[MAXNARG], **argnp = NULL; - if (INKERNEL((int)frame) && callpc == db_trap_symbol_value) { + sym = db_search_symbol(callpc, DB_STGY_ANY, &offset); + db_symbol_values(sym, &name, NULL); + + if (lastframe == 0 && sym == NULL) { + /* Symbol not found, peek at code */ + int instr = db_get_value(callpc, 4, FALSE); + + offset = 1; + if ((instr & 0x00ffffff) == 0x00e58955 || + /* enter: pushl %ebp, movl %esp, %ebp */ + (instr & 0x0000ffff) == 0x0000e589 + /* enter+1: movl %esp, %ebp */ ) { + offset = 0; + } + } +#define STRCMP(s1,s2) ((s1) && (s2) && strcmp((s1), (s2)) == 0) + if (INKERNEL((int)frame) && STRCMP(name, "_trap")) { narg = 1; is_trap = TRAP; } else - if (INKERNEL((int)frame) && callpc == db_kdintr_symbol_value) { + if (INKERNEL((int)frame) && STRCMP(name, "_kdintr")) { is_trap = INTERRUPT; narg = 0; } + else + if (INKERNEL((int)frame) && STRCMP(name, "_syscall")) { + is_trap = SYSCALL; + narg = 0; + } +#undef STRCMP else { is_trap = 0; - narg = db_numargs(frame); + narg = MAXNARG; + if (db_sym_numargs(sym, &narg, argnames)) { + argnp = argnames; + } else { + narg = db_numargs(frame); + } } - db_find_sym_and_offset(callpc, &name, &offset); db_printf("%s(", name); - argp = &frame->f_arg0; + if (lastframe == 0 && offset == 0 && !have_addr) { + /* + * We have a breakpoint before the frame is set up + * Use %esp instead + */ + argp = &((struct i386_frame *)(ddb_regs.tf_esp-4))->f_arg0; + } else + argp = &frame->f_arg0; + while (narg) { + if (argnp) + db_printf("%s=", *argnp++); db_printf("%x", db_get_value((int)argp, 4, FALSE)); argp++; if (--narg != 0) db_printf(","); } db_printf(") at "); - db_printsym(callpc, DB_STGY_XTRN); + db_printsym(callpc, DB_STGY_PROC); db_printf("\n"); + if (lastframe == 0 && offset == 0 && !have_addr) { + /* Frame really belongs to next callpc */ + lastframe = (struct i386_frame *)(ddb_regs.tf_esp-4); + callpc = (db_addr_t)db_get_value((int)&lastframe->f_retaddr, 4, FALSE); + continue; + } + lastframe = frame; db_nextframe(&frame, &callpc, &frame->f_arg0, is_trap); @@ -257,7 +326,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif) else { /* in user */ if (frame <= lastframe) { - db_printf("Bad frame pointer: 0x%x\n", frame); + db_printf("Bad user frame pointer: 0x%x\n", frame); break; } } diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index d6de874..93aed94 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: exception.s,v 1.1 1993/11/13 02:24:57 davidg Exp $ */ #include "npx.h" /* NNPX */ @@ -181,7 +181,7 @@ calltrap: * Return through doreti to handle ASTs. Have to change trap frame * to interrupt frame. */ - movl $T_ASTFLT,4+4+32(%esp) /* new trap type (err code not used) */ + movl $T_ASTFLT,TF_TRAPNO(%esp) /* new trap type (err code not used) */ pushl _cpl pushl $0 /* dummy unit */ jmp doreti @@ -195,8 +195,8 @@ calltrap: bpttraps: pushal nop - pushl %es pushl %ds + pushl %es movl $KDSEL,%eax movl %ax,%ds movl %ax,%es @@ -211,38 +211,24 @@ bpttraps: */ SUPERALIGN_TEXT IDTVEC(syscall) - pushfl /* only for stupid carry bit and more stupid wait3 cc kludge */ - /* XXX - also for direction flag (bzero, etc. clear it) */ - pushal /* only need eax,ecx,edx - trap resaves others */ + pushfl /* Room for tf_err */ + pushfl /* Room for tf_trapno */ + pushal nop + pushl %ds + pushl %es movl $KDSEL,%eax /* switch to kernel segments */ movl %ax,%ds movl %ax,%es + movl TF_ERR(%esp),%eax /* copy eflags from tf_err to fs_eflags */ + movl %eax,TF_EFLAGS(%esp) + movl $0,TF_ERR(%esp) /* zero tf_err */ incl _cnt+V_SYSCALL call _syscall /* - * Return through doreti to handle ASTs. Have to change syscall frame - * to interrupt frame. - * - * XXX - we should have set up the frame earlier to avoid the - * following popal/pushal (not much can be done to avoid shuffling - * the flags). Consistent frames would simplify things all over. + * Return through doreti to handle ASTs. */ - movl 32+0(%esp),%eax /* old flags, shuffle to above cs:eip */ - movl 32+4(%esp),%ebx /* `int' frame should have been ef, eip, cs */ - movl 32+8(%esp),%ecx - movl %ebx,32+0(%esp) - movl %ecx,32+4(%esp) - movl %eax,32+8(%esp) - popal - nop - pushl $0 /* dummy error code */ - pushl $T_ASTFLT - pushal - nop - movl __udatasel,%eax /* switch back to user segments */ - pushl %eax /* XXX - better to preserve originals? */ - pushl %eax + movl $T_ASTFLT,TF_TRAPNO(%esp) /* new trap type (err code not used) */ pushl _cpl pushl $0 jmp doreti diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 4171474..f47d9e6 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.22 1993/12/19 00:50:03 wollman Exp $ + * $Id: machdep.c,v 1.23 1993/12/22 13:12:04 davidg Exp $ */ #include "npx.h" @@ -418,7 +418,6 @@ sendsig(catcher, sig, mask, code) regs = p->p_regs; oonstack = ps->ps_onstack; - frmtrap = curpcb->pcb_flags & FM_TRAP; /* * Allocate and validate space for the signal handler * context. Note that if the stack is in P0 space, the @@ -431,12 +430,8 @@ sendsig(catcher, sig, mask, code) - sizeof(struct sigframe)); ps->ps_onstack = 1; } else { - if (frmtrap) - fp = (struct sigframe *)(regs[tESP] - - sizeof(struct sigframe)); - else - fp = (struct sigframe *)(regs[sESP] - - sizeof(struct sigframe)); + fp = (struct sigframe *)(regs[tESP] + - sizeof(struct sigframe)); } if (useracc((caddr_t)fp, sizeof (struct sigframe), B_WRITE) == 0) { @@ -463,35 +458,21 @@ sendsig(catcher, sig, mask, code) fp->sf_handler = catcher; /* save scratch registers */ - if(frmtrap) { - fp->sf_eax = regs[tEAX]; - fp->sf_edx = regs[tEDX]; - fp->sf_ecx = regs[tECX]; - } else { - fp->sf_eax = regs[sEAX]; - fp->sf_edx = regs[sEDX]; - fp->sf_ecx = regs[sECX]; - } + fp->sf_eax = regs[tEAX]; + fp->sf_edx = regs[tEDX]; + fp->sf_ecx = regs[tECX]; + /* * Build the signal context to be used by sigreturn. */ fp->sf_sc.sc_onstack = oonstack; fp->sf_sc.sc_mask = mask; - if(frmtrap) { - fp->sf_sc.sc_sp = regs[tESP]; - fp->sf_sc.sc_fp = regs[tEBP]; - fp->sf_sc.sc_pc = regs[tEIP]; - fp->sf_sc.sc_ps = regs[tEFLAGS]; - regs[tESP] = (int)fp; - regs[tEIP] = (int)((struct pcb *)kstack)->pcb_sigc; - } else { - fp->sf_sc.sc_sp = regs[sESP]; - fp->sf_sc.sc_fp = regs[sEBP]; - fp->sf_sc.sc_pc = regs[sEIP]; - fp->sf_sc.sc_ps = regs[sEFLAGS]; - regs[sESP] = (int)fp; - regs[sEIP] = (int)((struct pcb *)kstack)->pcb_sigc; - } + fp->sf_sc.sc_sp = regs[tESP]; + fp->sf_sc.sc_fp = regs[tEBP]; + fp->sf_sc.sc_pc = regs[tEIP]; + fp->sf_sc.sc_ps = regs[tEFLAGS]; + regs[tESP] = (int)fp; + regs[tEIP] = (int)((struct pcb *)kstack)->pcb_sigc; } /* @@ -519,7 +500,7 @@ sigreturn(p, uap, retval) register int *regs = p->p_regs; /* - * (XXX old comment) regs[sESP] points to the return address. + * (XXX old comment) regs[tESP] points to the return address. * The user scp pointer is above that. * The return address is faked in the signal trampoline code * for consistency. @@ -532,9 +513,9 @@ sigreturn(p, uap, retval) return(EINVAL); /* restore scratch registers */ - regs[sEAX] = fp->sf_eax ; - regs[sEDX] = fp->sf_edx ; - regs[sECX] = fp->sf_ecx ; + regs[tEAX] = fp->sf_eax ; + regs[tEDX] = fp->sf_edx ; + regs[tECX] = fp->sf_ecx ; if (useracc((caddr_t)scp, sizeof (*scp), 0) == 0) return(EINVAL); @@ -546,10 +527,10 @@ sigreturn(p, uap, retval) p->p_sigacts->ps_onstack = scp->sc_onstack & 01; p->p_sigmask = scp->sc_mask &~ (sigmask(SIGKILL)|sigmask(SIGCONT)|sigmask(SIGSTOP)); - regs[sEBP] = scp->sc_fp; - regs[sESP] = scp->sc_sp; - regs[sEIP] = scp->sc_pc; - regs[sEFLAGS] = scp->sc_ps; + regs[tEBP] = scp->sc_fp; + regs[tESP] = scp->sc_sp; + regs[tEIP] = scp->sc_pc; + regs[tEFLAGS] = scp->sc_ps; return(EJUSTRETURN); } @@ -762,13 +743,18 @@ initcpu() * Clear registers on exec */ void -setregs(p, entry) +setregs(p, entry, stack) struct proc *p; u_long entry; + u_long stack; { - - p->p_regs[sEBP] = 0; /* bottom of the fp chain */ - p->p_regs[sEIP] = entry; + p->p_regs[tEBP] = 0; /* bottom of the fp chain */ + p->p_regs[tEIP] = entry; + p->p_regs[tESP] = stack; + p->p_regs[tSS] = _udatasel; + p->p_regs[tDS] = _udatasel; + p->p_regs[tES] = _udatasel; + p->p_regs[tCS] = _ucodesel; p->p_addr->u_pcb.pcb_flags = 0; /* no fp at all */ load_cr0(rcr0() | CR0_TS); /* start emulating */ @@ -1153,7 +1139,7 @@ init386(first) x = (int) &IDTVEC(syscall); gdp->gd_looffset = x++; gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL); - gdp->gd_stkcpy = 0; + gdp->gd_stkcpy = 1; /* Leaves room for eflags like a trap */ gdp->gd_type = SDT_SYS386CGT; gdp->gd_dpl = SEL_UPL; gdp->gd_p = 1; @@ -1268,35 +1254,24 @@ _remque(element) int ptrace_set_pc (struct proc *p, unsigned int addr) { - struct pcb *pcb; void *regs = (char*)p->p_addr + ((char*) p->p_regs - (char*) kstack); - pcb = &p->p_addr->u_pcb; - if (pcb->pcb_flags & FM_TRAP) - ((struct trapframe *)regs)->tf_eip = addr; - else - ((struct syscframe *)regs)->sf_eip = addr; + ((struct trapframe *)regs)->tf_eip = addr; return 0; } int ptrace_single_step (struct proc *p) { - struct pcb *pcb; void *regs = (char*)p->p_addr + ((char*) p->p_regs - (char*) kstack); - pcb = &p->p_addr->u_pcb; - if (pcb->pcb_flags & FM_TRAP) - ((struct trapframe *)regs)->tf_eflags |= PSL_T; - else - ((struct syscframe *)regs)->sf_eflags |= PSL_T; + ((struct trapframe *)regs)->tf_eflags |= PSL_T; return 0; } /* - * Copy the registers to user-space. This is tedious because - * we essentially duplicate code for trapframe and syscframe. *sigh* + * Copy the registers to user-space. */ int @@ -1325,50 +1300,24 @@ int fill_regs(struct proc *p, struct regs *regs) { int error; struct trapframe *tp; - struct syscframe *sp; - struct pcb *pcb; void *ptr = (char*)p->p_addr + ((char*) p->p_regs - (char*) kstack); - pcb = &p->p_addr->u_pcb; - if (pcb->pcb_flags & FM_TRAP) { - tp = ptr; - regs->r_es = tp->tf_es; - regs->r_ds = tp->tf_ds; - regs->r_edi = tp->tf_edi; - regs->r_esi = tp->tf_esi; - regs->r_ebp = tp->tf_ebp; - regs->r_ebx = tp->tf_ebx; - regs->r_edx = tp->tf_edx; - regs->r_ecx = tp->tf_ecx; - regs->r_eax = tp->tf_eax; - regs->r_eip = tp->tf_eip; - regs->r_cs = tp->tf_cs; - regs->r_eflags = tp->tf_eflags; - regs->r_esp = tp->tf_esp; - regs->r_ss = tp->tf_ss; - } else { - sp = ptr; - /* - * No sf_es or sf_ds... dunno why. - */ - /* - * regs.r_es = sp->sf_es; - * regs.r_ds = sp->sf_ds; - */ - regs->r_edi = sp->sf_edi; - regs->r_esi = sp->sf_esi; - regs->r_ebp = sp->sf_ebp; - regs->r_ebx = sp->sf_ebx; - regs->r_edx = sp->sf_edx; - regs->r_ecx = sp->sf_ecx; - regs->r_eax = sp->sf_eax; - regs->r_eip = sp->sf_eip; - regs->r_cs = sp->sf_cs; - regs->r_eflags = sp->sf_eflags; - regs->r_esp = sp->sf_esp; - regs->r_ss = sp->sf_ss; - } + tp = ptr; + regs->r_es = tp->tf_es; + regs->r_ds = tp->tf_ds; + regs->r_edi = tp->tf_edi; + regs->r_esi = tp->tf_esi; + regs->r_ebp = tp->tf_ebp; + regs->r_ebx = tp->tf_ebx; + regs->r_edx = tp->tf_edx; + regs->r_ecx = tp->tf_ecx; + regs->r_eax = tp->tf_eax; + regs->r_eip = tp->tf_eip; + regs->r_cs = tp->tf_cs; + regs->r_eflags = tp->tf_eflags; + regs->r_esp = tp->tf_esp; + regs->r_ss = tp->tf_ss; return 0; } @@ -1376,122 +1325,27 @@ int set_regs (struct proc *p, struct regs *regs) { int error; struct trapframe *tp; - struct syscframe *sp; - struct pcb *pcb; void *ptr = (char*)p->p_addr + ((char*) p->p_regs - (char*) kstack); - pcb = &p->p_addr->u_pcb; - if (pcb->pcb_flags & FM_TRAP) { - tp = ptr; - tp->tf_es = regs->r_es; - tp->tf_ds = regs->r_ds; - tp->tf_edi = regs->r_edi; - tp->tf_esi = regs->r_esi; - tp->tf_ebp = regs->r_ebp; - tp->tf_ebx = regs->r_ebx; - tp->tf_edx = regs->r_edx; - tp->tf_ecx = regs->r_ecx; - tp->tf_eax = regs->r_eax; - tp->tf_eip = regs->r_eip; - tp->tf_cs = regs->r_cs; - tp->tf_eflags = regs->r_eflags; - tp->tf_esp = regs->r_esp; - tp->tf_ss = regs->r_ss; - } else { - sp = ptr; - /* - * No sf_es or sf_ds members, dunno why... - */ - /* - * sp->sf_es = regs.r_es; - * sp->sf_ds = regs.r_ds; - */ - sp->sf_edi = regs->r_edi; - sp->sf_esi = regs->r_esi; - sp->sf_ebp = regs->r_ebp; - sp->sf_ebx = regs->r_ebx; - sp->sf_edx = regs->r_edx; - sp->sf_ecx = regs->r_ecx; - sp->sf_eax = regs->r_eax; - sp->sf_eip = regs->r_eip; - sp->sf_cs = regs->r_cs; - sp->sf_eflags = regs->r_eflags; - sp->sf_esp = regs->r_esp; - sp->sf_ss = regs->r_ss; - } + tp = ptr; + tp->tf_es = regs->r_es; + tp->tf_ds = regs->r_ds; + tp->tf_edi = regs->r_edi; + tp->tf_esi = regs->r_esi; + tp->tf_ebp = regs->r_ebp; + tp->tf_ebx = regs->r_ebx; + tp->tf_edx = regs->r_edx; + tp->tf_ecx = regs->r_ecx; + tp->tf_eax = regs->r_eax; + tp->tf_eip = regs->r_eip; + tp->tf_cs = regs->r_cs; + tp->tf_eflags = regs->r_eflags; + tp->tf_esp = regs->r_esp; + tp->tf_ss = regs->r_ss; return 0; } -#ifdef SLOW_OLD_COPYSTRS -vmunaccess() {} - -#if 0 /* assembler versions now in locore.s */ -/* - * Below written in C to allow access to debugging code - */ -copyinstr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *toaddr, *fromaddr; { - int c,tally; - - tally = 0; - while (maxlength--) { - c = fubyte(fromaddr++); - if (c == -1) { - if(lencopied) *lencopied = tally; - return(EFAULT); - } - tally++; - *(char *)toaddr++ = (char) c; - if (c == 0){ - if(lencopied) *lencopied = (u_int)tally; - return(0); - } - } - if(lencopied) *lencopied = (u_int)tally; - return(ENAMETOOLONG); -} - -copyoutstr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *fromaddr, *toaddr; { - int c; - int tally; - - tally = 0; - while (maxlength--) { - c = subyte(toaddr++, *(char *)fromaddr); - if (c == -1) return(EFAULT); - tally++; - if (*(char *)fromaddr++ == 0){ - if(lencopied) *lencopied = tally; - return(0); - } - } - if(lencopied) *lencopied = tally; - return(ENAMETOOLONG); -} - -#endif /* SLOW_OLD_COPYSTRS */ - -copystr(fromaddr, toaddr, maxlength, lencopied) u_int *lencopied, maxlength; - void *fromaddr, *toaddr; { - u_int tally; - - tally = 0; - while (maxlength--) { - *(u_char *)toaddr = *(u_char *)fromaddr++; - tally++; - if (*(u_char *)toaddr++ == 0) { - if(lencopied) *lencopied = tally; - return(0); - } - } - if(lencopied) *lencopied = tally; - return(ENAMETOOLONG); -} - -#endif - #include "ddb.h" #if NDDB <= 0 void diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c index b9a912a..c3899a1 100644 --- a/sys/i386/i386/mem.c +++ b/sys/i386/i386/mem.c @@ -38,7 +38,7 @@ * * from: Utah $Hdr: mem.c 1.13 89/10/08$ * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 - * $Id: mem.c,v 1.5 1993/11/25 01:30:59 wollman Exp $ + * $Id: mem.c,v 1.6 1993/12/19 00:50:06 wollman Exp $ */ /* @@ -70,12 +70,12 @@ mmclose(dev, uio, flags) struct uio *uio; int flags; { - struct syscframe *fp; + struct trapframe *fp; switch (minor(dev)) { case 14: - fp = (struct syscframe *)curproc->p_regs; - fp->sf_eflags &= ~PSL_IOPL; + fp = (struct trapframe *)curproc->p_regs; + fp->tf_eflags &= ~PSL_IOPL; break; default: break; @@ -89,12 +89,12 @@ mmopen(dev, uio, flags) struct uio *uio; int flags; { - struct syscframe *fp; + struct trapframe *fp; switch (minor(dev)) { case 14: - fp = (struct syscframe *)curproc->p_regs; - fp->sf_eflags |= PSL_IOPL; + fp = (struct trapframe *)curproc->p_regs; + fp->tf_eflags |= PSL_IOPL; break; default: break; diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 41370cc..c85ac57 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.11 1993/12/12 12:22:57 davidg Exp $ + * $Id: trap.c,v 1.12 1993/12/19 00:50:09 wollman Exp $ */ /* @@ -179,7 +179,6 @@ copyfault: if (ISPL(frame.tf_cs) == SEL_UPL) { type |= T_USER; p->p_regs = (int *)&frame; - curpcb->pcb_flags |= FM_TRAP; /* used by sendsig */ } ucode=0; @@ -487,7 +486,6 @@ out: } } curpri = p->p_pri; - curpcb->pcb_flags &= ~FM_TRAP; /* used by sendsig */ } /* @@ -575,7 +573,7 @@ int trapwrite(addr) /*ARGSUSED*/ void syscall(frame) - volatile struct syscframe frame; + volatile struct trapframe frame; { register int *locr0 = ((int *)&frame); register caddr_t params; @@ -591,29 +589,30 @@ syscall(frame) r0 = 0; r0 = r0; r1 = 0; r1 = r1; #endif syst = p->p_stime; - if (ISPL(frame.sf_cs) != SEL_UPL) + if (ISPL(frame.tf_cs) != SEL_UPL) panic("syscall"); - code = frame.sf_eax; - curpcb->pcb_flags &= ~FM_TRAP; /* used by sendsig */ + code = frame.tf_eax; p->p_regs = (int *)&frame; - params = (caddr_t)frame.sf_esp + sizeof (int) ; + params = (caddr_t)frame.tf_esp + sizeof (int) ; /* * Reconstruct pc, assuming lcall $X,y is 7 bytes, as it is always. */ - opc = frame.sf_eip - 7; - callp = (code >= nsysent) ? &sysent[63] : &sysent[code]; - if (callp == sysent) { - i = fuword(params); + opc = frame.tf_eip - 7; + if (code == 0) { + code = fuword(params); params += sizeof (int); - callp = (code >= nsysent) ? &sysent[63] : &sysent[code]; } + if (code < 0 || code >= nsysent) + callp = &sysent[0]; + else + callp = &sysent[code]; if ((i = callp->sy_narg * sizeof (int)) && (error = copyin(params, (caddr_t)args, (u_int)i))) { - frame.sf_eax = error; - frame.sf_eflags |= PSL_C; /* carry bit */ + frame.tf_eax = error; + frame.tf_eflags |= PSL_C; /* carry bit */ #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) ktrsyscall(p->p_tracep, code, callp->sy_narg, args); @@ -625,20 +624,20 @@ syscall(frame) ktrsyscall(p->p_tracep, code, callp->sy_narg, args); #endif rval[0] = 0; - rval[1] = frame.sf_edx; + rval[1] = frame.tf_edx; /*pg("%d. s %d\n", p->p_pid, code);*/ error = (*callp->sy_call)(p, args, rval); if (error == ERESTART) - frame.sf_eip = opc; + frame.tf_eip = opc; else if (error != EJUSTRETURN) { if (error) { /*pg("error %d", error);*/ - frame.sf_eax = error; - frame.sf_eflags |= PSL_C; /* carry bit */ + frame.tf_eax = error; + frame.tf_eflags |= PSL_C; /* carry bit */ } else { - frame.sf_eax = rval[0]; - frame.sf_edx = rval[1]; - frame.sf_eflags &= ~PSL_C; /* carry bit */ + frame.tf_eax = rval[0]; + frame.tf_edx = rval[1]; + frame.tf_eflags &= ~PSL_C; /* carry bit */ } } /* else if (error == EJUSTRETURN) */ @@ -679,10 +678,10 @@ done: if (ticks) { #ifdef PROFTIMER extern int profscale; - addupc(frame.sf_eip, &p->p_stats->p_prof, + addupc(frame.tf_eip, &p->p_stats->p_prof, ticks * profscale); #else - addupc(frame.sf_eip, &p->p_stats->p_prof, ticks); + addupc(frame.tf_eip, &p->p_stats->p_prof, ticks); #endif } } @@ -693,13 +692,13 @@ done: #endif #ifdef DIAGNOSTICx { extern int _udatasel, _ucodesel; - if (frame.sf_ss != _udatasel) - printf("ss %x call %d\n", frame.sf_ss, code); - if ((frame.sf_cs&0xffff) != _ucodesel) - printf("cs %x call %d\n", frame.sf_cs, code); - if (frame.sf_eip > VM_MAXUSER_ADDRESS) { - printf("eip %x call %d\n", frame.sf_eip, code); - frame.sf_eip = 0; + if (frame.tf_ss != _udatasel) + printf("ss %x call %d\n", frame.tf_ss, code); + if ((frame.tf_cs&0xffff) != _ucodesel) + printf("cs %x call %d\n", frame.tf_cs, code); + if (frame.tf_eip > VM_MAXUSER_ADDRESS) { + printf("eip %x call %d\n", frame.tf_eip, code); + frame.tf_eip = 0; } } #endif diff --git a/sys/i386/include/frame.h b/sys/i386/include/frame.h index c61d179..b36c141 100644 --- a/sys/i386/include/frame.h +++ b/sys/i386/include/frame.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 - * $Id: frame.h,v 1.5 1993/12/03 05:10:00 alm Exp $ + * $Id: frame.h,v 1.6 1993/12/19 00:50:15 wollman Exp $ */ #ifndef _MACHINE_FRAME_H_ @@ -113,28 +113,5 @@ struct sigframe { int sf_edx; int sf_ecx; struct sigcontext sf_sc; -} ; - -/* - * Call Gate/System Call Stack Frame - */ - -struct syscframe { - int sf_edi; - int sf_esi; - int sf_ebp; - int :32; /* redundant save of isp */ - int sf_ebx; - int sf_edx; - int sf_ecx; - int sf_eax; - int sf_eflags; - /* below portion defined in 386 hardware */ -/* int sf_args[N];*/ /* if call gate copy args enabled!*/ - int sf_eip; - int sf_cs; - /* below only when transitting rings (e.g. user to kernel) */ - int sf_esp; - int sf_ss; }; #endif /* _MACHINE_FRAME_H_ */ diff --git a/sys/i386/include/pcb.h b/sys/i386/include/pcb.h index 1090798..a7a29df 100644 --- a/sys/i386/include/pcb.h +++ b/sys/i386/include/pcb.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 - * $Id: pcb.h,v 1.2 1993/10/08 20:51:00 rgrimes Exp $ + * $Id: pcb.h,v 1.3 1993/11/07 17:42:59 wollman Exp $ */ #ifndef _I386_PCB_H_ @@ -72,7 +72,6 @@ struct pcb { #define FP_NEEDSRESTORE 0x04 /* ... that needs restore on next DNA fault */ #endif #define FP_USESEMC 0x08 /* process uses EMC memory-mapped mode */ -#define FM_TRAP 0x10 /* process entered kernel on a trap frame */ #define FP_SOFTFP 0x20 /* process using software fltng pnt emulator */ short pcb_iml; /* interrupt mask level */ caddr_t pcb_onfault; /* copyin/out fault recovery */ diff --git a/sys/i386/include/reg.h b/sys/i386/include/reg.h index 969df87..4cefae0 100644 --- a/sys/i386/include/reg.h +++ b/sys/i386/include/reg.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)reg.h 5.5 (Berkeley) 1/18/91 - * $Id: reg.h,v 1.4 1993/11/16 09:54:57 davidg Exp $ + * $Id: reg.h,v 1.5 1993/12/03 05:10:08 alm Exp $ */ #ifndef _MACHINE_REG_H_ @@ -68,28 +68,6 @@ #define tESP (15) #define tSS (16) -/* During a system call, registers are at these offsets instead of above. */ - -#define sEDI (0) -#define sESI (1) -#define sEBP (2) - -#define sEBX (4) -#define sEDX (5) -#define sECX (6) -#define sEAX (7) -#define sEFLAGS (8) -#define sEIP (9) -#define sCS (10) -#define sESP (11) -#define sSS (12) - -#define PC sEIP -#define SP sESP -#define PS sEFLAGS -#define R0 sEDX -#define R1 sECX - /* * Registers accessible to ptrace(2) syscall for debugger * The machine-dependent code for PT_{SET,GET}REGS needs to diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c index 0e90bff..796dfbb 100644 --- a/sys/i386/isa/npx.c +++ b/sys/i386/isa/npx.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: @(#)npx.c 7.2 (Berkeley) 5/12/91 - * $Id: npx.c,v 1.4 1993/11/03 00:29:19 paul Exp $ + * $Id: npx.c,v 1.5 1993/11/03 23:32:35 paul Exp $ */ #include "npx.h" @@ -439,7 +439,6 @@ npxintr(frame) * just before it is used). */ curproc->p_regs = (int *)&frame.if_es; - curpcb->pcb_flags |= FM_TRAP; /* used by sendsig */ #ifdef notyet /* * Encode the appropriate code for detailed information on @@ -450,7 +449,6 @@ npxintr(frame) code = 0; /* XXX */ #endif trapsignal(curproc, SIGFPE, code); - curpcb->pcb_flags &= ~FM_TRAP; } else { /* * Nested interrupt. These losers occur when: diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c index b683ea0..f8c8763 100644 --- a/sys/i386/isa/syscons.c +++ b/sys/i386/isa/syscons.c @@ -35,7 +35,7 @@ * * from: @(#)pccons.c 5.11 (Berkeley) 5/21/91 * from: @(#)syscons.c 1.1 931021 - * $Id: syscons.c,v 1.22 1993/12/21 02:49:13 rich Exp $ + * $Id: syscons.c,v 1.23 1993/12/21 03:27:26 rich Exp $ * * Heavily modified by Søren Schmidt (sos@login.dkuug.dk) to provide: * @@ -526,14 +526,8 @@ pcparam(struct tty *tp, struct termios *t) return(0); } - -#if defined(NetBSD) #define frametype struct trapframe #define eflags tf_eflags -#else -#define frametype struct syscframe -#define eflags sf_eflags -#endif int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c index b683ea0..f8c8763 100644 --- a/sys/isa/syscons.c +++ b/sys/isa/syscons.c @@ -35,7 +35,7 @@ * * from: @(#)pccons.c 5.11 (Berkeley) 5/21/91 * from: @(#)syscons.c 1.1 931021 - * $Id: syscons.c,v 1.22 1993/12/21 02:49:13 rich Exp $ + * $Id: syscons.c,v 1.23 1993/12/21 03:27:26 rich Exp $ * * Heavily modified by Søren Schmidt (sos@login.dkuug.dk) to provide: * @@ -526,14 +526,8 @@ pcparam(struct tty *tp, struct termios *t) return(0); } - -#if defined(NetBSD) #define frametype struct trapframe #define eflags tf_eflags -#else -#define frametype struct syscframe -#define eflags sf_eflags -#endif int pcioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 41370cc..c85ac57 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.11 1993/12/12 12:22:57 davidg Exp $ + * $Id: trap.c,v 1.12 1993/12/19 00:50:09 wollman Exp $ */ /* @@ -179,7 +179,6 @@ copyfault: if (ISPL(frame.tf_cs) == SEL_UPL) { type |= T_USER; p->p_regs = (int *)&frame; - curpcb->pcb_flags |= FM_TRAP; /* used by sendsig */ } ucode=0; @@ -487,7 +486,6 @@ out: } } curpri = p->p_pri; - curpcb->pcb_flags &= ~FM_TRAP; /* used by sendsig */ } /* @@ -575,7 +573,7 @@ int trapwrite(addr) /*ARGSUSED*/ void syscall(frame) - volatile struct syscframe frame; + volatile struct trapframe frame; { register int *locr0 = ((int *)&frame); register caddr_t params; @@ -591,29 +589,30 @@ syscall(frame) r0 = 0; r0 = r0; r1 = 0; r1 = r1; #endif syst = p->p_stime; - if (ISPL(frame.sf_cs) != SEL_UPL) + if (ISPL(frame.tf_cs) != SEL_UPL) panic("syscall"); - code = frame.sf_eax; - curpcb->pcb_flags &= ~FM_TRAP; /* used by sendsig */ + code = frame.tf_eax; p->p_regs = (int *)&frame; - params = (caddr_t)frame.sf_esp + sizeof (int) ; + params = (caddr_t)frame.tf_esp + sizeof (int) ; /* * Reconstruct pc, assuming lcall $X,y is 7 bytes, as it is always. */ - opc = frame.sf_eip - 7; - callp = (code >= nsysent) ? &sysent[63] : &sysent[code]; - if (callp == sysent) { - i = fuword(params); + opc = frame.tf_eip - 7; + if (code == 0) { + code = fuword(params); params += sizeof (int); - callp = (code >= nsysent) ? &sysent[63] : &sysent[code]; } + if (code < 0 || code >= nsysent) + callp = &sysent[0]; + else + callp = &sysent[code]; if ((i = callp->sy_narg * sizeof (int)) && (error = copyin(params, (caddr_t)args, (u_int)i))) { - frame.sf_eax = error; - frame.sf_eflags |= PSL_C; /* carry bit */ + frame.tf_eax = error; + frame.tf_eflags |= PSL_C; /* carry bit */ #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) ktrsyscall(p->p_tracep, code, callp->sy_narg, args); @@ -625,20 +624,20 @@ syscall(frame) ktrsyscall(p->p_tracep, code, callp->sy_narg, args); #endif rval[0] = 0; - rval[1] = frame.sf_edx; + rval[1] = frame.tf_edx; /*pg("%d. s %d\n", p->p_pid, code);*/ error = (*callp->sy_call)(p, args, rval); if (error == ERESTART) - frame.sf_eip = opc; + frame.tf_eip = opc; else if (error != EJUSTRETURN) { if (error) { /*pg("error %d", error);*/ - frame.sf_eax = error; - frame.sf_eflags |= PSL_C; /* carry bit */ + frame.tf_eax = error; + frame.tf_eflags |= PSL_C; /* carry bit */ } else { - frame.sf_eax = rval[0]; - frame.sf_edx = rval[1]; - frame.sf_eflags &= ~PSL_C; /* carry bit */ + frame.tf_eax = rval[0]; + frame.tf_edx = rval[1]; + frame.tf_eflags &= ~PSL_C; /* carry bit */ } } /* else if (error == EJUSTRETURN) */ @@ -679,10 +678,10 @@ done: if (ticks) { #ifdef PROFTIMER extern int profscale; - addupc(frame.sf_eip, &p->p_stats->p_prof, + addupc(frame.tf_eip, &p->p_stats->p_prof, ticks * profscale); #else - addupc(frame.sf_eip, &p->p_stats->p_prof, ticks); + addupc(frame.tf_eip, &p->p_stats->p_prof, ticks); #endif } } @@ -693,13 +692,13 @@ done: #endif #ifdef DIAGNOSTICx { extern int _udatasel, _ucodesel; - if (frame.sf_ss != _udatasel) - printf("ss %x call %d\n", frame.sf_ss, code); - if ((frame.sf_cs&0xffff) != _ucodesel) - printf("cs %x call %d\n", frame.sf_cs, code); - if (frame.sf_eip > VM_MAXUSER_ADDRESS) { - printf("eip %x call %d\n", frame.sf_eip, code); - frame.sf_eip = 0; + if (frame.tf_ss != _udatasel) + printf("ss %x call %d\n", frame.tf_ss, code); + if ((frame.tf_cs&0xffff) != _ucodesel) + printf("cs %x call %d\n", frame.tf_cs, code); + if (frame.tf_eip > VM_MAXUSER_ADDRESS) { + printf("eip %x call %d\n", frame.tf_eip, code); + frame.tf_eip = 0; } } #endif |