Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116598
b: refs/heads/master
c: 6f93fc0
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt authored and Ingo Molnar committed Oct 14, 2008
1 parent dc70f76 commit 667e19d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8feff1cacc29e9cfdc6d1ce5f2108db87b91046e
refs/heads/master: 6f93fc076a464bfe24e8d4c5fea3f6ca5bdb264d
38 changes: 13 additions & 25 deletions trunk/arch/x86/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <linux/spinlock.h>
#include <linux/hardirq.h>
#include <linux/uaccess.h>
#include <linux/ftrace.h>
#include <linux/percpu.h>
#include <linux/init.h>
Expand Down Expand Up @@ -60,41 +61,28 @@ notrace int
ftrace_modify_code(unsigned long ip, unsigned char *old_code,
unsigned char *new_code)
{
unsigned replaced;
unsigned old = *(unsigned *)old_code; /* 4 bytes */
unsigned new = *(unsigned *)new_code; /* 4 bytes */
unsigned char newch = new_code[4];
int faulted = 0;
unsigned char replaced[MCOUNT_INSN_SIZE];

/*
* Note: Due to modules and __init, code can
* disappear and change, we need to protect against faulting
* as well as code changing.
*
* No real locking needed, this code is run through
* kstop_machine.
* kstop_machine, or before SMP starts.
*/
asm volatile (
"1: lock\n"
" cmpxchg %3, (%2)\n"
" jnz 2f\n"
" movb %b4, 4(%2)\n"
"2:\n"
".section .fixup, \"ax\"\n"
"3: movl $1, %0\n"
" jmp 2b\n"
".previous\n"
_ASM_EXTABLE(1b, 3b)
: "=r"(faulted), "=a"(replaced)
: "r"(ip), "r"(new), "c"(newch),
"0"(faulted), "a"(old)
: "memory");
sync_core();
if (__copy_from_user(replaced, (char __user *)ip, MCOUNT_INSN_SIZE))
return 1;

if (replaced != old && replaced != new)
faulted = 2;
if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0)
return 2;

return faulted;
WARN_ON_ONCE(__copy_to_user((char __user *)ip, new_code,
MCOUNT_INSN_SIZE));

sync_core();

return 0;
}

notrace int ftrace_update_ftrace_func(ftrace_func_t func)
Expand Down

0 comments on commit 667e19d

Please sign in to comment.