Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
9f36eaed | 2 | * |
3a523f5b MD |
3 | * wrapper/tracepoint.h |
4 | * | |
5 | * wrapper around DECLARE_EVENT_CLASS. | |
6 | * | |
7 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
3a523f5b MD |
8 | */ |
9 | ||
9f36eaed MJ |
10 | #ifndef _LTTNG_WRAPPER_TRACEPOINT_H |
11 | #define _LTTNG_WRAPPER_TRACEPOINT_H | |
12 | ||
3a523f5b MD |
13 | #include <linux/version.h> |
14 | #include <linux/tracepoint.h> | |
dd8d5afb | 15 | #include <linux/module.h> |
3a523f5b | 16 | |
3a523f5b MD |
17 | #ifndef HAVE_KABI_2635_TRACEPOINT |
18 | ||
19 | #define kabi_2635_tracepoint_probe_register tracepoint_probe_register | |
20 | #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister | |
3a523f5b MD |
21 | |
22 | #endif /* HAVE_KABI_2635_TRACEPOINT */ | |
23 | ||
20591cf7 MD |
24 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) |
25 | ||
2df37e95 | 26 | #include <lttng/tracepoint.h> |
20591cf7 MD |
27 | |
28 | #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register | |
29 | #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister | |
30 | ||
31 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */ | |
32 | ||
33 | #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register | |
34 | #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister | |
35 | ||
36 | static inline | |
37 | int lttng_tracepoint_init(void) | |
38 | { | |
39 | return 0; | |
40 | } | |
41 | ||
42 | static inline | |
43 | void lttng_tracepoint_exit(void) | |
44 | { | |
45 | } | |
46 | ||
47 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */ | |
48 | ||
b1152922 | 49 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) |
dd8d5afb MD |
50 | |
51 | #include <linux/kallsyms.h> | |
5a2f5e92 | 52 | #include <wrapper/kallsyms.h> |
dd8d5afb MD |
53 | |
54 | static inline | |
55 | int wrapper_tracepoint_module_notify(struct notifier_block *nb, | |
56 | unsigned long val, struct module *mod) | |
57 | { | |
58 | int (*tracepoint_module_notify_sym)(struct notifier_block *nb, | |
59 | unsigned long val, struct module *mod); | |
60 | ||
61 | tracepoint_module_notify_sym = | |
62 | (void *) kallsyms_lookup_funcptr("tracepoint_module_notify"); | |
63 | if (tracepoint_module_notify_sym) { | |
64 | return tracepoint_module_notify_sym(nb, val, mod); | |
65 | } else { | |
e36de50d | 66 | printk_once(KERN_WARNING "LTTng: tracepoint_module_notify symbol lookup failed. It probably means you kernel don't need this work-around. Please consider upgrading LTTng modules to make this warning go away.\n"); |
dd8d5afb MD |
67 | return -ENOSYS; |
68 | } | |
69 | } | |
70 | ||
b1152922 | 71 | #endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */ |
0147ae64 | 72 | |
b1152922 | 73 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) |
0147ae64 | 74 | |
dd8d5afb MD |
75 | static inline |
76 | int wrapper_lttng_fixup_sig(struct module *mod) | |
77 | { | |
78 | int ret = 0; | |
79 | ||
80 | /* | |
81 | * This is for module.c confusing force loaded modules with | |
82 | * unsigned modules. | |
83 | */ | |
84 | if (!THIS_MODULE->sig_ok && | |
85 | THIS_MODULE->taints & (1U << TAINT_FORCED_MODULE)) { | |
86 | THIS_MODULE->taints &= ~(1U << TAINT_FORCED_MODULE); | |
87 | ret = wrapper_tracepoint_module_notify(NULL, | |
88 | MODULE_STATE_COMING, mod); | |
89 | THIS_MODULE->taints |= (1U << TAINT_FORCED_MODULE); | |
90 | } | |
91 | return ret; | |
92 | } | |
93 | ||
b1152922 | 94 | #else /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */ |
dd8d5afb MD |
95 | |
96 | static inline | |
97 | int wrapper_lttng_fixup_sig(struct module *mod) | |
98 | { | |
99 | return 0; | |
100 | } | |
101 | ||
b1152922 | 102 | #endif /* #else #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */ |
dd8d5afb | 103 | |
c1b0a625 MD |
104 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) |
105 | static inline struct tracepoint *lttng_tracepoint_ptr_deref(tracepoint_ptr_t *p) | |
106 | { | |
107 | return tracepoint_ptr_deref(p); | |
108 | } | |
109 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */ | |
61259e63 | 110 | static inline struct tracepoint *lttng_tracepoint_ptr_deref(struct tracepoint * const *p) |
c1b0a625 MD |
111 | { |
112 | return *p; | |
113 | } | |
114 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */ | |
115 | ||
3a523f5b | 116 | #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */ |