Fix: update kvm instrumentation for Ubuntu 4.15.0-92
[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
7dd4e3c5 77#endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */
0147ae64 78
7dd4e3c5 79#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE))
0147ae64 80
dd8d5afb
MD
81static inline
82int wrapper_lttng_fixup_sig(struct module *mod)
83{
84 int ret = 0;
85
86 /*
87 * This is for module.c confusing force loaded modules with
88 * unsigned modules.
89 */
90 if (!THIS_MODULE->sig_ok &&
91 THIS_MODULE->taints & (1U << TAINT_FORCED_MODULE)) {
92 THIS_MODULE->taints &= ~(1U << TAINT_FORCED_MODULE);
93 ret = wrapper_tracepoint_module_notify(NULL,
94 MODULE_STATE_COMING, mod);
95 THIS_MODULE->taints |= (1U << TAINT_FORCED_MODULE);
96 }
97 return ret;
98}
99
7dd4e3c5 100#else /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
dd8d5afb
MD
101
102static inline
103int wrapper_lttng_fixup_sig(struct module *mod)
104{
105 return 0;
106}
107
7dd4e3c5 108#endif /* #else #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
dd8d5afb 109
dd49a655
MD
110#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
111static inline struct tracepoint *lttng_tracepoint_ptr_deref(tracepoint_ptr_t *p)
112{
113 return tracepoint_ptr_deref(p);
114}
115#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
80265be2 116static inline struct tracepoint *lttng_tracepoint_ptr_deref(struct tracepoint * const *p)
dd49a655
MD
117{
118 return *p;
119}
120#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
121
3a523f5b 122#endif /* _LTTNG_WRAPPER_TRACEPOINT_H */
This page took 0.038639 seconds and 4 git commands to generate.