1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __ASM_JUMP_LABEL_H
20#define __ASM_JUMP_LABEL_H
21
22#ifndef __ASSEMBLY__
23
24#include <linux/types.h>
25#include <asm/insn.h>
26
27#define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE
28
29static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
30{
31 asm goto("1: nop\n\t"
32 ".pushsection __jump_table, \"aw\"\n\t"
33 ".align 3\n\t"
34 ".quad 1b, %l[l_yes], %c0\n\t"
35 ".popsection\n\t"
36 : : "i"(&((char *)key)[branch]) : : l_yes);
37
38 return false;
39l_yes:
40 return true;
41}
42
43static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
44{
45 asm goto("1: b %l[l_yes]\n\t"
46 ".pushsection __jump_table, \"aw\"\n\t"
47 ".align 3\n\t"
48 ".quad 1b, %l[l_yes], %c0\n\t"
49 ".popsection\n\t"
50 : : "i"(&((char *)key)[branch]) : : l_yes);
51
52 return false;
53l_yes:
54 return true;
55}
56
57typedef u64 jump_label_t;
58
59struct jump_entry {
60 jump_label_t code;
61 jump_label_t target;
62 jump_label_t key;
63};
64
65#endif
66#endif
67