Commit | Line | Data |
---|---|---|
9f36eaed MJ |
1 | /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) |
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 | ||
b78104db | 13 | #include <lttng-kernel-version.h> |
3a523f5b | 14 | #include <linux/tracepoint.h> |
dd8d5afb | 15 | #include <linux/module.h> |
3a523f5b | 16 | |
b78104db | 17 | #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(2,6,35)) |
3a523f5b MD |
18 | |
19 | #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) | |
20 | ||
21 | #endif | |
22 | ||
b78104db | 23 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0)) |
c6b31b34 MJ |
24 | #define LTTNG_DEFINE_TRACE(name, proto, args) \ |
25 | DEFINE_TRACE(name, PARAMS(proto), PARAMS(args)) | |
26 | #else | |
27 | #define LTTNG_DEFINE_TRACE(name, proto, args) \ | |
28 | DEFINE_TRACE(name) | |
29 | #endif | |
30 | ||
3a523f5b MD |
31 | #ifndef HAVE_KABI_2635_TRACEPOINT |
32 | ||
33 | #define kabi_2635_tracepoint_probe_register tracepoint_probe_register | |
34 | #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister | |
3a523f5b MD |
35 | |
36 | #endif /* HAVE_KABI_2635_TRACEPOINT */ | |
37 | ||
b78104db | 38 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) |
20591cf7 | 39 | |
5a2f5e92 | 40 | #include <lttng-tracepoint.h> |
20591cf7 MD |
41 | |
42 | #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register | |
43 | #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister | |
44 | ||
b78104db | 45 | #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) */ |
20591cf7 MD |
46 | |
47 | #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register | |
48 | #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister | |
49 | ||
50 | static inline | |
51 | int lttng_tracepoint_init(void) | |
52 | { | |
53 | return 0; | |
54 | } | |
55 | ||
56 | static inline | |
57 | void lttng_tracepoint_exit(void) | |
58 | { | |
59 | } | |
60 | ||
b78104db | 61 | #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) */ |
20591cf7 | 62 | |
b78104db | 63 | #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) |
dd8d5afb MD |
64 | |
65 | #include <linux/kallsyms.h> | |
5a2f5e92 | 66 | #include <wrapper/kallsyms.h> |
dd8d5afb MD |
67 | |
68 | static inline | |
69 | int wrapper_tracepoint_module_notify(struct notifier_block *nb, | |
70 | unsigned long val, struct module *mod) | |
71 | { | |
72 | int (*tracepoint_module_notify_sym)(struct notifier_block *nb, | |
73 | unsigned long val, struct module *mod); | |
74 | ||
75 | tracepoint_module_notify_sym = | |
76 | (void *) kallsyms_lookup_funcptr("tracepoint_module_notify"); | |
77 | if (tracepoint_module_notify_sym) { | |
78 | return tracepoint_module_notify_sym(nb, val, mod); | |
79 | } else { | |
e36de50d | 80 | 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 |
81 | return -ENOSYS; |
82 | } | |
83 | } | |
84 | ||
9e52289b MJ |
85 | /* |
86 | * No canary for 'tracepoint_module_notify()', it's only defined in 'kernel/tracepoint.c'. | |
87 | * | |
88 | * static inline | |
89 | * int __canary__tracepoint_module_notify(struct notifier_block *nb, | |
90 | * unsigned long val, struct module *mod) | |
91 | * { | |
92 | * return tracepoint_module_notify(nb, val, mod); | |
93 | * } | |
94 | */ | |
95 | ||
b78104db | 96 | #endif /* #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */ |
0147ae64 | 97 | |
b78104db | 98 | #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) |
0147ae64 | 99 | |
dd8d5afb MD |
100 | static inline |
101 | int wrapper_lttng_fixup_sig(struct module *mod) | |
102 | { | |
103 | int ret = 0; | |
104 | ||
105 | /* | |
106 | * This is for module.c confusing force loaded modules with | |
107 | * unsigned modules. | |
108 | */ | |
109 | if (!THIS_MODULE->sig_ok && | |
110 | THIS_MODULE->taints & (1U << TAINT_FORCED_MODULE)) { | |
111 | THIS_MODULE->taints &= ~(1U << TAINT_FORCED_MODULE); | |
112 | ret = wrapper_tracepoint_module_notify(NULL, | |
113 | MODULE_STATE_COMING, mod); | |
114 | THIS_MODULE->taints |= (1U << TAINT_FORCED_MODULE); | |
115 | } | |
116 | return ret; | |
117 | } | |
118 | ||
b78104db | 119 | #else /* #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */ |
dd8d5afb MD |
120 | |
121 | static inline | |
122 | int wrapper_lttng_fixup_sig(struct module *mod) | |
123 | { | |
124 | return 0; | |
125 | } | |
126 | ||
b78104db | 127 | #endif /* #else #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */ |
dd8d5afb | 128 | |
b78104db | 129 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0)) |
dd49a655 MD |
130 | static inline struct tracepoint *lttng_tracepoint_ptr_deref(tracepoint_ptr_t *p) |
131 | { | |
132 | return tracepoint_ptr_deref(p); | |
133 | } | |
b78104db | 134 | #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0)) */ |
80265be2 | 135 | static inline struct tracepoint *lttng_tracepoint_ptr_deref(struct tracepoint * const *p) |
dd49a655 MD |
136 | { |
137 | return *p; | |
138 | } | |
b78104db | 139 | #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0)) */ |
dd49a655 | 140 | |
3a523f5b | 141 | #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */ |