diff options
Diffstat (limited to 'arch/x86/include/asm/jump_label.h')
-rw-r--r-- | arch/x86/include/asm/jump_label.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h new file mode 100644 index 000000000000..a32b18ce6ead --- /dev/null +++ b/arch/x86/include/asm/jump_label.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef _ASM_X86_JUMP_LABEL_H | ||
2 | #define _ASM_X86_JUMP_LABEL_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | #include <linux/types.h> | ||
7 | #include <asm/nops.h> | ||
8 | #include <asm/asm.h> | ||
9 | |||
10 | #define JUMP_LABEL_NOP_SIZE 5 | ||
11 | |||
12 | #define JUMP_LABEL_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t" | ||
13 | |||
14 | static __always_inline bool arch_static_branch(struct jump_label_key *key) | ||
15 | { | ||
16 | asm goto("1:" | ||
17 | JUMP_LABEL_INITIAL_NOP | ||
18 | ".pushsection __jump_table, \"aw\" \n\t" | ||
19 | _ASM_ALIGN "\n\t" | ||
20 | _ASM_PTR "1b, %l[l_yes], %c0 \n\t" | ||
21 | ".popsection \n\t" | ||
22 | : : "i" (key) : : l_yes); | ||
23 | return false; | ||
24 | l_yes: | ||
25 | return true; | ||
26 | } | ||
27 | |||
28 | #endif /* __KERNEL__ */ | ||
29 | |||
30 | #ifdef CONFIG_X86_64 | ||
31 | typedef u64 jump_label_t; | ||
32 | #else | ||
33 | typedef u32 jump_label_t; | ||
34 | #endif | ||
35 | |||
36 | struct jump_entry { | ||
37 | jump_label_t code; | ||
38 | jump_label_t target; | ||
39 | jump_label_t key; | ||
40 | }; | ||
41 | |||
42 | #endif | ||