Merge tag 'hsi-for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-hsi
[sfrench/cifs-2.6.git] / arch / s390 / include / asm / jump_label.h
1 #ifndef _ASM_S390_JUMP_LABEL_H
2 #define _ASM_S390_JUMP_LABEL_H
3
4 #ifndef __ASSEMBLY__
5
6 #include <linux/types.h>
7
8 #define JUMP_LABEL_NOP_SIZE 6
9 #define JUMP_LABEL_NOP_OFFSET 2
10
11 #ifdef CONFIG_64BIT
12 #define ASM_PTR ".quad"
13 #define ASM_ALIGN ".balign 8"
14 #else
15 #define ASM_PTR ".long"
16 #define ASM_ALIGN ".balign 4"
17 #endif
18
19 /*
20  * We use a brcl 0,2 instruction for jump labels at compile time so it
21  * can be easily distinguished from a hotpatch generated instruction.
22  */
23 static __always_inline bool arch_static_branch(struct static_key *key)
24 {
25         asm_volatile_goto("0:   brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n"
26                 ".pushsection __jump_table, \"aw\"\n"
27                 ASM_ALIGN "\n"
28                 ASM_PTR " 0b, %l[label], %0\n"
29                 ".popsection\n"
30                 : : "X" (key) : : label);
31         return false;
32 label:
33         return true;
34 }
35
36 typedef unsigned long jump_label_t;
37
38 struct jump_entry {
39         jump_label_t code;
40         jump_label_t target;
41         jump_label_t key;
42 };
43
44 #endif  /* __ASSEMBLY__ */
45 #endif