Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[deliverable/linux.git] / arch / x86 / include / asm / jump_label.h
CommitLineData
d9f5ab7b
JB
1#ifndef _ASM_X86_JUMP_LABEL_H
2#define _ASM_X86_JUMP_LABEL_H
3
55dd0df7 4#ifndef __ASSEMBLY__
d9f5ab7b 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
11276d53 19static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
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"
d420acd8 25 _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
d430d3d7 26 ".popsection \n\t"
d420acd8 27 : : "i" (key), "i" (branch) : : l_yes);
11276d53
PZ
28
29 return false;
30l_yes:
31 return true;
32}
33
34static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
35{
36 asm_volatile_goto("1:"
37 ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
38 "2:\n\t"
39 ".pushsection __jump_table, \"aw\" \n\t"
40 _ASM_ALIGN "\n\t"
d420acd8 41 _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t"
11276d53 42 ".popsection \n\t"
d420acd8 43 : : "i" (key), "i" (branch) : : l_yes);
11276d53 44
d430d3d7
JB
45 return false;
46l_yes:
47 return true;
48}
d9f5ab7b 49
d9f5ab7b 50#ifdef CONFIG_X86_64
d9f5ab7b 51typedef u64 jump_label_t;
d9f5ab7b 52#else
d9f5ab7b 53typedef u32 jump_label_t;
95fccd46 54#endif
d9f5ab7b
JB
55
56struct jump_entry {
57 jump_label_t code;
58 jump_label_t target;
59 jump_label_t key;
60};
61
55dd0df7 62#endif /* __ASSEMBLY__ */
d9f5ab7b 63#endif
This page took 0.306206 seconds and 5 git commands to generate.