Activate USER_LDT by default. The new thread libraries are going to

depend on this.  The linux ABI emulator tries to use it for some linux
binaries too.  VM86 had a bigger cost than this and it was made default
a while ago.

Reviewed by:	jhb, imp
This commit is contained in:
Peter Wemm 2001-02-23 01:25:02 +00:00
parent 7aea583ef1
commit f1532aadee
34 changed files with 20 additions and 143 deletions

View File

@ -37,7 +37,6 @@
*/
#include "opt_npx.h"
#include "opt_user_ldt.h"
#include <machine/asmacros.h>
#include <machine/ipl.h>
@ -241,7 +240,6 @@ sw1b:
/* XXX FIXME: we should be restoring the local APIC TPR */
#endif /* SMP */
#ifdef USER_LDT
cmpl $0, PCB_USERLDT(%edx)
jnz 1f
movl __default_ldt,%eax
@ -254,7 +252,6 @@ sw1b:
call _set_user_ldt
popl %edx
2:
#endif
/* This must be done after loading the user LDT. */
.globl cpu_switch_load_gs

View File

@ -37,8 +37,6 @@
* $FreeBSD$
*/
#include "opt_user_ldt.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/assym.h>
@ -115,10 +113,7 @@ ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx));
ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip));
ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0));
#ifdef USER_LDT
ASSYM(PCB_USERLDT, offsetof(struct pcb, pcb_ldt));
#endif
ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
@ -177,10 +172,7 @@ ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
ASSYM(GD_SWITCHTICKS, offsetof(struct globaldata, gd_switchticks));
ASSYM(GD_COMMON_TSSD, offsetof(struct globaldata, gd_common_tssd));
ASSYM(GD_TSS_GDT, offsetof(struct globaldata, gd_tss_gdt));
#ifdef USER_LDT
ASSYM(GD_CURRENTLDT, offsetof(struct globaldata, gd_currentldt));
#endif
ASSYM(GD_WITNESS_SPIN_CHECK, offsetof(struct globaldata, gd_witness_spin_check));

View File

@ -49,7 +49,6 @@
#include "opt_msgbuf.h"
#include "opt_npx.h"
#include "opt_perfmon.h"
#include "opt_user_ldt.h"
#include "opt_userconfig.h"
#include <sys/param.h>
@ -1048,10 +1047,8 @@ setregs(p, entry, stack, ps_strings)
struct trapframe *regs = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
#ifdef USER_LDT
/* was i386_user_cleanup() in NetBSD */
user_ldt_free(pcb);
#endif
if (pcb->pcb_ldt)
user_ldt_free(pcb);
bzero((char *)regs, sizeof(struct trapframe));
regs->tf_eip = entry;
@ -1939,9 +1936,7 @@ init386(first)
_default_ldt = GSEL(GLDT_SEL, SEL_KPL);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
/* exceptions */
for (x = 0; x < NIDT; x++)

View File

@ -26,7 +26,6 @@
*/
#include "opt_cpu.h"
#include "opt_user_ldt.h"
#ifdef SMP
#include <machine/smptests.h>
@ -521,9 +520,7 @@ init_secondary(void)
lidt(&r_idt);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;

View File

@ -26,7 +26,6 @@
*/
#include "opt_cpu.h"
#include "opt_user_ldt.h"
#ifdef SMP
#include <machine/smptests.h>
@ -521,9 +520,7 @@ init_secondary(void)
lidt(&r_idt);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;

View File

@ -71,7 +71,6 @@
#include "opt_disable_pse.h"
#include "opt_pmap.h"
#include "opt_msgbuf.h"
#include "opt_user_ldt.h"
#include <sys/param.h>
#include <sys/systm.h>

View File

@ -37,7 +37,6 @@
*/
#include "opt_npx.h"
#include "opt_user_ldt.h"
#include <machine/asmacros.h>
#include <machine/ipl.h>
@ -241,7 +240,6 @@ sw1b:
/* XXX FIXME: we should be restoring the local APIC TPR */
#endif /* SMP */
#ifdef USER_LDT
cmpl $0, PCB_USERLDT(%edx)
jnz 1f
movl __default_ldt,%eax
@ -254,7 +252,6 @@ sw1b:
call _set_user_ldt
popl %edx
2:
#endif
/* This must be done after loading the user LDT. */
.globl cpu_switch_load_gs

