]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com) | |
3 | * | |
4 | * This file implements mcount(), which is used to collect profiling data. | |
5 | * This can also be tweaked for kernel stack overflow detection. | |
6 | */ | |
7 | ||
1da177e4 LT |
8 | #include <linux/linkage.h> |
9 | ||
10 | #include <asm/ptrace.h> | |
11 | #include <asm/thread_info.h> | |
12 | ||
13 | /* | |
14 | * This is the main variant and is called by C code. GCC's -pg option | |
15 | * automatically instruments every C function with a call to this. | |
16 | */ | |
17 | ||
18 | #ifdef CONFIG_STACK_DEBUG | |
19 | ||
20 | #define OVSTACKSIZE 4096 /* lets hope this is enough */ | |
21 | ||
22 | .data | |
23 | .align 8 | |
24 | panicstring: | |
25 | .asciz "Stack overflow\n" | |
26 | .align 8 | |
27 | ovstack: | |
28 | .skip OVSTACKSIZE | |
29 | #endif | |
30 | .text | |
31 | .align 32 | |
32 | .globl mcount, _mcount | |
33 | mcount: | |
34 | _mcount: | |
35 | #ifdef CONFIG_STACK_DEBUG | |
36 | /* | |
37 | * Check whether %sp is dangerously low. | |
38 | */ | |
39 | ldub [%g6 + TI_FPDEPTH], %g1 | |
40 | srl %g1, 1, %g3 | |
41 | add %g3, 1, %g3 | |
42 | sllx %g3, 8, %g3 ! each fpregs frame is 256b | |
43 | add %g3, 192, %g3 | |
44 | add %g6, %g3, %g3 ! where does task_struct+frame end? | |
45 | sub %g3, STACK_BIAS, %g3 | |
46 | cmp %sp, %g3 | |
47 | bg,pt %xcc, 1f | |
48 | sethi %hi(panicstring), %g3 | |
49 | sethi %hi(ovstack), %g7 ! cant move to panic stack fast enough | |
50 | or %g7, %lo(ovstack), %g7 | |
51 | add %g7, OVSTACKSIZE, %g7 | |
52 | sub %g7, STACK_BIAS, %g7 | |
53 | mov %g7, %sp | |
54 | call prom_printf | |
55 | or %g3, %lo(panicstring), %o0 | |
56 | call prom_halt | |
57 | nop | |
58 | #endif | |
59 | 1: retl | |
60 | nop |