2 * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com)
4 * This file implements mcount(), which is used to collect profiling data.
5 * This can also be tweaked for kernel stack overflow detection.
8 #include <linux/config.h>
9 #include <linux/linkage.h>
11 #include <asm/ptrace.h>
12 #include <asm/thread_info.h>
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.
19 #ifdef CONFIG_STACK_DEBUG
21 #define OVSTACKSIZE 4096 /* lets hope this is enough */
26 .asciz "Stack overflow\n"
33 .globl mcount, _mcount
36 #ifdef CONFIG_STACK_DEBUG
38 * Check whether %sp is dangerously low.
40 ldub [%g6 + TI_FPDEPTH], %g1
43 sllx %g3, 8, %g3 ! each fpregs frame is 256b
45 add %g6, %g3, %g3 ! where does task_struct+frame end?
46 sub %g3, STACK_BIAS, %g3
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
56 or %g3, %lo(panicstring), %o0