iwlwifi: mvm: fix version check for GEO_TX_POWER_LIMIT support
[linux/fpc-iii.git] / arch / x86 / include / asm / jump_label.h
blob7010e1c594c435889dc3d623e1e082dbd5fb4bc4
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
7 #ifdef CONFIG_X86_64
8 # define STATIC_KEY_INIT_NOP P6_NOP5_ATOMIC
9 #else
10 # define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC
11 #endif
13 #include <asm/asm.h>
14 #include <asm/nops.h>
16 #ifndef __ASSEMBLY__
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"
26 _ASM_ALIGN "\n\t"
27 _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
28 ".popsection \n\t"
29 : : "i" (key), "i" (branch) : : l_yes);
31 return false;
32 l_yes:
33 return true;
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"
40 "2:\n\t"
41 ".pushsection __jump_table, \"aw\" \n\t"
42 _ASM_ALIGN "\n\t"
43 _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
44 ".popsection \n\t"
45 : : "i" (key), "i" (branch) : : l_yes);
47 return false;
48 l_yes:
49 return true;
52 #ifdef CONFIG_X86_64
53 typedef u64 jump_label_t;
54 #else
55 typedef u32 jump_label_t;
56 #endif
58 struct jump_entry {
59 jump_label_t code;
60 jump_label_t target;
61 jump_label_t key;
64 #else /* __ASSEMBLY__ */
66 .macro STATIC_JUMP_IF_TRUE target, key, def
67 .Lstatic_jump_\@:
68 .if \def
69 /* Equivalent to "jmp.d32 \target" */
70 .byte 0xe9
71 .long \target - .Lstatic_jump_after_\@
72 .Lstatic_jump_after_\@:
73 .else
74 .byte STATIC_KEY_INIT_NOP
75 .endif
76 .pushsection __jump_table, "aw"
77 _ASM_ALIGN
78 _ASM_PTR .Lstatic_jump_\@, \target, \key
79 .popsection
80 .endm
82 .macro STATIC_JUMP_IF_FALSE target, key, def
83 .Lstatic_jump_\@:
84 .if \def
85 .byte STATIC_KEY_INIT_NOP
86 .else
87 /* Equivalent to "jmp.d32 \target" */
88 .byte 0xe9
89 .long \target - .Lstatic_jump_after_\@
90 .Lstatic_jump_after_\@:
91 .endif
92 .pushsection __jump_table, "aw"
93 _ASM_ALIGN
94 _ASM_PTR .Lstatic_jump_\@, \target, \key + 1
95 .popsection
96 .endm
98 #endif /* __ASSEMBLY__ */
100 #endif