12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2ac5f89c7SMichael Ellerman #ifndef _ASM_POWERPC_JUMP_LABEL_H 3ac5f89c7SMichael Ellerman #define _ASM_POWERPC_JUMP_LABEL_H 4ac5f89c7SMichael Ellerman 5ac5f89c7SMichael Ellerman /* 6ac5f89c7SMichael Ellerman * Copyright 2010 Michael Ellerman, IBM Corp. 7ac5f89c7SMichael Ellerman */ 8ac5f89c7SMichael Ellerman 9cc1adb5fSAnton Blanchard #ifndef __ASSEMBLY__ 10ac5f89c7SMichael Ellerman #include <linux/types.h> 11ac5f89c7SMichael Ellerman 12ac5f89c7SMichael Ellerman #include <asm/feature-fixups.h> 13ec0c464cSChristophe Leroy #include <asm/asm-const.h> 14ac5f89c7SMichael Ellerman 15ac5f89c7SMichael Ellerman #define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG) 16ac5f89c7SMichael Ellerman #define JUMP_LABEL_NOP_SIZE 4 17ac5f89c7SMichael Ellerman 1811276d53SPeter Zijlstra static __always_inline bool arch_static_branch(struct static_key *key, bool branch) 19ac5f89c7SMichael Ellerman { 203f0116c3SIngo Molnar asm_volatile_goto("1:\n\t" 21e2985fd9SMichael Ellerman "nop # arch_static_branch\n\t" 22ac5f89c7SMichael Ellerman ".pushsection __jump_table, \"aw\"\n\t" 23b0b3b2c7SChristophe Leroy ".long 1b - ., %l[l_yes] - .\n\t" 24b0b3b2c7SChristophe Leroy JUMP_ENTRY_TYPE "%c0 - .\n\t" 25ac5f89c7SMichael Ellerman ".popsection \n\t" 2611276d53SPeter Zijlstra : : "i" (&((char *)key)[branch]) : : l_yes); 2711276d53SPeter Zijlstra 2811276d53SPeter Zijlstra return false; 2911276d53SPeter Zijlstra l_yes: 3011276d53SPeter Zijlstra return true; 3111276d53SPeter Zijlstra } 3211276d53SPeter Zijlstra 3311276d53SPeter Zijlstra static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch) 3411276d53SPeter Zijlstra { 3511276d53SPeter Zijlstra asm_volatile_goto("1:\n\t" 36e2985fd9SMichael Ellerman "b %l[l_yes] # arch_static_branch_jump\n\t" 3711276d53SPeter Zijlstra ".pushsection __jump_table, \"aw\"\n\t" 38b0b3b2c7SChristophe Leroy ".long 1b - ., %l[l_yes] - .\n\t" 39b0b3b2c7SChristophe Leroy JUMP_ENTRY_TYPE "%c0 - .\n\t" 4011276d53SPeter Zijlstra ".popsection \n\t" 4111276d53SPeter Zijlstra : : "i" (&((char *)key)[branch]) : : l_yes); 4211276d53SPeter Zijlstra 43ac5f89c7SMichael Ellerman return false; 44ac5f89c7SMichael Ellerman l_yes: 45ac5f89c7SMichael Ellerman return true; 46ac5f89c7SMichael Ellerman } 47ac5f89c7SMichael Ellerman 48cc1adb5fSAnton Blanchard #else 49cc1adb5fSAnton Blanchard #define ARCH_STATIC_BRANCH(LABEL, KEY) \ 50cc1adb5fSAnton Blanchard 1098: nop; \ 51cc1adb5fSAnton Blanchard .pushsection __jump_table, "aw"; \ 52b0b3b2c7SChristophe Leroy .long 1098b - ., LABEL - .; \ 53*478036c4SMichael Ellerman FTR_ENTRY_LONG KEY - .; \ 54cc1adb5fSAnton Blanchard .popsection 55cc1adb5fSAnton Blanchard #endif 56cc1adb5fSAnton Blanchard 57ac5f89c7SMichael Ellerman #endif /* _ASM_POWERPC_JUMP_LABEL_H */ 58