aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/ftrace.c
diff options
context:
space:
mode:
authorWu Zhangjin <wuzhangjin@gmail.com>2010-05-14 07:08:34 -0400
committerRalf Baechle <ralf@linux-mips.org>2010-07-05 12:17:30 -0400
commitc9f84873c1231621508cd438bb2991ddba770a69 (patch)
tree4bf6065b6d184dc54e01bb8445e2de28c42d50fb /arch/mips/kernel/ftrace.c
parent68ccf7521dc89bfcf01432fd1bf8cb4d7d534e4c (diff)
MIPS: Tracing: Cleanup of address space checking
This patch adds an inline function in_module() to check which space the instruction pointer in, kernel space or module space. Note: This will not work when the kernel space and module space are the same. If they are the same, we need to modify scripts/recordmcount.pl, ftrace_make_nop/call() and the other related parts to ensure the enabling/disabling of the calling site to _mcount is right for both kernel and module. [Ralf: It also is still incorrect for some 64-bit kernels.] Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com> Cc: linux-mips <linux-mips@linux-mips.org> Cc: David Daney <david.s.daney@gmail.com> Patchwork: http://patchwork.linux-mips.org/patch/1232/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/ftrace.c')
-rw-r--r--arch/mips/kernel/ftrace.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
index 628e90b992d1..5a84a1f11231 100644
--- a/arch/mips/kernel/ftrace.c
+++ b/arch/mips/kernel/ftrace.c
@@ -17,6 +17,22 @@
17#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
18#include <asm/uasm.h> 18#include <asm/uasm.h>
19 19
20/*
21 * If the Instruction Pointer is in module space (0xc0000000), return true;
22 * otherwise, it is in kernel space (0x80000000), return false.
23 *
24 * FIXME: This will not work when the kernel space and module space are the
25 * same. If they are the same, we need to modify scripts/recordmcount.pl,
26 * ftrace_make_nop/call() and the other related parts to ensure the
27 * enabling/disabling of the calling site to _mcount is right for both kernel
28 * and module.
29 */
30
31static inline int in_module(unsigned long ip)
32{
33 return ip & 0x40000000;
34}
35
20#ifdef CONFIG_DYNAMIC_FTRACE 36#ifdef CONFIG_DYNAMIC_FTRACE
21 37
22#define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */ 38#define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */
@@ -78,7 +94,7 @@ int ftrace_make_nop(struct module *mod,
78 * We have compiled module with -mlong-calls, but compiled the kernel 94 * We have compiled module with -mlong-calls, but compiled the kernel
79 * without it, we need to cope with them respectively. 95 * without it, we need to cope with them respectively.
80 */ 96 */
81 if (ip & 0x40000000) { 97 if (in_module(ip)) {
82#if defined(KBUILD_MCOUNT_RA_ADDRESS) && defined(CONFIG_32BIT) 98#if defined(KBUILD_MCOUNT_RA_ADDRESS) && defined(CONFIG_32BIT)
83 /* 99 /*
84 * lui v1, hi_16bit_of_mcount --> b 1f (0x10000005) 100 * lui v1, hi_16bit_of_mcount --> b 1f (0x10000005)
@@ -117,7 +133,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
117 unsigned long ip = rec->ip; 133 unsigned long ip = rec->ip;
118 134
119 /* ip, module: 0xc0000000, kernel: 0x80000000 */ 135 /* ip, module: 0xc0000000, kernel: 0x80000000 */
120 new = (ip & 0x40000000) ? insn_lui_v1_hi16_mcount : insn_jal_ftrace_caller; 136 new = in_module(ip) ? insn_lui_v1_hi16_mcount : insn_jal_ftrace_caller;
121 137
122 return ftrace_modify_code(ip, new); 138 return ftrace_modify_code(ip, new);
123} 139}
@@ -188,7 +204,7 @@ unsigned long ftrace_get_parent_addr(unsigned long self_addr,
188 * instruction "lui v1, hi_16bit_of_mcount"(offset is 20), but for 204 * instruction "lui v1, hi_16bit_of_mcount"(offset is 20), but for
189 * kernel, move to the instruction "move ra, at"(offset is 12) 205 * kernel, move to the instruction "move ra, at"(offset is 12)
190 */ 206 */
191 ip = self_addr - ((self_addr & 0x40000000) ? 20 : 12); 207 ip = self_addr - (in_module(self_addr) ? 20 : 12);
192 208
193 /* 209 /*
194 * search the text until finding the non-store instruction or "s{d,w} 210 * search the text until finding the non-store instruction or "s{d,w}