0001
0002 #ifndef _ASM_X86_JUMP_LABEL_H
0003 #define _ASM_X86_JUMP_LABEL_H
0004
0005 #define HAVE_JUMP_LABEL_BATCH
0006
0007 #include <asm/asm.h>
0008 #include <asm/nops.h>
0009
0010 #ifndef __ASSEMBLY__
0011
0012 #include <linux/stringify.h>
0013 #include <linux/types.h>
0014
0015 #define JUMP_TABLE_ENTRY \
0016 ".pushsection __jump_table, \"aw\" \n\t" \
0017 _ASM_ALIGN "\n\t" \
0018 ".long 1b - . \n\t" \
0019 ".long %l[l_yes] - . \n\t" \
0020 _ASM_PTR "%c0 + %c1 - .\n\t" \
0021 ".popsection \n\t"
0022
0023 #ifdef CONFIG_HAVE_JUMP_LABEL_HACK
0024
0025 static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
0026 {
0027 asm_volatile_goto("1:"
0028 "jmp %l[l_yes] # objtool NOPs this \n\t"
0029 JUMP_TABLE_ENTRY
0030 : : "i" (key), "i" (2 | branch) : : l_yes);
0031
0032 return false;
0033 l_yes:
0034 return true;
0035 }
0036
0037 #else
0038
0039 static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch)
0040 {
0041 asm_volatile_goto("1:"
0042 ".byte " __stringify(BYTES_NOP5) "\n\t"
0043 JUMP_TABLE_ENTRY
0044 : : "i" (key), "i" (branch) : : l_yes);
0045
0046 return false;
0047 l_yes:
0048 return true;
0049 }
0050
0051 #endif
0052
0053 static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch)
0054 {
0055 asm_volatile_goto("1:"
0056 "jmp %l[l_yes]\n\t"
0057 JUMP_TABLE_ENTRY
0058 : : "i" (key), "i" (branch) : : l_yes);
0059
0060 return false;
0061 l_yes:
0062 return true;
0063 }
0064
0065 extern int arch_jump_entry_size(struct jump_entry *entry);
0066
0067 #endif
0068
0069 #endif