1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
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 <lttng/kernel-version.h>
14 #include <linux/tracepoint.h>
15 #include <linux/module.h>
17 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0))
18 #define LTTNG_DEFINE_TRACE(name, proto, args) \
19 DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
21 #define LTTNG_DEFINE_TRACE(name, proto, args) \
25 #ifndef HAVE_KABI_2635_TRACEPOINT
27 #define kabi_2635_tracepoint_probe_register tracepoint_probe_register
28 #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
30 #endif /* HAVE_KABI_2635_TRACEPOINT */
32 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0))
34 #include <lttng/tracepoint.h>
36 #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
37 #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
39 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) */
41 #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
42 #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
45 int lttng_tracepoint_init(void)
51 void lttng_tracepoint_exit(void)
55 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) */
57 #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG))
59 #include <linux/kallsyms.h>
60 #include <wrapper/kallsyms.h>
63 int wrapper_tracepoint_module_notify(struct notifier_block
*nb
,
64 unsigned long val
, struct module
*mod
)
66 int (*tracepoint_module_notify_sym
)(struct notifier_block
*nb
,
67 unsigned long val
, struct module
*mod
);
69 tracepoint_module_notify_sym
=
70 (void *) kallsyms_lookup_funcptr("tracepoint_module_notify");
71 if (tracepoint_module_notify_sym
) {
72 return tracepoint_module_notify_sym(nb
, val
, mod
);
74 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");
80 * No canary for 'tracepoint_module_notify()', it's only defined in 'kernel/tracepoint.c'.
83 * int __canary__tracepoint_module_notify(struct notifier_block *nb,
84 * unsigned long val, struct module *mod)
86 * return tracepoint_module_notify(nb, val, mod);
90 #endif /* #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */
92 #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE))
95 int wrapper_lttng_fixup_sig(struct module
*mod
)
100 * This is for module.c confusing force loaded modules with
103 if (!THIS_MODULE
->sig_ok
&&
104 THIS_MODULE
->taints
& (1U << TAINT_FORCED_MODULE
)) {
105 THIS_MODULE
->taints
&= ~(1U << TAINT_FORCED_MODULE
);
106 ret
= wrapper_tracepoint_module_notify(NULL
,
107 MODULE_STATE_COMING
, mod
);
108 THIS_MODULE
->taints
|= (1U << TAINT_FORCED_MODULE
);
113 #else /* #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
116 int wrapper_lttng_fixup_sig(struct module
*mod
)
121 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
123 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0))
124 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(tracepoint_ptr_t
*p
)
126 return tracepoint_ptr_deref(p
);
128 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0)) */
129 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(struct tracepoint
* const *p
)
133 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0)) */
135 #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */