1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_JUMP_LABEL_H
3 #define _ASM_X86_JUMP_LABEL_H
5 #define HAVE_JUMP_LABEL_BATCH
7 #define JUMP_LABEL_NOP_SIZE 5
14 #include <linux/stringify.h>
15 #include <linux/types.h>
17 static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch)
19 asm_volatile_goto("1:"
20 ".byte " __stringify(BYTES_NOP5) "\n\t"
21 ".pushsection __jump_table, \"aw\" \n\t"
23 ".long 1b - ., %l[l_yes] - . \n\t"
24 _ASM_PTR "%c0 + %c1 - .\n\t"
26 : : "i" (key), "i" (branch) : : l_yes);
33 static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch)
35 asm_volatile_goto("1:"
36 ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
38 ".pushsection __jump_table, \"aw\" \n\t"
40 ".long 1b - ., %l[l_yes] - . \n\t"
41 _ASM_PTR "%c0 + %c1 - .\n\t"
43 : : "i" (key), "i" (branch) : : l_yes);
50 #else /* __ASSEMBLY__ */
52 .macro STATIC_JUMP_IF_TRUE target, key, def
55 /* Equivalent to "jmp.d32 \target" */
57 .long \target - .Lstatic_jump_after_\@
58 .Lstatic_jump_after_\@:
62 .pushsection __jump_table, "aw"
64 .long .Lstatic_jump_\@ - ., \target - .
69 .macro STATIC_JUMP_IF_FALSE target, key, def
74 /* Equivalent to "jmp.d32 \target" */
76 .long \target - .Lstatic_jump_after_\@
77 .Lstatic_jump_after_\@:
79 .pushsection __jump_table, "aw"
81 .long .Lstatic_jump_\@ - ., \target - .
86 #endif /* __ASSEMBLY__ */