~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/static_call.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _ASM_STATIC_CALL_H
  3 #define _ASM_STATIC_CALL_H
  4 
  5 #include <asm/text-patching.h>
  6 
  7 /*
  8  * For CONFIG_HAVE_STATIC_CALL_INLINE, this is a temporary trampoline which
  9  * uses the current value of the key->func pointer to do an indirect jump to
 10  * the function.  This trampoline is only used during boot, before the call
 11  * sites get patched by static_call_update().  The name of this trampoline has
 12  * a magical aspect: objtool uses it to find static call sites so it can create
 13  * the .static_call_sites section.
 14  *
 15  * For CONFIG_HAVE_STATIC_CALL, this is a permanent trampoline which
 16  * does a direct jump to the function.  The direct jump gets patched by
 17  * static_call_update().
 18  *
 19  * Having the trampoline in a special section forces GCC to emit a JMP.d32 when
 20  * it does tail-call optimization on the call; since you cannot compute the
 21  * relative displacement across sections.
 22  */
 23 
 24 /*
 25  * The trampoline is 8 bytes and of the general form:
 26  *
 27  *   jmp.d32 \func
 28  *   ud1 %esp, %ecx
 29  *
 30  * That trailing #UD provides both a speculation stop and serves as a unique
 31  * 3 byte signature identifying static call trampolines. Also see tramp_ud[]
 32  * and __static_call_fixup().
 33  */
 34 #define __ARCH_DEFINE_STATIC_CALL_TRAMP(name, insns)                    \
 35         asm(".pushsection .static_call.text, \"ax\"             \n"     \
 36             ".align 4                                           \n"     \
 37             ".globl " STATIC_CALL_TRAMP_STR(name) "             \n"     \
 38             STATIC_CALL_TRAMP_STR(name) ":                      \n"     \
 39             ANNOTATE_NOENDBR                                            \
 40             insns "                                             \n"     \
 41             ".byte 0x0f, 0xb9, 0xcc                             \n"     \
 42             ".type " STATIC_CALL_TRAMP_STR(name) ", @function   \n"     \
 43             ".size " STATIC_CALL_TRAMP_STR(name) ", . - " STATIC_CALL_TRAMP_STR(name) " \n" \
 44             ".popsection                                        \n")
 45 
 46 #define ARCH_DEFINE_STATIC_CALL_TRAMP(name, func)                       \
 47         __ARCH_DEFINE_STATIC_CALL_TRAMP(name, ".byte 0xe9; .long " #func " - (. + 4)")
 48 
 49 #ifdef CONFIG_MITIGATION_RETHUNK
 50 #define ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)                        \
 51         __ARCH_DEFINE_STATIC_CALL_TRAMP(name, "jmp __x86_return_thunk")
 52 #else
 53 #define ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)                        \
 54         __ARCH_DEFINE_STATIC_CALL_TRAMP(name, "ret; int3; nop; nop; nop")
 55 #endif
 56 
 57 #define ARCH_DEFINE_STATIC_CALL_RET0_TRAMP(name)                        \
 58         ARCH_DEFINE_STATIC_CALL_TRAMP(name, __static_call_return0)
 59 
 60 #define ARCH_ADD_TRAMP_KEY(name)                                        \
 61         asm(".pushsection .static_call_tramp_key, \"a\"         \n"     \
 62             ".long " STATIC_CALL_TRAMP_STR(name) " - .          \n"     \
 63             ".long " STATIC_CALL_KEY_STR(name) " - .            \n"     \
 64             ".popsection                                        \n")
 65 
 66 extern bool __static_call_fixup(void *tramp, u8 op, void *dest);
 67 
 68 #endif /* _ASM_STATIC_CALL_H */
 69 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php