Fix: Disable IBT around indirect function calls
[lttng-modules.git] / include / wrapper / kallsyms.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9f36eaed 2 *
886d51a3 3 * wrapper/kallsyms.h
cab3c961
AS
4 *
5 * wrapper around kallsyms_lookup_name. Implements arch-dependent code for
6 * arches where the address of the start of the function body is different
7 * from the pointer which can be used to call the function, e.g. ARM THUMB2.
8 *
886d51a3
MD
9 * Copyright (C) 2011 Avik Sil (avik.sil@linaro.org)
10 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
cab3c961
AS
11 */
12
9f36eaed
MJ
13#ifndef _LTTNG_WRAPPER_KALLSYMS_H
14#define _LTTNG_WRAPPER_KALLSYMS_H
15
f6566a02 16#include <linux/kallsyms.h>
5f4c791e 17#include <lttng/kernel-version.h>
f6566a02 18
92e2c5fe
MD
19#include <wrapper/ibt.h>
20
47af6022
MJ
21/* CONFIG_PPC64_ELF_ABI_V1/V2 were introduced in v5.19 */
22#if defined(CONFIG_PPC64_ELF_ABI_V2) || (defined(CONFIG_PPC64) && defined(CONFIG_CPU_LITTLE_ENDIAN))
23#define LTTNG_CONFIG_PPC64_ELF_ABI_V2
24#endif
25#if defined(CONFIG_PPC64_ELF_ABI_V1) || (defined(CONFIG_PPC64) && defined(CONFIG_CPU_BIG_ENDIAN))
26#define LTTNG_CONFIG_PPC64_ELF_ABI_V1
27#endif
28
43a2a0fa
MD
29/*
30 * PowerPC ABIv1 needs KALLSYMS_ALL to get the function descriptor,
31 * which is needed to perform the function call.
32 */
47af6022 33#ifdef LTTNG_CONFIG_PPC64_ELF_ABI_V1
43a2a0fa
MD
34# ifndef CONFIG_KALLSYMS_ALL
35# error "LTTng-modules requires CONFIG_KALLSYMS_ALL on PowerPC ABIv1"
36# endif
37#endif
38
5f4c791e 39#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,7,0))
a6576540
MD
40
41unsigned long wrapper_kallsyms_lookup_name(const char *name);
42
5f4c791e 43#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,7,0)) */
a6576540
MD
44
45static inline
46unsigned long wrapper_kallsyms_lookup_name(const char *name)
47{
48 return kallsyms_lookup_name(name);
49}
50
5f4c791e 51#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,7,0)) */
a6576540 52
cab3c961
AS
53static inline
54unsigned long kallsyms_lookup_funcptr(const char *name)
55{
56 unsigned long addr;
57
a6576540 58 addr = wrapper_kallsyms_lookup_name(name);
bb304164 59#if defined(CONFIG_ARM) && defined(CONFIG_THUMB2_KERNEL)
cab3c961
AS
60 if (addr)
61 addr |= 1; /* set bit 0 in address for thumb mode */
cab3c961
AS
62#endif
63 return addr;
64}
42d9070d
AG
65
66static inline
67unsigned long kallsyms_lookup_dataptr(const char *name)
68{
a6576540 69 return wrapper_kallsyms_lookup_name(name);
42d9070d 70}
a6576540 71
a90917c3 72#endif /* _LTTNG_WRAPPER_KALLSYMS_H */
This page took 0.056305 seconds and 4 git commands to generate.