1caab277bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 29732cafdSJiang Liu /* 39732cafdSJiang Liu * Copyright (C) 2013 Huawei Ltd. 49732cafdSJiang Liu * Author: Jiang Liu <liuj97@gmail.com> 59732cafdSJiang Liu * 69732cafdSJiang Liu * Based on arch/arm/include/asm/jump_label.h 79732cafdSJiang Liu */ 89732cafdSJiang Liu #ifndef __ASM_JUMP_LABEL_H 99732cafdSJiang Liu #define __ASM_JUMP_LABEL_H 1055dd0df7SAnton Blanchard 1155dd0df7SAnton Blanchard #ifndef __ASSEMBLY__ 1255dd0df7SAnton Blanchard 139732cafdSJiang Liu #include <linux/types.h> 149732cafdSJiang Liu #include <asm/insn.h> 159732cafdSJiang Liu 169732cafdSJiang Liu #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE 179732cafdSJiang Liu arch_static_branch(struct static_key * const key,const bool branch)18efbc9578SJisheng Zhangstatic __always_inline bool arch_static_branch(struct static_key * const key, 19efbc9578SJisheng Zhang const bool branch) 209732cafdSJiang Liu { 21*aaff74d8SLinus Torvalds asm goto( 22c296146cSArd Biesheuvel "1: nop \n\t" 239732cafdSJiang Liu " .pushsection __jump_table, \"aw\" \n\t" 249732cafdSJiang Liu " .align 3 \n\t" 25c296146cSArd Biesheuvel " .long 1b - ., %l[l_yes] - . \n\t" 26c296146cSArd Biesheuvel " .quad %c0 - . \n\t" 279732cafdSJiang Liu " .popsection \n\t" 2811276d53SPeter Zijlstra : : "i"(&((char *)key)[branch]) : : l_yes); 2911276d53SPeter Zijlstra 3011276d53SPeter Zijlstra return false; 3111276d53SPeter Zijlstra l_yes: 3211276d53SPeter Zijlstra return true; 3311276d53SPeter Zijlstra } 3411276d53SPeter Zijlstra arch_static_branch_jump(struct static_key * const key,const bool branch)35efbc9578SJisheng Zhangstatic __always_inline bool arch_static_branch_jump(struct static_key * const key, 36efbc9578SJisheng Zhang const bool branch) 3711276d53SPeter Zijlstra { 38*aaff74d8SLinus Torvalds asm goto( 39c296146cSArd Biesheuvel "1: b %l[l_yes] \n\t" 4011276d53SPeter Zijlstra " .pushsection __jump_table, \"aw\" \n\t" 4111276d53SPeter Zijlstra " .align 3 \n\t" 42c296146cSArd Biesheuvel " .long 1b - ., %l[l_yes] - . \n\t" 43c296146cSArd Biesheuvel " .quad %c0 - . \n\t" 4411276d53SPeter Zijlstra " .popsection \n\t" 4511276d53SPeter Zijlstra : : "i"(&((char *)key)[branch]) : : l_yes); 469732cafdSJiang Liu 479732cafdSJiang Liu return false; 489732cafdSJiang Liu l_yes: 499732cafdSJiang Liu return true; 509732cafdSJiang Liu } 519732cafdSJiang Liu 5255dd0df7SAnton Blanchard #endif /* __ASSEMBLY__ */ 539732cafdSJiang Liu #endif /* __ASM_JUMP_LABEL_H */ 54