Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100429
b: refs/heads/master
c: d61f82d
h: refs/heads/master
i:
  100427: 32dacc5
v: v3
  • Loading branch information
Steven Rostedt authored and Thomas Gleixner committed May 23, 2008
1 parent aabd015 commit 2aee91e
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 85 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: 3c1720f00bb619302ba19d55986ab565e74d06db
refs/heads/master: d61f82d06672f57fca410da6f7fffd15867db622
47 changes: 44 additions & 3 deletions trunk/arch/x86/kernel/entry_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -1110,10 +1110,50 @@ ENDPROC(xen_failsafe_callback)
#endif /* CONFIG_XEN */

#ifdef CONFIG_FTRACE
#ifdef CONFIG_DYNAMIC_FTRACE

ENTRY(mcount)
pushl %eax
pushl %ecx
pushl %edx
movl 0xc(%esp), %eax

.globl mcount_call
mcount_call:
call ftrace_stub

popl %edx
popl %ecx
popl %eax

ret
END(mcount)

ENTRY(ftrace_caller)
pushl %eax
pushl %ecx
pushl %edx
movl 0xc(%esp), %eax
movl 0x4(%ebp), %edx

.globl ftrace_call
ftrace_call:
call ftrace_stub

popl %edx
popl %ecx
popl %eax

.globl ftrace_stub
ftrace_stub:
ret
END(ftrace_caller)

#else /* ! CONFIG_DYNAMIC_FTRACE */

ENTRY(mcount)
cmpl $ftrace_stub, ftrace_trace_function
jnz trace

.globl ftrace_stub
ftrace_stub:
ret
Expand All @@ -1126,15 +1166,16 @@ trace:
movl 0xc(%esp), %eax
movl 0x4(%ebp), %edx

call *ftrace_trace_function
call *ftrace_trace_function

popl %edx
popl %ecx
popl %eax

jmp ftrace_stub
END(mcount)
#endif
#endif /* CONFIG_DYNAMIC_FTRACE */
#endif /* CONFIG_FTRACE */

.section .rodata,"a"
#include "syscall_table_32.S"
Expand Down
67 changes: 66 additions & 1 deletion trunk/arch/x86/kernel/entry_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,70 @@
.code64

#ifdef CONFIG_FTRACE
#ifdef CONFIG_DYNAMIC_FTRACE
ENTRY(mcount)

subq $0x38, %rsp
movq %rax, (%rsp)
movq %rcx, 8(%rsp)
movq %rdx, 16(%rsp)
movq %rsi, 24(%rsp)
movq %rdi, 32(%rsp)
movq %r8, 40(%rsp)
movq %r9, 48(%rsp)

movq 0x38(%rsp), %rdi

.globl mcount_call
mcount_call:
call ftrace_stub

movq 48(%rsp), %r9
movq 40(%rsp), %r8
movq 32(%rsp), %rdi
movq 24(%rsp), %rsi
movq 16(%rsp), %rdx
movq 8(%rsp), %rcx
movq (%rsp), %rax
addq $0x38, %rsp

retq
END(mcount)

ENTRY(ftrace_caller)

/* taken from glibc */
subq $0x38, %rsp
movq %rax, (%rsp)
movq %rcx, 8(%rsp)
movq %rdx, 16(%rsp)
movq %rsi, 24(%rsp)
movq %rdi, 32(%rsp)
movq %r8, 40(%rsp)
movq %r9, 48(%rsp)

movq 0x38(%rsp), %rdi
movq 8(%rbp), %rsi

.globl ftrace_call
ftrace_call:
call ftrace_stub

movq 48(%rsp), %r9
movq 40(%rsp), %r8
movq 32(%rsp), %rdi
movq 24(%rsp), %rsi
movq 16(%rsp), %rdx
movq 8(%rsp), %rcx
movq (%rsp), %rax
addq $0x38, %rsp

.globl ftrace_stub
ftrace_stub:
retq
END(ftrace_caller)

#else /* ! CONFIG_DYNAMIC_FTRACE */
ENTRY(mcount)
cmpq $ftrace_stub, ftrace_trace_function
jnz trace
Expand Down Expand Up @@ -89,7 +153,8 @@ trace:

jmp ftrace_stub
END(mcount)
#endif
#endif /* CONFIG_DYNAMIC_FTRACE */
#endif /* CONFIG_FTRACE */

#ifndef CONFIG_PREEMPT
#define retint_kernel retint_restore_args
Expand Down
41 changes: 40 additions & 1 deletion trunk/arch/x86/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,49 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
return faulted;
}

int __init ftrace_dyn_arch_init(void)
notrace int ftrace_update_ftrace_func(ftrace_func_t func)
{
unsigned long ip = (unsigned long)(&ftrace_call);
unsigned char old[5], *new;
int ret;

ip += CALL_BACK;

memcpy(old, &ftrace_call, 5);
new = ftrace_call_replace(ip, (unsigned long)func);
ret = ftrace_modify_code(ip, old, new);

return ret;
}

notrace int ftrace_mcount_set(unsigned long *data)
{
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;

/*
* Replace the mcount stub with a pointer to the
* ip recorder function.
*/
memcpy(old, &mcount_call, 5);
new = ftrace_call_replace(ip, *addr);
*addr = ftrace_modify_code(ip, old, new);

return 0;
}

int __init ftrace_dyn_arch_init(void *data)
{
const unsigned char *const *noptable = find_nop_table();

/* This is running in kstop_machine */

ftrace_mcount_set(data);

ftrace_nop = (unsigned long *)noptable[CALL_BACK];

return 0;
Expand Down
7 changes: 6 additions & 1 deletion trunk/include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ struct dyn_ftrace {
extern int ftrace_ip_converted(unsigned long ip);
extern unsigned char *ftrace_nop_replace(void);
extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
extern int ftrace_dyn_arch_init(void);
extern int ftrace_dyn_arch_init(void *data);
extern int ftrace_mcount_set(unsigned long *data);
extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
unsigned char *new_code);
extern int ftrace_update_ftrace_func(ftrace_func_t func);
extern void ftrace_caller(void);
extern void ftrace_call(void);
extern void mcount_call(void);
#endif

#ifdef CONFIG_FRAME_POINTER
Expand Down
Loading

0 comments on commit 2aee91e

Please sign in to comment.