diff options
author | Steven Rostedt <srostedt@redhat.com> | 2012-04-26 04:31:19 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2012-07-03 00:14:39 -0400 |
commit | 65b8c7226eb74a7db1a618d69d5cb0cb5f13e99d (patch) | |
tree | 72b4b1f749c2bccb9b3ceda3f3b8279d38738ee5 /arch/powerpc/kernel/ftrace.c | |
parent | b6e3796834faefe4b6e9a2aedfe12665cd51fbc5 (diff) |
powerpc/ftrace: Use patch_instruction instead of probe_kernel_write()
The patch_instruction() interface is made to modify kernel text. It is
safer to use that then the probe_kernel_write() when modifying kernel
code.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/ftrace.c')
-rw-r--r-- | arch/powerpc/kernel/ftrace.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c index d56848afd2cf..6f33296a0570 100644 --- a/arch/powerpc/kernel/ftrace.c +++ b/arch/powerpc/kernel/ftrace.c | |||
@@ -63,11 +63,9 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new) | |||
63 | return -EINVAL; | 63 | return -EINVAL; |
64 | 64 | ||
65 | /* replace the text with the new text */ | 65 | /* replace the text with the new text */ |
66 | if (probe_kernel_write((void *)ip, &new, MCOUNT_INSN_SIZE)) | 66 | if (patch_instruction((unsigned int *)ip, new)) |
67 | return -EPERM; | 67 | return -EPERM; |
68 | 68 | ||
69 | flush_icache_range(ip, ip + 8); | ||
70 | |||
71 | return 0; | 69 | return 0; |
72 | } | 70 | } |
73 | 71 | ||
@@ -212,12 +210,9 @@ __ftrace_make_nop(struct module *mod, | |||
212 | */ | 210 | */ |
213 | op = 0x48000008; /* b +8 */ | 211 | op = 0x48000008; /* b +8 */ |
214 | 212 | ||
215 | if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) | 213 | if (patch_instruction((unsigned int *)ip, op)) |
216 | return -EPERM; | 214 | return -EPERM; |
217 | 215 | ||
218 | |||
219 | flush_icache_range(ip, ip + 8); | ||
220 | |||
221 | return 0; | 216 | return 0; |
222 | } | 217 | } |
223 | 218 | ||
@@ -286,11 +281,9 @@ __ftrace_make_nop(struct module *mod, | |||
286 | 281 | ||
287 | op = PPC_INST_NOP; | 282 | op = PPC_INST_NOP; |
288 | 283 | ||
289 | if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) | 284 | if (patch_instruction((unsigned int *)ip, op)) |
290 | return -EPERM; | 285 | return -EPERM; |
291 | 286 | ||
292 | flush_icache_range(ip, ip + 8); | ||
293 | |||
294 | return 0; | 287 | return 0; |
295 | } | 288 | } |
296 | #endif /* PPC64 */ | 289 | #endif /* PPC64 */ |
@@ -426,11 +419,9 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) | |||
426 | 419 | ||
427 | pr_devel("write to %lx\n", rec->ip); | 420 | pr_devel("write to %lx\n", rec->ip); |
428 | 421 | ||
429 | if (probe_kernel_write((void *)ip, &op, MCOUNT_INSN_SIZE)) | 422 | if (patch_instruction((unsigned int *)ip, op)) |
430 | return -EPERM; | 423 | return -EPERM; |
431 | 424 | ||
432 | flush_icache_range(ip, ip + 8); | ||
433 | |||
434 | return 0; | 425 | return 0; |
435 | } | 426 | } |
436 | #endif /* CONFIG_PPC64 */ | 427 | #endif /* CONFIG_PPC64 */ |