Loading...
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * arch/arm/probes/decode-thumb.h
4 *
5 * Copyright 2013 Linaro Ltd.
6 * Written by: David A. Long
7 */
8
9#ifndef _ARM_KERNEL_PROBES_THUMB_H
10#define _ARM_KERNEL_PROBES_THUMB_H
11
12#include "decode.h"
13
14/*
15 * True if current instruction is in an IT block.
16 */
17#define in_it_block(cpsr) ((cpsr & 0x06000c00) != 0x00000000)
18
19/*
20 * Return the condition code to check for the currently executing instruction.
21 * This is in ITSTATE<7:4> which is in CPSR<15:12> but is only valid if
22 * in_it_block returns true.
23 */
24#define current_cond(cpsr) ((cpsr >> 12) & 0xf)
25
26enum probes_t32_action {
27 PROBES_T32_EMULATE_NONE,
28 PROBES_T32_SIMULATE_NOP,
29 PROBES_T32_LDMSTM,
30 PROBES_T32_LDRDSTRD,
31 PROBES_T32_TABLE_BRANCH,
32 PROBES_T32_TST,
33 PROBES_T32_CMP,
34 PROBES_T32_MOV,
35 PROBES_T32_ADDSUB,
36 PROBES_T32_LOGICAL,
37 PROBES_T32_ADDWSUBW_PC,
38 PROBES_T32_ADDWSUBW,
39 PROBES_T32_MOVW,
40 PROBES_T32_SAT,
41 PROBES_T32_BITFIELD,
42 PROBES_T32_SEV,
43 PROBES_T32_WFE,
44 PROBES_T32_MRS,
45 PROBES_T32_BRANCH_COND,
46 PROBES_T32_BRANCH,
47 PROBES_T32_PLDI,
48 PROBES_T32_LDR_LIT,
49 PROBES_T32_LDRSTR,
50 PROBES_T32_SIGN_EXTEND,
51 PROBES_T32_MEDIA,
52 PROBES_T32_REVERSE,
53 PROBES_T32_MUL_ADD,
54 PROBES_T32_MUL_ADD2,
55 PROBES_T32_MUL_ADD_LONG,
56 NUM_PROBES_T32_ACTIONS
57};
58
59enum probes_t16_action {
60 PROBES_T16_ADD_SP,
61 PROBES_T16_CBZ,
62 PROBES_T16_SIGN_EXTEND,
63 PROBES_T16_PUSH,
64 PROBES_T16_POP,
65 PROBES_T16_SEV,
66 PROBES_T16_WFE,
67 PROBES_T16_IT,
68 PROBES_T16_CMP,
69 PROBES_T16_ADDSUB,
70 PROBES_T16_LOGICAL,
71 PROBES_T16_BLX,
72 PROBES_T16_HIREGOPS,
73 PROBES_T16_LDR_LIT,
74 PROBES_T16_LDRHSTRH,
75 PROBES_T16_LDRSTR,
76 PROBES_T16_ADR,
77 PROBES_T16_LDMSTM,
78 PROBES_T16_BRANCH_COND,
79 PROBES_T16_BRANCH,
80 NUM_PROBES_T16_ACTIONS
81};
82
83extern const union decode_item probes_decode_thumb32_table[];
84extern const union decode_item probes_decode_thumb16_table[];
85
86enum probes_insn __kprobes
87thumb16_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
88 bool emulate, const union decode_action *actions,
89 const struct decode_checker *checkers[]);
90enum probes_insn __kprobes
91thumb32_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
92 bool emulate, const union decode_action *actions,
93 const struct decode_checker *checkers[]);
94
95#endif
1/*
2 * arch/arm/probes/decode-thumb.h
3 *
4 * Copyright 2013 Linaro Ltd.
5 * Written by: David A. Long
6 *
7 * The code contained herein is licensed under the GNU General Public
8 * License. You may obtain a copy of the GNU General Public License
9 * Version 2 or later at the following locations:
10 *
11 * http://www.opensource.org/licenses/gpl-license.html
12 * http://www.gnu.org/copyleft/gpl.html
13 */
14
15#ifndef _ARM_KERNEL_PROBES_THUMB_H
16#define _ARM_KERNEL_PROBES_THUMB_H
17
18#include "decode.h"
19
20/*
21 * True if current instruction is in an IT block.
22 */
23#define in_it_block(cpsr) ((cpsr & 0x06000c00) != 0x00000000)
24
25/*
26 * Return the condition code to check for the currently executing instruction.
27 * This is in ITSTATE<7:4> which is in CPSR<15:12> but is only valid if
28 * in_it_block returns true.
29 */
30#define current_cond(cpsr) ((cpsr >> 12) & 0xf)
31
32enum probes_t32_action {
33 PROBES_T32_EMULATE_NONE,
34 PROBES_T32_SIMULATE_NOP,
35 PROBES_T32_LDMSTM,
36 PROBES_T32_LDRDSTRD,
37 PROBES_T32_TABLE_BRANCH,
38 PROBES_T32_TST,
39 PROBES_T32_CMP,
40 PROBES_T32_MOV,
41 PROBES_T32_ADDSUB,
42 PROBES_T32_LOGICAL,
43 PROBES_T32_ADDWSUBW_PC,
44 PROBES_T32_ADDWSUBW,
45 PROBES_T32_MOVW,
46 PROBES_T32_SAT,
47 PROBES_T32_BITFIELD,
48 PROBES_T32_SEV,
49 PROBES_T32_WFE,
50 PROBES_T32_MRS,
51 PROBES_T32_BRANCH_COND,
52 PROBES_T32_BRANCH,
53 PROBES_T32_PLDI,
54 PROBES_T32_LDR_LIT,
55 PROBES_T32_LDRSTR,
56 PROBES_T32_SIGN_EXTEND,
57 PROBES_T32_MEDIA,
58 PROBES_T32_REVERSE,
59 PROBES_T32_MUL_ADD,
60 PROBES_T32_MUL_ADD2,
61 PROBES_T32_MUL_ADD_LONG,
62 NUM_PROBES_T32_ACTIONS
63};
64
65enum probes_t16_action {
66 PROBES_T16_ADD_SP,
67 PROBES_T16_CBZ,
68 PROBES_T16_SIGN_EXTEND,
69 PROBES_T16_PUSH,
70 PROBES_T16_POP,
71 PROBES_T16_SEV,
72 PROBES_T16_WFE,
73 PROBES_T16_IT,
74 PROBES_T16_CMP,
75 PROBES_T16_ADDSUB,
76 PROBES_T16_LOGICAL,
77 PROBES_T16_BLX,
78 PROBES_T16_HIREGOPS,
79 PROBES_T16_LDR_LIT,
80 PROBES_T16_LDRHSTRH,
81 PROBES_T16_LDRSTR,
82 PROBES_T16_ADR,
83 PROBES_T16_LDMSTM,
84 PROBES_T16_BRANCH_COND,
85 PROBES_T16_BRANCH,
86 NUM_PROBES_T16_ACTIONS
87};
88
89extern const union decode_item probes_decode_thumb32_table[];
90extern const union decode_item probes_decode_thumb16_table[];
91
92enum probes_insn __kprobes
93thumb16_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
94 bool emulate, const union decode_action *actions,
95 const struct decode_checker *checkers[]);
96enum probes_insn __kprobes
97thumb32_probes_decode_insn(probes_opcode_t insn, struct arch_probes_insn *asi,
98 bool emulate, const union decode_action *actions,
99 const struct decode_checker *checkers[]);
100
101#endif