View File

@ -35,8 +35,6 @@
*
*/
#include "opt_user_ldt.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
@ -68,10 +66,8 @@
#ifdef USER_LDT
static int i386_get_ldt __P((struct proc *, char *));
static int i386_set_ldt __P((struct proc *, char *));
#endif
static int i386_get_ioperm __P((struct proc *, char *));
static int i386_set_ioperm __P((struct proc *, char *));
int i386_extend_pcb __P((struct proc *));
@ -91,7 +87,6 @@ sysarch(p, uap)
int error = 0;
switch(uap->op) {
#ifdef USER_LDT
case I386_GET_LDT:
error = i386_get_ldt(p, uap->parms);
break;
@ -99,7 +94,6 @@ sysarch(p, uap)
case I386_SET_LDT:
error = i386_set_ldt(p, uap->parms);
break;
#endif
case I386_GET_IOPERM:
error = i386_get_ioperm(p, uap->parms);
break;
@ -242,10 +236,9 @@ done:
return (error);
}
#ifdef USER_LDT
/*
* Update the GDT entry pointing to the LDT to point to the LDT of the
* current process. Do not staticize.
* current process.
*/
void
set_user_ldt(struct pcb *pcb)
@ -499,4 +492,3 @@ i386_set_ldt(p, args)
splx(s);
return(error);
}
#endif /* USER_LDT */

View File

@ -42,7 +42,6 @@
*/
#include "opt_npx.h"
#include "opt_user_ldt.h"
#ifdef PC98
#include "opt_pc98.h"
#endif
@ -126,7 +125,6 @@ cpu_fork(p1, p2, flags)
struct pcb *pcb2;
if ((flags & RFPROC) == 0) {
#ifdef USER_LDT
if ((flags & RFMEM) == 0) {
/* unshare user LDT */
struct pcb *pcb1 = &p1->p_addr->u_pcb;
@ -138,7 +136,6 @@ cpu_fork(p1, p2, flags)
set_user_ldt(pcb1);
}
}
#endif
return;
}
@ -188,7 +185,6 @@ cpu_fork(p1, p2, flags)
*/
pcb2->pcb_ext = 0;
#ifdef USER_LDT
/* Copy the LDT, if necessary. */
if (pcb2->pcb_ldt != 0) {
if (flags & RFMEM) {
@ -198,7 +194,6 @@ cpu_fork(p1, p2, flags)
pcb2->pcb_ldt->ldt_len);
}
}
#endif
/*
* Now, cpu_switch() can schedule the new process.
@ -249,9 +244,8 @@ cpu_exit(p)
ctob(IOPAGES + 1));
pcb->pcb_ext = 0;
}
#ifdef USER_LDT
user_ldt_free(pcb);
#endif
if (pcb->pcb_ldt)
user_ldt_free(pcb);
if (pcb->pcb_flags & PCB_DBREGS) {
/*
* disable all hardware breakpoints

View File

@ -26,7 +26,6 @@
*/
#include "opt_cpu.h"
#include "opt_user_ldt.h"
#ifdef SMP
#include <machine/smptests.h>
@ -521,9 +520,7 @@ init_secondary(void)
lidt(&r_idt);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;

View File

