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