1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/module.h>
4 #include <linux/mm.h> /* for handle_mm_fault() */
5 #include <linux/ftrace.h>
7 extern void my_direct_func(struct vm_area_struct *vma,
8 unsigned long address, unsigned int flags);
10 void my_direct_func(struct vm_area_struct *vma,
11 unsigned long address, unsigned int flags)
13 trace_printk("handle mm fault vma=%p address=%lx flags=%x\n",
17 extern void my_tramp(void *);
20 " .pushsection .text, \"ax\", @progbits\n"
21 " .type my_tramp, @function\n"
29 " call my_direct_func\n"
35 " .size my_tramp, .-my_tramp\n"
40 static int __init ftrace_direct_init(void)
42 return register_ftrace_direct((unsigned long)handle_mm_fault,
43 (unsigned long)my_tramp);
46 static void __exit ftrace_direct_exit(void)
48 unregister_ftrace_direct((unsigned long)handle_mm_fault,
49 (unsigned long)my_tramp);
52 module_init(ftrace_direct_init);
53 module_exit(ftrace_direct_exit);
55 MODULE_AUTHOR("Steven Rostedt");
56 MODULE_DESCRIPTION("Another example use case of using register_ftrace_direct()");
57 MODULE_LICENSE("GPL");