i386 Ldt cleanups 1
PATCH 17/21 i386 Ldt cleanups 1
Big cleanup of LDT code. This code has very little type checking and is not frequently used, so I audited the code, added type checking and size optimizations to generate smaller assembly code.
First, just introduce some small definitions that will be used later.
Signed-off-by Zachary Amsden <[email protected]>
arch/i386/kernel/entry.S +2 -2
@@ -250,8 +250,8 @@ restore_all: # See comments in process.c:copy_thread() for details. movb OLDSS(%esp), %ah movb CS(%esp), %al - andl $(VM_MASK | (4 << 8) | 3), %eax - cmpl $((4 << 8) | 3), %eax + andl $(VM_MASK | (LDT_SEGMENT << 8) | 3), %eax + cmpl $((LDT_SEGMENT << 8) | 3), %eax je ldt_ss # returning to user-space with LDT SS restore_nocheck: RESTORE_REGS
arch/i386/kernel/ptrace.c +0 -2
@@ -146,8 +146,6 @@ static unsigned long getreg(struct task_return retval; } -#define LDT_SEGMENT 4 -static unsigned long convert_eip_to_linear (struct task_struct *child,struct pt_regs *regs) {unsigned long addr, seg;
include/asm-i386/segment.h +5 -0
@@ -121,4 +121,9 @@*/ #define IDT_ENTRIES 256 +/* +* This bit is set to indicate segment selectors are in the LDT +*/ +#define LDT_SEGMENT 4 +#endif
include/asm-i386/ldt.h +2 -0
@@ -10,6 +10,8 @@#define LDT_ENTRIES 8192/* The size of each LDT entry. */ #define LDT_ENTRY_SIZE 8 +/* The number of LDT entries per page */ +#define LDT_ENTRIES_PER_PAGE (PAGE_SIZE / LDT_ENTRY_SIZE)#ifndef __ASSEMBLY__ struct user_desc {