summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/i386/sys/i386_get_ldt.23
-rw-r--r--sys/i386/i386/sys_machdep.c8
-rw-r--r--sys/i386/include/sysarch.h1
3 files changed, 7 insertions, 5 deletions
diff --git a/lib/libc/i386/sys/i386_get_ldt.2 b/lib/libc/i386/sys/i386_get_ldt.2
index bc6357883fa6..61448b91dc9e 100644
--- a/lib/libc/i386/sys/i386_get_ldt.2
+++ b/lib/libc/i386/sys/i386_get_ldt.2
@@ -76,7 +76,8 @@ as disjoint bit-fields, so care must be taken in constructing them.
.Pp
If
.Fa start_sel
-is 0,
+is
+.Em LDT_AUTO_ALLOC ,
.Fa num_sels
is 1 and the descriptor pointed to by
.Fa descs
diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c
index a3330cfb4828..f595b5e1a739 100644
--- a/sys/i386/i386/sys_machdep.c
+++ b/sys/i386/i386/sys_machdep.c
@@ -464,7 +464,7 @@ i386_set_ldt(td, args)
return (0);
}
- if (!(uap->start == 0 && uap->num == 1)) {
+ if (!(uap->start == LDT_AUTO_ALLOC && uap->num == 1)) {
#ifdef DEBUG
/* complain a for a while if using old methods */
if (ldt_warnings++ < NUM_LDT_WARNINGS) {
@@ -475,7 +475,7 @@ i386_set_ldt(td, args)
#endif
/* verify range of descriptors to modify */
largest_ld = uap->start + uap->num;
- if (uap->start <= LUDATA_SEL || uap->start >= MAX_LD ||
+ if (uap->start >= MAX_LD ||
uap->num < 0 || largest_ld > MAX_LD) {
return (EINVAL);
}
@@ -560,7 +560,7 @@ i386_set_ldt(td, args)
}
}
- if (uap->start == 0 && uap->num == 1) {
+ if (uap->start == LDT_AUTO_ALLOC && uap->num == 1) {
/* Allocate a free slot */
pldt = mdp->md_ldt;
if (pldt == NULL) {
@@ -574,11 +574,11 @@ i386_set_ldt(td, args)
}
again:
mtx_lock_spin(&sched_lock);
- dp = &((union descriptor *)(pldt->ldt_base))[NLDT];
/*
* start scanning a bit up to leave room for NVidia and
* Wine, which still user the "Blat" method of allocation.
*/
+ dp = &((union descriptor *)(pldt->ldt_base))[NLDT];
for (i = NLDT; i < pldt->ldt_len; ++i) {
if (dp->sd.sd_type == SDT_SYSNULL)
break;
diff --git a/sys/i386/include/sysarch.h b/sys/i386/include/sysarch.h
index c5574ff8157a..6b237c00243c 100644
--- a/sys/i386/include/sysarch.h
+++ b/sys/i386/include/sysarch.h
@@ -41,6 +41,7 @@
#define I386_GET_LDT 0
#define I386_SET_LDT 1
+#define LDT_AUTO_ALLOC 0xffffffff
/* I386_IOPL */
#define I386_GET_IOPERM 3
#define I386_SET_IOPERM 4