Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 297595
b: refs/heads/master
c: dc283d7
h: refs/heads/master
i:
  297593: 6d80f0e
  297591: dbadc83
v: v3
  • Loading branch information
Rabin Vincent authored and Russell King committed Mar 24, 2012
1 parent a341aa1 commit 1911e88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 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: 9141a003a491c7230d17b9c29677ce2be437b95c
refs/heads/master: dc283d7037555aa6891188719be2f1b4af9535c9
28 changes: 14 additions & 14 deletions trunk/arch/arm/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
}

static int ftrace_modify_code(unsigned long pc, unsigned long old,
unsigned long new)
unsigned long new, bool validate)
{
unsigned long replaced;

if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE))
return -EFAULT;
if (validate) {
if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE))
return -EFAULT;

if (replaced != old)
return -EINVAL;
if (replaced != old)
return -EINVAL;
}

if (probe_kernel_write((void *)pc, &new, MCOUNT_INSN_SIZE))
return -EPERM;
Expand All @@ -141,23 +143,21 @@ static int ftrace_modify_code(unsigned long pc, unsigned long old,

int ftrace_update_ftrace_func(ftrace_func_t func)
{
unsigned long pc, old;
unsigned long pc;
unsigned long new;
int ret;

pc = (unsigned long)&ftrace_call;
memcpy(&old, &ftrace_call, MCOUNT_INSN_SIZE);
new = ftrace_call_replace(pc, (unsigned long)func);

ret = ftrace_modify_code(pc, old, new);
ret = ftrace_modify_code(pc, 0, new, false);

#ifdef CONFIG_OLD_MCOUNT
if (!ret) {
pc = (unsigned long)&ftrace_call_old;
memcpy(&old, &ftrace_call_old, MCOUNT_INSN_SIZE);
new = ftrace_call_replace(pc, (unsigned long)func);

ret = ftrace_modify_code(pc, old, new);
ret = ftrace_modify_code(pc, 0, new, false);
}
#endif

Expand All @@ -172,7 +172,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
old = ftrace_nop_replace(rec);
new = ftrace_call_replace(ip, adjust_address(rec, addr));

return ftrace_modify_code(rec->ip, old, new);
return ftrace_modify_code(rec->ip, old, new, true);
}

int ftrace_make_nop(struct module *mod,
Expand All @@ -185,15 +185,15 @@ int ftrace_make_nop(struct module *mod,

old = ftrace_call_replace(ip, adjust_address(rec, addr));
new = ftrace_nop_replace(rec);
ret = ftrace_modify_code(ip, old, new);
ret = ftrace_modify_code(ip, old, new, true);

#ifdef CONFIG_OLD_MCOUNT
if (ret == -EINVAL && addr == MCOUNT_ADDR) {
rec->arch.old_mcount = true;

old = ftrace_call_replace(ip, adjust_address(rec, addr));
new = ftrace_nop_replace(rec);
ret = ftrace_modify_code(ip, old, new);
ret = ftrace_modify_code(ip, old, new, true);
}
#endif

Expand Down Expand Up @@ -254,7 +254,7 @@ static int __ftrace_modify_caller(unsigned long *callsite,
unsigned long old = enable ? nop : branch;
unsigned long new = enable ? branch : nop;

return ftrace_modify_code(pc, old, new);
return ftrace_modify_code(pc, old, new, true);
}

static int ftrace_modify_graph_caller(bool enable)
Expand Down

0 comments on commit 1911e88

Please sign in to comment.