]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/linux/indirect_call_wrapper.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_INDIRECT_CALL_WRAPPER_H
3 #define _LINUX_INDIRECT_CALL_WRAPPER_H
5 #ifdef CONFIG_RETPOLINE
8 * INDIRECT_CALL_$NR - wrapper for indirect calls with $NR known builtin
10 * @f$NR: builtin functions names, up to $NR of them
11 * @__VA_ARGS__: arguments for @f
13 * Avoid retpoline overhead for known builtin, checking @f vs each of them and
14 * eventually invoking directly the builtin function. The functions are check
15 * in the given order. Fallback to the indirect call.
17 #define INDIRECT_CALL_1(f, f1, ...) \
19 likely(f == f1) ? f1(__VA_ARGS__) : f(__VA_ARGS__); \
21 #define INDIRECT_CALL_2(f, f2, f1, ...) \
23 likely(f == f2) ? f2(__VA_ARGS__) : \
24 INDIRECT_CALL_1(f, f1, __VA_ARGS__); \
27 #define INDIRECT_CALLABLE_DECLARE(f) f
28 #define INDIRECT_CALLABLE_SCOPE
31 #define INDIRECT_CALL_1(f, f1, ...) f(__VA_ARGS__)
32 #define INDIRECT_CALL_2(f, f2, f1, ...) f(__VA_ARGS__)
33 #define INDIRECT_CALLABLE_DECLARE(f)
34 #define INDIRECT_CALLABLE_SCOPE static
38 * We can use INDIRECT_CALL_$NR for ipv6 related functions only if ipv6 is
39 * builtin, this macro simplify dealing with indirect calls with only ipv4/ipv6
42 #if IS_BUILTIN(CONFIG_IPV6)
43 #define INDIRECT_CALL_INET(f, f2, f1, ...) \
44 INDIRECT_CALL_2(f, f2, f1, __VA_ARGS__)
45 #elif IS_ENABLED(CONFIG_INET)
46 #define INDIRECT_CALL_INET(f, f2, f1, ...) INDIRECT_CALL_1(f, f1, __VA_ARGS__)
48 #define INDIRECT_CALL_INET(f, f2, f1, ...) f(__VA_ARGS__)