This source file includes following definitions.
- arch_jump_label_transform
1
2
3
4
5
6
7
8
9 #include <linux/jump_label.h>
10 #include <linux/kernel.h>
11 #include <linux/memory.h>
12 #include <linux/mutex.h>
13 #include <linux/types.h>
14 #include <linux/cpu.h>
15
16 #include <asm/cacheflush.h>
17 #include <asm/inst.h>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #define J_ISA_BIT IS_ENABLED(CONFIG_CPU_MICROMIPS)
34 #define J_RANGE_SHIFT (2 - J_ISA_BIT)
35 #define J_RANGE_MASK ((1ul << (26 + J_RANGE_SHIFT)) - 1)
36 #define J_ALIGN_MASK ((1ul << J_RANGE_SHIFT) - 1)
37
38 void arch_jump_label_transform(struct jump_entry *e,
39 enum jump_label_type type)
40 {
41 union mips_instruction *insn_p;
42 union mips_instruction insn;
43 long offset;
44
45 insn_p = (union mips_instruction *)msk_isa16_mode(e->code);
46
47
48 BUG_ON((e->target & J_ALIGN_MASK) != J_ISA_BIT);
49
50 if (type == JUMP_LABEL_JMP) {
51 if (!IS_ENABLED(CONFIG_CPU_MICROMIPS) && MIPS_ISA_REV >= 6) {
52 offset = e->target - ((unsigned long)insn_p + 4);
53 offset >>= 2;
54
55
56
57
58
59 WARN_ON((offset >= BIT(25)) ||
60 (offset < -(long)BIT(25)));
61
62 insn.j_format.opcode = bc6_op;
63 insn.j_format.target = offset;
64 } else {
65
66
67
68
69 WARN_ON((e->target & ~J_RANGE_MASK) !=
70 ((e->code + 4) & ~J_RANGE_MASK));
71
72 insn.j_format.opcode = J_ISA_BIT ? mm_j32_op : j_op;
73 insn.j_format.target = e->target >> J_RANGE_SHIFT;
74 }
75 } else {
76 insn.word = 0;
77 }
78
79 mutex_lock(&text_mutex);
80 if (IS_ENABLED(CONFIG_CPU_MICROMIPS)) {
81 insn_p->halfword[0] = insn.word >> 16;
82 insn_p->halfword[1] = insn.word;
83 } else
84 *insn_p = insn;
85
86 flush_icache_range((unsigned long)insn_p,
87 (unsigned long)insn_p + sizeof(*insn_p));
88
89 mutex_unlock(&text_mutex);
90 }