diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 2004-07-02 16:29:56 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 2004-07-02 16:29:56 +0000 |
commit | 4e21c2c5fe2cb2f5ea3cf71a36b36246fada3387 (patch) | |
tree | 289c5bc05d11c5e8dc16a8f4e3faf2238fd2d585 /sys/arch/i386 | |
parent | 85c22057751f71fe482c7ef954fc69924d59b2c3 (diff) |
Maintain %f and %gs over traps. Mostly from NetBSD. Preparation for SMP
speedups.
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/db_interface.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/db_trace.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/i386/genassym.cf | 13 | ||||
-rw-r--r-- | sys/arch/i386/i386/kgdb_machdep.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/linux_machdep.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/i386/locore.s | 86 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 19 | ||||
-rw-r--r-- | sys/arch/i386/i386/pmap.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/process_machdep.c | 38 | ||||
-rw-r--r-- | sys/arch/i386/i386/svr4_machdep.c | 9 | ||||
-rw-r--r-- | sys/arch/i386/i386/trap.c | 28 | ||||
-rw-r--r-- | sys/arch/i386/include/db_machdep.h | 4 | ||||
-rw-r--r-- | sys/arch/i386/include/frame.h | 6 | ||||
-rw-r--r-- | sys/arch/i386/include/pcb.h | 4 |
14 files changed, 94 insertions, 140 deletions
diff --git a/sys/arch/i386/i386/db_interface.c b/sys/arch/i386/i386/db_interface.c index 5ee659efcbb..bbf7a09c6bc 100644 --- a/sys/arch/i386/i386/db_interface.c +++ b/sys/arch/i386/i386/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.14 2004/06/21 22:41:11 andreas Exp $ */ +/* $OpenBSD: db_interface.c,v 1.15 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: db_interface.c,v 1.22 1996/05/03 19:42:00 christos Exp $ */ /* @@ -144,6 +144,8 @@ kdb_trap(type, code, regs) db_active--; splx(s); + regs->tf_fs = ddb_regs.tf_fs & 0xffff; + regs->tf_gs = ddb_regs.tf_gs & 0xffff; regs->tf_es = ddb_regs.tf_es & 0xffff; regs->tf_ds = ddb_regs.tf_ds & 0xffff; regs->tf_edi = ddb_regs.tf_edi; diff --git a/sys/arch/i386/i386/db_trace.c b/sys/arch/i386/i386/db_trace.c index 40ea010c316..a552cc883e9 100644 --- a/sys/arch/i386/i386/db_trace.c +++ b/sys/arch/i386/i386/db_trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_trace.c,v 1.9 2003/05/20 09:51:22 andreas Exp $ */ +/* $OpenBSD: db_trace.c,v 1.10 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */ /* @@ -43,8 +43,10 @@ * Machine register set. */ struct db_variable db_regs[] = { - { "es", (long *)&ddb_regs.tf_es, FCN_NULL }, { "ds", (long *)&ddb_regs.tf_ds, FCN_NULL }, + { "es", (long *)&ddb_regs.tf_es, FCN_NULL }, + { "fs", (long *)&ddb_regs.tf_fs, FCN_NULL }, + { "gs", (long *)&ddb_regs.tf_gs, FCN_NULL }, { "edi", (long *)&ddb_regs.tf_edi, FCN_NULL }, { "esi", (long *)&ddb_regs.tf_esi, FCN_NULL }, { "ebp", (long *)&ddb_regs.tf_ebp, FCN_NULL }, diff --git a/sys/arch/i386/i386/genassym.cf b/sys/arch/i386/i386/genassym.cf index c29811bf5e1..7453c773fed 100644 --- a/sys/arch/i386/i386/genassym.cf +++ b/sys/arch/i386/i386/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.16 2004/06/28 02:00:20 deraadt Exp $ +# $OpenBSD: genassym.cf,v 1.17 2004/07/02 16:29:55 niklas Exp $ # # Copyright (c) 1982, 1990 The Regents of the University of California. # All rights reserved. @@ -103,8 +103,6 @@ struct pcb member pcb_cr3 member pcb_ebp member pcb_esp -member pcb_fs -member pcb_gs member pcb_cr0 member pcb_ldt_sel member pcb_onfault @@ -126,9 +124,6 @@ struct sigframe SIGF_ member HANDLER sf_handler member SC sf_sc struct sigcontext -member sc_fs -member sc_gs -member sc_eflags # mbuf fields ifdef INET @@ -144,9 +139,6 @@ struct svr4_sigframe SVR4_SIGF_ member HANDLER sf_handler member UC sf_uc struct svr4_ucontext SVR4_UC_ -member FS uc_mcontext.greg[SVR4_X86_FS] -member GS uc_mcontext.greg[SVR4_X86_GS] -member EFLAGS uc_mcontext.greg[SVR4_X86_EFL] endif # Linux frame offsets @@ -155,9 +147,6 @@ struct linux_sigframe LINUX_SIGF_ member HANDLER sf_handler member SC sf_sc struct linux_sigcontext LINUX_ -member sc_fs -member sc_gs -member sc_eflags endif # FreeBSD frame offsets diff --git a/sys/arch/i386/i386/kgdb_machdep.c b/sys/arch/i386/i386/kgdb_machdep.c index fc74f997647..3e926ecf4f4 100644 --- a/sys/arch/i386/i386/kgdb_machdep.c +++ b/sys/arch/i386/i386/kgdb_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kgdb_machdep.c,v 1.2 2001/11/06 19:53:14 miod Exp $ */ +/* $OpenBSD: kgdb_machdep.c,v 1.3 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: kgdb_machdep.c,v 1.6 1998/08/13 21:36:03 thorpej Exp $ */ /*- @@ -181,6 +181,8 @@ kgdb_getregs(regs, gdb_regs) gdb_regs[10] = regs->tf_cs; gdb_regs[12] = regs->tf_ds; gdb_regs[13] = regs->tf_es; + gdb_regs[14] = regs->tf_fs; + gdb_regs[15] = regs->tf_gs; if (KERNELMODE(regs->tf_cs, regs->tf_eflags)) { /* diff --git a/sys/arch/i386/i386/linux_machdep.c b/sys/arch/i386/i386/linux_machdep.c index 5e4abf72251..46cd7f6ffe9 100644 --- a/sys/arch/i386/i386/linux_machdep.c +++ b/sys/arch/i386/i386/linux_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_machdep.c,v 1.29 2003/08/15 20:32:13 tedu Exp $ */ +/* $OpenBSD: linux_machdep.c,v 1.30 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: linux_machdep.c,v 1.29 1996/05/03 19:42:11 christos Exp $ */ /* @@ -150,8 +150,8 @@ linux_sendsig(catcher, sig, mask, code, type, val) } else #endif { - __asm("movl %%gs,%k0" : "=r" (frame.sf_sc.sc_gs)); - __asm("movl %%fs,%k0" : "=r" (frame.sf_sc.sc_fs)); + frame.sf_sc.sc_fs = tf->tf_fs; + frame.sf_sc.sc_gs = tf->tf_gs; frame.sf_sc.sc_es = tf->tf_es; frame.sf_sc.sc_ds = tf->tf_ds; frame.sf_sc.sc_eflags = tf->tf_eflags; @@ -248,7 +248,8 @@ linux_sys_sigreturn(p, v, retval) !USERMODE(context.sc_cs, context.sc_eflags)) return (EINVAL); - /* %fs and %gs were restored by the trampoline. */ + tf->tf_fs = context.sc_fs; + tf->tf_gs = context.sc_gs; tf->tf_es = context.sc_es; tf->tf_ds = context.sc_ds; tf->tf_eflags = context.sc_eflags; diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index c738cee27c1..8686395cce3 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.78 2004/06/13 21:49:15 niklas Exp $ */ +/* $OpenBSD: locore.s,v 1.79 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -153,10 +153,17 @@ pushl %edi ; \ pushl %ds ; \ pushl %es ; \ + pushl %gs ; \ movl $GSEL(GDATA_SEL, SEL_KPL),%eax ; \ movw %ax,%ds ; \ - movw %ax,%es + movw %ax,%es ; \ + movw %ax,%gs ; \ + pushl %fs ; \ + movl $GSEL(GCPU_SEL, SEL_KPL),%eax ; \ + movw %ax,%fs #define INTRFASTEXIT \ + popl %fs ; \ + popl %gs ; \ popl %es ; \ popl %ds ; \ popl %edi ; \ @@ -295,6 +302,11 @@ start: movw $0x1234,0x472 # warm boot pushl $PSL_MBO popfl + /* Clear segment registers; always null in proc0. */ + xorl %eax,%eax + movw %ax,%fs + movw %ax,%gs + /* Find out our CPU type. */ try386: /* Try to toggle alignment check flag; does not exist on 386. */ @@ -704,11 +716,6 @@ begin: call _C_LABEL(init386) # wire 386 chip for unix operation addl $4,%esp - /* Clear segment registers; always null in proc0. */ - xorl %ecx,%ecx - movw %cx,%fs - movw %cx,%gs - call _C_LABEL(main) NENTRY(proc_trampoline) @@ -731,15 +738,7 @@ NENTRY(sigcode) call *SIGF_HANDLER(%esp) leal SIGF_SC(%esp),%eax # scp (the call may have clobbered the # copy at SIGF_SCP(%esp)) -#ifdef VM86 - testl $PSL_VM,SC_EFLAGS(%eax) - jnz 1f -#endif - movl SC_FS(%eax),%ecx - movl SC_GS(%eax),%edx - movw %cx,%fs - movw %dx,%gs -1: pushl %eax + pushl %eax pushl %eax # junk to fake return address movl $SYS_sigreturn,%eax int $0x80 # enter kernel with args on stack @@ -755,15 +754,7 @@ NENTRY(svr4_sigcode) call *SVR4_SIGF_HANDLER(%esp) leal SVR4_SIGF_UC(%esp),%eax # ucp (the call may have clobbered the # copy at SIGF_UCP(%esp)) -#ifdef VM86 - testl $PSL_VM,SVR4_UC_EFLAGS(%eax) - jnz 1f -#endif - movl SVR4_UC_FS(%eax),%ecx - movl SVR4_UC_GS(%eax),%edx - movw %cx,%fs - movw %dx,%gs -1: pushl %eax + pushl %eax pushl $1 # setcontext(p) == syscontext(1, p) pushl %eax # junk to fake return address movl $SVR4_SYS_context,%eax @@ -784,15 +775,7 @@ NENTRY(linux_sigcode) call *LINUX_SIGF_HANDLER(%esp) leal LINUX_SIGF_SC(%esp),%ebx # scp (the call may have clobbered the # copy at SIGF_SCP(%esp)) -#ifdef VM86 - testl $PSL_VM,LINUX_SC_EFLAGS(%ebx) - jnz 1f -#endif - movl LINUX_SC_FS(%ebx),%ecx - movl LINUX_SC_GS(%ebx),%edx - movw %cx,%fs - movw %dx,%gs -1: pushl %eax # junk to fake return address + pushl %eax # junk to fake return address movl $LINUX_SYS_sigreturn,%eax int $0x80 # enter kernel with args on stack movl $LINUX_SYS_exit,%eax @@ -1749,16 +1732,6 @@ switch_search: movl P_ADDR(%esi),%esi - /* Save segment registers. */ -#ifdef DDB - xorl %eax, %eax - xorl %ecx, %ecx -#endif - movw %fs,%ax - movw %gs,%cx - movl %eax,PCB_FS(%esi) - movl %ecx,PCB_GS(%esi) - /* Save stack pointers. */ movl %esp,PCB_ESP(%esi) movl %ebp,PCB_EBP(%esi) @@ -1822,12 +1795,6 @@ switch_exited: lldt %dx #endif /* USER_LDT */ - /* Restore segment registers. */ - movl PCB_FS(%esi),%eax - movl PCB_GS(%esi),%ecx - movw %ax,%fs - movw %cx,%gs - switch_restored: /* Restore cr0 (including FPU state). */ movl PCB_CR0(%esi),%ecx @@ -1957,16 +1924,6 @@ ENTRY(switch_exit) ENTRY(savectx) movl 4(%esp),%edx # edx = p->p_addr - /* Save segment registers. */ -#ifdef DDB - xorl %eax, %eax - xorl %ecx, %ecx -#endif - movw %fs,%ax - movw %gs,%cx - movl %eax,PCB_FS(%edx) - movl %ecx,PCB_GS(%edx) - /* Save stack pointers. */ movl %esp,PCB_ESP(%edx) movl %ebp,PCB_EBP(%edx) @@ -2108,9 +2065,18 @@ IDTVEC(align) NENTRY(resume_iret) ZTRAP(T_PROTFLT) NENTRY(resume_pop_ds) + pushl %es movl $GSEL(GDATA_SEL, SEL_KPL),%eax movw %ax,%es NENTRY(resume_pop_es) + pushl %gs + movl $GSEL(GDATA_SEL, SEL_KPL),%eax + movw %ax,%gs +NENTRY(resume_pop_gs) + pushl %fs + movl $GSEL(GDATA_SEL, SEL_KPL),%eax + movw %ax,%fs +NENTRY(resume_pop_fs) movl $T_PROTFLT,TF_TRAPNO(%esp) jmp calltrap diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index d4d28d8b55f..89fdc3b9c6d 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.302 2004/06/28 20:51:02 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.303 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -2268,8 +2268,8 @@ sendsig(catcher, sig, mask, code, type, val) } else #endif { - __asm("movw %%gs,%w0" : "=r" (frame.sf_sc.sc_gs)); - __asm("movw %%fs,%w0" : "=r" (frame.sf_sc.sc_fs)); + frame.sf_sc.sc_fs = tf->tf_fs; + frame.sf_sc.sc_gs = tf->tf_gs; frame.sf_sc.sc_es = tf->tf_es; frame.sf_sc.sc_ds = tf->tf_ds; frame.sf_sc.sc_eflags = tf->tf_eflags; @@ -2308,8 +2308,8 @@ sendsig(catcher, sig, mask, code, type, val) /* * Build context to run handler in. */ - __asm("movw %w0,%%gs" : : "r" (GSEL(GUDATA_SEL, SEL_UPL))); - __asm("movw %w0,%%fs" : : "r" (GSEL(GUDATA_SEL, SEL_UPL))); + tf->tf_fs = GSEL(GUDATA_SEL, SEL_UPL); + tf->tf_gs = GSEL(GUDATA_SEL, SEL_UPL); tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL); tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL); tf->tf_eip = p->p_sigcode; @@ -2376,7 +2376,8 @@ sys_sigreturn(p, v, retval) !USERMODE(context.sc_cs, context.sc_eflags)) return (EINVAL); - /* %fs and %gs were restored by the trampoline. */ + tf->tf_fs = context.sc_fs; + tf->tf_gs = context.sc_gs; tf->tf_es = context.sc_es; tf->tf_ds = context.sc_ds; tf->tf_eflags = context.sc_eflags; @@ -2718,8 +2719,8 @@ setregs(p, pack, stack, retval) } else pcb->pcb_savefpu.sv_87.sv_env.en_cw = __OpenBSD_NPXCW__; - __asm("movw %w0,%%gs" : : "r" (LSEL(LUDATA_SEL, SEL_UPL))); - __asm("movw %w0,%%fs" : : "r" (LSEL(LUDATA_SEL, SEL_UPL))); + tf->tf_fs = LSEL(LUDATA_SEL, SEL_UPL); + tf->tf_gs = LSEL(LUDATA_SEL, SEL_UPL); tf->tf_es = LSEL(LUDATA_SEL, SEL_UPL); tf->tf_ds = LSEL(LUDATA_SEL, SEL_UPL); tf->tf_ebp = 0; @@ -2869,7 +2870,7 @@ init386(paddr_t first_avail) bios_memmap_t *im; proc0.p_addr = proc0paddr; - curpcb = &proc0.p_addr->u_pcb; + cpu_info_primary.ci_curpcb = &proc0.p_addr->u_pcb; /* * Initialize the I/O port and I/O mem extent maps. diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index ea8bc0b9efe..e4fdf112d48 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.77 2004/06/23 17:42:46 niklas Exp $ */ +/* $OpenBSD: pmap.c,v 1.78 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */ /* @@ -935,8 +935,6 @@ pmap_bootstrap(kva_start) * operation of the system. */ - curpcb->pcb_pmap = kpm; /* proc0's pcb */ - /* * enable global TLB entries if they are supported */ diff --git a/sys/arch/i386/i386/process_machdep.c b/sys/arch/i386/i386/process_machdep.c index fbf8c250220..32476fdec43 100644 --- a/sys/arch/i386/i386/process_machdep.c +++ b/sys/arch/i386/i386/process_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process_machdep.c,v 1.16 2004/06/13 21:49:15 niklas Exp $ */ +/* $OpenBSD: process_machdep.c,v 1.17 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: process_machdep.c,v 1.22 1996/05/03 19:42:25 christos Exp $ */ /* @@ -168,7 +168,6 @@ process_read_regs(p, regs) struct reg *regs; { struct trapframe *tf = process_frame(p); - struct pcb *pcb = &p->p_addr->u_pcb; #ifdef VM86 if (tf->tf_eflags & PSL_VM) { @@ -180,8 +179,8 @@ process_read_regs(p, regs) } else #endif { - regs->r_gs = pcb->pcb_gs & 0xffff; - regs->r_fs = pcb->pcb_fs & 0xffff; + regs->r_gs = tf->tf_gs & 0xffff; + regs->r_fs = tf->tf_fs & 0xffff; regs->r_es = tf->tf_es & 0xffff; regs->r_ds = tf->tf_ds & 0xffff; regs->r_eflags = tf->tf_eflags; @@ -236,7 +235,6 @@ process_write_regs(p, regs) struct reg *regs; { struct trapframe *tf = process_frame(p); - struct pcb *pcb = &p->p_addr->u_pcb; #ifdef VM86 if (tf->tf_eflags & PSL_VM) { @@ -248,23 +246,6 @@ process_write_regs(p, regs) } else #endif { -#if 0 - extern int gdt_size; - -#define verr_ldt(slot) (slot < pcb->pcb_ldt_len && \ - (pcb->pcb_ldt[slot].sd.sd_type & SDT_MEMRO) != 0 && \ - pcb->pcb_ldt[slot].sd.sd_dpl == SEL_UPL && \ - pcb->pcb_ldt[slot].sd.sd_p == 1) -#define verr_gdt(slot) (slot < gdt_size && \ - (gdt[slot].sd.sd_type & SDT_MEMRO) != 0 && \ - gdt[slot].sd.sd_dpl == SEL_UPL && \ - gdt[slot].sd.sd_p == 1) -#define verr(sel) (ISLDT(sel) ? verr_ldt(IDXSEL(sel)) : \ - verr_gdt(IDXSEL(sel))) -#define valid_sel(sel) (ISPL(sel) == SEL_UPL && verr(sel)) -#define null_sel(sel) (!ISLDT(sel) && IDXSEL(sel) == 0) -#endif - /* * Check for security violations. */ @@ -272,17 +253,8 @@ process_write_regs(p, regs) !USERMODE(regs->r_cs, regs->r_eflags)) return (EINVAL); - /* XXX Is this safe to remove. */ -#if 0 - if ((regs->r_gs != pcb->pcb_gs && \ - !valid_sel(regs->r_gs) && !null_sel(regs->r_gs)) || - (regs->r_fs != pcb->pcb_fs && \ - !valid_sel(regs->r_fs) && !null_sel(regs->r_fs))) - return (EINVAL); -#endif - - pcb->pcb_gs = regs->r_gs & 0xffff; - pcb->pcb_fs = regs->r_fs & 0xffff; + tf->tf_gs = regs->r_gs & 0xffff; + tf->tf_fs = regs->r_fs & 0xffff; tf->tf_es = regs->r_es & 0xffff; tf->tf_ds = regs->r_ds & 0xffff; tf->tf_eflags = regs->r_eflags; diff --git a/sys/arch/i386/i386/svr4_machdep.c b/sys/arch/i386/i386/svr4_machdep.c index b50246f2108..9fe0fe5ba19 100644 --- a/sys/arch/i386/i386/svr4_machdep.c +++ b/sys/arch/i386/i386/svr4_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_machdep.c,v 1.20 2003/05/13 03:49:04 art Exp $ */ +/* $OpenBSD: svr4_machdep.c,v 1.21 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: svr4_machdep.c,v 1.24 1996/05/03 19:42:26 christos Exp $ */ /* @@ -85,8 +85,8 @@ svr4_getcontext(p, uc, mask, oonstack) } else #endif { - __asm("movl %%gs,%k0" : "=r" (r[SVR4_X86_GS])); - __asm("movl %%fs,%k0" : "=r" (r[SVR4_X86_FS])); + r[SVR4_X86_FS] = tf->tf_fs; + r[SVR4_X86_GS] = tf->tf_gs; r[SVR4_X86_ES] = tf->tf_es; r[SVR4_X86_DS] = tf->tf_ds; r[SVR4_X86_EFL] = tf->tf_eflags; @@ -179,7 +179,8 @@ svr4_setcontext(p, uc) !USERMODE(r[SVR4_X86_CS], r[SVR4_X86_EFL])) return (EINVAL); - /* %fs and %gs were restored by the trampoline. */ + tf->tf_fs = r[SVR4_X86_FS]; + tf->tf_gs = r[SVR4_X86_GS]; tf->tf_es = r[SVR4_X86_ES]; tf->tf_ds = r[SVR4_X86_DS]; tf->tf_eflags = r[SVR4_X86_EFL]; diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index 223c6bf3544..5a5541184b6 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.63 2004/06/13 21:49:15 niklas Exp $ */ +/* $OpenBSD: trap.c,v 1.64 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -180,7 +180,8 @@ trap(frame) int type = frame.tf_trapno; u_quad_t sticks; struct pcb *pcb = NULL; - extern char resume_iret[], resume_pop_ds[], resume_pop_es[]; + extern char resume_iret[], resume_pop_ds[], resume_pop_es[], + resume_pop_fs[], resume_pop_gs[]; struct trapframe *vframe; int resume; vm_prot_t vftype, ftype; @@ -298,17 +299,34 @@ trap(frame) */ switch (*(u_char *)frame.tf_eip) { case 0xcf: /* iret */ - vframe = (void *)((int)&frame.tf_esp - 44); + vframe = (void *)((int)&frame.tf_esp - + offsetof(struct trapframe, tf_eip)); resume = (int)resume_iret; break; case 0x1f: /* popl %ds */ - vframe = (void *)((int)&frame.tf_esp - 4); + vframe = (void *)((int)&frame.tf_esp - + offsetof(struct trapframe, tf_ds)); resume = (int)resume_pop_ds; break; case 0x07: /* popl %es */ - vframe = (void *)((int)&frame.tf_esp - 0); + vframe = (void *)((int)&frame.tf_esp - + offsetof(struct trapframe, tf_es)); resume = (int)resume_pop_es; break; + case 0x0f: /* 0x0f prefix */ + switch (*(u_char *)(frame.tf_eip+1)) { + case 0xa1: /* popl %fs */ + vframe = (void *)((int)&frame.tf_esp - + offsetof(struct trapframe, tf_fs)); + resume = (int)resume_pop_fs; + break; + case 0xa9: /* popl %gs */ + vframe = (void *)((int)&frame.tf_esp - + offsetof(struct trapframe, tf_gs)); + resume = (int)resume_pop_gs; + break; + } + break; default: goto we_re_toast; } diff --git a/sys/arch/i386/include/db_machdep.h b/sys/arch/i386/include/db_machdep.h index 4d4be44f9a7..d39c95fd135 100644 --- a/sys/arch/i386/include/db_machdep.h +++ b/sys/arch/i386/include/db_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.h,v 1.11 2004/06/21 22:41:11 andreas Exp $ */ +/* $OpenBSD: db_machdep.h,v 1.12 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: db_machdep.h,v 1.9 1996/05/03 19:23:59 christos Exp $ */ /* @@ -106,7 +106,7 @@ boolean_t db_phys_eq(task_t, vaddr_t, task_t, vaddr_t); * Constants for KGDB. */ typedef long kgdb_reg_t; -#define KGDB_NUMREGS 14 +#define KGDB_NUMREGS 16 #define KGDB_BUFLEN 512 #if 0 diff --git a/sys/arch/i386/include/frame.h b/sys/arch/i386/include/frame.h index 5c408bc0a27..cbe9a1a805d 100644 --- a/sys/arch/i386/include/frame.h +++ b/sys/arch/i386/include/frame.h @@ -1,4 +1,4 @@ -/* $OpenBSD: frame.h,v 1.5 2003/06/02 23:27:47 millert Exp $ */ +/* $OpenBSD: frame.h,v 1.6 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: frame.h,v 1.12 1995/10/11 04:20:08 mycroft Exp $ */ /*- @@ -46,6 +46,8 @@ * Exception/Trap Stack Frame */ struct trapframe { + int tf_fs; + int tf_gs; int tf_es; int tf_ds; int tf_edi; @@ -76,6 +78,8 @@ struct trapframe { */ struct intrframe { int if_ppl; + int if_fs; + int if_gs; int if_es; int if_ds; int if_edi; diff --git a/sys/arch/i386/include/pcb.h b/sys/arch/i386/include/pcb.h index 641f8874f17..0788135e06d 100644 --- a/sys/arch/i386/include/pcb.h +++ b/sys/arch/i386/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.12 2004/06/13 21:49:16 niklas Exp $ */ +/* $OpenBSD: pcb.h,v 1.13 2004/07/02 16:29:55 niklas Exp $ */ /* $NetBSD: pcb.h,v 1.21 1996/01/08 13:51:42 mycroft Exp $ */ /*- @@ -58,8 +58,6 @@ struct pcb { #define pcb_esp pcb_tss.tss_esp #define pcb_ebp pcb_tss.tss_ebp #define pcb_cs pcb_tss.tss_cs -#define pcb_fs pcb_tss.tss_fs -#define pcb_gs pcb_tss.tss_gs #define pcb_ldt_sel pcb_tss.tss_ldt int pcb_tss_sel; union descriptor *pcb_ldt; /* per process (user) LDT */ |