@ -61,11 +61,7 @@ struct pcb {
int pcb_dr6;
int pcb_dr7;
#ifdef USER_LDT
struct pcb_ldt *pcb_ldt; /* per process (user) LDT */
#else
struct pcb_ldt *pcb_ldt_dontuse;
#endif
struct save87 pcb_savefpu; /* floating point state for 287/387 */
u_char pcb_flags;
#define FP_SOFTFP 0x01 /* process using software fltng pnt emulator */

View File

@ -53,11 +53,9 @@ struct pcb_ldt {
#ifdef _KERNEL
#ifdef USER_LDT
void set_user_ldt __P((struct pcb *));
struct pcb_ldt *user_ldt_alloc __P((struct pcb *, int));
void user_ldt_free __P((struct pcb *));
#endif
#endif

View File

@ -60,7 +60,7 @@ struct globaldata {
int gd_switchticks;
struct segment_descriptor gd_common_tssd;
struct segment_descriptor *gd_tss_gdt;
int gd_currentldt; /* only used for USER_LDT */
int gd_currentldt;
u_int gd_cpuid;
u_int gd_other_cpus;
SLIST_ENTRY(globaldata) gd_allcpu;

View File

@ -283,13 +283,6 @@ options GPL_MATH_EMULATE #Support for x87 emulation via
#
options COMPAT_43
#
# Allow user-mode programs to manipulate their local descriptor tables.
# This option is required for the WINE Windows(tm) emulator, and is
# not used by anything else (that we know of).
#
options USER_LDT #allow user-level control of i386 ldt
#
# These three options provide support for System V Interface
# Definition-style interprocess communication, in the form of shared

View File

@ -2,7 +2,6 @@
DISABLE_PSE
IDE_DELAY
USER_LDT
MATH_EMULATE opt_math_emulate.h
GPL_MATH_EMULATE opt_math_emulate.h
PMAP_SHPGPERPROC opt_pmap.h

View File

@ -2,7 +2,6 @@
DISABLE_PSE
IDE_DELAY
USER_LDT
MATH_EMULATE opt_math_emulate.h
GPL_MATH_EMULATE opt_math_emulate.h
PMAP_SHPGPERPROC opt_pmap.h

View File

@ -283,13 +283,6 @@ options GPL_MATH_EMULATE #Support for x87 emulation via
#
options COMPAT_43
#
# Allow user-mode programs to manipulate their local descriptor tables.
# This option is required for the WINE Windows(tm) emulator, and is
# not used by anything else (that we know of).
#
options USER_LDT #allow user-level control of i386 ldt
#
# These three options provide support for System V Interface
# Definition-style interprocess communication, in the form of shared

View File

@ -37,8 +37,6 @@
* $FreeBSD$
*/
#include "opt_user_ldt.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/assym.h>
@ -115,10 +113,7 @@ ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx));
ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip));
ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0));
#ifdef USER_LDT
ASSYM(PCB_USERLDT, offsetof(struct pcb, pcb_ldt));
#endif
ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
@ -177,10 +172,7 @@ ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
ASSYM(GD_SWITCHTICKS, offsetof(struct globaldata, gd_switchticks));
ASSYM(GD_COMMON_TSSD, offsetof(struct globaldata, gd_common_tssd));
ASSYM(GD_TSS_GDT, offsetof(struct globaldata, gd_tss_gdt));
#ifdef USER_LDT
ASSYM(GD_CURRENTLDT, offsetof(struct globaldata, gd_currentldt));
#endif
ASSYM(GD_WITNESS_SPIN_CHECK, offsetof(struct globaldata, gd_witness_spin_check));

View File

@ -49,7 +49,6 @@
#include "opt_msgbuf.h"
#include "opt_npx.h"
#include "opt_perfmon.h"
#include "opt_user_ldt.h"
#include "opt_userconfig.h"
#include <sys/param.h>
@ -1048,10 +1047,8 @@ setregs(p, entry, stack, ps_strings)
struct trapframe *regs = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
#ifdef USER_LDT
/* was i386_user_cleanup() in NetBSD */
user_ldt_free(pcb);
#endif
if (pcb->pcb_ldt)
user_ldt_free(pcb);
bzero((char *)regs, sizeof(struct trapframe));
regs->tf_eip = entry;
@ -1939,9 +1936,7 @@ init386(first)
_default_ldt = GSEL(GLDT_SEL, SEL_KPL);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
/* exceptions */
for (x = 0; x < NIDT; x++)

View File

@ -26,7 +26,6 @@
*/
#include "opt_cpu.h"
#include "opt_user_ldt.h"
#ifdef SMP
#include <machine/smptests.h>
@ -521,9 +520,7 @@ init_secondary(void)
lidt(&r_idt);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;

View File

@ -26,7 +26,6 @@
*/
#include "opt_cpu.h"
#include "opt_user_ldt.h"
#ifdef SMP
#include <machine/smptests.h>
@ -521,9 +520,7 @@ init_secondary(void)
lidt(&r_idt);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;

View File

@ -71,7 +71,6 @@
#include "opt_disable_pse.h"
#include "opt_pmap.h"
#include "opt_msgbuf.h"
#include "opt_user_ldt.h"
#include <sys/param.h>
#include <sys/systm.h>

