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
10 # define STATIC_KEY_INIT_NOP P6_NOP5_ATOMIC
12 # define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC
20 #include <linux/stringify.h>
21 #include <linux/types.h>
23 static __always_inline
bool arch_static_branch(struct static_key
*key
, bool branch
)
25 asm_volatile_goto("1:"
26 ".byte " __stringify(STATIC_KEY_INIT_NOP
) "\n\t"
27 ".pushsection __jump_table, \"aw\" \n\t"
29 ".long 1b - ., %l[l_yes] - . \n\t"
30 _ASM_PTR
"%c0 + %c1 - .\n\t"
32 : : "i" (key
), "i" (branch
) : : l_yes
);
39 static __always_inline
bool arch_static_branch_jump(struct static_key
*key
, bool branch
)
41 asm_volatile_goto("1:"
42 ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
44 ".pushsection __jump_table, \"aw\" \n\t"
46 ".long 1b - ., %l[l_yes] - . \n\t"
47 _ASM_PTR
"%c0 + %c1 - .\n\t"
49 : : "i" (key
), "i" (branch
) : : l_yes
);
56 #else /* __ASSEMBLY__ */
58 .macro STATIC_JUMP_IF_TRUE target
, key
, def
61 /* Equivalent to "jmp.d32 \target" */
63 .long \target
- .Lstatic_jump_after_\@
64 .Lstatic_jump_after_\@
:
66 .byte STATIC_KEY_INIT_NOP
68 .pushsection __jump_table
, "aw"
70 .long .Lstatic_jump_\@
- ., \target
- .
75 .macro STATIC_JUMP_IF_FALSE target
, key
, def
78 .byte STATIC_KEY_INIT_NOP
80 /* Equivalent to "jmp.d32 \target" */
82 .long \target
- .Lstatic_jump_after_\@
83 .Lstatic_jump_after_\@
:
85 .pushsection __jump_table
, "aw"
87 .long .Lstatic_jump_\@
- ., \target
- .
92 #endif /* __ASSEMBLY__ */