0001
0002 #ifndef _ASM_ARC_JUMP_LABEL_H
0003 #define _ASM_ARC_JUMP_LABEL_H
0004
0005 #ifndef __ASSEMBLY__
0006
0007 #include <linux/stringify.h>
0008 #include <linux/types.h>
0009
0010 #define JUMP_LABEL_NOP_SIZE 4
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 static __always_inline bool arch_static_branch(struct static_key *key,
0032 bool branch)
0033 {
0034 asm_volatile_goto(".balign "__stringify(JUMP_LABEL_NOP_SIZE)" \n"
0035 "1: \n"
0036 "nop \n"
0037 ".pushsection __jump_table, \"aw\" \n"
0038 ".word 1b, %l[l_yes], %c0 \n"
0039 ".popsection \n"
0040 : : "i" (&((char *)key)[branch]) : : l_yes);
0041
0042 return false;
0043 l_yes:
0044 return true;
0045 }
0046
0047 static __always_inline bool arch_static_branch_jump(struct static_key *key,
0048 bool branch)
0049 {
0050 asm_volatile_goto(".balign "__stringify(JUMP_LABEL_NOP_SIZE)" \n"
0051 "1: \n"
0052 "b %l[l_yes] \n"
0053 ".pushsection __jump_table, \"aw\" \n"
0054 ".word 1b, %l[l_yes], %c0 \n"
0055 ".popsection \n"
0056 : : "i" (&((char *)key)[branch]) : : l_yes);
0057
0058 return false;
0059 l_yes:
0060 return true;
0061 }
0062
0063 typedef u32 jump_label_t;
0064
0065 struct jump_entry {
0066 jump_label_t code;
0067 jump_label_t target;
0068 jump_label_t key;
0069 };
0070
0071 #endif
0072 #endif