Merge tag 'v5.7-rc6' into objtool/core, to pick up fixes and resolve semantic conflict
[linux-2.6-block.git] / samples / ftrace / ftrace-direct-too.c
CommitLineData
156473a0
SRV
1// SPDX-License-Identifier: GPL-2.0-only
2#include <linux/module.h>
3
4#include <linux/mm.h> /* for handle_mm_fault() */
5#include <linux/ftrace.h>
6
7void my_direct_func(struct vm_area_struct *vma,
8 unsigned long address, unsigned int flags)
9{
10 trace_printk("handle mm fault vma=%p address=%lx flags=%x\n",
11 vma, address, flags);
12}
13
14extern void my_tramp(void *);
15
16asm (
17" .pushsection .text, \"ax\", @progbits\n"
18" my_tramp:"
19" pushq %rbp\n"
20" movq %rsp, %rbp\n"
21" pushq %rdi\n"
22" pushq %rsi\n"
23" pushq %rdx\n"
24" call my_direct_func\n"
25" popq %rdx\n"
26" popq %rsi\n"
27" popq %rdi\n"
28" leave\n"
29" ret\n"
30" .popsection\n"
31);
32
33
34static int __init ftrace_direct_init(void)
35{
36 return register_ftrace_direct((unsigned long)handle_mm_fault,
37 (unsigned long)my_tramp);
38}
39
40static void __exit ftrace_direct_exit(void)
41{
42 unregister_ftrace_direct((unsigned long)handle_mm_fault,
43 (unsigned long)my_tramp);
44}
45
46module_init(ftrace_direct_init);
47module_exit(ftrace_direct_exit);
48
49MODULE_AUTHOR("Steven Rostedt");
50MODULE_DESCRIPTION("Another example use case of using register_ftrace_direct()");
51MODULE_LICENSE("GPL");