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 16*dd0aaa9aSWill Deacon #define HAVE_JUMP_LABEL_BATCH 179732cafdSJiang Liu #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE 189732cafdSJiang Liu arch_static_branch(struct static_key * const key,const bool branch)19efbc9578SJisheng Zhangstatic __always_inline bool arch_static_branch(struct static_key * const key, 20efbc9578SJisheng Zhang const bool branch) 219732cafdSJiang Liu { 22aaff74d8SLinus Torvalds asm goto( 23c296146cSArd Biesheuvel "1: nop \n\t" 249732cafdSJiang Liu " .pushsection __jump_table, \"aw\" \n\t" 259732cafdSJiang Liu " .align 3 \n\t" 26c296146cSArd Biesheuvel " .long 1b - ., %l[l_yes] - . \n\t" 27c296146cSArd Biesheuvel " .quad %c0 - . \n\t" 289732cafdSJiang Liu " .popsection \n\t" 2911276d53SPeter Zijlstra : : "i"(&((char *)key)[branch]) : : l_yes); 3011276d53SPeter Zijlstra 3111276d53SPeter Zijlstra return false; 3211276d53SPeter Zijlstra l_yes: 3311276d53SPeter Zijlstra return true; 3411276d53SPeter Zijlstra } 3511276d53SPeter Zijlstra arch_static_branch_jump(struct static_key * const key,const bool branch)36efbc9578SJisheng Zhangstatic __always_inline bool arch_static_branch_jump(struct static_key * const key, 37efbc9578SJisheng Zhang const bool branch) 3811276d53SPeter Zijlstra { 39aaff74d8SLinus Torvalds asm goto( 40c296146cSArd Biesheuvel "1: b %l[l_yes] \n\t" 4111276d53SPeter Zijlstra " .pushsection __jump_table, \"aw\" \n\t" 4211276d53SPeter Zijlstra " .align 3 \n\t" 43c296146cSArd Biesheuvel " .long 1b - ., %l[l_yes] - . \n\t" 44c296146cSArd Biesheuvel " .quad %c0 - . \n\t" 4511276d53SPeter Zijlstra " .popsection \n\t" 4611276d53SPeter Zijlstra : : "i"(&((char *)key)[branch]) : : l_yes); 479732cafdSJiang Liu 489732cafdSJiang Liu return false; 499732cafdSJiang Liu l_yes: 509732cafdSJiang Liu return true; 519732cafdSJiang Liu } 529732cafdSJiang Liu 5355dd0df7SAnton Blanchard #endif /* __ASSEMBLY__ */ 549732cafdSJiang Liu #endif /* __ASM_JUMP_LABEL_H */ 55