Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_S390_JUMP_LABEL_H
0003 #define _ASM_S390_JUMP_LABEL_H
0004 
0005 #define HAVE_JUMP_LABEL_BATCH
0006 
0007 #ifndef __ASSEMBLY__
0008 
0009 #include <linux/types.h>
0010 #include <linux/stringify.h>
0011 
0012 #define JUMP_LABEL_NOP_SIZE 6
0013 
0014 #ifdef CONFIG_CC_IS_CLANG
0015 #define JUMP_LABEL_STATIC_KEY_CONSTRAINT "i"
0016 #elif __GNUC__ < 9
0017 #define JUMP_LABEL_STATIC_KEY_CONSTRAINT "X"
0018 #else
0019 #define JUMP_LABEL_STATIC_KEY_CONSTRAINT "jdd"
0020 #endif
0021 
0022 /*
0023  * We use a brcl 0,<offset> instruction for jump labels so it
0024  * can be easily distinguished from a hotpatch generated instruction.
0025  */
0026 static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
0027 {
0028     asm_volatile_goto("0:   brcl 0,%l[label]\n"
0029               ".pushsection __jump_table,\"aw\"\n"
0030               ".balign  8\n"
0031               ".long    0b-.,%l[label]-.\n"
0032               ".quad    %0+%1-.\n"
0033               ".popsection\n"
0034               : : JUMP_LABEL_STATIC_KEY_CONSTRAINT (key), "i" (branch) : : label);
0035     return false;
0036 label:
0037     return true;
0038 }
0039 
0040 static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
0041 {
0042     asm_volatile_goto("0:   brcl 15,%l[label]\n"
0043               ".pushsection __jump_table,\"aw\"\n"
0044               ".balign  8\n"
0045               ".long    0b-.,%l[label]-.\n"
0046               ".quad    %0+%1-.\n"
0047               ".popsection\n"
0048               : : JUMP_LABEL_STATIC_KEY_CONSTRAINT (key), "i" (branch) : : label);
0049     return false;
0050 label:
0051     return true;
0052 }
0053 
0054 #endif  /* __ASSEMBLY__ */
0055 #endif