Namespace kernel version macros
[lttng-modules.git] / include / wrapper / tracepoint.h
CommitLineData
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
5f4c791e 13#include <lttng/kernel-version.h>
3a523f5b 14#include <linux/tracepoint.h>
dd8d5afb 15#include <linux/module.h>
3a523f5b 16
5f4c791e 17#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0))
0116245f
MJ
18#define LTTNG_DEFINE_TRACE(name, proto, args) \
19 DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
20#else
21#define LTTNG_DEFINE_TRACE(name, proto, args) \
22 DEFINE_TRACE(name)
23#endif
24
3a523f5b
MD
25#ifndef HAVE_KABI_2635_TRACEPOINT
26
27#define kabi_2635_tracepoint_probe_register tracepoint_probe_register
28#define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
3a523f5b
MD
29
30#endif /* HAVE_KABI_2635_TRACEPOINT */
31
5f4c791e 32#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0))
20591cf7 33
2df37e95 34#include <lttng/tracepoint.h>
20591cf7
MD
35
36#define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
37#define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
38
5f4c791e 39#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) */
20591cf7
MD
40
41#define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
42#define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
43
44static inline
45int lttng_tracepoint_init(void)
46{
47 return 0;
48}
49
50static inline
51void lttng_tracepoint_exit(void)
52{
53}
54
5f4c791e 55#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,15,0)) */
20591cf7 56
5f4c791e 57#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG))
dd8d5afb
MD
58
59#include <linux/kallsyms.h>
5a2f5e92 60#include <wrapper/kallsyms.h>
dd8d5afb
MD
61
62static inline
63int wrapper_tracepoint_module_notify(struct notifier_block *nb,
64 unsigned long val, struct module *mod)
65{
66 int (*tracepoint_module_notify_sym)(struct notifier_block *nb,
67 unsigned long val, struct module *mod);
68
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);
73 } else {
e36de50d 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");
dd8d5afb
MD
75 return -ENOSYS;
76 }
77}
78
3dfec228
MJ
79/*
80 * No canary for 'tracepoint_module_notify()', it's only defined in 'kernel/tracepoint.c'.
81 *
82 * static inline
83 * int __canary__tracepoint_module_notify(struct notifier_block *nb,
84 * unsigned long val, struct module *mod)
85 * {
86 * return tracepoint_module_notify(nb, val, mod);
87 * }
88 */
89
5f4c791e 90#endif /* #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */
0147ae64 91
5f4c791e 92#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE))
0147ae64 93
dd8d5afb
MD
94static inline
95int wrapper_lttng_fixup_sig(struct module *mod)
96{
97 int ret = 0;
98
99 /*
100 * This is for module.c confusing force loaded modules with
101 * unsigned modules.
102 */
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);
109 }
110 return ret;
111}
112
5f4c791e 113#else /* #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
dd8d5afb
MD
114
115static inline
116int wrapper_lttng_fixup_sig(struct module *mod)
117{
118 return 0;
119}
120
5f4c791e 121#endif /* #else #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
dd8d5afb 122
5f4c791e 123#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0))
c1b0a625
MD
124static inline struct tracepoint *lttng_tracepoint_ptr_deref(tracepoint_ptr_t *p)
125{
126 return tracepoint_ptr_deref(p);
127}
5f4c791e 128#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0)) */
61259e63 129static inline struct tracepoint *lttng_tracepoint_ptr_deref(struct tracepoint * const *p)
c1b0a625
MD
130{
131 return *p;
132}
5f4c791e 133#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,19,0)) */
c1b0a625 134
3a523f5b 135#endif /* _LTTNG_WRAPPER_TRACEPOINT_H */
This page took 0.046861 seconds and 4 git commands to generate.