Whamcloud - gitweb
* Removed the (new) tcp zero-copy patches
[fs/lustre-release.git] / lustre / kernel_patches / patches / configurable-x86-stack-2.4.21-suse-171.patch
1 Index: linux-2.4.21-171/arch/i386/kernel/entry.S
2 ===================================================================
3 --- linux-2.4.21-171.orig/arch/i386/kernel/entry.S      2004-02-24 13:43:40.000000000 -0500
4 +++ linux-2.4.21-171/arch/i386/kernel/entry.S   2004-04-03 16:02:32.000000000 -0500
5 @@ -45,6 +45,7 @@
6  #include <linux/linkage.h>
7  #include <asm/segment.h>
8  #include <asm/smp.h>
9 +#include <asm/current.h>
10  
11  EBX            = 0x00
12  ECX            = 0x04
13 @@ -130,10 +131,6 @@
14         .long 3b,6b;    \
15  .previous
16  
17 -#define GET_CURRENT(reg) \
18 -       movl $-8192, reg; \
19 -       andl %esp, reg
20 -
21  ENTRY(lcall7)
22         pushfl                  # We get a different stack layout with call gates,
23         pushl %eax              # which has to be cleaned up later..
24 @@ -149,7 +146,7 @@
25         movl %ecx,CS(%esp)      #
26         movl %esp,%ebx
27         pushl %ebx
28 -       andl $-8192,%ebx        # GET_CURRENT
29 +       andl $-THREAD_SIZE,%ebx # GET_CURRENT
30         movl exec_domain(%ebx),%edx     # Get the execution domain
31         movl 4(%edx),%edx       # Get the lcall7 handler for the domain
32         pushl $0x7
33 @@ -173,7 +170,7 @@
34         movl %ecx,CS(%esp)      #
35         movl %esp,%ebx
36         pushl %ebx
37 -       andl $-8192,%ebx        # GET_CURRENT
38 +       andl $-THREAD_SIZE,%ebx # GET_CURRENT
39         movl exec_domain(%ebx),%edx     # Get the execution domain
40         movl 4(%edx),%edx       # Get the lcall7 handler for the domain
41         pushl $0x27
42 Index: linux-2.4.21-171/arch/i386/kernel/smpboot.c
43 ===================================================================
44 --- linux-2.4.21-171.orig/arch/i386/kernel/smpboot.c    2004-02-24 13:43:40.000000000 -0500
45 +++ linux-2.4.21-171/arch/i386/kernel/smpboot.c 2004-04-03 16:02:32.000000000 -0500
46 @@ -833,7 +833,7 @@
47  
48         /* So we see what's up   */
49         printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
50 -       stack_start.esp = (void *) (1024 + PAGE_SIZE + (char *)idle);
51 +       stack_start.esp = (void *)idle->thread.esp;
52  
53         /*
54          * This grunge runs the startup process for
55 @@ -914,7 +914,7 @@
56                         Dprintk("CPU has booted.\n");
57                 } else {
58                         boot_error= 1;
59 -                       if (*((volatile unsigned char *)phys_to_virt(8192))
60 +                       if (*((volatile unsigned char *)phys_to_virt(THREAD_SIZE))
61                                         == 0xA5)
62                                 /* trampoline started but...? */
63                                 printk("Stuck ??\n");
64 @@ -937,7 +937,7 @@
65         }
66  
67         /* mark "stuck" area as not stuck */
68 -       *((volatile unsigned long *)phys_to_virt(8192)) = 0;
69 +       *((volatile unsigned long *)phys_to_virt(THREAD_SIZE)) = 0;
70  
71  #ifdef CONFIG_ES7000
72         if (!es7000_plat)
73 Index: linux-2.4.21-171/arch/i386/kernel/traps.c
74 ===================================================================
75 --- linux-2.4.21-171.orig/arch/i386/kernel/traps.c      2004-02-24 13:43:40.000000000 -0500
76 +++ linux-2.4.21-171/arch/i386/kernel/traps.c   2004-04-03 16:02:32.000000000 -0500
77 @@ -193,7 +193,7 @@
78         unsigned long esp = tsk->thread.esp;
79  
80         /* User space on another CPU? */
81 -       if ((esp ^ (unsigned long)tsk) & (PAGE_MASK<<1))
82 +       if ((esp ^ (unsigned long)tsk) & ~(THREAD_SIZE - 1))
83                 return;
84         show_trace((unsigned long *)esp);
85  }
86 Index: linux-2.4.21-171/arch/i386/kernel/head.S
87 ===================================================================
88 --- linux-2.4.21-171.orig/arch/i386/kernel/head.S       2004-02-24 13:43:40.000000000 -0500
89 +++ linux-2.4.21-171/arch/i386/kernel/head.S    2004-04-03 16:02:32.000000000 -0500
90 @@ -15,6 +15,7 @@
91  #include <asm/page.h>
92  #include <asm/pgtable.h>
93  #include <asm/desc.h>
94 +#include <asm/current.h>
95  
96  #define OLD_CL_MAGIC_ADDR      0x90020
97  #define OLD_CL_MAGIC           0xA33F
98 @@ -326,7 +327,7 @@
99         ret
100  
101  ENTRY(stack_start)
102 -       .long SYMBOL_NAME(init_task_union)+8192
103 +       .long SYMBOL_NAME(init_task_union)+THREAD_SIZE
104         .long __KERNEL_DS
105  
106  /* This is the default interrupt "handler" :-) */
107 Index: linux-2.4.21-171/arch/i386/kernel/irq.c
108 ===================================================================
109 --- linux-2.4.21-171.orig/arch/i386/kernel/irq.c        2004-02-24 13:43:40.000000000 -0500
110 +++ linux-2.4.21-171/arch/i386/kernel/irq.c     2004-04-03 16:05:17.000000000 -0500
111 @@ -597,7 +597,9 @@
112         long esp;
113  
114         /* Debugging check for stack overflow: is there less than 1KB free? */
115 -       __asm__ __volatile__("andl %%esp,%0" : "=r" (esp) : "0" (8191));
116 +       __asm__ __volatile__(
117 +               "andl %%esp,%0"
118 +               : "=r" (esp) : "0" (THREAD_SIZE-1));
119         if (unlikely(esp < (sizeof(struct task_struct) + sysctl_stackwarn))) {
120                 static unsigned long next_jiffies;      /* ratelimiting */
121                 static long least_esp = THREAD_SIZE;
122 Index: linux-2.4.21-171/arch/i386/lib/getuser.S
123 ===================================================================
124 --- linux-2.4.21-171.orig/arch/i386/lib/getuser.S       2004-02-24 13:43:40.000000000 -0500
125 +++ linux-2.4.21-171/arch/i386/lib/getuser.S    2004-04-03 16:02:32.000000000 -0500
126 @@ -21,6 +21,10 @@
127   * as they get called from within inline assembly.
128   */
129  
130 +/* Duplicated from asm/processor.h */
131 +#include <asm/current.h>
132 +#include <linux/config.h>
133 +
134  addr_limit = 12
135  
136  .text
137 @@ -28,7 +32,7 @@
138  .globl __get_user_1
139  __get_user_1:
140         movl %esp,%edx
141 -       andl $0xffffe000,%edx
142 +       andl $~(THREAD_SIZE - 1),%edx
143         cmpl addr_limit(%edx),%eax
144         jae bad_get_user
145  1:     movzbl (%eax),%edx
146 @@ -41,7 +45,7 @@
147         addl $1,%eax
148         movl %esp,%edx
149         jc bad_get_user
150 -       andl $0xffffe000,%edx
151 +       andl $~(THREAD_SIZE - 1),%edx
152         cmpl addr_limit(%edx),%eax
153         jae bad_get_user
154  2:     movzwl -1(%eax),%edx
155 @@ -54,7 +58,7 @@
156         addl $3,%eax
157         movl %esp,%edx
158         jc bad_get_user
159 -       andl $0xffffe000,%edx
160 +       andl $~(THREAD_SIZE - 1),%edx
161         cmpl addr_limit(%edx),%eax
162         jae bad_get_user
163  3:     movl -3(%eax),%edx
164 Index: linux-2.4.21-171/arch/i386/config.in
165 ===================================================================
166 --- linux-2.4.21-171.orig/arch/i386/config.in   2004-02-24 13:43:40.000000000 -0500
167 +++ linux-2.4.21-171/arch/i386/config.in        2004-04-03 16:02:32.000000000 -0500
168 @@ -325,6 +325,29 @@
169  if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then
170     define_bool CONFIG_HAVE_DEC_LOCK y
171  fi
172 +
173 +choice 'Bigger Stack Size Support' \
174 +     "off    CONFIG_NOBIGSTACK \
175 +      16KB   CONFIG_STACK_SIZE_16KB \
176 +      32KB   CONFIG_STACK_SIZE_32KB \
177 +      64KB   CONFIG_STACK_SIZE_64KB" off
178 +
179 +if [ "$CONFIG_NOBIGSTACK" = "y" ]; then
180 +   define_int CONFIG_STACK_SIZE_SHIFT 1
181 +else
182 +  if [ "$CONFIG_STACK_SIZE_16KB" = "y" ]; then
183 +     define_int CONFIG_STACK_SIZE_SHIFT 2
184 +  else
185 +    if [ "$CONFIG_STACK_SIZE_32KB" = "y" ]; then
186 +      define_int CONFIG_STACK_SIZE_SHIFT 3
187 +    else
188 +      if [ "$CONFIG_STACK_SIZE_64KB" = "y" ]; then
189 +        define_int CONFIG_STACK_SIZE_SHIFT 4
190 +      fi
191 +    fi
192 +  fi
193 +fi
194
195  endmenu
196  
197  mainmenu_option next_comment
198 Index: linux-2.4.21-171/arch/i386/vmlinux.lds.S
199 ===================================================================
200 --- linux-2.4.21-171.orig/arch/i386/vmlinux.lds.S       2004-02-24 13:43:40.000000000 -0500
201 +++ linux-2.4.21-171/arch/i386/vmlinux.lds.S    2004-04-03 16:02:32.000000000 -0500
202 @@ -39,7 +39,8 @@
203  
204    _edata = .;                  /* End of data section */
205  
206 -  . = ALIGN(8192);             /* init_task */
207 +/* chose the biggest of the possible stack sizes here? */
208 +  . = ALIGN(65536);            /* init_task */
209    .data.init_task : { *(.data.init_task) }
210  
211    . = ALIGN(4096);             /* Init code and data */
212 Index: linux-2.4.21-171/include/asm-i386/current.h
213 ===================================================================
214 --- linux-2.4.21-171.orig/include/asm-i386/current.h    2004-02-24 13:42:29.000000000 -0500
215 +++ linux-2.4.21-171/include/asm-i386/current.h 2004-04-03 16:02:32.000000000 -0500
216 @@ -1,15 +1,43 @@
217  #ifndef _I386_CURRENT_H
218  #define _I386_CURRENT_H
219 +#include <asm/page.h>
220 +
221 +/*
222 + * Configurable page sizes on i386, mainly for debugging purposes.
223 + * (c) Balbir Singh
224 + */
225 +
226 +#ifdef __ASSEMBLY__
227 +
228 +#define PAGE_SIZE      4096    /* as cannot handle 1UL << 12 */
229 +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE)
230 +
231 +#define GET_CURRENT(reg) \
232 +        movl $-THREAD_SIZE, reg; \
233 +        andl %esp, reg
234 +
235 +#else  /* __ASSEMBLY__ */
236 +
237 +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE)
238 +#define alloc_task_struct() \
239 +  ((struct task_struct *) __get_free_pages(GFP_KERNEL,CONFIG_STACK_SIZE_SHIFT))
240 +
241 +#define free_task_struct(p) \
242 +  free_pages((unsigned long) (p), CONFIG_STACK_SIZE_SHIFT)
243 +
244 +#define INIT_TASK_SIZE THREAD_SIZE
245  
246  struct task_struct;
247  
248  static inline struct task_struct * get_current(void)
249  {
250         struct task_struct *current;
251 -       __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
252 +       __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~(THREAD_SIZE - 1)));
253         return current;
254   }
255   
256  #define current get_current()
257  
258 +#endif /* __ASSEMBLY__ */
259 +
260  #endif /* !(_I386_CURRENT_H) */
261 Index: linux-2.4.21-171/include/asm-i386/hw_irq.h
262 ===================================================================
263 --- linux-2.4.21-171.orig/include/asm-i386/hw_irq.h     2004-02-24 13:42:29.000000000 -0500
264 +++ linux-2.4.21-171/include/asm-i386/hw_irq.h  2004-04-03 16:02:32.000000000 -0500
265 @@ -16,6 +16,7 @@
266  #include <linux/sched.h>
267  #include <asm/atomic.h>
268  #include <asm/irq.h>
269 +#include <asm/current.h>
270  
271  /*
272   * IDT vectors usable for external interrupt sources start
273 @@ -116,10 +117,6 @@
274  #define IRQ_NAME2(nr) nr##_interrupt(void)
275  #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr)
276  
277 -#define GET_CURRENT \
278 -       "movl %esp, %ebx\n\t" \
279 -       "andl $-8192, %ebx\n\t"
280 -
281  /*
282   *     SMP has a few special interrupts for IPI messages
283   */
284 Index: linux-2.4.21-171/include/asm-i386/processor.h
285 ===================================================================
286 --- linux-2.4.21-171.orig/include/asm-i386/processor.h  2004-02-24 13:42:29.000000000 -0500
287 +++ linux-2.4.21-171/include/asm-i386/processor.h       2004-04-03 16:02:32.000000000 -0500
288 @@ -14,6 +14,7 @@
289  #include <asm/types.h>
290  #include <asm/sigcontext.h>
291  #include <asm/cpufeature.h>
292 +#include <asm/current.h>
293  #include <linux/cache.h>
294  #include <linux/config.h>
295  #include <linux/threads.h>
296 @@ -464,9 +465,6 @@
297  #define KSTK_EIP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)))[1019])
298  #define KSTK_ESP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)))[1022])
299  
300 -#define THREAD_SIZE (2*PAGE_SIZE)
301 -#define alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
302 -#define free_task_struct(p) free_pages((unsigned long) (p), 1)
303  #define get_task_struct(tsk)      atomic_inc(&virt_to_page(tsk)->count)
304  
305  #define init_task      (init_task_union.task)
306 Index: linux-2.4.21-171/include/linux/sched.h
307 ===================================================================
308 --- linux-2.4.21-171.orig/include/linux/sched.h 2004-03-31 14:58:26.000000000 -0500
309 +++ linux-2.4.21-171/include/linux/sched.h      2004-04-03 16:02:32.000000000 -0500
310 @@ -2,6 +2,7 @@
311  #define _LINUX_SCHED_H
312  
313  #include <asm/param.h> /* for HZ */
314 +#include <asm/current.h>       /* maybe for INIT_TASK_SIZE */
315  
316  extern unsigned long event;
317