Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/arch/i386/i386 Pull up revision 1.33 (via patch, re...



details:   https://anonhg.NetBSD.org/src/rev/ed0086fd1e77
branches:  netbsd-1-5
changeset: 491931:ed0086fd1e77
user:      he <he%NetBSD.org@localhost>
date:      Sun Jun 17 22:29:16 2001 +0000

description:
Pull up revision 1.33 (via patch, requested by sommerfeld):
  Add %fs/%gs to trap frame and save/restore them on trap/interupt/
  syscall entry from userspace.

  Remove special-case ``by hand'' validation of %fs/%gs register
  values s well as special handling of them in various signal
  handling paths.  Now, like %ds and %es, they are validated by
  the hardware on return to userland.

  This paves the way for the use of %fs for per-cpu data on multi-
  processor systems, and fixes an otherwise difficult-to-fix
  interaction between threads/clone(2) and USER_LDT.

diffstat:

 sys/arch/i386/i386/process_machdep.c |  36 +++++-------------------------------
 1 files changed, 5 insertions(+), 31 deletions(-)

diffs (78 lines):

diff -r ea7d17197491 -r ed0086fd1e77 sys/arch/i386/i386/process_machdep.c
--- a/sys/arch/i386/i386/process_machdep.c      Sun Jun 17 22:28:55 2001 +0000
+++ b/sys/arch/i386/i386/process_machdep.c      Sun Jun 17 22:29:16 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process_machdep.c,v 1.30 1999/05/12 21:21:48 thorpej Exp $     */
+/*     $NetBSD: process_machdep.c,v 1.30.14.1 2001/06/17 22:29:16 he Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -105,7 +105,6 @@
        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) {
@@ -117,8 +116,8 @@
        } else
 #endif
        {
-               regs->r_gs = pcb->pcb_gs;
-               regs->r_fs = pcb->pcb_fs;
+               regs->r_gs = tf->tf_gs;
+               regs->r_fs = tf->tf_fs;
                regs->r_es = tf->tf_es;
                regs->r_ds = tf->tf_ds;
                regs->r_eflags = tf->tf_eflags;
@@ -178,8 +177,6 @@
        struct reg *regs;
 {
        struct trapframe *tf = process_frame(p);
-       struct pcb *pcb = &p->p_addr->u_pcb;
-       pmap_t pmap = p->p_vmspace->vm_map.pmap;
 
 #ifdef VM86
        if (tf->tf_eflags & PSL_VM) {
@@ -191,19 +188,6 @@
        } else
 #endif
        {
-#define        verr_ldt(slot)  (slot < pmap->pm_ldt_len && \
-                        (pmap->pm_ldt[slot].sd.sd_type & SDT_MEMRO) != 0 && \
-                        pmap->pm_ldt[slot].sd.sd_dpl == SEL_UPL && \
-                        pmap->pm_ldt[slot].sd.sd_p == 1)
-#define        verr_gdt(slot)  (slot < NGDT && \
-                        (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)
-
                /*
                 * Check for security violations.
                 */
@@ -211,18 +195,8 @@
                    !USERMODE(regs->r_cs, regs->r_eflags))
                        return (EINVAL);
 
-               simple_lock(&pmap->pm_lock);
-
-               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);
-
-               simple_unlock(&pmap->pm_lock);
-
-               pcb->pcb_gs = regs->r_gs;
-               pcb->pcb_fs = regs->r_fs;
+               tf->tf_gs = regs->r_gs;
+               tf->tf_fs = regs->r_fs;
                tf->tf_es = regs->r_es;
                tf->tf_ds = regs->r_ds;
                tf->tf_eflags = regs->r_eflags;



Home | Main Index | Thread Index | Old Index