Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349446
b: refs/heads/master
c: 58b6940
h: refs/heads/master
v: v3
  • Loading branch information
Al Cooper authored and Ralf Baechle committed Jan 31, 2013
1 parent 06dcc20 commit d9488bb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 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: 196897a2979498d19edbdf5b4af02261afbc1a96
refs/heads/master: 58b69401c797e470c8f638c598dddc44a4ce8a96
36 changes: 35 additions & 1 deletion trunk/arch/mips/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
#define MCOUNT_OFFSET_INSNS 4
#endif

/* Arch override because MIPS doesn't need to run this from stop_machine() */
void arch_ftrace_update_code(int command)
{
ftrace_modify_all_code(command);
}

/*
* Check if the address is in kernel space
*
Expand Down Expand Up @@ -89,6 +95,24 @@ static int ftrace_modify_code(unsigned long ip, unsigned int new_code)
return 0;
}

#ifndef CONFIG_64BIT
static int ftrace_modify_code_2(unsigned long ip, unsigned int new_code1,
unsigned int new_code2)
{
int faulted;

safe_store_code(new_code1, ip, faulted);
if (unlikely(faulted))
return -EFAULT;
ip += 4;
safe_store_code(new_code2, ip, faulted);
if (unlikely(faulted))
return -EFAULT;
flush_icache_range(ip, ip + 8); /* original ip + 12 */
return 0;
}
#endif

/*
* The details about the calling site of mcount on MIPS
*
Expand Down Expand Up @@ -131,8 +155,18 @@ int ftrace_make_nop(struct module *mod,
* needed.
*/
new = in_kernel_space(ip) ? INSN_NOP : INSN_B_1F;

#ifdef CONFIG_64BIT
return ftrace_modify_code(ip, new);
#else
/*
* On 32 bit MIPS platforms, gcc adds a stack adjust
* instruction in the delay slot after the branch to
* mcount and expects mcount to restore the sp on return.
* This is based on a legacy API and does nothing but
* waste instructions so it's being removed at runtime.
*/
return ftrace_modify_code_2(ip, new, INSN_NOP);
#endif
}

int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
Expand Down
7 changes: 4 additions & 3 deletions trunk/arch/mips/kernel/mcount.S
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@
PTR_L a5, PT_R9(sp)
PTR_L a6, PT_R10(sp)
PTR_L a7, PT_R11(sp)
PTR_ADDIU sp, PT_SIZE
#else
PTR_ADDIU sp, (PT_SIZE + 8)
PTR_ADDIU sp, PT_SIZE
#endif
.endm

Expand All @@ -69,7 +68,9 @@ NESTED(ftrace_caller, PT_SIZE, ra)
.globl _mcount
_mcount:
b ftrace_stub
nop
addiu sp,sp,8

/* When tracing is activated, it calls ftrace_caller+8 (aka here) */
lw t1, function_trace_stop
bnez t1, ftrace_stub
nop
Expand Down

0 comments on commit d9488bb

Please sign in to comment.