]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - samples/ftrace/ftrace-direct-too.c
Merge tag 'efi_updates_for_v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git...
[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
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"
9d907f1a 18" .type my_tramp, @function\n"
983df5f2 19" .globl my_tramp\n"
156473a0
SRV
20" my_tramp:"
21" pushq %rbp\n"
22" movq %rsp, %rbp\n"
23" pushq %rdi\n"
24" pushq %rsi\n"
25" pushq %rdx\n"
26" call my_direct_func\n"
27" popq %rdx\n"
28" popq %rsi\n"
29" popq %rdi\n"
30" leave\n"
31" ret\n"
9d907f1a 32" .size my_tramp, .-my_tramp\n"
156473a0
SRV
33" .popsection\n"
34);
35
36
37static int __init ftrace_direct_init(void)
38{
39 return register_ftrace_direct((unsigned long)handle_mm_fault,
40 (unsigned long)my_tramp);
41}
42
43static void __exit ftrace_direct_exit(void)
44{
45 unregister_ftrace_direct((unsigned long)handle_mm_fault,
46 (unsigned long)my_tramp);
47}
48
49module_init(ftrace_direct_init);
50module_exit(ftrace_direct_exit);
51
52MODULE_AUTHOR("Steven Rostedt");
53MODULE_DESCRIPTION("Another example use case of using register_ftrace_direct()");
54MODULE_LICENSE("GPL");