diff options
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/i386/i386/gdt.c | 27 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 15 | ||||
-rw-r--r-- | sys/arch/i386/i386/pmap.c | 85 | ||||
-rw-r--r-- | sys/arch/i386/i386/sys_machdep.c | 254 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 12 | ||||
-rw-r--r-- | sys/arch/i386/include/gdt.h | 4 | ||||
-rw-r--r-- | sys/arch/i386/include/pmap.h | 11 | ||||
-rw-r--r-- | sys/arch/i386/include/sysarch.h | 18 |
9 files changed, 10 insertions, 419 deletions
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 7eb8672183c..0984e5b5226 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.812 2016/02/28 15:46:18 naddy Exp $ +# $OpenBSD: GENERIC,v 1.813 2016/03/03 12:41:30 naddy Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -17,7 +17,6 @@ option USER_PCICONF # user-space PCI configuration #option VM86 # Virtual 8086 emulation option KVM86 # Kernel Virtual 8086 emulation -option USER_LDT # user-settable LDT; see i386_set_ldt(2) option APERTURE # in-kernel aperture driver for XFree86 option MTRR # CPU memory range attributes control diff --git a/sys/arch/i386/i386/gdt.c b/sys/arch/i386/i386/gdt.c index 26e35b77d54..71a7a4cb8e1 100644 --- a/sys/arch/i386/i386/gdt.c +++ b/sys/arch/i386/i386/gdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gdt.c,v 1.35 2015/02/11 05:54:48 dlg Exp $ */ +/* $OpenBSD: gdt.c,v 1.36 2016/03/03 12:41:30 naddy Exp $ */ /* $NetBSD: gdt.c,v 1.28 2002/12/14 09:38:50 junyoung Exp $ */ /*- @@ -221,28 +221,3 @@ tss_free(int sel) gdt_put_slot(IDXSEL(sel)); } - -#ifdef USER_LDT -/* - * Caller must have pmap locked for both of these functions. - */ -void -ldt_alloc(struct pmap *pmap, union descriptor *ldt, size_t len) -{ - int slot; - - slot = gdt_get_slot(); - setgdt(slot, ldt, len - 1, SDT_SYSLDT, SEL_KPL, 0, 0); - pmap->pm_ldt_sel = GSEL(slot, SEL_KPL); -} - -void -ldt_free(struct pmap *pmap) -{ - int slot; - - slot = IDXSEL(pmap->pm_ldt_sel); - - gdt_put_slot(slot); -} -#endif /* USER_LDT */ diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 68352e91744..1677fa5f622 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.579 2015/12/27 04:31:34 jsg Exp $ */ +/* $OpenBSD: machdep.c,v 1.580 2016/03/03 12:41:30 naddy Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -189,10 +189,6 @@ void (*cpu_idle_enter_fcn)(void) = NULL; int cpu_apmhalt = 0; /* sysctl'd to 1 for halt -p hack */ #endif -#ifdef USER_LDT -int user_ldt_enable = 0; /* sysctl'd to 1 to enable */ -#endif - struct uvm_constraint_range isa_constraint = { 0x0, 0x00ffffffUL }; struct uvm_constraint_range dma_constraint = { 0x0, 0xffffffffUL }; struct uvm_constraint_range *uvm_md_constraints[] = { @@ -2907,10 +2903,6 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack, p->p_md.md_flags &= ~MDP_USEDFPU; #endif -#ifdef USER_LDT - pmap_ldt_cleanup(p); -#endif - /* * Reset the code segment limit to I386_MAX_EXE_ADDR in the pmap; * this gets copied into the GDT for GUCODE_SEL by pmap_activate(). @@ -3585,11 +3577,6 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, else return (sysctl_int(oldp, oldlenp, newp, newlen, &kbd_reset)); -#ifdef USER_LDT - case CPU_USERLDT: - return (sysctl_int(oldp, oldlenp, newp, newlen, - &user_ldt_enable)); -#endif case CPU_OSFXSR: return (sysctl_rdint(oldp, oldlenp, newp, i386_use_fxsave)); case CPU_SSE: diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index 0338dc848c4..c487e959c0e 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.186 2015/10/23 09:36:09 kettenis Exp $ */ +/* $OpenBSD: pmap.c,v 1.187 2016/03/03 12:41:30 naddy Exp $ */ /* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */ /* @@ -1362,20 +1362,6 @@ pmap_destroy(struct pmap *pmap) uvm_km_free(kernel_map, pmap->pm_pdir, pmap->pm_pdirsize); pmap->pm_pdir = 0; -#ifdef USER_LDT - if (pmap->pm_flags & PMF_USER_LDT) { - /* - * no need to switch the LDT; this address space is gone, - * nothing is using it. - * - * No need to lock the pmap for ldt_free (or anything else), - * we're the last one to use it. - */ - ldt_free(pmap); - uvm_km_free(kernel_map, (vaddr_t)pmap->pm_ldt, - pmap->pm_ldt_len * sizeof(union descriptor)); - } -#endif pool_put(&pmap_pmap_pool, pmap); } @@ -1390,75 +1376,6 @@ pmap_reference(struct pmap *pmap) atomic_inc_int(&pmap->pm_obj.uo_refs); } -#if defined(PMAP_FORK) -/* - * pmap_fork: perform any necessary data structure manipulation when - * a VM space is forked. - */ - -void -pmap_fork(struct pmap *pmap1, struct pmap *pmap2) -{ -#ifdef USER_LDT - /* Copy the LDT, if necessary. */ - if (pmap1->pm_flags & PMF_USER_LDT) { - union descriptor *new_ldt; - size_t len; - - len = pmap1->pm_ldt_len * sizeof(union descriptor); - new_ldt = (union descriptor *)uvm_km_alloc(kernel_map, len); - if (new_ldt == NULL) { - /* XXX needs to be able to fail properly */ - panic("pmap_fork: out of kva"); - } - bcopy(pmap1->pm_ldt, new_ldt, len); - pmap2->pm_ldt = new_ldt; - pmap2->pm_ldt_len = pmap1->pm_ldt_len; - pmap2->pm_flags |= PMF_USER_LDT; - ldt_alloc(pmap2, new_ldt, len); - } -#endif /* USER_LDT */ -} -#endif /* PMAP_FORK */ - -#ifdef USER_LDT -/* - * pmap_ldt_cleanup: if the pmap has a local LDT, deallocate it, and - * restore the default. - */ - -void -pmap_ldt_cleanup(struct proc *p) -{ - struct pcb *pcb = &p->p_addr->u_pcb; - pmap_t pmap = p->p_vmspace->vm_map.pmap; - union descriptor *old_ldt = NULL; - size_t len = 0; - - if (pmap->pm_flags & PMF_USER_LDT) { - ldt_free(pmap); - pmap->pm_ldt_sel = GSEL(GLDT_SEL, SEL_KPL); - pcb->pcb_ldt_sel = pmap->pm_ldt_sel; - /* Reset the cached address of the LDT that this process uses */ -#ifdef MULTIPROCESSOR - pcb->pcb_ldt = curcpu()->ci_ldt; -#else - pcb->pcb_ldt = ldt; -#endif - if (pcb == curpcb) - lldt(pcb->pcb_ldt_sel); - old_ldt = pmap->pm_ldt; - len = pmap->pm_ldt_len * sizeof(union descriptor); - pmap->pm_ldt = NULL; - pmap->pm_ldt_len = 0; - pmap->pm_flags &= ~PMF_USER_LDT; - } - - if (old_ldt != NULL) - uvm_km_free(kernel_map, (vaddr_t)old_ldt, len); -} -#endif /* USER_LDT */ - void pmap_activate(struct proc *p) { diff --git a/sys/arch/i386/i386/sys_machdep.c b/sys/arch/i386/i386/sys_machdep.c index bf509e25eec..285b7f2ce9f 100644 --- a/sys/arch/i386/i386/sys_machdep.c +++ b/sys/arch/i386/i386/sys_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_machdep.c,v 1.35 2015/09/08 07:12:56 deraadt Exp $ */ +/* $OpenBSD: sys_machdep.c,v 1.36 2016/03/03 12:41:30 naddy Exp $ */ /* $NetBSD: sys_machdep.c,v 1.28 1996/05/03 19:42:29 christos Exp $ */ /*- @@ -73,248 +73,6 @@ int i386_iopl(struct proc *, void *, register_t *); int i386_get_ioperm(struct proc *, void *, register_t *); int i386_set_ioperm(struct proc *, void *, register_t *); -#ifdef USER_LDT - -#ifdef LDT_DEBUG -static void i386_print_ldt(int, const struct segment_descriptor *); - -static void -i386_print_ldt(int i, const struct segment_descriptor *d) -{ - printf("[%d] lolimit=0x%x, lobase=0x%x, type=%u, dpl=%u, p=%u, " - "hilimit=0x%x, xx=%x, def32=%u, gran=%u, hibase=0x%x\n", - i, d->sd_lolimit, d->sd_lobase, d->sd_type, d->sd_dpl, d->sd_p, - d->sd_hilimit, d->sd_xx, d->sd_def32, d->sd_gran, d->sd_hibase); -} -#endif - -int -i386_get_ldt(struct proc *p, void *args, register_t *retval) -{ - int error; - pmap_t pmap = p->p_vmspace->vm_map.pmap; - int nldt, num; - union descriptor *lp, *cp; - struct i386_get_ldt_args ua; - - if (user_ldt_enable == 0) - return (ENOSYS); - - if ((error = copyin(args, &ua, sizeof(ua))) != 0) - return (error); - -#ifdef LDT_DEBUG - printf("i386_get_ldt: start=%d num=%d descs=%p\n", ua.start, - ua.num, ua.desc); -#endif - - if (ua.start < 0 || ua.num < 0 || ua.start > 8192 || ua.num > 8192 || - ua.start + ua.num > 8192) - return (EINVAL); - - cp = mallocarray(ua.num, sizeof(union descriptor), M_TEMP, M_WAITOK); - - if (pmap->pm_flags & PMF_USER_LDT) { - nldt = pmap->pm_ldt_len; - lp = pmap->pm_ldt; - } else { - nldt = NLDT; - lp = ldt; - } - - if (ua.start > nldt) { - free(cp, M_TEMP, ua.num * sizeof(union descriptor)); - return (EINVAL); - } - - lp += ua.start; - num = min(ua.num, nldt - ua.start); -#ifdef LDT_DEBUG - { - int i; - for (i = 0; i < num; i++) - i386_print_ldt(i, &lp[i].sd); - } -#endif - - memcpy(cp, lp, num * sizeof(union descriptor)); - - error = copyout(cp, ua.desc, num * sizeof(union descriptor)); - if (error == 0) - *retval = num; - - free(cp, M_TEMP, ua.num * sizeof(union descriptor)); - return (error); -} - -int -i386_set_ldt(struct proc *p, void *args, register_t *retval) -{ - int error, i, n; - struct pcb *pcb = &p->p_addr->u_pcb; - pmap_t pmap = p->p_vmspace->vm_map.pmap; - struct i386_set_ldt_args ua; - union descriptor *descv; - size_t old_len, new_len, ldt_len; - union descriptor *old_ldt, *new_ldt; - - if (user_ldt_enable == 0) - return (ENOSYS); - - if ((error = copyin(args, &ua, sizeof(ua))) != 0) - return (error); - - if (ua.start < 0 || ua.num < 0 || ua.start > 8192 || ua.num > 8192 || - ua.start + ua.num > 8192) - return (EINVAL); - - descv = mallocarray(ua.num, sizeof(*descv), M_TEMP, M_NOWAIT); - if (descv == NULL) - return (ENOMEM); - - if ((error = copyin(ua.desc, descv, sizeof (*descv) * ua.num)) != 0) - goto out; - - /* Check descriptors for access violations. */ - for (i = 0; i < ua.num; i++) { - union descriptor *desc = &descv[i]; - - switch (desc->sd.sd_type) { - case SDT_SYSNULL: - desc->sd.sd_p = 0; - break; - case SDT_SYS286CGT: - case SDT_SYS386CGT: - /* - * Only allow call gates targeting a segment - * in the LDT or a user segment in the fixed - * part of the gdt. Segments in the LDT are - * constrained (below) to be user segments. - */ - if (desc->gd.gd_p != 0 && - !ISLDT(desc->gd.gd_selector) && - ((IDXSEL(desc->gd.gd_selector) >= NGDT) || - (gdt[IDXSEL(desc->gd.gd_selector)].sd.sd_dpl != - SEL_UPL))) { - error = EACCES; - goto out; - } - break; - case SDT_MEMEC: - case SDT_MEMEAC: - case SDT_MEMERC: - case SDT_MEMERAC: - /* Must be "present" if executable and conforming. */ - if (desc->sd.sd_p == 0) { - error = EACCES; - goto out; - } - break; - case SDT_MEMRO: - case SDT_MEMROA: - case SDT_MEMRW: - case SDT_MEMRWA: - case SDT_MEMROD: - case SDT_MEMRODA: - case SDT_MEMRWD: - case SDT_MEMRWDA: - case SDT_MEME: - case SDT_MEMEA: - case SDT_MEMER: - case SDT_MEMERA: - break; - default: - /* - * Make sure that unknown descriptor types are - * not marked present. - */ - if (desc->sd.sd_p != 0) { - error = EACCES; - goto out; - } - break; - } - - if (desc->sd.sd_p != 0) { - /* Only user (ring-3) descriptors may be present. */ - if (desc->sd.sd_dpl != SEL_UPL) { - error = EACCES; - goto out; - } - } - } - - /* allocate user ldt */ - if (pmap->pm_ldt == 0 || (ua.start + ua.num) > pmap->pm_ldt_len) { - if (pmap->pm_flags & PMF_USER_LDT) - ldt_len = pmap->pm_ldt_len; - else - ldt_len = 512; - while ((ua.start + ua.num) > ldt_len) - ldt_len *= 2; - new_len = ldt_len * sizeof(union descriptor); - - new_ldt = (union descriptor *)uvm_km_alloc(kernel_map, - new_len); - if (new_ldt == NULL) { - error = ENOMEM; - goto out; - } - - if (pmap->pm_ldt != NULL && ldt_len <= pmap->pm_ldt_len) { - /* - * Another thread (re)allocated the LDT to - * sufficient size while we were blocked in - * uvm_km_alloc. Oh well. The new entries - * will quite probably not be right, but - * hey.. not our problem if user applications - * have race conditions like that. - */ - uvm_km_free(kernel_map, (vaddr_t)new_ldt, new_len); - goto copy; - } - - old_ldt = pmap->pm_ldt; - - if (old_ldt != NULL) { - old_len = pmap->pm_ldt_len * sizeof(union descriptor); - } else { - old_len = NLDT * sizeof(union descriptor); - old_ldt = ldt; - } - - memcpy(new_ldt, old_ldt, old_len); - memset((caddr_t)new_ldt + old_len, 0, new_len - old_len); - - if (old_ldt != ldt) - uvm_km_free(kernel_map, (vaddr_t)old_ldt, old_len); - - pmap->pm_ldt = new_ldt; - pmap->pm_ldt_len = ldt_len; - - if (pmap->pm_flags & PMF_USER_LDT) - ldt_free(pmap); - else - pmap->pm_flags |= PMF_USER_LDT; - ldt_alloc(pmap, new_ldt, new_len); - pcb->pcb_ldt_sel = pmap->pm_ldt_sel; - if (pcb == curpcb) - lldt(pcb->pcb_ldt_sel); - - } -copy: - /* Now actually replace the descriptors. */ - for (i = 0, n = ua.start; i < ua.num; i++, n++) - pmap->pm_ldt[n] = descv[i]; - - *retval = ua.start; - -out: - free(descv, M_TEMP, ua.num * sizeof(*descv)); - return (error); -} -#endif /* USER_LDT */ - #ifdef APERTURE extern int allowaperture; #endif @@ -425,16 +183,6 @@ sys_sysarch(struct proc *p, void *v, register_t *retval) int error = 0; switch(SCARG(uap, op)) { -#ifdef USER_LDT - case I386_GET_LDT: - error = i386_get_ldt(p, SCARG(uap, parms), retval); - break; - - case I386_SET_LDT: - error = i386_set_ldt(p, SCARG(uap, parms), retval); - break; -#endif - case I386_IOPL: error = i386_iopl(p, SCARG(uap, parms), retval); break; diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 3d27ce6b0af..3d9bc1bef7a 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.145 2015/12/07 06:34:14 jsg Exp $ */ +/* $OpenBSD: cpu.h,v 1.146 2016/03/03 12:41:30 naddy Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -441,13 +441,6 @@ void npxdrop(struct proc *); void npxsave_proc(struct proc *, int); void npxsave_cpu(struct cpu_info *, int); -#ifdef USER_LDT -/* sys_machdep.h */ -extern int user_ldt_enable; -int i386_get_ldt(struct proc *, void *, register_t *); -int i386_set_ldt(struct proc *, void *, register_t *); -#endif - /* isa_machdep.c */ void isa_defaultirq(void); int isa_nmi(void); @@ -485,7 +478,6 @@ int cpu_paenable(void *); #define CPU_APMWARN 9 /* APM battery warning percentage */ #define CPU_KBDRESET 10 /* keyboard reset under pcvt */ #define CPU_APMHALT 11 /* halt -p hack */ -#define CPU_USERLDT 12 #define CPU_OSFXSR 13 /* uses FXSAVE/FXRSTOR */ #define CPU_SSE 14 /* supports SSE */ #define CPU_SSE2 15 /* supports SSE2 */ @@ -506,7 +498,7 @@ int cpu_paenable(void *); { "apmwarn", CTLTYPE_INT }, \ { "kbdreset", CTLTYPE_INT }, \ { "apmhalt", CTLTYPE_INT }, \ - { "userldt", CTLTYPE_INT }, \ + { 0, 0 }, \ { "osfxsr", CTLTYPE_INT }, \ { "sse", CTLTYPE_INT }, \ { "sse2", CTLTYPE_INT }, \ diff --git a/sys/arch/i386/include/gdt.h b/sys/arch/i386/include/gdt.h index b34872d6ff3..2b5d0dcf3b3 100644 --- a/sys/arch/i386/include/gdt.h +++ b/sys/arch/i386/include/gdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gdt.h,v 1.12 2009/02/03 11:24:19 mikeb Exp $ */ +/* $OpenBSD: gdt.h,v 1.13 2016/03/03 12:41:30 naddy Exp $ */ /* $NetBSD: gdt.h,v 1.7.10.6 2002/08/19 01:22:36 sommerfeld Exp $ */ /*- @@ -42,8 +42,6 @@ int gdt_get_slot(void); void gdt_init(void); void gdt_init_cpu(struct cpu_info *); void gdt_reload_cpu(/* XXX struct cpu_info * */ void); -void ldt_alloc(struct pmap *, union descriptor *, size_t); -void ldt_free(struct pmap *); int tss_alloc(struct pcb *); void tss_free(int); void setgdt(int, void *, size_t, int, int, int, int); diff --git a/sys/arch/i386/include/pmap.h b/sys/arch/i386/include/pmap.h index 6ef814f36e2..39667e4c8fc 100644 --- a/sys/arch/i386/include/pmap.h +++ b/sys/arch/i386/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.79 2015/10/23 09:36:09 kettenis Exp $ */ +/* $OpenBSD: pmap.h,v 1.80 2016/03/03 12:41:30 naddy Exp $ */ /* $NetBSD: pmap.h,v 1.44 2000/04/24 17:18:18 thorpej Exp $ */ /* @@ -111,9 +111,6 @@ struct pmap { int pm_ldt_sel; /* LDT selector */ }; -/* pm_flags */ -#define PMF_USER_LDT 0x01 /* pmap has user-set LDT */ - /* * For each managed physical page we maintain a list of <PMAP,VA>s * which it is mapped at. The list is headed by a pv_head structure. @@ -223,7 +220,6 @@ void pmap_init(void); struct pmap *pmap_create(void); void pmap_destroy(struct pmap *); void pmap_reference(struct pmap *); -void pmap_fork(struct pmap *, struct pmap *); void pmap_remove(struct pmap *, vaddr_t, vaddr_t); void pmap_collect(struct pmap *); void pmap_activate(struct proc *); @@ -458,11 +454,6 @@ pmap_is_curpmap(struct pmap *pmap) return (pmap_is_active(pmap, curcpu())); } -#if defined(USER_LDT) -void pmap_ldt_cleanup(struct proc *); -#define PMAP_FORK -#endif /* USER_LDT */ - #endif /* _KERNEL */ struct pv_entry; diff --git a/sys/arch/i386/include/sysarch.h b/sys/arch/i386/include/sysarch.h index 0cf97b86694..fae1affb4f8 100644 --- a/sys/arch/i386/include/sysarch.h +++ b/sys/arch/i386/include/sysarch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysarch.h,v 1.12 2012/12/05 23:20:12 deraadt Exp $ */ +/* $OpenBSD: sysarch.h,v 1.13 2016/03/03 12:41:30 naddy Exp $ */ /* $NetBSD: sysarch.h,v 1.8 1996/01/08 13:51:44 mycroft Exp $ */ #ifndef _MACHINE_SYSARCH_H_ @@ -7,8 +7,6 @@ /* * Architecture specific syscalls (i386) */ -#define I386_GET_LDT 0 -#define I386_SET_LDT 1 #define I386_IOPL 2 #define I386_GET_IOPERM 3 #define I386_SET_IOPERM 4 @@ -18,18 +16,6 @@ #define I386_GET_GSBASE 8 #define I386_SET_GSBASE 9 -struct i386_get_ldt_args { - int start; - union descriptor *desc; - int num; -}; - -struct i386_set_ldt_args { - int start; - union descriptor *desc; - int num; -}; - struct i386_iopl_args { int iopl; }; @@ -50,8 +36,6 @@ int i386_set_threadbase(struct proc *, uint32_t, int); #include <sys/cdefs.h> __BEGIN_DECLS -int i386_get_ldt(int, union descriptor *, int); -int i386_set_ldt(int, union descriptor *, int); int i386_iopl(int); int i386_get_ioperm(u_long *); int i386_set_ioperm(u_long *); |