Whamcloud - gitweb
- missed patches from suse-2.4.21-2 series added
[fs/lustre-release.git] / lustre / kernel_patches / patches / configurable-x86-stack-2.4.19-pre1.patch
1 Index: linux-2.4.19-pre1/arch/i386/kernel/entry.S
2 ===================================================================
3 --- linux-2.4.19-pre1.orig/arch/i386/kernel/entry.S     2003-11-21 03:38:55.000000000 +0300
4 +++ linux-2.4.19-pre1/arch/i386/kernel/entry.S  2003-12-01 18:14:32.000000000 +0300
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 @@ -128,10 +129,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 @@ -144,7 +141,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 @@ -165,7 +162,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.19-pre1/arch/i386/kernel/smpboot.c
43 ===================================================================
44 --- linux-2.4.19-pre1.orig/arch/i386/kernel/smpboot.c   2001-12-21 20:41:53.000000000 +0300
45 +++ linux-2.4.19-pre1/arch/i386/kernel/smpboot.c        2003-12-01 18:14:32.000000000 +0300
46 @@ -819,7 +819,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 @@ -892,7 +892,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 @@ -915,7 +915,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         if(clustered_apic_mode) {
72                 printk("Restoring NMI vector\n");
73 Index: linux-2.4.19-pre1/arch/i386/kernel/traps.c
74 ===================================================================
75 --- linux-2.4.19-pre1.orig/arch/i386/kernel/traps.c     2003-12-01 18:11:31.000000000 +0300
76 +++ linux-2.4.19-pre1/arch/i386/kernel/traps.c  2003-12-01 18:14:32.000000000 +0300
77 @@ -158,7 +158,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.19-pre1/arch/i386/kernel/head.S
87 ===================================================================
88 --- linux-2.4.19-pre1.orig/arch/i386/kernel/head.S      2003-11-20 19:01:35.000000000 +0300
89 +++ linux-2.4.19-pre1/arch/i386/kernel/head.S   2003-12-01 18:14:32.000000000 +0300
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 @@ -320,7 +321,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.19-pre1/arch/i386/lib/getuser.S
108 ===================================================================
109 --- linux-2.4.19-pre1.orig/arch/i386/lib/getuser.S      1998-01-13 00:42:52.000000000 +0300
110 +++ linux-2.4.19-pre1/arch/i386/lib/getuser.S   2003-12-01 18:14:32.000000000 +0300
111 @@ -21,6 +21,10 @@
112   * as they get called from within inline assembly.
113   */
114  
115 +/* Duplicated from asm/processor.h */
116 +#include <asm/current.h>
117 +#include <linux/config.h>
118 +
119  addr_limit = 12
120  
121  .text
122 @@ -28,7 +32,7 @@
123  .globl __get_user_1
124  __get_user_1:
125         movl %esp,%edx
126 -       andl $0xffffe000,%edx
127 +       andl $~(THREAD_SIZE - 1),%edx
128         cmpl addr_limit(%edx),%eax
129         jae bad_get_user
130  1:     movzbl (%eax),%edx
131 @@ -41,7 +45,7 @@
132         addl $1,%eax
133         movl %esp,%edx
134         jc bad_get_user
135 -       andl $0xffffe000,%edx
136 +       andl $~(THREAD_SIZE - 1),%edx
137         cmpl addr_limit(%edx),%eax
138         jae bad_get_user
139  2:     movzwl -1(%eax),%edx
140 @@ -54,7 +58,7 @@
141         addl $3,%eax
142         movl %esp,%edx
143         jc bad_get_user
144 -       andl $0xffffe000,%edx
145 +       andl $~(THREAD_SIZE - 1),%edx
146         cmpl addr_limit(%edx),%eax
147         jae bad_get_user
148  3:     movl -3(%eax),%edx
149 Index: linux-2.4.19-pre1/arch/i386/config.in
150 ===================================================================
151 --- linux-2.4.19-pre1.orig/arch/i386/config.in  2003-11-20 19:01:35.000000000 +0300
152 +++ linux-2.4.19-pre1/arch/i386/config.in       2003-12-01 18:14:32.000000000 +0300
153 @@ -201,6 +201,29 @@
154  if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then
155     define_bool CONFIG_HAVE_DEC_LOCK y
156  fi
157 +
158 +choice 'Bigger Stack Size Support' \
159 +     "off    CONFIG_NOBIGSTACK \
160 +      16KB   CONFIG_STACK_SIZE_16KB \
161 +      32KB   CONFIG_STACK_SIZE_32KB \
162 +      64KB   CONFIG_STACK_SIZE_64KB" off
163 +
164 +if [ "$CONFIG_NOBIGSTACK" = "y" ]; then
165 +   define_int CONFIG_STACK_SIZE_SHIFT 1
166 +else
167 +  if [ "$CONFIG_STACK_SIZE_16KB" = "y" ]; then
168 +     define_int CONFIG_STACK_SIZE_SHIFT 2
169 +  else
170 +    if [ "$CONFIG_STACK_SIZE_32KB" = "y" ]; then
171 +      define_int CONFIG_STACK_SIZE_SHIFT 3
172 +    else
173 +      if [ "$CONFIG_STACK_SIZE_64KB" = "y" ]; then
174 +        define_int CONFIG_STACK_SIZE_SHIFT 4
175 +      fi
176 +    fi
177 +  fi
178 +fi
179
180  endmenu
181  
182  mainmenu_option next_comment
183 Index: linux-2.4.19-pre1/arch/i386/vmlinux.lds
184 ===================================================================
185 --- linux-2.4.19-pre1.orig/arch/i386/vmlinux.lds        2003-11-20 19:01:35.000000000 +0300
186 +++ linux-2.4.19-pre1/arch/i386/vmlinux.lds     2003-12-01 18:14:32.000000000 +0300
187 @@ -35,7 +35,8 @@
188  
189    _edata = .;                  /* End of data section */
190  
191 -  . = ALIGN(8192);             /* init_task */
192 +/* chose the biggest of the possible stack sizes here? */
193 +  . = ALIGN(65536);            /* init_task */
194    .data.init_task : { *(.data.init_task) }
195  
196    . = ALIGN(4096);             /* Init code and data */
197 Index: linux-2.4.19-pre1/include/asm-i386/current.h
198 ===================================================================
199 --- linux-2.4.19-pre1.orig/include/asm-i386/current.h   1998-08-15 03:35:22.000000000 +0400
200 +++ linux-2.4.19-pre1/include/asm-i386/current.h        2003-12-01 18:14:32.000000000 +0300
201 @@ -1,15 +1,43 @@
202  #ifndef _I386_CURRENT_H
203  #define _I386_CURRENT_H
204 +#include <asm/page.h>
205 +
206 +/*
207 + * Configurable page sizes on i386, mainly for debugging purposes.
208 + * (c) Balbir Singh
209 + */
210 +
211 +#ifdef __ASSEMBLY__
212 +
213 +#define PAGE_SIZE      4096    /* as cannot handle 1UL << 12 */
214 +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE)
215 +
216 +#define GET_CURRENT(reg) \
217 +        movl $-THREAD_SIZE, reg; \
218 +        andl %esp, reg
219 +
220 +#else  /* __ASSEMBLY__ */
221 +
222 +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE)
223 +#define alloc_task_struct() \
224 +  ((struct task_struct *) __get_free_pages(GFP_KERNEL,CONFIG_STACK_SIZE_SHIFT))
225 +
226 +#define free_task_struct(p) \
227 +  free_pages((unsigned long) (p), CONFIG_STACK_SIZE_SHIFT)
228 +
229 +#define INIT_TASK_SIZE THREAD_SIZE
230  
231  struct task_struct;
232  
233  static inline struct task_struct * get_current(void)
234  {
235         struct task_struct *current;
236 -       __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
237 +       __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~(THREAD_SIZE - 1)));
238         return current;
239   }
240   
241  #define current get_current()
242  
243 +#endif /* __ASSEMBLY__ */
244 +
245  #endif /* !(_I386_CURRENT_H) */
246 Index: linux-2.4.19-pre1/include/asm-i386/hw_irq.h
247 ===================================================================
248 --- linux-2.4.19-pre1.orig/include/asm-i386/hw_irq.h    2003-11-21 02:59:05.000000000 +0300
249 +++ linux-2.4.19-pre1/include/asm-i386/hw_irq.h 2003-12-01 18:14:32.000000000 +0300
250 @@ -15,6 +15,7 @@
251  #include <linux/config.h>
252  #include <asm/atomic.h>
253  #include <asm/irq.h>
254 +#include <asm/current.h>
255  
256  /*
257   * IDT vectors usable for external interrupt sources start
258 @@ -113,10 +114,6 @@
259  #define IRQ_NAME2(nr) nr##_interrupt(void)
260  #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr)
261  
262 -#define GET_CURRENT \
263 -       "movl %esp, %ebx\n\t" \
264 -       "andl $-8192, %ebx\n\t"
265 -
266  /*
267   *     SMP has a few special interrupts for IPI messages
268   */
269 Index: linux-2.4.19-pre1/include/asm-i386/processor.h
270 ===================================================================
271 --- linux-2.4.19-pre1.orig/include/asm-i386/processor.h 2003-11-21 02:59:05.000000000 +0300
272 +++ linux-2.4.19-pre1/include/asm-i386/processor.h      2003-12-01 18:14:32.000000000 +0300
273 @@ -14,6 +14,7 @@
274  #include <asm/types.h>
275  #include <asm/sigcontext.h>
276  #include <asm/cpufeature.h>
277 +#include <asm/current.h>
278  #include <linux/cache.h>
279  #include <linux/config.h>
280  #include <linux/threads.h>
281 @@ -447,9 +448,6 @@
282  #define KSTK_EIP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)))[1019])
283  #define KSTK_ESP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)))[1022])
284  
285 -#define THREAD_SIZE (2*PAGE_SIZE)
286 -#define alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
287 -#define free_task_struct(p) free_pages((unsigned long) (p), 1)
288  #define get_task_struct(tsk)      atomic_inc(&virt_to_page(tsk)->count)
289  
290  #define init_task      (init_task_union.task)
291 Index: linux-2.4.19-pre1/include/linux/sched.h
292 ===================================================================
293 --- linux-2.4.19-pre1.orig/include/linux/sched.h        2003-12-01 18:11:28.000000000 +0300
294 +++ linux-2.4.19-pre1/include/linux/sched.h     2003-12-01 18:14:32.000000000 +0300
295 @@ -2,6 +2,7 @@
296  #define _LINUX_SCHED_H
297  
298  #include <asm/param.h> /* for HZ */
299 +#include <asm/current.h>       /* maybe for INIT_TASK_SIZE */
300  
301  extern unsigned long event;
302