1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_S390_JUMP_LABEL_H 3 #define _ASM_S390_JUMP_LABEL_H 4 5 #ifndef __ASSEMBLY__ 6 7 #include <linux/types.h> 8 #include <linux/stringify.h> 9 10 #define JUMP_LABEL_NOP_SIZE 6 11 #define JUMP_LABEL_NOP_OFFSET 2 12 13 /* 14 * We use a brcl 0,2 instruction for jump labels at compile time so it 15 * can be easily distinguished from a hotpatch generated instruction. 16 */ 17 static __always_inline bool arch_static_branch(struct static_key *key, bool branch) 18 { 19 asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n" 20 ".pushsection __jump_table, \"aw\"\n" 21 ".balign 8\n" 22 ".quad 0b, %l[label], %0\n" 23 ".popsection\n" 24 : : "X" (&((char *)key)[branch]) : : label); 25 26 return false; 27 label: 28 return true; 29 } 30 31 static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) 32 { 33 asm_volatile_goto("0: brcl 15, %l[label]\n" 34 ".pushsection __jump_table, \"aw\"\n" 35 ".balign 8\n" 36 ".quad 0b, %l[label], %0\n" 37 ".popsection\n" 38 : : "X" (&((char *)key)[branch]) : : label); 39 40 return false; 41 label: 42 return true; 43 } 44 45 typedef unsigned long jump_label_t; 46 47 struct jump_entry { 48 jump_label_t code; 49 jump_label_t target; 50 jump_label_t key; 51 }; 52 53 #endif /* __ASSEMBLY__ */ 54 #endif 55