1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
5 * wrapper around DECLARE_EVENT_CLASS.
7 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #ifndef _LTTNG_WRAPPER_TRACEPOINT_H
11 #define _LTTNG_WRAPPER_TRACEPOINT_H
13 #include <linux/version.h>
14 #include <linux/tracepoint.h>
15 #include <linux/module.h>
17 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
19 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
23 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))
24 #define LTTNG_DEFINE_TRACE(name, proto, args) \
25 DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
27 #define LTTNG_DEFINE_TRACE(name, proto, args) \
31 #ifndef HAVE_KABI_2635_TRACEPOINT
33 #define kabi_2635_tracepoint_probe_register tracepoint_probe_register
34 #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
36 #endif /* HAVE_KABI_2635_TRACEPOINT */
38 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
40 #include <lttng-tracepoint.h>
42 #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
43 #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
45 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
47 #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
48 #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
51 int lttng_tracepoint_init(void)
57 void lttng_tracepoint_exit(void)
61 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
63 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG))
65 #include <linux/kallsyms.h>
66 #include <wrapper/kallsyms.h>
69 int wrapper_tracepoint_module_notify(struct notifier_block
*nb
,
70 unsigned long val
, struct module
*mod
)
72 int (*tracepoint_module_notify_sym
)(struct notifier_block
*nb
,
73 unsigned long val
, struct module
*mod
);
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
);
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");
86 * No canary for 'tracepoint_module_notify()', it's only defined in 'kernel/tracepoint.c'.
89 * int __canary__tracepoint_module_notify(struct notifier_block *nb,
90 * unsigned long val, struct module *mod)
92 * return tracepoint_module_notify(nb, val, mod);
96 #endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */
98 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE))
101 int wrapper_lttng_fixup_sig(struct module
*mod
)
106 * This is for module.c confusing force loaded modules with
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
);
119 #else /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
122 int wrapper_lttng_fixup_sig(struct module
*mod
)
127 #endif /* #else #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
129 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
130 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(tracepoint_ptr_t
*p
)
132 return tracepoint_ptr_deref(p
);
134 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
135 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(struct tracepoint
* const *p
)
139 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
141 #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */