Commit | Line | Data |
---|---|---|
d9f5ab7b JB |
1 | #ifndef _ASM_X86_JUMP_LABEL_H |
2 | #define _ASM_X86_JUMP_LABEL_H | |
3 | ||
4 | #ifdef __KERNEL__ | |
5 | ||
c3c7f14a | 6 | #include <linux/stringify.h> |
d9f5ab7b JB |
7 | #include <linux/types.h> |
8 | #include <asm/nops.h> | |
d430d3d7 | 9 | #include <asm/asm.h> |
d9f5ab7b JB |
10 | |
11 | #define JUMP_LABEL_NOP_SIZE 5 | |
12 | ||
c3c7f14a SR |
13 | #ifdef CONFIG_X86_64 |
14 | # define STATIC_KEY_INIT_NOP P6_NOP5_ATOMIC | |
15 | #else | |
16 | # define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC | |
17 | #endif | |
d430d3d7 | 18 | |
c5905afb | 19 | static __always_inline bool arch_static_branch(struct static_key *key) |
d430d3d7 | 20 | { |
3f0116c3 | 21 | asm_volatile_goto("1:" |
c3c7f14a | 22 | ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" |
d430d3d7 | 23 | ".pushsection __jump_table, \"aw\" \n\t" |
ef647894 | 24 | _ASM_ALIGN "\n\t" |
d430d3d7 JB |
25 | _ASM_PTR "1b, %l[l_yes], %c0 \n\t" |
26 | ".popsection \n\t" | |
27 | : : "i" (key) : : l_yes); | |
28 | return false; | |
29 | l_yes: | |
30 | return true; | |
31 | } | |
d9f5ab7b JB |
32 | |
33 | #endif /* __KERNEL__ */ | |
34 | ||
35 | #ifdef CONFIG_X86_64 | |
d9f5ab7b | 36 | typedef u64 jump_label_t; |
d9f5ab7b | 37 | #else |
d9f5ab7b | 38 | typedef u32 jump_label_t; |
95fccd46 | 39 | #endif |
d9f5ab7b JB |
40 | |
41 | struct jump_entry { | |
42 | jump_label_t code; | |
43 | jump_label_t target; | |
44 | jump_label_t key; | |
45 | }; | |
46 | ||
47 | #endif |