Index: linux-2.4.22-ac1/arch/i386/kernel/entry.S =================================================================== --- linux-2.4.22-ac1.orig/arch/i386/kernel/entry.S 2003-09-25 14:16:34.000000000 +0400 +++ linux-2.4.22-ac1/arch/i386/kernel/entry.S 2003-12-01 18:34:08.000000000 +0300 @@ -46,6 +46,7 @@ #include #include #include +#include EBX = 0x00 ECX = 0x04 @@ -131,10 +132,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.. @@ -150,7 +147,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 @@ -174,7 +171,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.22-ac1/arch/i386/kernel/smpboot.c =================================================================== --- linux-2.4.22-ac1.orig/arch/i386/kernel/smpboot.c 2003-09-25 14:16:28.000000000 +0400 +++ linux-2.4.22-ac1/arch/i386/kernel/smpboot.c 2003-12-01 18:34:08.000000000 +0300 @@ -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.22-ac1/arch/i386/kernel/traps.c =================================================================== --- linux-2.4.22-ac1.orig/arch/i386/kernel/traps.c 2003-09-25 14:16:29.000000000 +0400 +++ linux-2.4.22-ac1/arch/i386/kernel/traps.c 2003-12-01 18:34:08.000000000 +0300 @@ -161,7 +161,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.22-ac1/arch/i386/kernel/head.S =================================================================== --- linux-2.4.22-ac1.orig/arch/i386/kernel/head.S 2003-09-25 14:16:27.000000000 +0400 +++ linux-2.4.22-ac1/arch/i386/kernel/head.S 2003-12-01 18:34:08.000000000 +0300 @@ -15,6 +15,7 @@ #include #include #include +#include #define OLD_CL_MAGIC_ADDR 0x90020 #define OLD_CL_MAGIC 0xA33F @@ -315,7 +316,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.22-ac1/arch/i386/kernel/irq.c =================================================================== --- linux-2.4.22-ac1.orig/arch/i386/kernel/irq.c 2003-09-25 14:16:18.000000000 +0400 +++ linux-2.4.22-ac1/arch/i386/kernel/irq.c 2003-12-01 18:34:08.000000000 +0300 @@ -581,7 +581,10 @@ 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.22-ac1/arch/i386/lib/getuser.S =================================================================== --- linux-2.4.22-ac1.orig/arch/i386/lib/getuser.S 1998-01-13 00:42:52.000000000 +0300 +++ linux-2.4.22-ac1/arch/i386/lib/getuser.S 2003-12-01 18:34:08.000000000 +0300 @@ -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.22-ac1/arch/i386/config.in =================================================================== --- linux-2.4.22-ac1.orig/arch/i386/config.in 2003-09-25 14:16:34.000000000 +0400 +++ linux-2.4.22-ac1/arch/i386/config.in 2003-12-01 18:34:08.000000000 +0300 @@ -304,6 +304,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.22-ac1/arch/i386/vmlinux.lds =================================================================== --- linux-2.4.22-ac1.orig/arch/i386/vmlinux.lds 2003-09-25 14:16:28.000000000 +0400 +++ linux-2.4.22-ac1/arch/i386/vmlinux.lds 2003-12-01 18:34:08.000000000 +0300 @@ -38,7 +38,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.22-ac1/include/asm-i386/current.h =================================================================== --- linux-2.4.22-ac1.orig/include/asm-i386/current.h 1998-08-15 03:35:22.000000000 +0400 +++ linux-2.4.22-ac1/include/asm-i386/current.h 2003-12-01 18:34:16.000000000 +0300 @@ -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.22-ac1/include/asm-i386/hw_irq.h =================================================================== --- linux-2.4.22-ac1.orig/include/asm-i386/hw_irq.h 2003-09-26 00:54:45.000000000 +0400 +++ linux-2.4.22-ac1/include/asm-i386/hw_irq.h 2003-12-01 18:34:08.000000000 +0300 @@ -114,10 +114,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.22-ac1/include/asm-i386/processor.h =================================================================== --- linux-2.4.22-ac1.orig/include/asm-i386/processor.h 2003-09-26 00:54:44.000000000 +0400 +++ linux-2.4.22-ac1/include/asm-i386/processor.h 2003-12-01 18:34:08.000000000 +0300 @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -465,10 +466,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.22-ac1/include/linux/sched.h =================================================================== --- linux-2.4.22-ac1.orig/include/linux/sched.h 2003-11-13 18:21:42.000000000 +0300 +++ linux-2.4.22-ac1/include/linux/sched.h 2003-12-01 18:34:08.000000000 +0300 @@ -2,6 +2,7 @@ #define _LINUX_SCHED_H #include /* for HZ */ +#include /* maybe for INIT_TASK_SIZE */ extern unsigned long event;