minor patch for arch/i386/kernel/ldt.c

Bill Hawes (whawes@transmeta.com)
Mon, 10 Aug 1998 10:30:08 -0700


This is a multi-part message in MIME format.
--------------1B7A4F0BA593B9ADA39E3371
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The attached patch fixes a bug in the ldt.c code when the allocated ldt
is freed, as the ldt pointer wasn't being updated. It's simpler to just
use mm->segments for all references.

The patch also simplifies the code a bit, now that we don't need to
validate the entries.

Regards,
Bill

--------------1B7A4F0BA593B9ADA39E3371
Content-Type: text/plain; charset=us-ascii; name="i386_ldt115-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="i386_ldt115-patch"

--- linux-2.1.115/arch/i386/kernel/ldt.c.old Tue Jul 7 12:35:14 1998
+++ linux-2.1.115/arch/i386/kernel/ldt.c Sat Aug 8 10:27:17 1998
@@ -36,9 +36,7 @@
static int write_ldt(void * ptr, unsigned long bytecount, int oldmode)
{
struct mm_struct * mm = current->mm;
- void * ldt;
__u32 entry_1, entry_2, *lp;
- __u16 selector, reg_fs, reg_gs;
int error;
struct modify_ldt_ldt_s ldt_info;

@@ -70,8 +68,8 @@
* For no good reason except historical, the GDT index of the LDT
* is chosen to follow the index number in the task[] array.
*/
- ldt = mm->segments;
- if (!ldt) {
+ if (!mm->segments) {
+ void * ldt;
error = -ENOMEM;
ldt = vmalloc(LDT_ENTRIES*LDT_ENTRY_SIZE);
if (!ldt)
@@ -93,19 +91,7 @@
}
}

- /*
- * Check whether the entry to be changed is currently in use.
- * If it is, we may need extra validation checks in case the
- * kernel is forced to save and restore the selector.
- *
- * Note: we check the fs and gs values as well, as these are
- * loaded by the signal code and during a task switch.
- */
- selector = (ldt_info.entry_number << 3) | 4;
- __asm__("movw %%fs,%0" : "=r"(reg_fs));
- __asm__("movw %%gs,%0" : "=r"(reg_gs));
-
- lp = (__u32 *) ((selector & ~7) + (char *) ldt);
+ lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->segments);

/* Allow LDTs to be cleared by the user. */
if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
@@ -118,7 +104,7 @@
ldt_info.useable == 0 )) {
entry_1 = 0;
entry_2 = 0;
- goto out_check;
+ goto install;
}
}

@@ -136,8 +122,8 @@
if (!oldmode)
entry_2 |= (ldt_info.useable << 20);

-out_check:
- /* OK to change the entry ... */
+ /* Install the new entry ... */
+install:
*lp = entry_1;
*(lp+1) = entry_2;
error = 0;

--------------1B7A4F0BA593B9ADA39E3371--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html