diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2003-03-28 00:49:14 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2003-03-28 00:49:14 +0000 |
commit | 58d3179258bacbf670c6109272a1441e9802e70e (patch) | |
tree | 482d6d68699068fbc0427ac9b9fd0a66e397279a /sys/arch | |
parent | fadb80427f4372e43bf4afde3acf20b21a6a5045 (diff) |
Add a sysctl to option USER_LDT, to control its behaviour, which will be
disabled by default.
Enable with sysctl -w machdep.userldt=1
This will allow people to use the few ports that require this functionality
to work without requiring the user to recompile a kernel.
The option USER_LDT remains in order to not increase size on the
installation media. It is now enabled in GENERIC.
Per espie@'s idea, but my diff was much simpler than his; ok deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/linux_machdep.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 11 | ||||
-rw-r--r-- | sys/arch/i386/i386/svr4_machdep.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/i386/sys_machdep.c | 12 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 7 |
6 files changed, 37 insertions, 11 deletions
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 591351f0207..5eb63404036 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.331 2003/03/09 01:54:20 tedu Exp $ +# $OpenBSD: GENERIC,v 1.332 2003/03/28 00:49:13 miod Exp $ # $NetBSD: GENERIC,v 1.48 1996/05/20 18:17:23 mrg Exp $ # # GENERIC -- everything that's currently supported @@ -17,7 +17,7 @@ option GPL_MATH_EMULATE # floating point emulation. option USER_PCICONF # user-space PCI configuration #option VM86 # Virtual 8086 emulation -#option USER_LDT # user-settable LDT; see i386_set_ldt(2) +option USER_LDT # user-settable LDT; see i386_set_ldt(2) option APERTURE # in-kernel aperture driver for XFree86 #option KGDB # Remote debugger support; exclusive of DDB diff --git a/sys/arch/i386/i386/linux_machdep.c b/sys/arch/i386/i386/linux_machdep.c index 8d580b53ec1..fd8dd6dc4c9 100644 --- a/sys/arch/i386/i386/linux_machdep.c +++ b/sys/arch/i386/i386/linux_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_machdep.c,v 1.24 2003/01/09 22:27:09 miod Exp $ */ +/* $OpenBSD: linux_machdep.c,v 1.25 2003/03/28 00:49:13 miod Exp $ */ /* $NetBSD: linux_machdep.c,v 1.29 1996/05/03 19:42:11 christos Exp $ */ /* @@ -295,6 +295,9 @@ linux_read_ldt(p, uap, retval) caddr_t sg; char *parms; + if (user_ldt_enable == 0) + return (ENOSYS); + sg = stackgap_init(p->p_emul); gl.start = 0; @@ -341,6 +344,9 @@ linux_write_ldt(p, uap, retval) caddr_t sg; char *parms; + if (user_ldt_enable == 0) + return (ENOSYS); + if (SCARG(uap, bytecount) != sizeof(ldt_info)) return (EINVAL); if ((error = copyin(SCARG(uap, ptr), &ldt_info, sizeof(ldt_info))) != 0) diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index f52c4133b5d..473c2e4c8ad 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.223 2003/03/28 00:28:22 weingart Exp $ */ +/* $OpenBSD: machdep.c,v 1.224 2003/03/28 00:49:13 miod Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -196,6 +196,10 @@ char machine_arch[] = "i386"; /* machine == machine_arch */ 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 + #ifdef NBUF int nbuf = NBUF; #else @@ -2621,6 +2625,11 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) 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 default: return EOPNOTSUPP; } diff --git a/sys/arch/i386/i386/svr4_machdep.c b/sys/arch/i386/i386/svr4_machdep.c index a0569208045..cd36a59e9e7 100644 --- a/sys/arch/i386/i386/svr4_machdep.c +++ b/sys/arch/i386/i386/svr4_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_machdep.c,v 1.16 2002/07/20 19:24:56 art Exp $ */ +/* $OpenBSD: svr4_machdep.c,v 1.17 2003/03/28 00:49:13 miod Exp $ */ /* $NetBSD: svr4_machdep.c,v 1.24 1996/05/03 19:42:26 christos Exp $ */ /* @@ -407,7 +407,9 @@ svr4_sys_sysarch(p, v, retval) case SVR4_SYSARCH_DSCR: #ifdef USER_LDT - { + if (user_ldt_enable == 0) + return (ENOSYS); + else { struct i386_set_ldt_args sa, *sap; struct sys_sysarch_args ua; diff --git a/sys/arch/i386/i386/sys_machdep.c b/sys/arch/i386/i386/sys_machdep.c index ee8f3ab8e0e..dc6f71f384a 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.19 2002/08/02 00:19:18 nate Exp $ */ +/* $OpenBSD: sys_machdep.c,v 1.20 2003/03/28 00:49:13 miod Exp $ */ /* $NetBSD: sys_machdep.c,v 1.28 1996/05/03 19:42:29 christos Exp $ */ /*- @@ -111,6 +111,9 @@ i386_get_ldt(p, args, retval) union descriptor *lp; struct i386_get_ldt_args ua; + if (user_ldt_enable == 0) + return (ENOSYS); + if ((error = copyin(args, &ua, sizeof(ua))) != 0) return (error); @@ -157,6 +160,9 @@ i386_set_ldt(p, args, retval) struct i386_set_ldt_args ua; union descriptor desc; + if (user_ldt_enable == 0) + return (ENOSYS); + if ((error = copyin(args, &ua, sizeof(ua))) != 0) return (error); @@ -195,10 +201,10 @@ i386_set_ldt(p, args, retval) bzero((caddr_t)new_ldt + old_len, new_len - old_len); pmap->pm_ldt = new_ldt; - if (pmap->pm_flags & PCB_USER_LDT) + if (pmap->pm_flags & PMF_USER_LDT) ldt_free(pmap); else - pmap->pm_flags |= PCB_USER_LDT; + pmap->pm_flags |= PMF_USER_LDT; ldt_alloc(pmap, new_ldt, new_len); pcb->pcb_ldt_sel = pmap->pm_ldt_sel; if (pcb == curpcb) diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 373902d18ed..20d694e7e24 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.45 2003/01/16 04:16:00 art Exp $ */ +/* $OpenBSD: cpu.h,v 1.46 2003/03/28 00:49:13 miod Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -197,6 +197,7 @@ int math_emulate(struct trapframe *); #ifdef USER_LDT /* sys_machdep.h */ +extern int user_ldt_enable; void i386_user_cleanup(struct pcb *); int i386_get_ldt(struct proc *, void *, register_t *); int i386_set_ldt(struct proc *, void *, register_t *); @@ -238,7 +239,8 @@ void setconf(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_MAXID 12 /* number of valid machdep ids */ +#define CPU_USERLDT 12 +#define CPU_MAXID 13 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ @@ -253,6 +255,7 @@ void setconf(void); { "apmwarn", CTLTYPE_INT }, \ { "kbdreset", CTLTYPE_INT }, \ { "apmhalt", CTLTYPE_INT }, \ + { "userldt", CTLTYPE_INT }, \ } #endif /* !_I386_CPU_H_ */ |