This source file includes following definitions.
- arm_check_stack
- arm_check_regs_nouse
- arm_check_regs_normal
- arm_check_regs_ldmstm
- arm_check_regs_mov_ip_sp
- arm_check_regs_ldrdstrd
1
2
3
4
5
6
7
8 #include <linux/kernel.h>
9 #include "../decode.h"
10 #include "../decode-arm.h"
11 #include "checkers.h"
12
13 static enum probes_insn __kprobes arm_check_stack(probes_opcode_t insn,
14 struct arch_probes_insn *asi,
15 const struct decode_header *h)
16 {
17
18
19
20
21
22 static const union decode_item table[] = {
23
24
25
26
27
28
29
30 DECODE_OR (0x0e10000f, 0x0600000d),
31 DECODE_OR (0x0e1f0000, 0x060d0000),
32
33
34
35
36
37
38 DECODE_OR (0x0e5000bf, 0x000000bd),
39 DECODE_CUSTOM (0x0e5f00b0, 0x000d00b0, STACK_USE_UNKNOWN),
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 DECODE_CUSTOM (0x0edf0000, 0x080d0000, STACK_USE_STMDX),
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 DECODE_CUSTOM (0x0f9f0000, 0x050d0000, STACK_USE_FIXED_XXX),
74
75
76 DECODE_CUSTOM (0x0fdf00b0, 0x014d00b0, STACK_USE_FIXED_X0X),
77
78
79 DECODE_CUSTOM (0, 0, STACK_USE_NONE),
80 DECODE_END
81 };
82
83 return probes_decode_insn(insn, asi, table, false, false, stack_check_actions, NULL);
84 }
85
86 const struct decode_checker arm_stack_checker[NUM_PROBES_ARM_ACTIONS] = {
87 [PROBES_LDRSTRD] = {.checker = arm_check_stack},
88 [PROBES_STORE_EXTRA] = {.checker = arm_check_stack},
89 [PROBES_STORE] = {.checker = arm_check_stack},
90 [PROBES_LDMSTM] = {.checker = arm_check_stack},
91 };
92
93 static enum probes_insn __kprobes arm_check_regs_nouse(probes_opcode_t insn,
94 struct arch_probes_insn *asi,
95 const struct decode_header *h)
96 {
97 asi->register_usage_flags = 0;
98 return INSN_GOOD;
99 }
100
101 static enum probes_insn arm_check_regs_normal(probes_opcode_t insn,
102 struct arch_probes_insn *asi,
103 const struct decode_header *h)
104 {
105 u32 regs = h->type_regs.bits >> DECODE_TYPE_BITS;
106 int i;
107
108 asi->register_usage_flags = 0;
109 for (i = 0; i < 5; regs >>= 4, insn >>= 4, i++)
110 if (regs & 0xf)
111 asi->register_usage_flags |= 1 << (insn & 0xf);
112
113 return INSN_GOOD;
114 }
115
116
117 static enum probes_insn arm_check_regs_ldmstm(probes_opcode_t insn,
118 struct arch_probes_insn *asi,
119 const struct decode_header *h)
120 {
121 unsigned int reglist = insn & 0xffff;
122 unsigned int rn = (insn >> 16) & 0xf;
123 asi->register_usage_flags = reglist | (1 << rn);
124 return INSN_GOOD;
125 }
126
127 static enum probes_insn arm_check_regs_mov_ip_sp(probes_opcode_t insn,
128 struct arch_probes_insn *asi,
129 const struct decode_header *h)
130 {
131
132 asi->register_usage_flags = (1 << 12) | (1<< 13);
133 return INSN_GOOD;
134 }
135
136
137
138
139
140
141
142
143
144
145
146
147
148 static enum probes_insn arm_check_regs_ldrdstrd(probes_opcode_t insn,
149 struct arch_probes_insn *asi,
150 const struct decode_header *h)
151 {
152 int rdt = (insn >> 12) & 0xf;
153 arm_check_regs_normal(insn, asi, h);
154 asi->register_usage_flags |= 1 << (rdt + 1);
155 return INSN_GOOD;
156 }
157
158
159 const struct decode_checker arm_regs_checker[NUM_PROBES_ARM_ACTIONS] = {
160 [PROBES_MRS] = {.checker = arm_check_regs_normal},
161 [PROBES_SATURATING_ARITHMETIC] = {.checker = arm_check_regs_normal},
162 [PROBES_MUL1] = {.checker = arm_check_regs_normal},
163 [PROBES_MUL2] = {.checker = arm_check_regs_normal},
164 [PROBES_MUL_ADD_LONG] = {.checker = arm_check_regs_normal},
165 [PROBES_MUL_ADD] = {.checker = arm_check_regs_normal},
166 [PROBES_LOAD] = {.checker = arm_check_regs_normal},
167 [PROBES_LOAD_EXTRA] = {.checker = arm_check_regs_normal},
168 [PROBES_STORE] = {.checker = arm_check_regs_normal},
169 [PROBES_STORE_EXTRA] = {.checker = arm_check_regs_normal},
170 [PROBES_DATA_PROCESSING_REG] = {.checker = arm_check_regs_normal},
171 [PROBES_DATA_PROCESSING_IMM] = {.checker = arm_check_regs_normal},
172 [PROBES_SEV] = {.checker = arm_check_regs_nouse},
173 [PROBES_WFE] = {.checker = arm_check_regs_nouse},
174 [PROBES_SATURATE] = {.checker = arm_check_regs_normal},
175 [PROBES_REV] = {.checker = arm_check_regs_normal},
176 [PROBES_MMI] = {.checker = arm_check_regs_normal},
177 [PROBES_PACK] = {.checker = arm_check_regs_normal},
178 [PROBES_EXTEND] = {.checker = arm_check_regs_normal},
179 [PROBES_EXTEND_ADD] = {.checker = arm_check_regs_normal},
180 [PROBES_BITFIELD] = {.checker = arm_check_regs_normal},
181 [PROBES_LDMSTM] = {.checker = arm_check_regs_ldmstm},
182 [PROBES_MOV_IP_SP] = {.checker = arm_check_regs_mov_ip_sp},
183 [PROBES_LDRSTRD] = {.checker = arm_check_regs_ldrdstrd},
184 };