]> git.karo-electronics.de Git - karo-tx-linux.git/commit
MIPS: ftrace: Fix dynamic tracing of kernel modules
authorPetri Gynther <pgynther@google.com>
Thu, 24 Jul 2014 05:55:02 +0000 (22:55 -0700)
committerRalf Baechle <ralf@linux-mips.org>
Wed, 30 Jul 2014 18:37:42 +0000 (20:37 +0200)
commitdce0e7d54a710400c0056d86d0f0ed972133b25d
tree09c4e4a9ff99b1d11150e62c21f519264513254c
parentb1442d39fac2fcfbe6a4814979020e993ca59c9e
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>
arch/mips/kernel/ftrace.c
arch/mips/kernel/mcount.S