Index: linux-2.4.21-171/arch/i386/kernel/entry.S =================================================================== --- linux-2.4.21-171.orig/arch/i386/kernel/entry.S 2004-02-24 13:43:40.000000000 -0500 +++ linux-2.4.21-171/arch/i386/kernel/entry.S 2004-04-03 16:02:32.000000000 -0500 @@ -45,6 +45,7 @@ #include #include #include +#include EBX = 0x00 ECX = 0x04 @@ -130,10 +131,6 @@ .long 3b,6b; \ .previous -#define GET_CURRENT(reg) \ - movl $-8192, reg; \ - andl %esp, reg - ENTRY(lcall7) pushfl # We get a different stack layout with call gates, pushl %eax # which has to be cleaned up later.. @@ -149,7 +146,7 @@ movl %ecx,CS(%esp) # movl %esp,%ebx pushl %ebx - andl $-8192,%ebx # GET_CURRENT + andl $-THREAD_SIZE,%ebx # GET_CURRENT movl exec_domain(%ebx),%edx # Get the execution domain movl 4(%edx),%edx # Get the lcall7 handler for the domain pushl $0x7 @@ -173,7 +170,7 @@ movl %ecx,CS(%esp) # movl %esp,%ebx pushl %ebx - andl $-8192,%ebx # GET_CURRENT + andl $-THREAD_SIZE,%ebx # GET_CURRENT movl exec_domain(%ebx),%edx # Get the execution domain movl 4(%edx),%edx # Get the lcall7 handler for the domain pushl $0x27 Index: linux-2.4.21-171/arch/i386/kernel/smpboot.c =================================================================== --- linux-2.4.21-171.orig/arch/i386/kernel/smpboot.c 2004-02-24 13:43:40.000000000 -0500 +++ linux-2.4.21-171/arch/i386/kernel/smpboot.c 2004-04-03 16:02:32.000000000 -0500 @@ -833,7 +833,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 @@ -914,7 +914,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"); @@ -937,7 +937,7 @@ } /* mark "stuck" area as not stuck */ - *((volatile unsigned long *)phys_to_virt(8192)) = 0; + *((volatile unsigned long *)phys_to_virt(THREAD_SIZE)) = 0; #ifdef CONFIG_ES7000 if (!es7000_plat) Index: linux-2.4.21-171/arch/i386/kernel/traps.c =================================================================== --- linux-2.4.21-171.orig/arch/i386/kernel/traps.c 2004-02-24 13:43:40.000000000 -0500 +++ linux-2.4.21-171/arch/i386/kernel/traps.c 2004-04-03 16:02:32.000000000 -0500 @@ -193,7 +193,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-171/arch/i386/kernel/head.S =================================================================== --- linux-2.4.21-171.orig/arch/i386/kernel/head.S 2004-02-24 13:43:40.000000000 -0500 +++ linux-2.4.21-171/arch/i386/kernel/head.S 2004-04-03 16:02:32.000000000 -0500 @@ -15,6 +15,7 @@ #include #include #include +#include #define OLD_CL_MAGIC_ADDR 0x90020 #define OLD_CL_MAGIC 0xA33F @@ -326,7 +327,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-171/arch/i386/kernel/irq.c =================================================================== --- linux-2.4.21-171.orig/arch/i386/kernel/irq.c 2004-02-24 13:43:40.000000000 -0500 +++ linux-2.4.21-171/arch/i386/kernel/irq.c 2004-04-03 16:05:17.000000000 -0500 @@ -597,7 +597,9 @@ 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) + sysctl_stackwarn))) { static unsigned long next_jiffies; /* ratelimiting */ static long least_esp = THREAD_SIZE; Index: linux-2.4.21-171/arch/i386/lib/getuser.S =================================================================== --- linux-2.4.21-171.orig/arch/i386/lib/getuser.S 2004-02-24 13:43:40.000000000 -0500 +++ linux-2.4.21-171/arch/i386/lib/getuser.S 2004-04-03 16:02:32.000000000 -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-171/arch/i386/config.in =================================================================== --- linux-2.4.21-171.orig/arch/i386/config.in 2004-02-24 13:43:40.000000000 -0500 +++ linux-2.4.21-171/arch/i386/config.in 2004-04-03 16:02:32.000000000 -0500 @@ -325,6 +325,29 @@ if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then define_bool CONFIG_HAVE_DEC_LOCK 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-171/arch/i386/vmlinux.lds.S =================================================================== --- linux-2.4.21-171.orig/arch/i386/vmlinux.lds.S 2004-02-24 13:43:40.000000000 -0500 +++ linux-2.4.21-171/arch/i386/vmlinux.lds.S 2004-04-03 16:02:32.000000000 -0500 @@ -39,7 +39,8 @@ _edata = .; /* End of data section */ - . = 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); /* Init code and data */ Index: linux-2.4.21-171/include/asm-i386/current.h =================================================================== --- linux-2.4.21-171.orig/include/asm-i386/current.h 2004-02-24 13:42:29.000000000 -0500 +++ linux-2.4.21-171/include/asm-i386/current.h 2004-04-03 16:02:32.000000000 -0500 @@ -1,15 +1,43 @@ #ifndef _I386_CURRENT_H #define _I386_CURRENT_H +#include + +/* + * Configurable page sizes on i386, mainly for debugging purposes. + * (c) Balbir Singh + */ + +#ifdef __ASSEMBLY__ + +#define PAGE_SIZE 4096 /* as cannot handle 1UL << 12 */ +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE) + +#define GET_CURRENT(reg) \ + movl $-THREAD_SIZE, reg; \ + andl %esp, reg + +#else /* __ASSEMBLY__ */ + +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE) +#define alloc_task_struct() \ + ((struct task_struct *) __get_free_pages(GFP_KERNEL,CONFIG_STACK_SIZE_SHIFT)) + +#define free_task_struct(p) \ + free_pages((unsigned long) (p), CONFIG_STACK_SIZE_SHIFT) + +#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-171/include/asm-i386/hw_irq.h =================================================================== --- linux-2.4.21-171.orig/include/asm-i386/hw_irq.h 2004-02-24 13:42:29.000000000 -0500 +++ linux-2.4.21-171/include/asm-i386/hw_irq.h 2004-04-03 16:02:32.000000000 -0500 @@ -16,6 +16,7 @@ #include #include #include +#include /* * IDT vectors usable for external interrupt sources start @@ -116,10 +117,6 @@ #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-171/include/asm-i386/processor.h =================================================================== --- linux-2.4.21-171.orig/include/asm-i386/processor.h 2004-02-24 13:42:29.000000000 -0500 +++ linux-2.4.21-171/include/asm-i386/processor.h 2004-04-03 16:02:32.000000000 -0500 @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -464,9 +465,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) free_pages((unsigned long) (p), 1) #define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count) #define init_task (init_task_union.task) Index: linux-2.4.21-171/include/linux/sched.h =================================================================== --- linux-2.4.21-171.orig/include/linux/sched.h 2004-03-31 14:58:26.000000000 -0500 +++ linux-2.4.21-171/include/linux/sched.h 2004-04-03 16:02:32.000000000 -0500 @@ -2,6 +2,7 @@ #define _LINUX_SCHED_H #include /* for HZ */ +#include /* maybe for INIT_TASK_SIZE */ extern unsigned long event;