cef679947fc66ca3a0c201255ff10e5601e5f89c
[linux-2.6.git] / arch / i386 / kernel / dstack.S
1 /*
2  *  linux/arch/i386/dstack.S
3  *
4  *  Copyright (C) 2005 Marc E. Fiuczynski
5  */
6
7 /*
8  * dstack.s contains the system specific support for stack overflows
9  * and discontiguous stack support.
10  */
11
12 #include <linux/config.h>
13 #include <linux/linkage.h>      
14 #include <asm/thread_info.h>    
15 #include <asm/errno.h>
16 #include <asm/segment.h>
17 #include <asm/smp.h>
18 #include <asm/page.h>
19
20 .data
21 .globl stack_overflowed
22 stack_overflowed:
23         .long 0
24 .text
25
26 ENTRY(mcount)
27 #warning stack check enabled
28         push %eax
29         movl $(THREAD_SIZE - 1),%eax
30         andl %esp,%eax
31         cmpl $STACK_WARN,%eax
32         jle 1f
33 2:
34         popl %eax
35         ret
36 1:
37         /* prevent infinite recursion from call to mcount from the
38          * stack_overflow function.  Need to revisit this code for
39          * SMP based systems.
40          */
41         lock; btsl $0,stack_overflowed
42         jc 2b
43
44         /* prepare to jmp to stack_overflow directly, as if it were 
45          * called directly by the caller of mcount.  
46          */
47         pushl %ebp
48         pushl %ebx
49         pushl %esi
50         pushl %edi
51         
52         call stack_overflow
53         /* Note that stack_overflow() will clear the stack_overflowed
54          * variable.
55          */
56
57         popl %edi
58         popl %esi
59         popl %ebx
60         popl %ebp
61         
62         popl %eax       
63         ret