View File

@ -37,7 +37,6 @@
*/
#include "opt_npx.h"
#include "opt_user_ldt.h"
#include <machine/asmacros.h>
#include <machine/ipl.h>
@ -241,7 +240,6 @@ sw1b:
/* XXX FIXME: we should be restoring the local APIC TPR */
#endif /* SMP */
#ifdef USER_LDT
cmpl $0, PCB_USERLDT(%edx)
jnz 1f
movl __default_ldt,%eax
@ -254,7 +252,6 @@ sw1b:
call _set_user_ldt
popl %edx
2:
#endif
/* This must be done after loading the user LDT. */
.globl cpu_switch_load_gs

View File

@ -35,8 +35,6 @@
*
*/
#include "opt_user_ldt.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
@ -68,10 +66,8 @@
#ifdef USER_LDT
static int i386_get_ldt __P((struct proc *, char *));
static int i386_set_ldt __P((struct proc *, char *));
#endif
static int i386_get_ioperm __P((struct proc *, char *));
static int i386_set_ioperm __P((struct proc *, char *));
int i386_extend_pcb __P((struct proc *));
@ -91,7 +87,6 @@ sysarch(p, uap)
int error = 0;
switch(uap->op) {
#ifdef USER_LDT
case I386_GET_LDT:
error = i386_get_ldt(p, uap->parms);
break;
@ -99,7 +94,6 @@ sysarch(p, uap)
case I386_SET_LDT:
error = i386_set_ldt(p, uap->parms);
break;
#endif
case I386_GET_IOPERM:
error = i386_get_ioperm(p, uap->parms);
break;
@ -242,10 +236,9 @@ done:
return (error);
}
#ifdef USER_LDT
/*
* Update the GDT entry pointing to the LDT to point to the LDT of the
* current process. Do not staticize.
* current process.
*/
void
set_user_ldt(struct pcb *pcb)
@ -499,4 +492,3 @@ i386_set_ldt(p, args)
splx(s);
return(error);
}
#endif /* USER_LDT */

View File

@ -42,7 +42,6 @@
*/
#include "opt_npx.h"
#include "opt_user_ldt.h"
#ifdef PC98
#include "opt_pc98.h"
#endif
@ -126,7 +125,6 @@ cpu_fork(p1, p2, flags)
struct pcb *pcb2;
if ((flags & RFPROC) == 0) {
#ifdef USER_LDT
if ((flags & RFMEM) == 0) {
/* unshare user LDT */
struct pcb *pcb1 = &p1->p_addr->u_pcb;
@ -138,7 +136,6 @@ cpu_fork(p1, p2, flags)
set_user_ldt(pcb1);
}
}
#endif
return;
}
@ -188,7 +185,6 @@ cpu_fork(p1, p2, flags)
*/
pcb2->pcb_ext = 0;
#ifdef USER_LDT
/* Copy the LDT, if necessary. */
if (pcb2->pcb_ldt != 0) {
if (flags & RFMEM) {
@ -198,7 +194,6 @@ cpu_fork(p1, p2, flags)
pcb2->pcb_ldt->ldt_len);
}
}
#endif
/*
* Now, cpu_switch() can schedule the new process.
@ -249,9 +244,8 @@ cpu_exit(p)
ctob(IOPAGES + 1));
pcb->pcb_ext = 0;
}
#ifdef USER_LDT
user_ldt_free(pcb);
#endif
if (pcb->pcb_ldt)
user_ldt_free(pcb);
if (pcb->pcb_flags & PCB_DBREGS) {
/*
* disable all hardware breakpoints

View File

@ -60,7 +60,7 @@ struct globaldata {
int gd_switchticks;
struct segment_descriptor gd_common_tssd;
struct segment_descriptor *gd_tss_gdt;
int gd_currentldt; /* only used for USER_LDT */
int gd_currentldt;
u_int gd_cpuid;
u_int gd_other_cpus;
SLIST_ENTRY(globaldata) gd_allcpu;

View File

@ -26,7 +26,6 @@
*/
#include "opt_cpu.h"
#include "opt_user_ldt.h"
#ifdef SMP
#include <machine/smptests.h>
@ -521,9 +520,7 @@ init_secondary(void)
lidt(&r_idt);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;

