Commit 8564c315 authored by Florent Revest's avatar Florent Revest Committed by Steven Rostedt (Google)

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 bce617ed ("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

Cc: stable@vger.kernel.org
Fixes: bce617ed ("mm: do page fault accounting in handle_mm_fault")
Reviewed-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarFlorent Revest <revest@chromium.org>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 06c2afb8
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
#include <linux/ftrace.h> #include <linux/ftrace.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
extern void my_direct_func(struct vm_area_struct *vma, extern void my_direct_func(struct vm_area_struct *vma, unsigned long address,
unsigned long address, unsigned int flags); unsigned int flags, struct pt_regs *regs);
void my_direct_func(struct vm_area_struct *vma, void my_direct_func(struct vm_area_struct *vma, unsigned long address,
unsigned long address, unsigned int flags) unsigned int flags, struct pt_regs *regs)
{ {
trace_printk("handle mm fault vma=%p address=%lx flags=%x\n", trace_printk("handle mm fault vma=%p address=%lx flags=%x regs=%p\n",
vma, address, flags); vma, address, flags, regs);
} }
extern void my_tramp(void *); extern void my_tramp(void *);
...@@ -34,7 +34,9 @@ asm ( ...@@ -34,7 +34,9 @@ asm (
" pushq %rdi\n" " pushq %rdi\n"
" pushq %rsi\n" " pushq %rsi\n"
" pushq %rdx\n" " pushq %rdx\n"
" pushq %rcx\n"
" call my_direct_func\n" " call my_direct_func\n"
" popq %rcx\n"
" popq %rdx\n" " popq %rdx\n"
" popq %rsi\n" " popq %rsi\n"
" popq %rdi\n" " popq %rdi\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment