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