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