diff options
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 10 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/pmap.c | 76 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/sys_machdep.c | 210 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 18 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/vector.S | 15 | ||||
-rw-r--r-- | sys/arch/amd64/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/amd64/include/pcb.h | 3 | ||||
-rw-r--r-- | sys/arch/amd64/include/pmap.h | 10 | ||||
-rw-r--r-- | sys/arch/amd64/include/segments.h | 6 |
9 files changed, 10 insertions, 341 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 8c99f42b4e9..ba1925d4e3c 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.74 2008/04/30 13:59:33 dlg Exp $ */ +/* $OpenBSD: machdep.c,v 1.75 2008/05/23 15:39:43 jasper Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -1051,10 +1051,6 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack, if (p->p_addr->u_pcb.pcb_fpcpu != NULL) fpusave_proc(p, 0); -#ifdef USER_LDT - pmap_ldt_cleanup(p); -#endif - p->p_md.md_flags &= ~MDP_USEDFPU; pcb->pcb_flags = 0; pcb->pcb_savefpu.fp_fxsave.fx_fcw = __INITIAL_NPXCW__; @@ -1740,11 +1736,7 @@ idt_vec_free(int vec) int cpu_maxproc(void) { -#ifdef USER_LDT - return ((MAXGDTSIZ - DYNSEL_START) / 32); -#else return (MAXGDTSIZ - DYNSEL_START) / 16; -#endif } #ifdef DIAGNOSTIC diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c index 9c5f4747660..52e413ffcbd 100644 --- a/sys/arch/amd64/amd64/pmap.c +++ b/sys/arch/amd64/amd64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.30 2007/12/09 00:24:04 tedu Exp $ */ +/* $OpenBSD: pmap.c,v 1.31 2008/05/23 15:39:43 jasper Exp $ */ /* $NetBSD: pmap.c,v 1.3 2003/05/08 18:13:13 thorpej Exp $ */ /* @@ -1136,21 +1136,6 @@ pmap_destroy(struct pmap *pmap) /* XXX: need to flush it out of other processor's APTE space? */ pool_put(&pmap_pdp_pool, pmap->pm_pdir); -#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); - } -#endif - pool_put(&pmap_pmap_pool, pmap); } @@ -1164,65 +1149,6 @@ pmap_reference(struct pmap *pmap) pmap->pm_obj[0].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) { - char *new_ldt; - size_t len; - - len = pmap1->pm_ldt_len; - new_ldt = (char *)uvm_km_alloc(kernel_map, len); - memcpy(new_ldt, pmap1->pm_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; - char *old_ldt = NULL; - size_t len = 0; - - if (pmap->pm_flags & PMF_USER_LDT) { - ldt_free(pmap); - pmap->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL); - pcb->pcb_ldt_sel = pmap->pm_ldt_sel; - if (pcb == curpcb) - lldt(pcb->pcb_ldt_sel); - old_ldt = pmap->pm_ldt; - len = pmap->pm_ldt_len; - 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 */ - /* * pmap_activate: activate a process' pmap (fill in %cr3 and LDT info) * diff --git a/sys/arch/amd64/amd64/sys_machdep.c b/sys/arch/amd64/amd64/sys_machdep.c index 780edc32787..a8d37ff41a0 100644 --- a/sys/arch/amd64/amd64/sys_machdep.c +++ b/sys/arch/amd64/amd64/sys_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_machdep.c,v 1.5 2007/01/15 23:19:05 jsg Exp $ */ +/* $OpenBSD: sys_machdep.c,v 1.6 2008/05/23 15:39:43 jasper Exp $ */ /* $NetBSD: sys_machdep.c,v 1.1 2003/04/26 18:39:32 fvdl Exp $ */ /*- @@ -37,10 +37,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* - * XXXfvdl check USER_LDT - */ - #include <sys/param.h> #include <sys/systm.h> #include <sys/ioctl.h> @@ -80,201 +76,6 @@ int amd64_iopl(struct proc *, void *, register_t *); int amd64_get_mtrr(struct proc *, void *, register_t *); int amd64_set_mtrr(struct proc *, void *, register_t *); -/* XXXfvdl disabled USER_LDT stuff until I check this stuff */ - -#if defined(USER_LDT) && 0 -int -amd64_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; - struct amd64_get_ldt_args ua; - - if ((error = copyin(args, &ua, sizeof(ua))) != 0) - return (error); - -#ifdef LDT_DEBUG - printf("amd64_get_ldt: start=%d num=%d descs=%p\n", ua.start, - ua.num, ua.desc); -#endif - - if (ua.start < 0 || ua.num < 0) - return (EINVAL); - - /* - * XXX LOCKING. - */ - - 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) - return (EINVAL); - - lp += ua.start; - num = min(ua.num, nldt - ua.start); - - error = copyout(lp, ua.desc, num * sizeof(union descriptor)); - if (error) - return (error); - - *retval = num; - return (0); -} - -int -amd64_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 amd64_set_ldt_args ua; - union descriptor desc; - - if ((error = copyin(args, &ua, sizeof(ua))) != 0) - return (error); - -#ifdef LDT_DEBUG - printf("amd64_set_ldt: start=%d num=%d descs=%p\n", ua.start, - ua.num, ua.desc); -#endif - - if (ua.start < 0 || ua.num < 0) - return (EINVAL); - if (ua.start > 8192 || (ua.start + ua.num) > 8192) - return (EINVAL); - - /* - * XXX LOCKING - */ - - /* allocate user ldt */ - if (pmap->pm_ldt == 0 || (ua.start + ua.num) > pmap->pm_ldt_len) { - size_t old_len, new_len; - union descriptor *old_ldt, *new_ldt; - - if (pmap->pm_flags & PMF_USER_LDT) { - old_len = pmap->pm_ldt_len * sizeof(union descriptor); - old_ldt = pmap->pm_ldt; - } else { - old_len = NLDT * sizeof(union descriptor); - old_ldt = ldt; - pmap->pm_ldt_len = 512; - } - while ((ua.start + ua.num) > pmap->pm_ldt_len) - pmap->pm_ldt_len *= 2; - new_len = pmap->pm_ldt_len * sizeof(union descriptor); - new_ldt = (union descriptor *)uvm_km_alloc(kernel_map, new_len); - memcpy(new_ldt, old_ldt, old_len); - memset((caddr_t)new_ldt + old_len, 0, new_len - old_len); - pmap->pm_ldt = new_ldt; - - if (pmap->pm_flags & PCB_USER_LDT) - ldt_free(pmap); - else - pmap->pm_flags |= PCB_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); - - /* - * XXX Need to notify other processors which may be - * XXX currently using this pmap that they need to - * XXX re-load the LDT. - */ - - if (old_ldt != ldt) - uvm_km_free(kernel_map, (vaddr_t)old_ldt, old_len); -#ifdef LDT_DEBUG - printf("amd64_set_ldt(%d): new_ldt=%p\n", p->p_pid, new_ldt); -#endif - } - - if (pcb == curpcb) - savectx(curpcb); - error = 0; - - /* Check descriptors for access violations. */ - for (i = 0, n = ua.start; i < ua.num; i++, n++) { - if ((error = copyin(&ua.desc[i], &desc, sizeof(desc))) != 0) - return (error); - - 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))) - return (EACCES); - 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) - return (EACCES); - 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: - /* Only care if it's present. */ - if (desc.sd.sd_p != 0) - return (EACCES); - break; - } - - if (desc.sd.sd_p != 0) { - /* Only user (ring-3) descriptors may be present. */ - if (desc.sd.sd_dpl != SEL_UPL) - return (EACCES); - } - } - - /* Now actually replace the descriptors. */ - for (i = 0, n = ua.start; i < ua.num; i++, n++) { - if ((error = copyin(&ua.desc[i], &desc, sizeof(desc))) != 0) - goto out; - - pmap->pm_ldt[n] = desc; - } - - *retval = ua.start; - -out: - return (error); -} -#endif /* USER_LDT */ - #ifdef APERTURE extern int allowaperture; #endif @@ -411,15 +212,6 @@ sys_sysarch(struct proc *p, void *v, register_t *retval) int error = 0; switch(SCARG(uap, op)) { -#if defined(USER_LDT) && 0 - case AMD64_GET_LDT: - error = amd64_get_ldt(p, SCARG(uap, parms), retval); - break; - - case AMD64_SET_LDT: - error = amd64_set_ldt(p, SCARG(uap, parms), retval); - break; -#endif case AMD64_IOPL: error = amd64_iopl(p, SCARG(uap, parms), retval); break; diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 257965668d9..d3b62501b12 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.13 2007/05/11 10:06:55 pedro Exp $ */ +/* $OpenBSD: trap.c,v 1.14 2008/05/23 15:39:43 jasper Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -263,22 +263,6 @@ copyfault: vframe = (void *)((u_int64_t)&frame.tf_rsp - 44); resume = resume_iret; break; -/* - * XXXfvdl these are illegal in long mode (not in compat mode, though) - * and we do not take back the descriptors from the signal context anyway, - * but may do so later for USER_LDT, in which case we need to intercept - * other instructions (movl %eax, %Xs). - */ -#if 0 - case 0x1f: /* popl %ds */ - vframe = (void *)((u_int64_t)&frame.tf_rsp - 4); - resume = resume_pop_ds; - break; - case 0x07: /* popl %es */ - vframe = (void *)((u_int64_t)&frame.tf_rsp - 0); - resume = resume_pop_es; - break; -#endif default: goto we_re_toast; } diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S index 7a70f67824d..08a3ec85285 100644 --- a/sys/arch/amd64/amd64/vector.S +++ b/sys/arch/amd64/amd64/vector.S @@ -1,4 +1,4 @@ -/* $OpenBSD: vector.S,v 1.12 2008/05/14 21:53:08 weingart Exp $ */ +/* $OpenBSD: vector.S,v 1.13 2008/05/23 15:39:43 jasper Exp $ */ /* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */ /* @@ -197,22 +197,9 @@ IDTVEC(exceptions) * change %eip to point to one of these labels. We clean up the stack, if * necessary, and resume as if we were handling a general protection fault. * This will cause the process to get a SIGBUS. - * - * XXXfvdl currently unused, as pop %ds and pop %es are illegal in long - * mode. However, if the x86-64 port is going to support USER_LDT, we - * may need something like this after all. */ NENTRY(resume_iret) ZTRAP(T_PROTFLT) -#if 0 -NENTRY(resume_pop_ds) - movl $GSEL(GDATA_SEL, SEL_KPL),%eax - movl %eax,%es -NENTRY(resume_pop_es) - movl $T_PROTFLT,TF_TRAPNO(%rsp) - jmp calltrap -#endif - /* * All traps go through here. Call the generic trap handler, and * check for ASTs afterwards. diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index bee69462583..e2de92acf80 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.229 2008/05/23 14:04:18 brad Exp $ +# $OpenBSD: GENERIC,v 1.230 2008/05/23 15:39:43 jasper Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -16,7 +16,6 @@ maxusers 80 # estimated number of users option USER_PCICONF # user-space PCI configuration #option VM86 # Virtual 8086 emulation -#option USER_LDT # user-settable LDT; see amd64_set_ldt(2) option APERTURE # in-kernel aperture driver for XFree86 #option MTRR # CPU memory range attributes control diff --git a/sys/arch/amd64/include/pcb.h b/sys/arch/amd64/include/pcb.h index 762d7d3a48d..1408953a5bc 100644 --- a/sys/arch/amd64/include/pcb.h +++ b/sys/arch/amd64/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.3 2006/05/10 01:39:04 krw Exp $ */ +/* $OpenBSD: pcb.h,v 1.4 2008/05/23 15:39:43 jasper Exp $ */ /* $NetBSD: pcb.h,v 1.1 2003/04/26 18:39:45 fvdl Exp $ */ /*- @@ -109,7 +109,6 @@ struct pcb { struct savefpu pcb_savefpu; /* floating point state */ int pcb_cr0; /* saved image of CR0 */ int pcb_flags; -#define PCB_USER_LDT 0x01 /* has user-set LDT */ caddr_t pcb_onfault; /* copyin/out fault recovery */ struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */ unsigned pcb_iomap[NIOPORTS/32]; /* I/O bitmap */ diff --git a/sys/arch/amd64/include/pmap.h b/sys/arch/amd64/include/pmap.h index bd70d929026..452d865519c 100644 --- a/sys/arch/amd64/include/pmap.h +++ b/sys/arch/amd64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.17 2007/09/10 18:49:44 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.18 2008/05/23 15:39:43 jasper Exp $ */ /* $NetBSD: pmap.h,v 1.1 2003/04/26 18:39:46 fvdl Exp $ */ /* @@ -332,9 +332,6 @@ struct pmap { u_int32_t pm_cpus; /* mask of CPUs using pmap */ }; -/* pm_flags */ -#define PMF_USER_LDT 0x01 /* pmap has user-set LDT */ - /* * We keep mod/ref flags in struct vm_page->pg_flags. */ @@ -560,11 +557,6 @@ kvtopte(vaddr_t va) vaddr_t pmap_map(vaddr_t, paddr_t, paddr_t, vm_prot_t); -#if 0 /* XXXfvdl was USER_LDT, need to check if that can be supported */ -void pmap_ldt_cleanup(struct proc *); -#define PMAP_FORK -#endif /* USER_LDT */ - #define PMAP_DIRECT_MAP(pa) ((vaddr_t)PMAP_DIRECT_BASE + pa) #define PMAP_DIRECT_UNMAP(va) ((paddr_t)va - PMAP_DIRECT_BASE) #define pmap_map_direct(pg) PMAP_DIRECT_MAP(VM_PAGE_TO_PHYS(pg)) diff --git a/sys/arch/amd64/include/segments.h b/sys/arch/amd64/include/segments.h index e8cdc1fa785..5e9fbd6b2bc 100644 --- a/sys/arch/amd64/include/segments.h +++ b/sys/arch/amd64/include/segments.h @@ -1,4 +1,4 @@ -/* $OpenBSD: segments.h,v 1.4 2005/12/13 00:18:19 jsg Exp $ */ +/* $OpenBSD: segments.h,v 1.5 2008/05/23 15:39:43 jasper Exp $ */ /* $NetBSD: segments.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */ /*- @@ -299,9 +299,7 @@ void cpu_init_idt(void); #define LSYSRETBASE_SEL LUCODE32_SEL /* - * Checks for valid user selectors. If USER_LDT ever gets implemented - * for amd64, these must check the ldt length and SEL_UPL if a user - * ldt is active. + * Checks for valid user selectors. */ #define VALID_USER_DSEL32(s) \ ((s) == GSEL(GUDATA32_SEL, SEL_UPL) || (s) == LSEL(LUDATA32_SEL, SEL_UPL)) |