1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_JUMP_LABEL_H
3 #define _ASM_X86_JUMP_LABEL_H
5 #define JUMP_LABEL_NOP_SIZE 5
8 # define STATIC_KEY_INIT_NOP P6_NOP5_ATOMIC
10 # define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC
18 #include <linux/stringify.h>
19 #include <linux/types.h>
21 static __always_inline
bool arch_static_branch(struct static_key
*key
, bool branch
)
23 asm_volatile_goto("1:"
24 ".byte " __stringify(STATIC_KEY_INIT_NOP
) "\n\t"
25 ".pushsection __jump_table, \"aw\" \n\t"
27 _ASM_PTR
"1b, %l[l_yes], %c0 + %c1 \n\t"
29 : : "i" (key
), "i" (branch
) : : l_yes
);
36 static __always_inline
bool arch_static_branch_jump(struct static_key
*key
, bool branch
)
38 asm_volatile_goto("1:"
39 ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
41 ".pushsection __jump_table, \"aw\" \n\t"
43 _ASM_PTR
"1b, %l[l_yes], %c0 + %c1 \n\t"
45 : : "i" (key
), "i" (branch
) : : l_yes
);
53 typedef u64 jump_label_t
;
55 typedef u32 jump_label_t
;
64 #else /* __ASSEMBLY__ */
66 .macro STATIC_JUMP_IF_TRUE target
, key
, def
69 /* Equivalent to "jmp.d32 \target" */
71 .long \target
- .Lstatic_jump_after_\@
72 .Lstatic_jump_after_\@
:
74 .byte STATIC_KEY_INIT_NOP
76 .pushsection __jump_table
, "aw"
78 _ASM_PTR
.Lstatic_jump_\@
, \target
, \key
82 .macro STATIC_JUMP_IF_FALSE target
, key
, def
85 .byte STATIC_KEY_INIT_NOP
87 /* Equivalent to "jmp.d32 \target" */
89 .long \target
- .Lstatic_jump_after_\@
90 .Lstatic_jump_after_\@
:
92 .pushsection __jump_table
, "aw"
94 _ASM_PTR
.Lstatic_jump_\@
, \target
, \key
+ 1
98 #endif /* __ASSEMBLY__ */