]> git.hungrycats.org Git - linux/commitdiff
[PATCH] cleanup patch that prepares for 4Kb stacks
authorAndrew Morton <akpm@osdl.org>
Wed, 18 Feb 2004 12:55:53 +0000 (04:55 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 18 Feb 2004 12:55:53 +0000 (04:55 -0800)
From: Arjan van de Ven <arjanv@redhat.com>

I have 4Kb stacks + IRQ stacks working in my tree.  The biggest part of the
4K-stacks work is changing hardcoded 8Kb assumptions to the proper,
pre-existing define for this.  That part of the patch is appropriate in
general, even when 4Kb stacks might not be.

arch/i386/kernel/entry.S
arch/i386/kernel/head.S
arch/i386/kernel/irq.c
arch/i386/kernel/process.c
arch/i386/kernel/traps.c
include/asm-i386/thread_info.h

index a8ec801f5423e99d996ddd67a6211e8b4e2421ff..628c08497e76abe5a46eee28fdc419f046d7dd08 100644 (file)
@@ -515,8 +515,8 @@ ENTRY(nmi)
        /* Do not access memory above the end of our stack page,
         * it might not exist.
         */
-       andl $0x1fff,%eax
-       cmpl $0x1fec,%eax
+       andl $(THREAD_SIZE-1),%eax
+       cmpl $(THREAD_SIZE-20),%eax
        popl %eax
        jae nmi_stack_correct
        cmpl $sysenter_entry,12(%esp)
index ddac80a424d786ee018345283710363ea07b1213..8633eb01e4fcbee2955bab322e6bb36b071d2b0c 100644 (file)
@@ -16,6 +16,8 @@
 #include <asm/pgtable.h>
 #include <asm/desc.h>
 #include <asm/cache.h>
+#include <asm/thread_info.h>
+
 
 #define OLD_CL_MAGIC_ADDR      0x90020
 #define OLD_CL_MAGIC           0xA33F
@@ -325,7 +327,7 @@ rp_sidt:
        ret
 
 ENTRY(stack_start)
-       .long init_thread_union+8192
+       .long init_thread_union+THREAD_SIZE
        .long __BOOT_DS
 
 /* This is the default interrupt "handler" :-) */
index d2f3bf0fdd5d7e813a55ab4b7a2851f8054e93da..9930e2ec0b856f0493cf5ca092375005dd9174cc 100644 (file)
@@ -435,7 +435,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs)
                long esp;
 
                __asm__ __volatile__("andl %%esp,%0" :
-                                       "=r" (esp) : "0" (8191));
+                                       "=r" (esp) : "0" (THREAD_SIZE - 1));
                if (unlikely(esp < (sizeof(struct thread_info) + 1024))) {
                        printk("do_IRQ: stack overflow: %ld\n",
                                esp - sizeof(struct thread_info));
index 4032331a954fa24708ae650ba5c35177772453a9..20dd1731eee0573979babb7f692ade2f2b71155c 100644 (file)
@@ -637,6 +637,8 @@ extern void scheduling_functions_start_here(void);
 extern void scheduling_functions_end_here(void);
 #define first_sched    ((unsigned long) scheduling_functions_start_here)
 #define last_sched     ((unsigned long) scheduling_functions_end_here)
+#define top_esp                (THREAD_SIZE - sizeof(unsigned long))
+#define top_ebp                (THREAD_SIZE - 2*sizeof(unsigned long))
 
 unsigned long get_wchan(struct task_struct *p)
 {
@@ -647,12 +649,12 @@ unsigned long get_wchan(struct task_struct *p)
                return 0;
        stack_page = (unsigned long)p->thread_info;
        esp = p->thread.esp;
-       if (!stack_page || esp < stack_page || esp > 8188+stack_page)
+       if (!stack_page || esp < stack_page || esp > top_esp+stack_page)
                return 0;
        /* include/asm-i386/system.h:switch_to() pushes ebp last. */
        ebp = *(unsigned long *) esp;
        do {
-               if (ebp < stack_page || ebp > 8184+stack_page)
+               if (ebp < stack_page || ebp > top_ebp+stack_page)
                        return 0;
                eip = *(unsigned long *) (ebp+4);
                if (eip < first_sched || eip >= last_sched)
index f86037183b98436297d69e773ecdf50883f35ffc..8821e577c6f5d88b0c88f5ee437844f7a88db59c 100644 (file)
@@ -119,7 +119,7 @@ void show_trace_task(struct task_struct *tsk)
        unsigned long esp = tsk->thread.esp;
 
        /* User space on another CPU? */
-       if ((esp ^ (unsigned long)tsk->thread_info) & (PAGE_MASK<<1))
+       if ((esp ^ (unsigned long)tsk->thread_info) & ~(THREAD_SIZE - 1))
                return;
        show_trace(tsk, (unsigned long *)esp);
 }
index 1574d103074bb95b21acceb47197aad6acfd0250..b259831f44fa286577046d1906d40bb6237485d1 100644 (file)
@@ -77,16 +77,17 @@ struct thread_info {
 #define init_thread_info       (init_thread_union.thread_info)
 #define init_stack             (init_thread_union.stack)
 
+#define THREAD_SIZE (2*PAGE_SIZE)
+
 /* how to get the thread information struct from C */
 static inline struct thread_info *current_thread_info(void)
 {
        struct thread_info *ti;
-       __asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~8191UL));
+       __asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~(THREAD_SIZE - 1)));
        return ti;
 }
 
 /* thread information allocation */
-#define THREAD_SIZE (2*PAGE_SIZE)
 #define alloc_thread_info(task) ((struct thread_info *)kmalloc(THREAD_SIZE, GFP_KERNEL))
 #define free_thread_info(info) kfree(info)
 #define get_thread_info(ti) get_task_struct((ti)->task)
@@ -94,9 +95,11 @@ static inline struct thread_info *current_thread_info(void)
 
 #else /* !__ASSEMBLY__ */
 
+#define THREAD_SIZE    8192
+
 /* how to get the thread information struct from ASM */
 #define GET_THREAD_INFO(reg) \
-       movl $-8192, reg; \
+       movl $-THREAD_SIZE, reg; \
        andl %esp, reg
 
 #endif