#include <linux/list.h>
#include <asm/alternative.h>
+#include <asm/ftrace.h>
-#define CALL_BACK 5
/* Long is fine, even if it is only 4 bytes ;-) */
static long *ftrace_nop;
union ftrace_code_union {
- char code[5];
+ char code[MCOUNT_INSN_SIZE];
struct {
char e8;
int offset;
} __attribute__((packed));
};
-notrace int ftrace_ip_converted(unsigned long ip)
-{
- unsigned long save;
-
- ip -= CALL_BACK;
- save = *(long *)ip;
-
- return save == *ftrace_nop;
-}
static int notrace ftrace_calc_offset(long ip, long addr)
{
static union ftrace_code_union calc;
calc.e8 = 0xe8;
- calc.offset = ftrace_calc_offset(ip, addr);
+ calc.offset = ftrace_calc_offset(ip + MCOUNT_INSN_SIZE, addr);
/*
* No locking needed, this must be called via kstop_machine
unsigned char newch = new_code[4];
int faulted = 0;
- /* move the IP back to the start of the call */
- ip -= CALL_BACK;
-
/*
* Note: Due to modules and __init, code can
* disappear and change, we need to protect against faulting
".previous\n"
_ASM_EXTABLE(1b, 3b)
: "=r"(faulted), "=a"(replaced)
- : "r"(ip), "r"(new), "r"(newch),
+ : "r"(ip), "r"(new), "c"(newch),
"0"(faulted), "a"(old)
: "memory");
sync_core();
notrace int ftrace_update_ftrace_func(ftrace_func_t func)
{
unsigned long ip = (unsigned long)(&ftrace_call);
- unsigned char old[5], *new;
+ unsigned char old[MCOUNT_INSN_SIZE], *new;
int ret;
- ip += CALL_BACK;
-
- memcpy(old, &ftrace_call, 5);
+ memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
new = ftrace_call_replace(ip, (unsigned long)func);
ret = ftrace_modify_code(ip, old, new);
{
unsigned long ip = (long)(&mcount_call);
unsigned long *addr = data;
- unsigned char old[5], *new;
-
- /* ip is at the location, but modify code will subtact this */
- ip += CALL_BACK;
+ unsigned char old[MCOUNT_INSN_SIZE], *new;
/*
* Replace the mcount stub with a pointer to the
* ip recorder function.
*/
- memcpy(old, &mcount_call, 5);
+ memcpy(old, &mcount_call, MCOUNT_INSN_SIZE);
new = ftrace_call_replace(ip, *addr);
*addr = ftrace_modify_code(ip, old, new);
ftrace_mcount_set(data);
- ftrace_nop = (unsigned long *)noptable[CALL_BACK];
+ ftrace_nop = (unsigned long *)noptable[MCOUNT_INSN_SIZE];
return 0;
}
-