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 #ifndef HAVE_KABI_2635_TRACEPOINT
19 #define kabi_2635_tracepoint_probe_register tracepoint_probe_register
20 #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
22 #endif /* HAVE_KABI_2635_TRACEPOINT */
24 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
26 #include <lttng-tracepoint.h>
28 #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
29 #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
31 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
33 #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
34 #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
37 int lttng_tracepoint_init(void)
43 void lttng_tracepoint_exit(void)
47 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
49 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG))
51 #include <linux/kallsyms.h>
52 #include <wrapper/kallsyms.h>
55 int wrapper_tracepoint_module_notify(struct notifier_block
*nb
,
56 unsigned long val
, struct module
*mod
)
58 int (*tracepoint_module_notify_sym
)(struct notifier_block
*nb
,
59 unsigned long val
, struct module
*mod
);
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
);
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");
72 * No canary for 'tracepoint_module_notify()', it's only defined in 'kernel/tracepoint.c'.
75 * int __canary__tracepoint_module_notify(struct notifier_block *nb,
76 * unsigned long val, struct module *mod)
78 * return tracepoint_module_notify(nb, val, mod);
82 #endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */
84 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE))
87 int wrapper_lttng_fixup_sig(struct module
*mod
)
92 * This is for module.c confusing force loaded modules with
95 if (!THIS_MODULE
->sig_ok
&&
96 THIS_MODULE
->taints
& (1U << TAINT_FORCED_MODULE
)) {
97 THIS_MODULE
->taints
&= ~(1U << TAINT_FORCED_MODULE
);
98 ret
= wrapper_tracepoint_module_notify(NULL
,
99 MODULE_STATE_COMING
, mod
);
100 THIS_MODULE
->taints
|= (1U << TAINT_FORCED_MODULE
);
105 #else /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
108 int wrapper_lttng_fixup_sig(struct module
*mod
)
113 #endif /* #else #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
115 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
116 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(tracepoint_ptr_t
*p
)
118 return tracepoint_ptr_deref(p
);
120 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
121 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(struct tracepoint
* const *p
)
125 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
127 #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */