diff options
author | Petri Gynther <pgynther@google.com> | 2014-07-24 01:55:02 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-07-30 14:37:42 -0400 |
commit | dce0e7d54a710400c0056d86d0f0ed972133b25d (patch) | |
tree | 09c4e4a9ff99b1d11150e62c21f519264513254c /arch/mips/kernel/mcount.S | |
parent | b1442d39fac2fcfbe6a4814979020e993ca59c9e (diff) |
MIPS: ftrace: Fix dynamic tracing of kernel modules
Dynamic tracing of kernel modules is broken on 32-bit MIPS. When modules
are loaded, the kernel crashes when dynamic tracing is enabled with:
cd /sys/kernel/debug/tracing
echo > set_ftrace_filter
echo function > current_tracer
1) arch/mips/kernel/ftrace.c
When the kernel boots, or when a module is initialized, ftrace_make_nop()
modifies every _mcount call site to eliminate the ftrace overhead.
However, when ftrace is later enabled for a call site, ftrace_make_call()
does not currently restore the _mcount call correctly for module call sites.
Added ftrace_modify_code_2r() and modified ftrace_make_call() to fix this.
2) arch/mips/kernel/mcount.S
_mcount assembly routine is supposed to have the caller's _mcount call site
address in register a0. However, a0 is currently not calculated correctly for
module call sites. a0 should be (ra - 20) or (ra - 24), depending on whether
the kernel was built with KBUILD_MCOUNT_RA_ADDRESS or not.
This fix has been tested on Broadcom BMIPS5000 processor. Dynamic tracing
now works for both built-in functions and module functions.
Signed-off-by: Petri Gynther <pgynther@google.com>
Cc: linux-mips@linux-mips.org
Cc: rostedt@goodmis.org
Cc: alcooperx@gmail.com
Cc: cminyard@mvista.com
Patchwork: https://patchwork.linux-mips.org/patch/7476/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/mcount.S')
-rw-r--r-- | arch/mips/kernel/mcount.S | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S index 539b6294b613..26ceb3c0eca9 100644 --- a/arch/mips/kernel/mcount.S +++ b/arch/mips/kernel/mcount.S | |||
@@ -84,6 +84,19 @@ _mcount: | |||
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | PTR_SUBU a0, ra, 8 /* arg1: self address */ | 86 | PTR_SUBU a0, ra, 8 /* arg1: self address */ |
87 | PTR_LA t1, _stext | ||
88 | sltu t2, a0, t1 /* t2 = (a0 < _stext) */ | ||
89 | PTR_LA t1, _etext | ||
90 | sltu t3, t1, a0 /* t3 = (a0 > _etext) */ | ||
91 | or t1, t2, t3 | ||
92 | beqz t1, ftrace_call | ||
93 | nop | ||
94 | #if defined(KBUILD_MCOUNT_RA_ADDRESS) && defined(CONFIG_32BIT) | ||
95 | PTR_SUBU a0, a0, 16 /* arg1: adjust to module's recorded callsite */ | ||
96 | #else | ||
97 | PTR_SUBU a0, a0, 12 | ||
98 | #endif | ||
99 | |||
87 | .globl ftrace_call | 100 | .globl ftrace_call |
88 | ftrace_call: | 101 | ftrace_call: |
89 | nop /* a placeholder for the call to a real tracing function */ | 102 | nop /* a placeholder for the call to a real tracing function */ |