diff options
author | 2008-05-23 15:38:34 +0000 | |
---|---|---|
committer | 2008-05-23 15:38:34 +0000 | |
commit | ba9e9fd6860725db5acb171cc93fc9392eccb331 (patch) | |
tree | 0488ffaa7e1d2a3ec369a7ce73236298d91715ee | |
parent | hexidecimal -> hexadecimal (diff) | |
download | wireguard-openbsd-ba9e9fd6860725db5acb171cc93fc9392eccb331.tar.xz wireguard-openbsd-ba9e9fd6860725db5acb171cc93fc9392eccb331.zip |
- remove USER_LDT, it was never in a state where it would copile, nor will
we support i386-compat mode on amd64.
agreed by beck@, dlg@, kettenis@
ok deraadt@, tom@
-rw-r--r-- | lib/libarch/amd64/Makefile | 9 | ||||
-rw-r--r-- | lib/libarch/amd64/amd64_get_ldt.2 | 124 | ||||
-rw-r--r-- | lib/libarch/amd64/amd64_get_ldt.c | 50 | ||||
-rw-r--r-- | lib/libarch/amd64/amd64_set_ldt.c | 50 | ||||
-rw-r--r-- | share/man/man3/intro.3 | 5 | ||||
-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 |
14 files changed, 16 insertions, 573 deletions
diff --git a/lib/libarch/amd64/Makefile b/lib/libarch/amd64/Makefile index 5e17493b768..53cc79a3095 100644 --- a/lib/libarch/amd64/Makefile +++ b/lib/libarch/amd64/Makefile @@ -1,16 +1,15 @@ -# $OpenBSD: Makefile,v 1.5 2004/02/28 23:51:35 deraadt Exp $ +# $OpenBSD: Makefile,v 1.6 2008/05/23 15:38:34 jasper Exp $ # $NetBSD: Makefile,v 1.1 1996/02/21 02:45:47 jtk Exp $ MANSUBDIR=amd64 -MAN+= amd64_get_ldt.2 amd64_iopl.2 amd64_get_ioperm.2 amd64_get_mtrr.2 -MLINKS+=amd64_get_ldt.2 amd64_set_ldt.2 \ - amd64_get_ioperm.2 amd64_set_ioperm.2 \ +MAN+= amd64_iopl.2 amd64_get_ioperm.2 amd64_get_mtrr.2 +MLINKS+=amd64_get_ioperm.2 amd64_set_ioperm.2 \ amd64_get_mtrr.2 amd64_set_mtrr.2 .if ${MACHINE_ARCH} == "amd64" .PATH: ${LIBC}/amd64 NOPIC= -SRCS+= amd64_get_ldt.c amd64_set_ldt.c amd64_iopl.c amd64_get_ioperm.c \ +SRCS+= amd64_iopl.c amd64_get_ioperm.c \ amd64_set_ioperm.c amd64_set_mtrr.c amd64_get_mtrr.c .include <bsd.lib.mk> .else diff --git a/lib/libarch/amd64/amd64_get_ldt.2 b/lib/libarch/amd64/amd64_get_ldt.2 deleted file mode 100644 index 735cb893d71..00000000000 --- a/lib/libarch/amd64/amd64_get_ldt.2 +++ /dev/null @@ -1,124 +0,0 @@ -.\" $OpenBSD: amd64_get_ldt.2,v 1.4 2007/05/31 19:19:27 jmc Exp $ -.\" -.\" Copyright (c) 1980, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)fork.2 6.5 (Berkeley) 3/10/91 -.\" $NetBSD: amd64_get_ldt.2,v 1.3 1996/01/05 14:56:44 pk Exp $ -.\" -.Dd $Mdocdate: May 31 2007 $ -.Dt AMD64_GET_LDT 2 amd64 -.Os -.Sh NAME -.Nm amd64_get_ldt , -.Nm amd64_set_ldt -.Nd manage amd64 per-process Local Descriptor Table entries -.Sh SYNOPSIS -.Fd #include <sys/types.h> -.Fd #include <machine/segments.h> -.Fd #include <machine/sysarch.h> -.Ft int -.Fn amd64_get_ldt "int start_sel" "union descriptor *descs" "int num_sels" -.Ft int -.Fn amd64_set_ldt "int start_sel" "union descriptor *descs" "int num_sels" -.Sh DESCRIPTION -.Fn amd64_get_ldt -returns a list of the amd64 descriptors in the current process' -LDT. -.Fn amd64_set_ldt -sets a list of amd64 descriptors in the current process' -LDT. -For both routines, -.Fa start_sel -specifies the index of the selector in the LDT at which to begin and -.Fa descs -points to an array of -.Fa num_sels -descriptors to be set or returned. -.Pp -Each entry in the -.Fa descs -array can be either a segment_descriptor or a gate_descriptor, -as defined in -.Aq Pa amd64/segments.h . -These structures are defined by the architecture -as disjoint bit-fields, so care must be taken in constructing them. -.Pp -Before this API can be used the functionality has to be enabled -using the machdep.userldt -.Xr sysctl 8 -variable. -.Pp -.Sy Note: -Code using the -.Fn amd64_get_ldt -and -.Fn amd64_set_ldt -functions must be compiled using -.Cm -lamd64 . -.Sh RETURN VALUES -Upon successful completion, -.Fn amd64_get_ldt -returns the number of amd64 descriptors copied into -.Fa descs -from the current process' LDT. -Otherwise, a value of \-1 is returned and the global -variable -.Va errno -is set to indicate the error. -.Pp -Upon successful completion, -.Fn amd64_set_ldt -returns the first selector set; -if the kernel allocated a descriptor in the LDT, -the allocated index is returned. -Otherwise, a value of \-1 is returned and the global -variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn amd64_get_ldt -and -.Fn amd64_set_ldt -will fail if: -.Bl -tag -width [EINVAL] -.It Bq Er EINVAL -An inappropriate parameter was used for -.Fa start_sel -or -.Fa num_sels . -.It Bq Er EACCES -The caller attempted to use a descriptor that would -circumvent protection or cause a failure. -.El -.Sh REFERENCES -.Rs -.%A Intel -.%T AMD64 Microprocessor Programmer's Reference Manual -.Re -.Sh WARNING -You can really hose your process using this. diff --git a/lib/libarch/amd64/amd64_get_ldt.c b/lib/libarch/amd64/amd64_get_ldt.c deleted file mode 100644 index 4989f9787be..00000000000 --- a/lib/libarch/amd64/amd64_get_ldt.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1993 John Brezak - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <sys/cdefs.h> -#include <sys/types.h> - -#include <machine/segments.h> -#include <machine/sysarch.h> - -int -amd64_get_ldt(start, desc, num) - int start; - union descriptor *desc; - int num; -{ - struct amd64_get_ldt_args p; - - p.start = start; - p.desc = desc; - p.num = num; - - /* LINTED pointer casts may be troublesome */ - return sysarch(AMD64_GET_LDT, (char *)&p); -} diff --git a/lib/libarch/amd64/amd64_set_ldt.c b/lib/libarch/amd64/amd64_set_ldt.c deleted file mode 100644 index e64b1e8df80..00000000000 --- a/lib/libarch/amd64/amd64_set_ldt.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1993 John Brezak - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <sys/cdefs.h> -#include <sys/types.h> - -#include <machine/segments.h> -#include <machine/sysarch.h> - -int -amd64_set_ldt(start, desc, num) - int start; - union descriptor *desc; - int num; -{ - struct amd64_set_ldt_args p; - - p.start = start; - p.desc = desc; - p.num = num; - - /* LINTED pointer casts may be troublesome */ - return sysarch(AMD64_SET_LDT, (char *)&p); -} diff --git a/share/man/man3/intro.3 b/share/man/man3/intro.3 index ec33ecdf1b5..c05a1050f78 100644 --- a/share/man/man3/intro.3 +++ b/share/man/man3/intro.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: intro.3,v 1.33 2007/10/21 18:45:59 jmc Exp $ +.\" $OpenBSD: intro.3,v 1.34 2008/05/23 15:38:34 jasper Exp $ .\" $NetBSD: intro.3,v 1.5 1995/05/10 22:46:24 jtc Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)intro.3 8.1 (Berkeley) 6/5/93 .\" -.Dd $Mdocdate: October 21 2007 $ +.Dd $Mdocdate: May 23 2008 $ .Dt INTRO 3 .Os .Sh NAME @@ -446,7 +446,6 @@ See AMD64 I/O and memory access functions. See .Xr amd64_get_ioperm 2 , -.Xr amd64_get_ldt 2 , .Xr amd64_get_mtrr 2 , .Xr amd64_iopl 2 , and 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)) |