History

samples: ftrace: Save required argument registers in sample trampolines

The ftrace-direct-too sample traces the handle_mm_fault function whose signature changed since the introduction of the sample. Since: commit bce617edecad ("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/20230427140700.625241-2-revest@chromium.org

Florent Revest committed 3 years ago

Commit 8564c311 parent 06c2afb1 file · +8 −6Browse files

Showing the changes to samples (1 of 1 file). Show all

Unified · Split

samples/ftrace/ftrace-direct-too.c+8−6
@@ -5,14 +5,14 @@ · 4 unmodified lines
55 #include <linux/ftrace.h>
66 #include <asm/asm-offsets.h>
77
8−extern void my_direct_func(struct vm_area_struct *vma,
9− unsigned long address, unsigned int flags);
8+extern void my_direct_func(struct vm_area_struct *vma, unsigned long address,
9+ unsigned int flags, struct pt_regs *regs);
1010
11−void my_direct_func(struct vm_area_struct *vma,
12− unsigned long address, unsigned int flags)
11+void my_direct_func(struct vm_area_struct *vma, unsigned long address,
12+ unsigned int flags, struct pt_regs *regs)
1313 {
14− trace_printk("handle mm fault vma=%p address=%lx flags=%x\n",
15− vma, address, flags);
14+ trace_printk("handle mm fault vma=%p address=%lx flags=%x regs=%p\n",
15+ vma, address, flags, regs);
1616 }
1717
1818 extern void my_tramp(void *);
@@ -34,7 +34,9 @@ asm ( · 15 unmodified lines
3434 " pushq %rdi\n"
3535 " pushq %rsi\n"
3636 " pushq %rdx\n"
37+" pushq %rcx\n"
3738 " call my_direct_func\n"
39+" popq %rcx\n"
3840 " popq %rdx\n"
3941 " popq %rsi\n"
4042 " popq %rdi\n"