Skip to contentSkip to conversation

i386 Ldt cleanups 1

PATCH In review Zachary Amsden 1 participant 1 message Nov 8, 2005 ptrace support

lore
Share & tools
lore
#0 lore raw

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.

arch/i386/kernel/entry.S +2 -2
Index: linux-2.6.14-zach-work/arch/i386/kernel/entry.S
===================================================================
@@ -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
Index: linux-2.6.14-zach-work/arch/i386/kernel/ptrace.c
===================================================================
@@ -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
Index: linux-2.6.14-zach-work/include/asm-i386/segment.h
===================================================================
@@ -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
Index: linux-2.6.14-zach-work/include/asm-i386/ldt.h
===================================================================
@@ -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 {