]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - samples/ftrace/ftrace-direct-too.c
ftrace/samples: Add missing prototypes direct functions
[mirror_ubuntu-jammy-kernel.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
73d72bc4
JO
7extern void my_direct_func(struct vm_area_struct *vma,
8 unsigned long address, unsigned int flags);
9
156473a0
SRV
10void my_direct_func(struct vm_area_struct *vma,
11 unsigned long address, unsigned int flags)
12{
13 trace_printk("handle mm fault vma=%p address=%lx flags=%x\n",
14 vma, address, flags);
15}
16
17extern void my_tramp(void *);
18
19asm (
20" .pushsection .text, \"ax\", @progbits\n"
9d907f1a 21" .type my_tramp, @function\n"
983df5f2 22" .globl my_tramp\n"
156473a0
SRV
23" my_tramp:"
24" pushq %rbp\n"
25" movq %rsp, %rbp\n"
26" pushq %rdi\n"
27" pushq %rsi\n"
28" pushq %rdx\n"
29" call my_direct_func\n"
30" popq %rdx\n"
31" popq %rsi\n"
32" popq %rdi\n"
33" leave\n"
34" ret\n"
9d907f1a 35" .size my_tramp, .-my_tramp\n"
156473a0
SRV
36" .popsection\n"
37);
38
39
40static int __init ftrace_direct_init(void)
41{
42 return register_ftrace_direct((unsigned long)handle_mm_fault,
43 (unsigned long)my_tramp);
44}
45
46static void __exit ftrace_direct_exit(void)
47{
48 unregister_ftrace_direct((unsigned long)handle_mm_fault,
49 (unsigned long)my_tramp);
50}
51
52module_init(ftrace_direct_init);
53module_exit(ftrace_direct_exit);
54
55MODULE_AUTHOR("Steven Rostedt");
56MODULE_DESCRIPTION("Another example use case of using register_ftrace_direct()");
57MODULE_LICENSE("GPL");