lkml.org 
[lkml]   [2008]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 03/11] ftrace: return error on failed modified text.
Return -1 on failed modified text.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
arch/x86/kernel/ftrace.c | 12 +++++++-----
kernel/trace/ftrace.c | 29 ++++++++++-------------------
2 files changed, 17 insertions(+), 24 deletions(-)

Index: linux-compile.git/arch/x86/kernel/ftrace.c
===================================================================
--- linux-compile.git.orig/arch/x86/kernel/ftrace.c 2008-10-22 13:10:58.000000000 -0400
+++ linux-compile.git/arch/x86/kernel/ftrace.c 2008-10-22 13:15:36.000000000 -0400
@@ -71,14 +71,16 @@ ftrace_modify_code(unsigned long ip, uns
* No real locking needed, this code is run through
* kstop_machine, or before SMP starts.
*/
- if (__copy_from_user_inatomic(replaced, (char __user *)ip, MCOUNT_INSN_SIZE))
- return 1;
+ if (__copy_from_user_inatomic(replaced, (char __user *)ip,
+ MCOUNT_INSN_SIZE))
+ return -1;

if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0)
- return 2;
+ return -1;

- WARN_ON_ONCE(__copy_to_user_inatomic((char __user *)ip, new_code,
- MCOUNT_INSN_SIZE));
+ if (__copy_to_user_inatomic((char __user *)ip, new_code,
+ MCOUNT_INSN_SIZE))
+ return -1;

sync_core();

Index: linux-compile.git/kernel/trace/ftrace.c
===================================================================
--- linux-compile.git.orig/kernel/trace/ftrace.c 2008-10-22 13:10:58.000000000 -0400
+++ linux-compile.git/kernel/trace/ftrace.c 2008-10-22 13:14:04.000000000 -0400
@@ -591,31 +591,22 @@ ftrace_code_disable(struct dyn_ftrace *r
{
unsigned long ip;
unsigned char *nop, *call;
- int failed;
+ int ret;

ip = rec->ip;

nop = ftrace_nop_replace();
call = ftrace_call_replace(ip, mcount_addr);

- failed = ftrace_modify_code(ip, call, nop);
- if (failed) {
- switch (failed) {
- case 1:
- WARN_ON_ONCE(1);
- pr_info("ftrace faulted on modifying ");
- print_ip_sym(ip);
- break;
- case 2:
- WARN_ON_ONCE(1);
- pr_info("ftrace failed to modify ");
- print_ip_sym(ip);
- print_ip_ins(" expected: ", call);
- print_ip_ins(" actual: ", (unsigned char *)ip);
- print_ip_ins(" replace: ", nop);
- printk(KERN_CONT "\n");
- break;
- }
+ ret = ftrace_modify_code(ip, call, nop);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ pr_info("ftrace failed to modify ");
+ print_ip_sym(ip);
+ print_ip_ins(" expected: ", call);
+ print_ip_ins(" replace: ", nop);
+ printk(KERN_CONT "\n");
+ break;

rec->flags |= FTRACE_FL_FAILED;
return 0;
--


\
 
 \ /
  Last update: 2008-10-22 20:55    [W:0.090 / U:2.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site