Jason Baron | d9f5ab7 | 2010-09-17 11:09:22 -0400 | [diff] [blame] | 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> |
Jason Baron | d430d3d | 2011-03-16 17:29:47 -0400 | [diff] [blame] | 8 | #include <asm/asm.h> |
Jason Baron | d9f5ab7 | 2010-09-17 11:09:22 -0400 | [diff] [blame] | 9 | |
| 10 | #define JUMP_LABEL_NOP_SIZE 5 |
| 11 | |
Ingo Molnar | c5905af | 2012-02-24 08:31:31 +0100 | [diff] [blame] | 12 | #define STATIC_KEY_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t" |
Jason Baron | d9f5ab7 | 2010-09-17 11:09:22 -0400 | [diff] [blame] | 13 | |
Ingo Molnar | c5905af | 2012-02-24 08:31:31 +0100 | [diff] [blame] | 14 | static __always_inline bool arch_static_branch(struct static_key *key) |
Jason Baron | d430d3d | 2011-03-16 17:29:47 -0400 | [diff] [blame] | 15 | { |
| 16 | asm goto("1:" |
Ingo Molnar | c5905af | 2012-02-24 08:31:31 +0100 | [diff] [blame] | 17 | STATIC_KEY_INITIAL_NOP |
Jason Baron | d430d3d | 2011-03-16 17:29:47 -0400 | [diff] [blame] | 18 | ".pushsection __jump_table, \"aw\" \n\t" |
Jason Baron | ef64789 | 2011-03-16 15:58:27 -0400 | [diff] [blame] | 19 | _ASM_ALIGN "\n\t" |
Jason Baron | d430d3d | 2011-03-16 17:29:47 -0400 | [diff] [blame] | 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 | } |
Jason Baron | d9f5ab7 | 2010-09-17 11:09:22 -0400 | [diff] [blame] | 27 | |
| 28 | #endif /* __KERNEL__ */ |
| 29 | |
| 30 | #ifdef CONFIG_X86_64 |
Jason Baron | d9f5ab7 | 2010-09-17 11:09:22 -0400 | [diff] [blame] | 31 | typedef u64 jump_label_t; |
Jason Baron | d9f5ab7 | 2010-09-17 11:09:22 -0400 | [diff] [blame] | 32 | #else |
Jason Baron | d9f5ab7 | 2010-09-17 11:09:22 -0400 | [diff] [blame] | 33 | typedef u32 jump_label_t; |
Steven Rostedt | 95fccd4 | 2010-09-22 17:37:43 -0400 | [diff] [blame] | 34 | #endif |
Jason Baron | d9f5ab7 | 2010-09-17 11:09:22 -0400 | [diff] [blame] | 35 | |
| 36 | struct jump_entry { |
| 37 | jump_label_t code; |
| 38 | jump_label_t target; |
| 39 | jump_label_t key; |
| 40 | }; |
| 41 | |
| 42 | #endif |