summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Weingartner <weingart@cvs.openbsd.org>2008-11-14 20:43:56 +0000
committerTobias Weingartner <weingart@cvs.openbsd.org>2008-11-14 20:43:56 +0000
commitf79fc6e28017b5dfaf824f84d4cc212ba68cb593 (patch)
tree5b7fbbd9f855965a1a237f715e1c6ff48094ce53
parent40883e0bb53b165b71bc995a8387087e2f889caa (diff)
Garbage collect the LDT segments, and simply use the GDT segments.
The beginning of i386 segment review/cleanup. Tested by various people.
-rw-r--r--sys/arch/i386/i386/machdep.c21
-rw-r--r--sys/arch/i386/i386/pmap.c12
-rw-r--r--sys/arch/i386/include/segments.h5
3 files changed, 15 insertions, 23 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 80b7c6f392b..673299a6e6f 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.437 2008/10/09 19:04:18 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.438 2008/11/14 20:43:54 weingart Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -2655,11 +2655,10 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
SDT_MEMERA, SEL_UPL, 1, 1);
/*
- * And update the GDT and LDT since we return to the user process
+ * And update the GDT since we return to the user process
* by leaving the syscall (we don't do another pmap_activate()).
*/
- curcpu()->ci_gdt[GUCODE_SEL].sd = pcb->pcb_ldt[LUCODE_SEL].sd =
- pmap->pm_codeseg;
+ curcpu()->ci_gdt[GUCODE_SEL].sd = pmap->pm_codeseg;
/*
* And reset the hiexec marker in the pmap.
@@ -2673,17 +2672,17 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
} else
pcb->pcb_savefpu.sv_87.sv_env.en_cw = __OpenBSD_NPXCW__;
- 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_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_ebp = 0;
tf->tf_ebx = (int)PS_STRINGS;
tf->tf_eip = pack->ep_entry;
- tf->tf_cs = LSEL(LUCODE_SEL, SEL_UPL);
+ tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
tf->tf_eflags = PSL_USERSET;
tf->tf_esp = stack;
- tf->tf_ss = LSEL(LUDATA_SEL, SEL_UPL);
+ tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
retval[1] = 0;
}
@@ -2875,8 +2874,6 @@ init386(paddr_t first_avail)
/* make ldt gates and memory segments */
setgate(&ldt[LSYS5CALLS_SEL].gd, &IDTVEC(osyscall), 1, SDT_SYS386CGT,
SEL_UPL, GCODE_SEL);
- ldt[LUCODE_SEL] = gdt[GUCODE_SEL];
- ldt[LUDATA_SEL] = gdt[GUDATA_SEL];
ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL];
/* exceptions */
diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c
index 9c286c62893..cca35c21a64 100644
--- a/sys/arch/i386/i386/pmap.c
+++ b/sys/arch/i386/i386/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.127 2008/11/14 15:10:31 kurt Exp $ */
+/* $OpenBSD: pmap.c,v 1.128 2008/11/14 20:43:54 weingart Exp $ */
/* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */
/*
@@ -664,11 +664,10 @@ setcslimit(struct pmap *pm, struct trapframe *tf, struct pcb *pcb,
setsegment(&pm->pm_codeseg, 0, atop(limit),
SDT_MEMERA, SEL_UPL, 1, 1);
- /* And update the GDT and LDT since we may be called by the
+ /* And update the GDT since we may be called by the
* trap handler (cpu_switch won't get a chance).
*/
- curcpu()->ci_gdt[GUCODE_SEL].sd = pcb->pcb_ldt[LUCODE_SEL].sd =
- pm->pm_codeseg;
+ curcpu()->ci_gdt[GUCODE_SEL].sd = pm->pm_codeseg;
pcb->pcb_cs = tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
}
@@ -1678,10 +1677,9 @@ pmap_activate(struct proc *p)
if (p == curproc) {
/*
* Set the correct descriptor value (i.e. with the
- * correct code segment X limit) in the GDT and the LDT.
+ * correct code segment X limit) in the GDT.
*/
- self->ci_gdt[GUCODE_SEL].sd = pcb->pcb_ldt[LUCODE_SEL].sd =
- pmap->pm_codeseg;
+ self->ci_gdt[GUCODE_SEL].sd = pmap->pm_codeseg;
lcr3(pcb->pcb_cr3);
lldt(pcb->pcb_ldt_sel);
diff --git a/sys/arch/i386/include/segments.h b/sys/arch/i386/include/segments.h
index e84cd3b951a..c7d1d6061db 100644
--- a/sys/arch/i386/include/segments.h
+++ b/sys/arch/i386/include/segments.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: segments.h,v 1.15 2008/09/01 17:30:56 deraadt Exp $ */
+/* $OpenBSD: segments.h,v 1.16 2008/11/14 20:43:55 weingart Exp $ */
/* $NetBSD: segments.h,v 1.23 1996/02/01 22:31:03 mycroft Exp $ */
/*-
@@ -230,9 +230,6 @@ void idt_vec_free(int);
*/
#define LSYS5CALLS_SEL 0 /* iBCS system call gate */
#define LSYS5SIGR_SEL 1 /* iBCS sigreturn gate */
-#define LUCODE1_SEL 2 /* User code descriptor */
-#define LUCODE_SEL 3 /* User code descriptor (a stack short) */
-#define LUDATA_SEL 4 /* User data descriptor */
#define LBSDICALLS_SEL 16 /* BSDI system call gate */
#define NLDT 17