From: Arjan van de Ven <arjanv@redhat.com>

some more hardcoded THREAD_SIZE cleanups.


---

 arch/i386/kernel/entry.S       |    2 +-
 include/asm-i386/processor.h   |   20 ++++++++++++++++++--
 include/asm-i386/thread_info.h |    4 ++++
 3 files changed, 23 insertions(+), 3 deletions(-)

diff -puN arch/i386/kernel/entry.S~remove-x86-THREAD_SIZE-assumptions arch/i386/kernel/entry.S
--- 25/arch/i386/kernel/entry.S~remove-x86-THREAD_SIZE-assumptions	2004-02-21 02:22:37.000000000 -0800
+++ 25-akpm/arch/i386/kernel/entry.S	2004-02-21 02:22:37.000000000 -0800
@@ -175,7 +175,7 @@ do_lcall:
 	movl %eax,EFLAGS(%ebp)	#
 	movl %edx,EIP(%ebp)	# Now we move them to their "normal" places
 	movl %ecx,CS(%ebp)	#
-	andl $-8192, %ebp	# GET_THREAD_INFO
+	GET_THREAD_INFO_WITH_ESP(%ebp)	# GET_THREAD_INFO
 	movl TI_EXEC_DOMAIN(%ebp), %edx	# Get the execution domain
 	call *4(%edx)		# Call the lcall7 handler for the domain
 	addl $4, %esp
diff -puN include/asm-i386/processor.h~remove-x86-THREAD_SIZE-assumptions include/asm-i386/processor.h
--- 25/include/asm-i386/processor.h~remove-x86-THREAD_SIZE-assumptions	2004-02-21 02:22:37.000000000 -0800
+++ 25-akpm/include/asm-i386/processor.h	2004-02-21 02:22:37.000000000 -0800
@@ -489,8 +489,24 @@ extern unsigned long thread_saved_pc(str
 void show_trace(struct task_struct *task, unsigned long *stack);
 
 unsigned long get_wchan(struct task_struct *p);
-#define KSTK_EIP(tsk)	(((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1019])
-#define KSTK_ESP(tsk)	(((unsigned long *)(4096+(unsigned long)(tsk)->thread_info))[1022])
+
+#define THREAD_SIZE_LONGS      (THREAD_SIZE/sizeof(unsigned long))
+#define KSTK_TOP(info)                                                 \
+({                                                                     \
+       unsigned long *__ptr = (unsigned long *)(info);                 \
+       (unsigned long)(&__ptr[THREAD_SIZE_LONGS]);                     \
+})
+
+#define task_pt_regs(task)                                             \
+({                                                                     \
+       struct pt_regs *__regs__;                                       \
+       __regs__ = (struct pt_regs *)KSTK_TOP((task)->thread_info);     \
+       __regs__ - 1;                                                   \
+})
+
+#define KSTK_EIP(task) (task_pt_regs(task)->eip)
+#define KSTK_ESP(task) (task_pt_regs(task)->esp)
+
 
 struct microcode_header {
 	unsigned int hdrver;
diff -puN include/asm-i386/thread_info.h~remove-x86-THREAD_SIZE-assumptions include/asm-i386/thread_info.h
--- 25/include/asm-i386/thread_info.h~remove-x86-THREAD_SIZE-assumptions	2004-02-21 02:22:37.000000000 -0800
+++ 25-akpm/include/asm-i386/thread_info.h	2004-02-21 02:22:37.000000000 -0800
@@ -115,6 +115,10 @@ static inline struct thread_info *curren
 	movl $-THREAD_SIZE, reg; \
 	andl %esp, reg
 
+/* use this one if reg already contains %esp */
+#define GET_THREAD_INFO_WITH_ESP(reg) \
+	andl $-THREAD_SIZE, reg
+
 #endif
 
 /*

_