Index: linux-2.4.21-27.EL/include/asm-i386/hw_irq.h =================================================================== --- linux-2.4.21-27.EL.orig/include/asm-i386/hw_irq.h 2004-12-21 13:51:09.000000000 -0500 +++ linux-2.4.21-27.EL/include/asm-i386/hw_irq.h 2005-01-07 10:55:45.367690072 -0500 @@ -135,21 +135,17 @@ " \ /* load the real stack - keep the offset */ \ \ - movl $-8192, %ebx; \ + movl $- " STR(THREAD_SIZE) ", %ebx; \ andl %esp, %ebx; \ movl 36(%ebx), %edx; \ movl %esp, %ebx; \ - andl $0x1fff, %ebx; \ + andl $( " STR(THREAD_SIZE) "-1), %ebx; \ orl %ebx, %edx; \ movl %edx, %esp;" #define IRQ_NAME2(nr) nr##_interrupt(void) #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr) -#define GET_CURRENT \ - "movl %esp, %ebx\n\t" \ - "andl $-8192, %ebx\n\t" - /* * SMP has a few special interrupts for IPI messages */ Index: linux-2.4.21-27.EL/include/asm-i386/processor.h =================================================================== --- linux-2.4.21-27.EL.orig/include/asm-i386/processor.h 2004-12-21 13:51:31.000000000 -0500 +++ linux-2.4.21-27.EL/include/asm-i386/processor.h 2005-01-07 10:55:45.376688704 -0500 @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -490,10 +491,6 @@ #define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1019]) #define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1022]) -#define THREAD_SIZE (2*PAGE_SIZE) -#define __alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1)) -#define __free_task_struct(p) do { BUG_ON((p)->state < TASK_ZOMBIE); free_pages((unsigned long) (p), 1); } while (0) - #define init_task (init_task_union.task) #define init_stack (init_task_union.stack) Index: linux-2.4.21-27.EL/include/asm-i386/current.h =================================================================== --- linux-2.4.21-27.EL.orig/include/asm-i386/current.h 1998-08-14 19:35:22.000000000 -0400 +++ linux-2.4.21-27.EL/include/asm-i386/current.h 2005-01-07 10:55:45.356691744 -0500 @@ -1,15 +1,64 @@ #ifndef _I386_CURRENT_H #define _I386_CURRENT_H +#include + +/* + * Configurable page sizes on i386, mainly for debugging purposes. + * (c) Balbir Singh + */ + +/* enumerate the values, include/asm-i386/hw_irq.h in particular needs this */ +#if (PAGE_SIZE != 4096) +#error PAGE_SIZE != 4096 unsupported +#endif + +#if (CONFIG_STACK_SIZE_SHIFT == 0) +#define THREAD_SIZE 4096 +#elif (CONFIG_STACK_SIZE_SHIFT == 1) +#define THREAD_SIZE 8192 +#elif (CONFIG_STACK_SIZE_SHIFT == 2) +#define THREAD_SIZE 16384 +#elif (CONFIG_STACK_SIZE_SHIFT == 3) +#define THREAD_SIZE 32768 +#elif (CONFIG_STACK_SIZE_SHIFT == 4) +#define THREAD_SIZE 65536 +#else +#error CONFIG_STACK_SIZE_SHIFT > 4 unsupported +#endif + +#if (CONFIG_STACK_SIZE_SHIFT != 1) && defined(CONFIG_X86_4G) +#error Large stacks with 4G/4G split unsupported +#endif + +#ifdef __ASSEMBLY__ + +#define GET_CURRENT(reg) \ + movl $-THREAD_SIZE, reg; \ + andl %esp, reg + +#else /* __ASSEMBLY__ */ + +#define __alloc_task_struct() \ + ((struct task_struct *) __get_free_pages(GFP_KERNEL, CONFIG_STACK_SIZE_SHIFT)) + +#define __free_task_struct(p) do { \ + BUG_ON((p)->state < TASK_ZOMBIE); \ + free_pages((unsigned long) (p), CONFIG_STACK_SIZE_SHIFT); \ +} while(0) + +#define INIT_TASK_SIZE THREAD_SIZE struct task_struct; static inline struct task_struct * get_current(void) { struct task_struct *current; - __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL)); + __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~(THREAD_SIZE - 1))); return current; } #define current get_current() +#endif /* __ASSEMBLY__ */ + #endif /* !(_I386_CURRENT_H) */ Index: linux-2.4.21-27.EL/include/asm-x86_64/processor.h =================================================================== --- linux-2.4.21-27.EL.orig/include/asm-x86_64/processor.h 2004-12-21 13:51:31.000000000 -0500 +++ linux-2.4.21-27.EL/include/asm-x86_64/processor.h 2005-01-07 10:58:24.167548824 -0500 @@ -407,8 +407,8 @@ /* Note: most of the infrastructure to separate stack and task_struct are already there. When you run out of stack try this first. */ -#define __alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1)) -#define __free_task_struct(p) free_pages((unsigned long) (p), 1) +#define __alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL, THREAD_ORDER)) +#define __free_task_struct(p) free_pages((unsigned long) (p), THREAD_ORDER) #define init_task (init_task_union.task) #define init_stack (init_task_union.stack) Index: linux-2.4.21-27.EL/include/asm-x86_64/page.h =================================================================== --- linux-2.4.21-27.EL.orig/include/asm-x86_64/page.h 2004-12-21 13:51:10.000000000 -0500 +++ linux-2.4.21-27.EL/include/asm-x86_64/page.h 2005-01-07 10:55:45.404684448 -0500 @@ -27,8 +27,8 @@ /* We still hope 8K is enough, but ... */ /* Currently it is actually ~6k. This would change when task_struct moves into an own slab. */ -#define THREAD_ORDER 1 -#define THREAD_SIZE (2*PAGE_SIZE) +#define THREAD_ORDER CONFIG_STACK_SIZE_SHIFT +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE) #define INIT_TASK_SIZE THREAD_SIZE #define CURRENT_MASK (~(THREAD_SIZE-1)) Index: linux-2.4.21-27.EL/include/asm-x86_64/current.h =================================================================== --- linux-2.4.21-27.EL.orig/include/asm-x86_64/current.h 2002-11-28 18:53:15.000000000 -0500 +++ linux-2.4.21-27.EL/include/asm-x86_64/current.h 2005-01-07 10:55:45.394685968 -0500 @@ -5,6 +5,7 @@ struct task_struct; #include +#include static inline struct task_struct *get_current(void) { Index: linux-2.4.21-27.EL/arch/x86_64/config.in =================================================================== --- linux-2.4.21-27.EL.orig/arch/x86_64/config.in 2004-12-21 13:51:30.000000000 -0500 +++ linux-2.4.21-27.EL/arch/x86_64/config.in 2005-01-07 10:55:45.324696608 -0500 @@ -90,6 +90,28 @@ define_bool CONFIG_NUMA y fi +choice 'Bigger Stack Size Support' \ + "off CONFIG_NOBIGSTACK \ + 16KB CONFIG_STACK_SIZE_16KB \ + 32KB CONFIG_STACK_SIZE_32KB \ + 64KB CONFIG_STACK_SIZE_64KB" off + +if [ "$CONFIG_NOBIGSTACK" = "y" ]; then + define_int CONFIG_STACK_SIZE_SHIFT 1 +else + if [ "$CONFIG_STACK_SIZE_16KB" = "y" ]; then + define_int CONFIG_STACK_SIZE_SHIFT 2 + else + if [ "$CONFIG_STACK_SIZE_32KB" = "y" ]; then + define_int CONFIG_STACK_SIZE_SHIFT 3 + else + if [ "$CONFIG_STACK_SIZE_64KB" = "y" ]; then + define_int CONFIG_STACK_SIZE_SHIFT 4 + fi + fi + fi +fi + endmenu mainmenu_option next_comment Index: linux-2.4.21-27.EL/arch/x86_64/kernel/smpboot.c =================================================================== --- linux-2.4.21-27.EL.orig/arch/x86_64/kernel/smpboot.c 2004-12-21 13:51:01.000000000 -0500 +++ linux-2.4.21-27.EL/arch/x86_64/kernel/smpboot.c 2005-01-07 10:55:45.325696456 -0500 @@ -753,7 +753,7 @@ Dprintk("CPU has booted.\n"); } else { boot_status = 1; - if (*((volatile unsigned char *)phys_to_virt(8192)) + if (*((volatile unsigned char *)phys_to_virt(THREAD_SIZE)) == 0xA5) /* trampoline started but...? */ printk("Stuck ??\n"); @@ -771,7 +771,7 @@ } /* mark "stuck" area as not stuck */ - *((volatile unsigned int *)phys_to_virt(8192)) = 0; + *((volatile unsigned int *)phys_to_virt(THREAD_SIZE)) = 0; return cpu; } Index: linux-2.4.21-27.EL/arch/x86_64/kernel/traps.c =================================================================== --- linux-2.4.21-27.EL.orig/arch/x86_64/kernel/traps.c 2004-12-21 13:51:15.000000000 -0500 +++ linux-2.4.21-27.EL/arch/x86_64/kernel/traps.c 2005-01-07 10:55:45.326696304 -0500 @@ -240,7 +240,7 @@ unsigned long rsp = tsk->thread.rsp; /* User space on another CPU? */ - if ((rsp ^ (unsigned long)tsk) & (PAGE_MASK<<1)) + if ((rsp ^ (unsigned long)tsk) & ~(THREAD_SIZE - 1)) return; show_trace((unsigned long *)rsp); } Index: linux-2.4.21-27.EL/arch/x86_64/vmlinux.lds =================================================================== --- linux-2.4.21-27.EL.orig/arch/x86_64/vmlinux.lds 2003-06-13 10:51:32.000000000 -0400 +++ linux-2.4.21-27.EL/arch/x86_64/vmlinux.lds 2005-01-07 10:55:45.327696152 -0500 @@ -72,7 +72,8 @@ .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT (LOADADDR(.vsyscall_0) + 1024) { *(.vsyscall_1) } . = LOADADDR(.vsyscall_0) + 4096; - . = ALIGN(8192); /* init_task */ +/* chose the biggest of the possible stack sizes here? */ + . = ALIGN(65536); /* init_task */ .data.init_task : { *(.data.init_task) } . = ALIGN(4096); Index: linux-2.4.21-27.EL/arch/i386/config.in =================================================================== --- linux-2.4.21-27.EL.orig/arch/i386/config.in 2004-12-21 13:51:31.000000000 -0500 +++ linux-2.4.21-27.EL/arch/i386/config.in 2005-01-07 10:55:45.324696608 -0500 @@ -306,6 +306,28 @@ fi fi +choice 'Bigger Stack Size Support' \ + "off CONFIG_NOBIGSTACK \ + 16KB CONFIG_STACK_SIZE_16KB \ + 32KB CONFIG_STACK_SIZE_32KB \ + 64KB CONFIG_STACK_SIZE_64KB" off + +if [ "$CONFIG_NOBIGSTACK" = "y" ]; then + define_int CONFIG_STACK_SIZE_SHIFT 1 +else + if [ "$CONFIG_STACK_SIZE_16KB" = "y" ]; then + define_int CONFIG_STACK_SIZE_SHIFT 2 + else + if [ "$CONFIG_STACK_SIZE_32KB" = "y" ]; then + define_int CONFIG_STACK_SIZE_SHIFT 3 + else + if [ "$CONFIG_STACK_SIZE_64KB" = "y" ]; then + define_int CONFIG_STACK_SIZE_SHIFT 4 + fi + fi + fi +fi + if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then define_bool CONFIG_HAVE_DEC_LOCK y fi Index: linux-2.4.21-27.EL/arch/i386/kernel/entry.S =================================================================== --- linux-2.4.21-27.EL.orig/arch/i386/kernel/entry.S 2004-12-21 13:51:31.000000000 -0500 +++ linux-2.4.21-27.EL/arch/i386/kernel/entry.S 2005-01-07 10:55:45.271704664 -0500 @@ -46,6 +46,7 @@ #include #include #include +#include #include EBX = 0x00 @@ -94,10 +95,6 @@ ENOSYS = 38 -#define GET_CURRENT(reg) \ - movl $-8192, reg; \ - andl %esp, reg - #if CONFIG_X86_HIGH_ENTRY #define call_SYMBOL_NAME_ABS(X) movl $X, %ebp; call *%ebp @@ -193,7 +190,7 @@ GET_CURRENT(%ebx); \ movl real_stack(%ebx), %edx; \ movl %esp, %ebx; \ - andl $0x1fff, %ebx; \ + andl $(THREAD_SIZE-1), %ebx; \ orl %ebx, %edx; \ movl %edx, %esp; @@ -228,7 +225,7 @@ return_path_start_marker: \ nop; \ movl %esp, %ebx; \ - andl $0x1fff, %ebx; \ + andl $(THREAD_SIZE-1), %ebx; \ orl %ebx, %edx; \ movl %esp, %eax; \ movl %edx, %esp; \ Index: linux-2.4.21-27.EL/arch/i386/kernel/irq.c =================================================================== --- linux-2.4.21-27.EL.orig/arch/i386/kernel/irq.c 2004-12-21 13:51:22.000000000 -0500 +++ linux-2.4.21-27.EL/arch/i386/kernel/irq.c 2005-01-07 10:55:45.307699192 -0500 @@ -45,6 +45,7 @@ #include #include #include +#include @@ -585,7 +586,7 @@ long esp; /* Debugging check for stack overflow: is there less than 1KB free? */ - __asm__ __volatile__("andl %%esp,%0" : "=r" (esp) : "0" (8191)); + __asm__ __volatile__("andl %%esp,%0" : "=r" (esp) : "0" (THREAD_SIZE-1)); if (unlikely(esp < (sizeof(struct task_struct) + 1024))) { extern void show_stack(unsigned long *); Index: linux-2.4.21-27.EL/arch/i386/kernel/smpboot.c =================================================================== --- linux-2.4.21-27.EL.orig/arch/i386/kernel/smpboot.c 2004-12-21 13:51:01.000000000 -0500 +++ linux-2.4.21-27.EL/arch/i386/kernel/smpboot.c 2005-01-07 10:55:45.305699496 -0500 @@ -814,7 +814,7 @@ /* So we see what's up */ printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip); - stack_start.esp = (void *) (1024 + PAGE_SIZE + (char *)idle); + stack_start.esp = (void *)idle->thread.esp; /* * This grunge runs the startup process for @@ -887,7 +887,7 @@ Dprintk("CPU has booted.\n"); } else { boot_error= 1; - if (*((volatile unsigned char *)phys_to_virt(8192)) + if (*((volatile unsigned char *)phys_to_virt(THREAD_SIZE)) == 0xA5) /* trampoline started but...? */ printk("Stuck ??\n"); @@ -910,7 +910,7 @@ } /* mark "stuck" area as not stuck */ - *((volatile unsigned long *)phys_to_virt(8192)) = 0; + *((volatile unsigned long *)phys_to_virt(THREAD_SIZE)) = 0; if(clustered_apic_mode == CLUSTERED_APIC_NUMAQ) { printk("Restoring NMI vector\n"); Index: linux-2.4.21-27.EL/arch/i386/kernel/traps.c =================================================================== --- linux-2.4.21-27.EL.orig/arch/i386/kernel/traps.c 2004-12-21 13:51:15.000000000 -0500 +++ linux-2.4.21-27.EL/arch/i386/kernel/traps.c 2005-01-07 10:55:45.306699344 -0500 @@ -180,7 +180,7 @@ unsigned long esp = tsk->thread.esp; /* User space on another CPU? */ - if ((esp ^ (unsigned long)tsk) & (PAGE_MASK<<1)) + if ((esp ^ (unsigned long)tsk) & ~(THREAD_SIZE - 1)) return; show_trace((unsigned long *)esp); } Index: linux-2.4.21-27.EL/arch/i386/kernel/head.S =================================================================== --- linux-2.4.21-27.EL.orig/arch/i386/kernel/head.S 2004-12-21 13:51:07.000000000 -0500 +++ linux-2.4.21-27.EL/arch/i386/kernel/head.S 2005-01-07 10:55:45.307699192 -0500 @@ -15,6 +15,7 @@ #include #include #include +#include #define OLD_CL_MAGIC_ADDR 0x90020 #define OLD_CL_MAGIC 0xA33F @@ -343,7 +344,7 @@ ret ENTRY(stack_start) - .long SYMBOL_NAME(init_task_union)+8192 + .long SYMBOL_NAME(init_task_union)+THREAD_SIZE .long __KERNEL_DS /* This is the default interrupt "handler" :-) */ Index: linux-2.4.21-27.EL/arch/i386/lib/getuser.S =================================================================== --- linux-2.4.21-27.EL.orig/arch/i386/lib/getuser.S 1998-01-12 16:42:52.000000000 -0500 +++ linux-2.4.21-27.EL/arch/i386/lib/getuser.S 2005-01-07 10:55:45.323696760 -0500 @@ -21,6 +21,10 @@ * as they get called from within inline assembly. */ +/* Duplicated from asm/processor.h */ +#include +#include + addr_limit = 12 .text @@ -28,7 +32,7 @@ .globl __get_user_1 __get_user_1: movl %esp,%edx - andl $0xffffe000,%edx + andl $~(THREAD_SIZE - 1),%edx cmpl addr_limit(%edx),%eax jae bad_get_user 1: movzbl (%eax),%edx @@ -41,7 +45,7 @@ addl $1,%eax movl %esp,%edx jc bad_get_user - andl $0xffffe000,%edx + andl $~(THREAD_SIZE - 1),%edx cmpl addr_limit(%edx),%eax jae bad_get_user 2: movzwl -1(%eax),%edx @@ -54,7 +58,7 @@ addl $3,%eax movl %esp,%edx jc bad_get_user - andl $0xffffe000,%edx + andl $~(THREAD_SIZE - 1),%edx cmpl addr_limit(%edx),%eax jae bad_get_user 3: movl -3(%eax),%edx Index: linux-2.4.21-27.EL/arch/i386/vmlinux.lds.in =================================================================== --- linux-2.4.21-27.EL.orig/arch/i386/vmlinux.lds.in 2004-12-21 13:51:08.000000000 -0500 +++ linux-2.4.21-27.EL/arch/i386/vmlinux.lds.in 2005-01-07 10:55:45.324696608 -0500 @@ -1,6 +1,7 @@ #define __ASSEMBLY__ #include +#include /* ld script to make i386 Linux kernel * Written by Martin Mares ; @@ -51,7 +52,7 @@ _edata = .; /* End of data section */ - . = ALIGN(8192); /* init_task */ + . = ALIGN(THREAD_SIZE); /* init_task */ .data.init_task : { *(.data.init_task) } entry_tramp_start = .;