summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/jump_label.h
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2021-05-06 22:33:56 +0300
committerIngo Molnar <mingo@kernel.org>2021-05-12 15:54:55 +0300
commite1aa35c4c4bc71e44dabc9d7d167b807edd7b439 (patch)
tree24d2087ed38ce5bdbc175f61a2d623b0158d4b33 /arch/x86/include/asm/jump_label.h
parent8bfafcdccb52e770695b12530b1f800fe98b16b1 (diff)
downloadlinux-e1aa35c4c4bc71e44dabc9d7d167b807edd7b439.tar.xz
jump_label, x86: Factor out the __jump_table generation
Both arch_static_branch() and arch_static_branch_jump() have the same blurb to generate the __jump_table entry, share it. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20210506194157.663132781@infradead.org
Diffstat (limited to 'arch/x86/include/asm/jump_label.h')
-rw-r--r--arch/x86/include/asm/jump_label.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h
index 01de21e2d967..dfdc2b1c17dd 100644
--- a/arch/x86/include/asm/jump_label.h
+++ b/arch/x86/include/asm/jump_label.h
@@ -14,15 +14,19 @@
#include <linux/stringify.h>
#include <linux/types.h>
+#define JUMP_TABLE_ENTRY \
+ ".pushsection __jump_table, \"aw\" \n\t" \
+ _ASM_ALIGN "\n\t" \
+ ".long 1b - . \n\t" \
+ ".long %l[l_yes] - . \n\t" \
+ _ASM_PTR "%c0 + %c1 - .\n\t" \
+ ".popsection \n\t"
+
static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch)
{
asm_volatile_goto("1:"
".byte " __stringify(BYTES_NOP5) "\n\t"
- ".pushsection __jump_table, \"aw\" \n\t"
- _ASM_ALIGN "\n\t"
- ".long 1b - ., %l[l_yes] - . \n\t"
- _ASM_PTR "%c0 + %c1 - .\n\t"
- ".popsection \n\t"
+ JUMP_TABLE_ENTRY
: : "i" (key), "i" (branch) : : l_yes);
return false;
@@ -33,13 +37,9 @@ l_yes:
static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch)
{
asm_volatile_goto("1:"
- ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
- "2:\n\t"
- ".pushsection __jump_table, \"aw\" \n\t"
- _ASM_ALIGN "\n\t"
- ".long 1b - ., %l[l_yes] - . \n\t"
- _ASM_PTR "%c0 + %c1 - .\n\t"
- ".popsection \n\t"
+ ".byte 0xe9 \n\t"
+ ".long %l[l_yes] - (. + 4) \n\t"
+ JUMP_TABLE_ENTRY
: : "i" (key), "i" (branch) : : l_yes);
return false;