View File

@ -61,11 +61,7 @@ struct pcb {
int pcb_dr6;
int pcb_dr7;
#ifdef USER_LDT
struct pcb_ldt *pcb_ldt; /* per process (user) LDT */
#else
struct pcb_ldt *pcb_ldt_dontuse;
#endif
struct save87 pcb_savefpu; /* floating point state for 287/387 */
u_char pcb_flags;
#define FP_SOFTFP 0x01 /* process using software fltng pnt emulator */

View File

@ -53,11 +53,9 @@ struct pcb_ldt {
#ifdef _KERNEL
#ifdef USER_LDT
void set_user_ldt __P((struct pcb *));
struct pcb_ldt *user_ldt_alloc __P((struct pcb *, int));
void user_ldt_free __P((struct pcb *));
#endif
#endif

View File

@ -60,7 +60,7 @@ struct globaldata {
int gd_switchticks;
struct segment_descriptor gd_common_tssd;
struct segment_descriptor *gd_tss_gdt;
int gd_currentldt; /* only used for USER_LDT */
int gd_currentldt;
u_int gd_cpuid;
u_int gd_other_cpus;
SLIST_ENTRY(globaldata) gd_allcpu;

View File

@ -503,7 +503,7 @@ svr4_sys_sysarch(p, v)
struct svr4_sys_sysarch_args *v;
{
struct svr4_sys_sysarch_args *uap = v;
#ifdef USER_LDT
#if 0 /* USER_LDT */
#if defined(__NetBSD__)
caddr_t sg = stackgap_init(p->p_emul);
#else
@ -511,12 +511,13 @@ svr4_sys_sysarch(p, v)
#endif
int error;
#endif
switch (uap->op) {
case SVR4_SYSARCH_FPHW:
return 0;
case SVR4_SYSARCH_DSCR:
#ifdef USER_LDT
#if 0 /* USER_LDT */
#warning "USER_LDT doesn't work - are you sure you want this?"
{
struct i386_set_ldt_args sa, *sap;

View File

@ -26,7 +26,6 @@
*/
#include "opt_cpu.h"
#include "opt_user_ldt.h"
#ifdef SMP
#include <machine/smptests.h>
@ -521,9 +520,7 @@ init_secondary(void)
lidt(&r_idt);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;

View File

@ -49,7 +49,6 @@
#include "opt_msgbuf.h"
#include "opt_npx.h"
#include "opt_perfmon.h"
#include "opt_user_ldt.h"
#include "opt_userconfig.h"
#include <sys/param.h>
@ -1061,10 +1060,8 @@ setregs(p, entry, stack, ps_strings)
struct trapframe *regs = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
#ifdef USER_LDT
/* was i386_user_cleanup() in NetBSD */
user_ldt_free(pcb);
#endif
if (pcb->pcb_ldt)
user_ldt_free(pcb);
bzero((char *)regs, sizeof(struct trapframe));
regs->tf_eip = entry;
@ -2248,9 +2245,7 @@ init386(first)
_default_ldt = GSEL(GLDT_SEL, SEL_KPL);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
/* exceptions */
for (x = 0; x < NIDT; x++)

View File

@ -49,7 +49,6 @@
#include "opt_msgbuf.h"
#include "opt_npx.h"
#include "opt_perfmon.h"
#include "opt_user_ldt.h"
#include "opt_userconfig.h"
#include <sys/param.h>
@ -1061,10 +1060,8 @@ setregs(p, entry, stack, ps_strings)
struct trapframe *regs = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
#ifdef USER_LDT
/* was i386_user_cleanup() in NetBSD */
user_ldt_free(pcb);
#endif
if (pcb->pcb_ldt)
user_ldt_free(pcb);
bzero((char *)regs, sizeof(struct trapframe));
regs->tf_eip = entry;
@ -2248,9 +2245,7 @@ init386(first)
_default_ldt = GSEL(GLDT_SEL, SEL_KPL);
lldt(_default_ldt);
#ifdef USER_LDT
PCPU_SET(currentldt, _default_ldt);
#endif
/* exceptions */
for (x = 0; x < NIDT; x++)