Skip to content

Commit 588de8c

Browse files
georgejguowilldeacon
authored andcommitted
arm64: simplify arch_static_branch/_jump function
Extracted the jump table definition code from the arch_static_branch and arch_static_branch_jump functions into a macro JUMP_TABLE_ENTRY to reduce code duplication. Signed-off-by: George Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 1279e8d commit 588de8c

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

arch/arm64/include/asm/jump_label.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,23 @@
1515

1616
#define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE
1717

18+
#define JUMP_TABLE_ENTRY(key, label) \
19+
".pushsection __jump_table, \"aw\"\n\t" \
20+
".align 3\n\t" \
21+
".long 1b - ., %l["#label"] - .\n\t" \
22+
".quad %c0 - .\n\t" \
23+
".popsection\n\t" \
24+
: : "i"(key) : : label
25+
1826
static __always_inline bool arch_static_branch(struct static_key * const key,
1927
const bool branch)
2028
{
29+
char *k = &((char *)key)[branch];
30+
2131
asm goto(
2232
"1: nop \n\t"
23-
" .pushsection __jump_table, \"aw\" \n\t"
24-
" .align 3 \n\t"
25-
" .long 1b - ., %l[l_yes] - . \n\t"
26-
" .quad %c0 - . \n\t"
27-
" .popsection \n\t"
28-
: : "i"(&((char *)key)[branch]) : : l_yes);
33+
JUMP_TABLE_ENTRY(k, l_yes)
34+
);
2935

3036
return false;
3137
l_yes:
@@ -35,15 +41,11 @@ static __always_inline bool arch_static_branch(struct static_key * const key,
3541
static __always_inline bool arch_static_branch_jump(struct static_key * const key,
3642
const bool branch)
3743
{
44+
char *k = &((char *)key)[branch];
3845
asm goto(
3946
"1: b %l[l_yes] \n\t"
40-
" .pushsection __jump_table, \"aw\" \n\t"
41-
" .align 3 \n\t"
42-
" .long 1b - ., %l[l_yes] - . \n\t"
43-
" .quad %c0 - . \n\t"
44-
" .popsection \n\t"
45-
: : "i"(&((char *)key)[branch]) : : l_yes);
46-
47+
JUMP_TABLE_ENTRY(k, l_yes)
48+
);
4749
return false;
4850
l_yes:
4951
return true;

0 commit comments

Comments
 (0)