aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-10-23 09:33:00 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-23 10:00:17 -0400
commit76aefee57657428fb77cbd8624119c1a440bee44 (patch)
tree31df8acbe185aeee1515d166d76cf2e85dd0eff6 /arch
parent593eb8a2d63e95772a5f22d746f18a997c5ee463 (diff)
ftrace: comment arch ftrace code
Add comments to explain what is happening in the x86 arch ftrace code. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/ftrace.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 428291581cb2..783455454d78 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -66,18 +66,23 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
66 /* 66 /*
67 * Note: Due to modules and __init, code can 67 * Note: Due to modules and __init, code can
68 * disappear and change, we need to protect against faulting 68 * disappear and change, we need to protect against faulting
69 * as well as code changing. 69 * as well as code changing. We do this by using the
70 * __copy_*_user functions.
70 * 71 *
71 * No real locking needed, this code is run through 72 * No real locking needed, this code is run through
72 * kstop_machine, or before SMP starts. 73 * kstop_machine, or before SMP starts.
73 */ 74 */
75
76 /* read the text we want to modify */
74 if (__copy_from_user_inatomic(replaced, (char __user *)ip, 77 if (__copy_from_user_inatomic(replaced, (char __user *)ip,
75 MCOUNT_INSN_SIZE)) 78 MCOUNT_INSN_SIZE))
76 return -EFAULT; 79 return -EFAULT;
77 80
81 /* Make sure it is what we expect it to be */
78 if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0) 82 if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0)
79 return -EINVAL; 83 return -EINVAL;
80 84
85 /* replace the text with the new text */
81 if (__copy_to_user_inatomic((char __user *)ip, new_code, 86 if (__copy_to_user_inatomic((char __user *)ip, new_code,
82 MCOUNT_INSN_SIZE)) 87 MCOUNT_INSN_SIZE))
83 return -EPERM; 88 return -EPERM;