Commit 7f21a60968221eabad5c53fe760db3d094994011
Committed by
Ralf Baechle
1 parent
2816e32596
Exists in
master
and in
39 other branches
MIPS, Tracing: Clean up ftrace_make_nop()
This moves the comments out of ftrace_make_nop() and cleans it. At the same time, a macro MCOUNT_OFFSET_INSNS is defined for sharing with the next patch. Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com> Cc: Steven Rostedt <srostedt@redhat.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/2008/ Signed-off-by: Ralf Baechle <ralf@duck.linux-mips.net>
Showing 1 changed file with 38 additions and 32 deletions Side-by-side Diff
arch/mips/kernel/ftrace.c
... | ... | @@ -24,8 +24,6 @@ |
24 | 24 | #define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */ |
25 | 25 | #define ADDR_MASK 0x03ffffff /* op_code|addr : 31...26|25 ....0 */ |
26 | 26 | |
27 | -#define INSN_B_1F_4 0x10000004 /* b 1f; offset = 4 */ | |
28 | -#define INSN_B_1F_5 0x10000005 /* b 1f; offset = 5 */ | |
29 | 27 | #define INSN_NOP 0x00000000 /* nop */ |
30 | 28 | #define INSN_JAL(addr) \ |
31 | 29 | ((unsigned int)(JAL | (((addr) >> 2) & ADDR_MASK))) |
... | ... | @@ -84,6 +82,42 @@ |
84 | 82 | return 0; |
85 | 83 | } |
86 | 84 | |
85 | +/* | |
86 | + * The details about the calling site of mcount on MIPS | |
87 | + * | |
88 | + * 1. For kernel: | |
89 | + * | |
90 | + * move at, ra | |
91 | + * jal _mcount --> nop | |
92 | + * | |
93 | + * 2. For modules: | |
94 | + * | |
95 | + * 2.1 For KBUILD_MCOUNT_RA_ADDRESS and CONFIG_32BIT | |
96 | + * | |
97 | + * lui v1, hi_16bit_of_mcount --> b 1f (0x10000005) | |
98 | + * addiu v1, v1, low_16bit_of_mcount | |
99 | + * move at, ra | |
100 | + * move $12, ra_address | |
101 | + * jalr v1 | |
102 | + * sub sp, sp, 8 | |
103 | + * 1: offset = 5 instructions | |
104 | + * 2.2 For the Other situations | |
105 | + * | |
106 | + * lui v1, hi_16bit_of_mcount --> b 1f (0x10000004) | |
107 | + * addiu v1, v1, low_16bit_of_mcount | |
108 | + * move at, ra | |
109 | + * jalr v1 | |
110 | + * nop | move $12, ra_address | sub sp, sp, 8 | |
111 | + * 1: offset = 4 instructions | |
112 | + */ | |
113 | + | |
114 | +#if defined(KBUILD_MCOUNT_RA_ADDRESS) && defined(CONFIG_32BIT) | |
115 | +#define MCOUNT_OFFSET_INSNS 5 | |
116 | +#else | |
117 | +#define MCOUNT_OFFSET_INSNS 4 | |
118 | +#endif | |
119 | +#define INSN_B_1F (0x10000000 | MCOUNT_OFFSET_INSNS) | |
120 | + | |
87 | 121 | int ftrace_make_nop(struct module *mod, |
88 | 122 | struct dyn_ftrace *rec, unsigned long addr) |
89 | 123 | { |
... | ... | @@ -94,36 +128,8 @@ |
94 | 128 | * If ip is in kernel space, no long call, otherwise, long call is |
95 | 129 | * needed. |
96 | 130 | */ |
97 | - if (in_kernel_space(ip)) { | |
98 | - /* | |
99 | - * move at, ra | |
100 | - * jal _mcount --> nop | |
101 | - */ | |
102 | - new = INSN_NOP; | |
103 | - } else { | |
104 | -#if defined(KBUILD_MCOUNT_RA_ADDRESS) && defined(CONFIG_32BIT) | |
105 | - /* | |
106 | - * lui v1, hi_16bit_of_mcount --> b 1f (0x10000005) | |
107 | - * addiu v1, v1, low_16bit_of_mcount | |
108 | - * move at, ra | |
109 | - * move $12, ra_address | |
110 | - * jalr v1 | |
111 | - * sub sp, sp, 8 | |
112 | - * 1: offset = 5 instructions | |
113 | - */ | |
114 | - new = INSN_B_1F_5; | |
115 | -#else | |
116 | - /* | |
117 | - * lui v1, hi_16bit_of_mcount --> b 1f (0x10000004) | |
118 | - * addiu v1, v1, low_16bit_of_mcount | |
119 | - * move at, ra | |
120 | - * jalr v1 | |
121 | - * nop | move $12, ra_address | sub sp, sp, 8 | |
122 | - * 1: offset = 4 instructions | |
123 | - */ | |
124 | - new = INSN_B_1F_4; | |
125 | -#endif | |
126 | - } | |
131 | + new = in_kernel_space(ip) ? INSN_NOP : INSN_B_1F; | |
132 | + | |
127 | 133 | return ftrace_modify_code(ip, new); |
128 | 134 | } |
129 | 135 |