Skip to content

Commit

Permalink
samples: ftrace: Save required argument registers in sample trampolines
Browse files Browse the repository at this point in the history
The ftrace-direct-too sample traces the handle_mm_fault function whose
signature changed since the introduction of the sample. Since:
commit bce617e ("mm: do page fault accounting in handle_mm_fault")
handle_mm_fault now has 4 arguments. Therefore, the sample trampoline
should save 4 argument registers.

s390 saves all argument registers already so it does not need a change
but x86_64 needs an extra push and pop.

This also evolves the signature of the tracing function to make it
mirror the signature of the traced function.

Link: https://lkml.kernel.org/r/[email protected]

Cc: [email protected]
Fixes: bce617e ("mm: do page fault accounting in handle_mm_fault")
Reviewed-by: Steven Rostedt (Google) <[email protected]>
Reviewed-by: Mark Rutland <[email protected]>
Acked-by: Catalin Marinas <[email protected]>
Signed-off-by: Florent Revest <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
  • Loading branch information
FlorentRevest authored and rostedt committed Jul 10, 2023
1 parent 06c2afb commit 8564c31
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions samples/ftrace/ftrace-direct-too.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#include <linux/ftrace.h>
#include <asm/asm-offsets.h>

extern void my_direct_func(struct vm_area_struct *vma,
unsigned long address, unsigned int flags);
extern void my_direct_func(struct vm_area_struct *vma, unsigned long address,
unsigned int flags, struct pt_regs *regs);

void my_direct_func(struct vm_area_struct *vma,
unsigned long address, unsigned int flags)
void my_direct_func(struct vm_area_struct *vma, unsigned long address,
unsigned int flags, struct pt_regs *regs)
{
trace_printk("handle mm fault vma=%p address=%lx flags=%x\n",
vma, address, flags);
trace_printk("handle mm fault vma=%p address=%lx flags=%x regs=%p\n",
vma, address, flags, regs);
}

extern void my_tramp(void *);
Expand All @@ -34,7 +34,9 @@ asm (
" pushq %rdi\n"
" pushq %rsi\n"
" pushq %rdx\n"
" pushq %rcx\n"
" call my_direct_func\n"
" popq %rcx\n"
" popq %rdx\n"
" popq %rsi\n"
" popq %rdi\n"
Expand Down

0 comments on commit 8564c31

Please sign in to comment.