Every mcount() call in the MIPS 32-bit kernel is done as follows: [...] move at, ra jal _mcount addiu sp, sp, -8 [...] but upon returning from the mcount() function, the stack pointer is not adjusted properly. This is explained in details in 58b69401c797 (MIPS: Function tracer: Fix broken function tracing). Commit ad8c396936e3 ("MIPS: Unbreak function tracer for 64-bit kernel.) fixed the stack manipulation for 64-bit but it didn't fix it completely for MIPS32.
Unified · Split
| @@ -129,7 +129,11 @@ NESTED(_mcount, PT_SIZE, ra) · 128 unmodified lines | ||
| 129 | 129 | nop |
| 130 | 130 | #endif |
| 131 | 131 | b ftrace_stub |
| 132 | +#ifdef CONFIG_32BIT | |
| 133 | + addiu sp, sp, 8 | |
| 134 | +#else | |
| 132 | 135 | nop |
| 136 | +#endif | |
| 133 | 137 | |
| 134 | 138 | static_trace: |
| 135 | 139 | MCOUNT_SAVE_REGS |
| @@ -139,6 +143,9 @@ static_trace: · 3 unmodified lines | ||
| 139 | 143 | move a1, AT /* arg2: parent's return address */ |
| 140 | 144 | |
| 141 | 145 | MCOUNT_RESTORE_REGS |
| 146 | +#ifdef CONFIG_32BIT | |
| 147 | + addiu sp, sp, 8 | |
| 148 | +#endif | |
| 142 | 149 | .globl ftrace_stub |
| 143 | 150 | ftrace_stub: |
| 144 | 151 | RETURN_BACK |
| @@ -183,6 +190,11 @@ NESTED(ftrace_graph_caller, PT_SIZE, ra) · 38 unmodified lines | ||
| 183 | 190 | jal prepare_ftrace_return |
| 184 | 191 | nop |
| 185 | 192 | MCOUNT_RESTORE_REGS |
| 193 | +#ifndef CONFIG_DYNAMIC_FTRACE | |
| 194 | +#ifdef CONFIG_32BIT | |
| 195 | + addiu sp, sp, 8 | |
| 196 | +#endif | |
| 197 | +#endif | |
| 186 | 198 | RETURN_BACK |
| 187 | 199 | END(ftrace_graph_caller) |
| 188 | 200 | |