Go to the documentation of this file.
13 #ifdef CONFIG_THUMB2_KERNEL
14 #define NORMAL_ISA "16"
16 #define NORMAL_ISA "32"
21 #define TEST_FLAG_NO_ITBLOCK (1<<0)
22 #define TEST_FLAG_FULL_ITBLOCK (1<<1)
23 #define TEST_FLAG_NARROW_INSTR (1<<2)
29 #define TEST_MEMORY_SIZE 256
48 #define ARG_TYPE_END 0
49 #define ARG_TYPE_REG 1
50 #define ARG_TYPE_PTR 2
51 #define ARG_TYPE_MEM 3
53 #define ARG_FLAG_UNSUPPORTED 0x01
54 #define ARG_FLAG_SUPPORTED 0x02
55 #define ARG_FLAG_THUMB 0x10
56 #define ARG_FLAG_ARM 0x20
101 #define verbose(fmt, ...) pr_info(fmt, ##__VA_ARGS__)
103 #define verbose(fmt, ...)
106 #define TEST_GROUP(title) \
108 verbose(title"\n"); \
109 verbose("---------------------------------------------------------\n");
111 #define TESTCASE_START(title) \
112 __asm__ __volatile__ ( \
113 "bl __kprobes_test_case_start \n\t" \
116 ".ascii "#title" \n\t" \
120 #define TEST_ARG_REG(reg, val) \
121 ".byte "__stringify(ARG_TYPE_REG)" \n\t" \
122 ".byte "#reg" \n\t" \
126 #define TEST_ARG_PTR(reg, val) \
127 ".byte "__stringify(ARG_TYPE_PTR)" \n\t" \
128 ".byte "#reg" \n\t" \
132 #define TEST_ARG_MEM(index, val) \
133 ".byte "__stringify(ARG_TYPE_MEM)" \n\t" \
134 ".byte "#index" \n\t" \
138 #define TEST_ARG_END(flags) \
139 ".byte "__stringify(ARG_TYPE_END)" \n\t" \
140 ".byte "TEST_ISA flags" \n\t" \
141 ".short 50f-0f \n\t" \
142 ".short 2f-0f \n\t" \
143 ".short 99f-0f \n\t" \
144 ".code "TEST_ISA" \n\t" \
147 #define TEST_INSTRUCTION(instruction) \
149 "1: "instruction" \n\t" \
152 #define TEST_BRANCH_F(instruction) \
153 TEST_INSTRUCTION(instruction) \
157 #define TEST_BRANCH_B(instruction) \
162 TEST_INSTRUCTION(instruction)
164 #define TEST_BRANCH_FX(instruction, codex) \
165 TEST_INSTRUCTION(instruction) \
171 #define TEST_BRANCH_BX(instruction, codex) \
177 TEST_INSTRUCTION(instruction)
179 #define TESTCASE_END \
182 " bl __kprobes_test_case_end_"TEST_ISA" \n\t" \
183 ".code "NORMAL_ISA" \n\t" \
185 : "r0", "r1", "r2", "r3", "ip", "lr", "memory", "cc" \
207 TESTCASE_START(code) \
209 TEST_INSTRUCTION(code) \
212 #define TEST_UNSUPPORTED(code) \
213 TESTCASE_START(code) \
214 TEST_ARG_END("|"__stringify(ARG_FLAG_UNSUPPORTED)) \
215 TEST_INSTRUCTION(code) \
218 #define TEST_SUPPORTED(code) \
219 TESTCASE_START(code) \
220 TEST_ARG_END("|"__stringify(ARG_FLAG_SUPPORTED)) \
221 TEST_INSTRUCTION(code) \
224 #define TEST_R(code1, reg, val, code2) \
225 TESTCASE_START(code1 #reg code2) \
226 TEST_ARG_REG(reg, val) \
228 TEST_INSTRUCTION(code1 #reg code2) \
231 #define TEST_RR(code1, reg1, val1, code2, reg2, val2, code3) \
232 TESTCASE_START(code1 #reg1 code2 #reg2 code3) \
233 TEST_ARG_REG(reg1, val1) \
234 TEST_ARG_REG(reg2, val2) \
236 TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3) \
239 #define TEST_RRR(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4)\
240 TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4) \
241 TEST_ARG_REG(reg1, val1) \
242 TEST_ARG_REG(reg2, val2) \
243 TEST_ARG_REG(reg3, val3) \
245 TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4) \
248 #define TEST_RRRR(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4, reg4, val4) \
249 TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4 #reg4) \
250 TEST_ARG_REG(reg1, val1) \
251 TEST_ARG_REG(reg2, val2) \
252 TEST_ARG_REG(reg3, val3) \
253 TEST_ARG_REG(reg4, val4) \
255 TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4 #reg4) \
258 #define TEST_P(code1, reg1, val1, code2) \
259 TESTCASE_START(code1 #reg1 code2) \
260 TEST_ARG_PTR(reg1, val1) \
262 TEST_INSTRUCTION(code1 #reg1 code2) \
265 #define TEST_PR(code1, reg1, val1, code2, reg2, val2, code3) \
266 TESTCASE_START(code1 #reg1 code2 #reg2 code3) \
267 TEST_ARG_PTR(reg1, val1) \
268 TEST_ARG_REG(reg2, val2) \
270 TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3) \
273 #define TEST_RP(code1, reg1, val1, code2, reg2, val2, code3) \
274 TESTCASE_START(code1 #reg1 code2 #reg2 code3) \
275 TEST_ARG_REG(reg1, val1) \
276 TEST_ARG_PTR(reg2, val2) \
278 TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3) \
281 #define TEST_PRR(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4)\
282 TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4) \
283 TEST_ARG_PTR(reg1, val1) \
284 TEST_ARG_REG(reg2, val2) \
285 TEST_ARG_REG(reg3, val3) \
287 TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4) \
290 #define TEST_RPR(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4)\
291 TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4) \
292 TEST_ARG_REG(reg1, val1) \
293 TEST_ARG_PTR(reg2, val2) \
294 TEST_ARG_REG(reg3, val3) \
296 TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4) \
299 #define TEST_RRP(code1, reg1, val1, code2, reg2, val2, code3, reg3, val3, code4)\
300 TESTCASE_START(code1 #reg1 code2 #reg2 code3 #reg3 code4) \
301 TEST_ARG_REG(reg1, val1) \
302 TEST_ARG_REG(reg2, val2) \
303 TEST_ARG_PTR(reg3, val3) \
305 TEST_INSTRUCTION(code1 #reg1 code2 #reg2 code3 #reg3 code4) \
308 #define TEST_BF_P(code1, reg1, val1, code2) \
309 TESTCASE_START(code1 #reg1 code2) \
310 TEST_ARG_PTR(reg1, val1) \
312 TEST_BRANCH_F(code1 #reg1 code2) \
315 #define TEST_BF(code) \
316 TESTCASE_START(code) \
318 TEST_BRANCH_F(code) \
321 #define TEST_BB(code) \
322 TESTCASE_START(code) \
324 TEST_BRANCH_B(code) \
327 #define TEST_BF_R(code1, reg, val, code2) \
328 TESTCASE_START(code1 #reg code2) \
329 TEST_ARG_REG(reg, val) \
331 TEST_BRANCH_F(code1 #reg code2) \
334 #define TEST_BB_R(code1, reg, val, code2) \
335 TESTCASE_START(code1 #reg code2) \
336 TEST_ARG_REG(reg, val) \
338 TEST_BRANCH_B(code1 #reg code2) \
341 #define TEST_BF_RR(code1, reg1, val1, code2, reg2, val2, code3) \
342 TESTCASE_START(code1 #reg1 code2 #reg2 code3) \
343 TEST_ARG_REG(reg1, val1) \
344 TEST_ARG_REG(reg2, val2) \
346 TEST_BRANCH_F(code1 #reg1 code2 #reg2 code3) \
349 #define TEST_BF_X(code, codex) \
350 TESTCASE_START(code) \
352 TEST_BRANCH_FX(code, codex) \
355 #define TEST_BB_X(code, codex) \
356 TESTCASE_START(code) \
358 TEST_BRANCH_BX(code, codex) \
361 #define TEST_BF_RX(code1, reg, val, code2, codex) \
362 TESTCASE_START(code1 #reg code2) \
363 TEST_ARG_REG(reg, val) \
365 TEST_BRANCH_FX(code1 #reg code2, codex) \
368 #define TEST_X(code, codex) \
369 TESTCASE_START(code) \
371 TEST_INSTRUCTION(code) \
376 #define TEST_RX(code1, reg, val, code2, codex) \
377 TESTCASE_START(code1 #reg code2) \
378 TEST_ARG_REG(reg, val) \
380 TEST_INSTRUCTION(code1 __stringify(reg) code2) \
385 #define TEST_RRX(code1, reg1, val1, code2, reg2, val2, code3, codex) \
386 TESTCASE_START(code1 #reg1 code2 #reg2 code3) \
387 TEST_ARG_REG(reg1, val1) \
388 TEST_ARG_REG(reg2, val2) \
390 TEST_INSTRUCTION(code1 __stringify(reg1) code2 __stringify(reg2) code3) \
403 #define SPACE_0x8 TWICE(".space 4\n\t")
404 #define SPACE_0x10 TWICE(SPACE_0x8)
405 #define SPACE_0x20 TWICE(SPACE_0x10)
406 #define SPACE_0x40 TWICE(SPACE_0x20)
407 #define SPACE_0x80 TWICE(SPACE_0x40)
408 #define SPACE_0x100 TWICE(SPACE_0x80)
409 #define SPACE_0x200 TWICE(SPACE_0x100)
410 #define SPACE_0x400 TWICE(SPACE_0x200)
411 #define SPACE_0x800 TWICE(SPACE_0x400)
412 #define SPACE_0x1000 TWICE(SPACE_0x800)
416 #define N(val) (val ^ 0xffffffff)
417 #define VAL1 0x12345678
419 #define VAL3 0xa5f801
421 #define VALM 0x456789ab
422 #define VALR 0xdeaddead
423 #define HH1 0x0123fecb
424 #define HH2 0xa9874567
427 #ifdef CONFIG_THUMB2_KERNEL