aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/lib/mcount.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc64/lib/mcount.S')
-rw-r--r--arch/sparc64/lib/mcount.S61
1 files changed, 61 insertions, 0 deletions
diff --git a/arch/sparc64/lib/mcount.S b/arch/sparc64/lib/mcount.S
new file mode 100644
index 000000000000..2ef2e268bdcf
--- /dev/null
+++ b/arch/sparc64/lib/mcount.S
@@ -0,0 +1,61 @@
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
8#include <linux/config.h>
9#include <linux/linkage.h>
10
11#include <asm/ptrace.h>
12#include <asm/thread_info.h>
13
14/*
15 * This is the main variant and is called by C code. GCC's -pg option
16 * automatically instruments every C function with a call to this.
17 */
18
19#ifdef CONFIG_STACK_DEBUG
20
21#define OVSTACKSIZE 4096 /* lets hope this is enough */
22
23 .data
24 .align 8
25panicstring:
26 .asciz "Stack overflow\n"
27 .align 8
28ovstack:
29 .skip OVSTACKSIZE
30#endif
31 .text
32 .align 32
33 .globl mcount, _mcount
34mcount:
35_mcount:
36#ifdef CONFIG_STACK_DEBUG
37 /*
38 * Check whether %sp is dangerously low.
39 */
40 ldub [%g6 + TI_FPDEPTH], %g1
41 srl %g1, 1, %g3
42 add %g3, 1, %g3
43 sllx %g3, 8, %g3 ! each fpregs frame is 256b
44 add %g3, 192, %g3
45 add %g6, %g3, %g3 ! where does task_struct+frame end?
46 sub %g3, STACK_BIAS, %g3
47 cmp %sp, %g3
48 bg,pt %xcc, 1f
49 sethi %hi(panicstring), %g3
50 sethi %hi(ovstack), %g7 ! cant move to panic stack fast enough
51 or %g7, %lo(ovstack), %g7
52 add %g7, OVSTACKSIZE, %g7
53 sub %g7, STACK_BIAS, %g7
54 mov %g7, %sp
55 call prom_printf
56 or %g3, %lo(panicstring), %o0
57 call prom_halt
58 nop
59#endif
601: retl
61 nop