0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _ASM_MIPS_JUMP_LABEL_H
0009 #define _ASM_MIPS_JUMP_LABEL_H
0010
0011 #define arch_jump_label_transform_static arch_jump_label_transform
0012
0013 #ifndef __ASSEMBLY__
0014
0015 #include <linux/types.h>
0016 #include <asm/isa-rev.h>
0017
0018 #define JUMP_LABEL_NOP_SIZE 4
0019
0020 #ifdef CONFIG_64BIT
0021 #define WORD_INSN ".dword"
0022 #else
0023 #define WORD_INSN ".word"
0024 #endif
0025
0026 #ifdef CONFIG_CPU_MICROMIPS
0027 # define B_INSN "b32"
0028 # define J_INSN "j32"
0029 #elif MIPS_ISA_REV >= 6
0030 # define B_INSN "bc"
0031 # define J_INSN "bc"
0032 #else
0033 # define B_INSN "b"
0034 # define J_INSN "j"
0035 #endif
0036
0037 static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
0038 {
0039 asm_volatile_goto("1:\t" B_INSN " 2f\n\t"
0040 "2:\t.insn\n\t"
0041 ".pushsection __jump_table, \"aw\"\n\t"
0042 WORD_INSN " 1b, %l[l_yes], %0\n\t"
0043 ".popsection\n\t"
0044 : : "i" (&((char *)key)[branch]) : : l_yes);
0045
0046 return false;
0047 l_yes:
0048 return true;
0049 }
0050
0051 static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
0052 {
0053 asm_volatile_goto("1:\t" J_INSN " %l[l_yes]\n\t"
0054 ".pushsection __jump_table, \"aw\"\n\t"
0055 WORD_INSN " 1b, %l[l_yes], %0\n\t"
0056 ".popsection\n\t"
0057 : : "i" (&((char *)key)[branch]) : : l_yes);
0058
0059 return false;
0060 l_yes:
0061 return true;
0062 }
0063
0064 #ifdef CONFIG_64BIT
0065 typedef u64 jump_label_t;
0066 #else
0067 typedef u32 jump_label_t;
0068 #endif
0069
0070 struct jump_entry {
0071 jump_label_t code;
0072 jump_label_t target;
0073 jump_label_t key;
0074 };
0075
0076 #endif
0077 #endif