David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/kernel/kprobes-thumb.c |
| 3 | * |
| 4 | * Copyright (C) 2011 Jon Medhurst <tixy@yxit.co.uk>. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/stddef.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/kprobes.h> |
| 14 | #include <linux/module.h> |
| 15 | |
| 16 | #include "kprobes.h" |
| 17 | #include "probes-thumb.h" |
| 18 | |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 19 | |
| 20 | static const union decode_item t32_table_1110_100x_x0xx[] = { |
| 21 | /* Load/store multiple instructions */ |
| 22 | |
| 23 | /* Rn is PC 1110 100x x0xx 1111 xxxx xxxx xxxx xxxx */ |
| 24 | DECODE_REJECT (0xfe4f0000, 0xe80f0000), |
| 25 | |
| 26 | /* SRS 1110 1000 00x0 xxxx xxxx xxxx xxxx xxxx */ |
| 27 | /* RFE 1110 1000 00x1 xxxx xxxx xxxx xxxx xxxx */ |
| 28 | DECODE_REJECT (0xffc00000, 0xe8000000), |
| 29 | /* SRS 1110 1001 10x0 xxxx xxxx xxxx xxxx xxxx */ |
| 30 | /* RFE 1110 1001 10x1 xxxx xxxx xxxx xxxx xxxx */ |
| 31 | DECODE_REJECT (0xffc00000, 0xe9800000), |
| 32 | |
| 33 | /* STM Rn, {...pc} 1110 100x x0x0 xxxx 1xxx xxxx xxxx xxxx */ |
| 34 | DECODE_REJECT (0xfe508000, 0xe8008000), |
| 35 | /* LDM Rn, {...lr,pc} 1110 100x x0x1 xxxx 11xx xxxx xxxx xxxx */ |
| 36 | DECODE_REJECT (0xfe50c000, 0xe810c000), |
| 37 | /* LDM/STM Rn, {...sp} 1110 100x x0xx xxxx xx1x xxxx xxxx xxxx */ |
| 38 | DECODE_REJECT (0xfe402000, 0xe8002000), |
| 39 | |
| 40 | /* STMIA 1110 1000 10x0 xxxx xxxx xxxx xxxx xxxx */ |
| 41 | /* LDMIA 1110 1000 10x1 xxxx xxxx xxxx xxxx xxxx */ |
| 42 | /* STMDB 1110 1001 00x0 xxxx xxxx xxxx xxxx xxxx */ |
| 43 | /* LDMDB 1110 1001 00x1 xxxx xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 44 | DECODE_CUSTOM (0xfe400000, 0xe8000000, PROBES_T32_LDMSTM), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 45 | |
| 46 | DECODE_END |
| 47 | }; |
| 48 | |
| 49 | static const union decode_item t32_table_1110_100x_x1xx[] = { |
| 50 | /* Load/store dual, load/store exclusive, table branch */ |
| 51 | |
| 52 | /* STRD (immediate) 1110 1000 x110 xxxx xxxx xxxx xxxx xxxx */ |
| 53 | /* LDRD (immediate) 1110 1000 x111 xxxx xxxx xxxx xxxx xxxx */ |
| 54 | DECODE_OR (0xff600000, 0xe8600000), |
| 55 | /* STRD (immediate) 1110 1001 x1x0 xxxx xxxx xxxx xxxx xxxx */ |
| 56 | /* LDRD (immediate) 1110 1001 x1x1 xxxx xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 57 | DECODE_EMULATEX (0xff400000, 0xe9400000, PROBES_T32_LDRDSTRD, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 58 | REGS(NOPCWB, NOSPPC, NOSPPC, 0, 0)), |
| 59 | |
| 60 | /* TBB 1110 1000 1101 xxxx xxxx xxxx 0000 xxxx */ |
| 61 | /* TBH 1110 1000 1101 xxxx xxxx xxxx 0001 xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 62 | DECODE_SIMULATEX(0xfff000e0, 0xe8d00000, PROBES_T32_TABLE_BRANCH, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 63 | REGS(NOSP, 0, 0, 0, NOSPPC)), |
| 64 | |
| 65 | /* STREX 1110 1000 0100 xxxx xxxx xxxx xxxx xxxx */ |
| 66 | /* LDREX 1110 1000 0101 xxxx xxxx xxxx xxxx xxxx */ |
| 67 | /* STREXB 1110 1000 1100 xxxx xxxx xxxx 0100 xxxx */ |
| 68 | /* STREXH 1110 1000 1100 xxxx xxxx xxxx 0101 xxxx */ |
| 69 | /* STREXD 1110 1000 1100 xxxx xxxx xxxx 0111 xxxx */ |
| 70 | /* LDREXB 1110 1000 1101 xxxx xxxx xxxx 0100 xxxx */ |
| 71 | /* LDREXH 1110 1000 1101 xxxx xxxx xxxx 0101 xxxx */ |
| 72 | /* LDREXD 1110 1000 1101 xxxx xxxx xxxx 0111 xxxx */ |
| 73 | /* And unallocated instructions... */ |
| 74 | DECODE_END |
| 75 | }; |
| 76 | |
| 77 | static const union decode_item t32_table_1110_101x[] = { |
| 78 | /* Data-processing (shifted register) */ |
| 79 | |
| 80 | /* TST 1110 1010 0001 xxxx xxxx 1111 xxxx xxxx */ |
| 81 | /* TEQ 1110 1010 1001 xxxx xxxx 1111 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 82 | DECODE_EMULATEX (0xff700f00, 0xea100f00, PROBES_T32_TST, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 83 | REGS(NOSPPC, 0, 0, 0, NOSPPC)), |
| 84 | |
| 85 | /* CMN 1110 1011 0001 xxxx xxxx 1111 xxxx xxxx */ |
| 86 | DECODE_OR (0xfff00f00, 0xeb100f00), |
| 87 | /* CMP 1110 1011 1011 xxxx xxxx 1111 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 88 | DECODE_EMULATEX (0xfff00f00, 0xebb00f00, PROBES_T32_TST, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 89 | REGS(NOPC, 0, 0, 0, NOSPPC)), |
| 90 | |
| 91 | /* MOV 1110 1010 010x 1111 xxxx xxxx xxxx xxxx */ |
| 92 | /* MVN 1110 1010 011x 1111 xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 93 | DECODE_EMULATEX (0xffcf0000, 0xea4f0000, PROBES_T32_MOV, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 94 | REGS(0, 0, NOSPPC, 0, NOSPPC)), |
| 95 | |
| 96 | /* ??? 1110 1010 101x xxxx xxxx xxxx xxxx xxxx */ |
| 97 | /* ??? 1110 1010 111x xxxx xxxx xxxx xxxx xxxx */ |
| 98 | DECODE_REJECT (0xffa00000, 0xeaa00000), |
| 99 | /* ??? 1110 1011 001x xxxx xxxx xxxx xxxx xxxx */ |
| 100 | DECODE_REJECT (0xffe00000, 0xeb200000), |
| 101 | /* ??? 1110 1011 100x xxxx xxxx xxxx xxxx xxxx */ |
| 102 | DECODE_REJECT (0xffe00000, 0xeb800000), |
| 103 | /* ??? 1110 1011 111x xxxx xxxx xxxx xxxx xxxx */ |
| 104 | DECODE_REJECT (0xffe00000, 0xebe00000), |
| 105 | |
| 106 | /* ADD/SUB SP, SP, Rm, LSL #0..3 */ |
| 107 | /* 1110 1011 x0xx 1101 x000 1101 xx00 xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 108 | DECODE_EMULATEX (0xff4f7f30, 0xeb0d0d00, PROBES_T32_ADDSUB, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 109 | REGS(SP, 0, SP, 0, NOSPPC)), |
| 110 | |
| 111 | /* ADD/SUB SP, SP, Rm, shift */ |
| 112 | /* 1110 1011 x0xx 1101 xxxx 1101 xxxx xxxx */ |
| 113 | DECODE_REJECT (0xff4f0f00, 0xeb0d0d00), |
| 114 | |
| 115 | /* ADD/SUB Rd, SP, Rm, shift */ |
| 116 | /* 1110 1011 x0xx 1101 xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 117 | DECODE_EMULATEX (0xff4f0000, 0xeb0d0000, PROBES_T32_ADDSUB, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 118 | REGS(SP, 0, NOPC, 0, NOSPPC)), |
| 119 | |
| 120 | /* AND 1110 1010 000x xxxx xxxx xxxx xxxx xxxx */ |
| 121 | /* BIC 1110 1010 001x xxxx xxxx xxxx xxxx xxxx */ |
| 122 | /* ORR 1110 1010 010x xxxx xxxx xxxx xxxx xxxx */ |
| 123 | /* ORN 1110 1010 011x xxxx xxxx xxxx xxxx xxxx */ |
| 124 | /* EOR 1110 1010 100x xxxx xxxx xxxx xxxx xxxx */ |
| 125 | /* PKH 1110 1010 110x xxxx xxxx xxxx xxxx xxxx */ |
| 126 | /* ADD 1110 1011 000x xxxx xxxx xxxx xxxx xxxx */ |
| 127 | /* ADC 1110 1011 010x xxxx xxxx xxxx xxxx xxxx */ |
| 128 | /* SBC 1110 1011 011x xxxx xxxx xxxx xxxx xxxx */ |
| 129 | /* SUB 1110 1011 101x xxxx xxxx xxxx xxxx xxxx */ |
| 130 | /* RSB 1110 1011 110x xxxx xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 131 | DECODE_EMULATEX (0xfe000000, 0xea000000, PROBES_T32_LOGICAL, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 132 | REGS(NOSPPC, 0, NOSPPC, 0, NOSPPC)), |
| 133 | |
| 134 | DECODE_END |
| 135 | }; |
| 136 | |
| 137 | static const union decode_item t32_table_1111_0x0x___0[] = { |
| 138 | /* Data-processing (modified immediate) */ |
| 139 | |
| 140 | /* TST 1111 0x00 0001 xxxx 0xxx 1111 xxxx xxxx */ |
| 141 | /* TEQ 1111 0x00 1001 xxxx 0xxx 1111 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 142 | DECODE_EMULATEX (0xfb708f00, 0xf0100f00, PROBES_T32_TST, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 143 | REGS(NOSPPC, 0, 0, 0, 0)), |
| 144 | |
| 145 | /* CMN 1111 0x01 0001 xxxx 0xxx 1111 xxxx xxxx */ |
| 146 | DECODE_OR (0xfbf08f00, 0xf1100f00), |
| 147 | /* CMP 1111 0x01 1011 xxxx 0xxx 1111 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 148 | DECODE_EMULATEX (0xfbf08f00, 0xf1b00f00, PROBES_T32_CMP, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 149 | REGS(NOPC, 0, 0, 0, 0)), |
| 150 | |
| 151 | /* MOV 1111 0x00 010x 1111 0xxx xxxx xxxx xxxx */ |
| 152 | /* MVN 1111 0x00 011x 1111 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 153 | DECODE_EMULATEX (0xfbcf8000, 0xf04f0000, PROBES_T32_MOV, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 154 | REGS(0, 0, NOSPPC, 0, 0)), |
| 155 | |
| 156 | /* ??? 1111 0x00 101x xxxx 0xxx xxxx xxxx xxxx */ |
| 157 | DECODE_REJECT (0xfbe08000, 0xf0a00000), |
| 158 | /* ??? 1111 0x00 110x xxxx 0xxx xxxx xxxx xxxx */ |
| 159 | /* ??? 1111 0x00 111x xxxx 0xxx xxxx xxxx xxxx */ |
| 160 | DECODE_REJECT (0xfbc08000, 0xf0c00000), |
| 161 | /* ??? 1111 0x01 001x xxxx 0xxx xxxx xxxx xxxx */ |
| 162 | DECODE_REJECT (0xfbe08000, 0xf1200000), |
| 163 | /* ??? 1111 0x01 100x xxxx 0xxx xxxx xxxx xxxx */ |
| 164 | DECODE_REJECT (0xfbe08000, 0xf1800000), |
| 165 | /* ??? 1111 0x01 111x xxxx 0xxx xxxx xxxx xxxx */ |
| 166 | DECODE_REJECT (0xfbe08000, 0xf1e00000), |
| 167 | |
| 168 | /* ADD Rd, SP, #imm 1111 0x01 000x 1101 0xxx xxxx xxxx xxxx */ |
| 169 | /* SUB Rd, SP, #imm 1111 0x01 101x 1101 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 170 | DECODE_EMULATEX (0xfb4f8000, 0xf10d0000, PROBES_T32_ADDSUB, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 171 | REGS(SP, 0, NOPC, 0, 0)), |
| 172 | |
| 173 | /* AND 1111 0x00 000x xxxx 0xxx xxxx xxxx xxxx */ |
| 174 | /* BIC 1111 0x00 001x xxxx 0xxx xxxx xxxx xxxx */ |
| 175 | /* ORR 1111 0x00 010x xxxx 0xxx xxxx xxxx xxxx */ |
| 176 | /* ORN 1111 0x00 011x xxxx 0xxx xxxx xxxx xxxx */ |
| 177 | /* EOR 1111 0x00 100x xxxx 0xxx xxxx xxxx xxxx */ |
| 178 | /* ADD 1111 0x01 000x xxxx 0xxx xxxx xxxx xxxx */ |
| 179 | /* ADC 1111 0x01 010x xxxx 0xxx xxxx xxxx xxxx */ |
| 180 | /* SBC 1111 0x01 011x xxxx 0xxx xxxx xxxx xxxx */ |
| 181 | /* SUB 1111 0x01 101x xxxx 0xxx xxxx xxxx xxxx */ |
| 182 | /* RSB 1111 0x01 110x xxxx 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 183 | DECODE_EMULATEX (0xfa008000, 0xf0000000, PROBES_T32_LOGICAL, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 184 | REGS(NOSPPC, 0, NOSPPC, 0, 0)), |
| 185 | |
| 186 | DECODE_END |
| 187 | }; |
| 188 | |
| 189 | static const union decode_item t32_table_1111_0x1x___0[] = { |
| 190 | /* Data-processing (plain binary immediate) */ |
| 191 | |
| 192 | /* ADDW Rd, PC, #imm 1111 0x10 0000 1111 0xxx xxxx xxxx xxxx */ |
| 193 | DECODE_OR (0xfbff8000, 0xf20f0000), |
| 194 | /* SUBW Rd, PC, #imm 1111 0x10 1010 1111 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 195 | DECODE_EMULATEX (0xfbff8000, 0xf2af0000, PROBES_T32_ADDWSUBW_PC, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 196 | REGS(PC, 0, NOSPPC, 0, 0)), |
| 197 | |
| 198 | /* ADDW SP, SP, #imm 1111 0x10 0000 1101 0xxx 1101 xxxx xxxx */ |
| 199 | DECODE_OR (0xfbff8f00, 0xf20d0d00), |
| 200 | /* SUBW SP, SP, #imm 1111 0x10 1010 1101 0xxx 1101 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 201 | DECODE_EMULATEX (0xfbff8f00, 0xf2ad0d00, PROBES_T32_ADDWSUBW, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 202 | REGS(SP, 0, SP, 0, 0)), |
| 203 | |
| 204 | /* ADDW 1111 0x10 0000 xxxx 0xxx xxxx xxxx xxxx */ |
| 205 | DECODE_OR (0xfbf08000, 0xf2000000), |
| 206 | /* SUBW 1111 0x10 1010 xxxx 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 207 | DECODE_EMULATEX (0xfbf08000, 0xf2a00000, PROBES_T32_ADDWSUBW, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 208 | REGS(NOPCX, 0, NOSPPC, 0, 0)), |
| 209 | |
| 210 | /* MOVW 1111 0x10 0100 xxxx 0xxx xxxx xxxx xxxx */ |
| 211 | /* MOVT 1111 0x10 1100 xxxx 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 212 | DECODE_EMULATEX (0xfb708000, 0xf2400000, PROBES_T32_MOVW, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 213 | REGS(0, 0, NOSPPC, 0, 0)), |
| 214 | |
| 215 | /* SSAT16 1111 0x11 0010 xxxx 0000 xxxx 00xx xxxx */ |
| 216 | /* SSAT 1111 0x11 00x0 xxxx 0xxx xxxx xxxx xxxx */ |
| 217 | /* USAT16 1111 0x11 1010 xxxx 0000 xxxx 00xx xxxx */ |
| 218 | /* USAT 1111 0x11 10x0 xxxx 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 219 | DECODE_EMULATEX (0xfb508000, 0xf3000000, PROBES_T32_SAT, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 220 | REGS(NOSPPC, 0, NOSPPC, 0, 0)), |
| 221 | |
| 222 | /* SFBX 1111 0x11 0100 xxxx 0xxx xxxx xxxx xxxx */ |
| 223 | /* UFBX 1111 0x11 1100 xxxx 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 224 | DECODE_EMULATEX (0xfb708000, 0xf3400000, PROBES_T32_BITFIELD, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 225 | REGS(NOSPPC, 0, NOSPPC, 0, 0)), |
| 226 | |
| 227 | /* BFC 1111 0x11 0110 1111 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 228 | DECODE_EMULATEX (0xfbff8000, 0xf36f0000, PROBES_T32_BITFIELD, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 229 | REGS(0, 0, NOSPPC, 0, 0)), |
| 230 | |
| 231 | /* BFI 1111 0x11 0110 xxxx 0xxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 232 | DECODE_EMULATEX (0xfbf08000, 0xf3600000, PROBES_T32_BITFIELD, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 233 | REGS(NOSPPCX, 0, NOSPPC, 0, 0)), |
| 234 | |
| 235 | DECODE_END |
| 236 | }; |
| 237 | |
| 238 | static const union decode_item t32_table_1111_0xxx___1[] = { |
| 239 | /* Branches and miscellaneous control */ |
| 240 | |
| 241 | /* YIELD 1111 0011 1010 xxxx 10x0 x000 0000 0001 */ |
| 242 | DECODE_OR (0xfff0d7ff, 0xf3a08001), |
| 243 | /* SEV 1111 0011 1010 xxxx 10x0 x000 0000 0100 */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 244 | DECODE_EMULATE (0xfff0d7ff, 0xf3a08004, PROBES_T32_SEV), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 245 | /* NOP 1111 0011 1010 xxxx 10x0 x000 0000 0000 */ |
| 246 | /* WFE 1111 0011 1010 xxxx 10x0 x000 0000 0010 */ |
| 247 | /* WFI 1111 0011 1010 xxxx 10x0 x000 0000 0011 */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 248 | DECODE_SIMULATE (0xfff0d7fc, 0xf3a08000, PROBES_T32_WFE), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 249 | |
| 250 | /* MRS Rd, CPSR 1111 0011 1110 xxxx 10x0 xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 251 | DECODE_SIMULATEX(0xfff0d000, 0xf3e08000, PROBES_T32_MRS, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 252 | REGS(0, 0, NOSPPC, 0, 0)), |
| 253 | |
| 254 | /* |
| 255 | * Unsupported instructions |
| 256 | * 1111 0x11 1xxx xxxx 10x0 xxxx xxxx xxxx |
| 257 | * |
| 258 | * MSR 1111 0011 100x xxxx 10x0 xxxx xxxx xxxx |
| 259 | * DBG hint 1111 0011 1010 xxxx 10x0 x000 1111 xxxx |
| 260 | * Unallocated hints 1111 0011 1010 xxxx 10x0 x000 xxxx xxxx |
| 261 | * CPS 1111 0011 1010 xxxx 10x0 xxxx xxxx xxxx |
| 262 | * CLREX/DSB/DMB/ISB 1111 0011 1011 xxxx 10x0 xxxx xxxx xxxx |
| 263 | * BXJ 1111 0011 1100 xxxx 10x0 xxxx xxxx xxxx |
| 264 | * SUBS PC,LR,#<imm8> 1111 0011 1101 xxxx 10x0 xxxx xxxx xxxx |
| 265 | * MRS Rd, SPSR 1111 0011 1111 xxxx 10x0 xxxx xxxx xxxx |
| 266 | * SMC 1111 0111 1111 xxxx 1000 xxxx xxxx xxxx |
| 267 | * UNDEFINED 1111 0111 1111 xxxx 1010 xxxx xxxx xxxx |
| 268 | * ??? 1111 0111 1xxx xxxx 1010 xxxx xxxx xxxx |
| 269 | */ |
| 270 | DECODE_REJECT (0xfb80d000, 0xf3808000), |
| 271 | |
| 272 | /* Bcc 1111 0xxx xxxx xxxx 10x0 xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 273 | DECODE_CUSTOM (0xf800d000, 0xf0008000, PROBES_T32_BRANCH_COND), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 274 | |
| 275 | /* BLX 1111 0xxx xxxx xxxx 11x0 xxxx xxxx xxx0 */ |
| 276 | DECODE_OR (0xf800d001, 0xf000c000), |
| 277 | /* B 1111 0xxx xxxx xxxx 10x1 xxxx xxxx xxxx */ |
| 278 | /* BL 1111 0xxx xxxx xxxx 11x1 xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 279 | DECODE_SIMULATE (0xf8009000, 0xf0009000, PROBES_T32_BRANCH), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 280 | |
| 281 | DECODE_END |
| 282 | }; |
| 283 | |
| 284 | static const union decode_item t32_table_1111_100x_x0x1__1111[] = { |
| 285 | /* Memory hints */ |
| 286 | |
| 287 | /* PLD (literal) 1111 1000 x001 1111 1111 xxxx xxxx xxxx */ |
| 288 | /* PLI (literal) 1111 1001 x001 1111 1111 xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 289 | DECODE_SIMULATE (0xfe7ff000, 0xf81ff000, PROBES_T32_PLDI), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 290 | |
| 291 | /* PLD{W} (immediate) 1111 1000 10x1 xxxx 1111 xxxx xxxx xxxx */ |
| 292 | DECODE_OR (0xffd0f000, 0xf890f000), |
| 293 | /* PLD{W} (immediate) 1111 1000 00x1 xxxx 1111 1100 xxxx xxxx */ |
| 294 | DECODE_OR (0xffd0ff00, 0xf810fc00), |
| 295 | /* PLI (immediate) 1111 1001 1001 xxxx 1111 xxxx xxxx xxxx */ |
| 296 | DECODE_OR (0xfff0f000, 0xf990f000), |
| 297 | /* PLI (immediate) 1111 1001 0001 xxxx 1111 1100 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 298 | DECODE_SIMULATEX(0xfff0ff00, 0xf910fc00, PROBES_T32_PLDI, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 299 | REGS(NOPCX, 0, 0, 0, 0)), |
| 300 | |
| 301 | /* PLD{W} (register) 1111 1000 00x1 xxxx 1111 0000 00xx xxxx */ |
| 302 | DECODE_OR (0xffd0ffc0, 0xf810f000), |
| 303 | /* PLI (register) 1111 1001 0001 xxxx 1111 0000 00xx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 304 | DECODE_SIMULATEX(0xfff0ffc0, 0xf910f000, PROBES_T32_PLDI, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 305 | REGS(NOPCX, 0, 0, 0, NOSPPC)), |
| 306 | |
| 307 | /* Other unallocated instructions... */ |
| 308 | DECODE_END |
| 309 | }; |
| 310 | |
| 311 | static const union decode_item t32_table_1111_100x[] = { |
| 312 | /* Store/Load single data item */ |
| 313 | |
| 314 | /* ??? 1111 100x x11x xxxx xxxx xxxx xxxx xxxx */ |
| 315 | DECODE_REJECT (0xfe600000, 0xf8600000), |
| 316 | |
| 317 | /* ??? 1111 1001 0101 xxxx xxxx xxxx xxxx xxxx */ |
| 318 | DECODE_REJECT (0xfff00000, 0xf9500000), |
| 319 | |
| 320 | /* ??? 1111 100x 0xxx xxxx xxxx 10x0 xxxx xxxx */ |
| 321 | DECODE_REJECT (0xfe800d00, 0xf8000800), |
| 322 | |
| 323 | /* STRBT 1111 1000 0000 xxxx xxxx 1110 xxxx xxxx */ |
| 324 | /* STRHT 1111 1000 0010 xxxx xxxx 1110 xxxx xxxx */ |
| 325 | /* STRT 1111 1000 0100 xxxx xxxx 1110 xxxx xxxx */ |
| 326 | /* LDRBT 1111 1000 0001 xxxx xxxx 1110 xxxx xxxx */ |
| 327 | /* LDRSBT 1111 1001 0001 xxxx xxxx 1110 xxxx xxxx */ |
| 328 | /* LDRHT 1111 1000 0011 xxxx xxxx 1110 xxxx xxxx */ |
| 329 | /* LDRSHT 1111 1001 0011 xxxx xxxx 1110 xxxx xxxx */ |
| 330 | /* LDRT 1111 1000 0101 xxxx xxxx 1110 xxxx xxxx */ |
| 331 | DECODE_REJECT (0xfe800f00, 0xf8000e00), |
| 332 | |
| 333 | /* STR{,B,H} Rn,[PC...] 1111 1000 xxx0 1111 xxxx xxxx xxxx xxxx */ |
| 334 | DECODE_REJECT (0xff1f0000, 0xf80f0000), |
| 335 | |
| 336 | /* STR{,B,H} PC,[Rn...] 1111 1000 xxx0 xxxx 1111 xxxx xxxx xxxx */ |
| 337 | DECODE_REJECT (0xff10f000, 0xf800f000), |
| 338 | |
| 339 | /* LDR (literal) 1111 1000 x101 1111 xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 340 | DECODE_SIMULATEX(0xff7f0000, 0xf85f0000, PROBES_T32_LDR_LIT, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 341 | REGS(PC, ANY, 0, 0, 0)), |
| 342 | |
| 343 | /* STR (immediate) 1111 1000 0100 xxxx xxxx 1xxx xxxx xxxx */ |
| 344 | /* LDR (immediate) 1111 1000 0101 xxxx xxxx 1xxx xxxx xxxx */ |
| 345 | DECODE_OR (0xffe00800, 0xf8400800), |
| 346 | /* STR (immediate) 1111 1000 1100 xxxx xxxx xxxx xxxx xxxx */ |
| 347 | /* LDR (immediate) 1111 1000 1101 xxxx xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 348 | DECODE_EMULATEX (0xffe00000, 0xf8c00000, PROBES_T32_LDRSTR, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 349 | REGS(NOPCX, ANY, 0, 0, 0)), |
| 350 | |
| 351 | /* STR (register) 1111 1000 0100 xxxx xxxx 0000 00xx xxxx */ |
| 352 | /* LDR (register) 1111 1000 0101 xxxx xxxx 0000 00xx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 353 | DECODE_EMULATEX (0xffe00fc0, 0xf8400000, PROBES_T32_LDRSTR, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 354 | REGS(NOPCX, ANY, 0, 0, NOSPPC)), |
| 355 | |
| 356 | /* LDRB (literal) 1111 1000 x001 1111 xxxx xxxx xxxx xxxx */ |
| 357 | /* LDRSB (literal) 1111 1001 x001 1111 xxxx xxxx xxxx xxxx */ |
| 358 | /* LDRH (literal) 1111 1000 x011 1111 xxxx xxxx xxxx xxxx */ |
| 359 | /* LDRSH (literal) 1111 1001 x011 1111 xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 360 | DECODE_SIMULATEX(0xfe5f0000, 0xf81f0000, PROBES_T32_LDR_LIT, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 361 | REGS(PC, NOSPPCX, 0, 0, 0)), |
| 362 | |
| 363 | /* STRB (immediate) 1111 1000 0000 xxxx xxxx 1xxx xxxx xxxx */ |
| 364 | /* STRH (immediate) 1111 1000 0010 xxxx xxxx 1xxx xxxx xxxx */ |
| 365 | /* LDRB (immediate) 1111 1000 0001 xxxx xxxx 1xxx xxxx xxxx */ |
| 366 | /* LDRSB (immediate) 1111 1001 0001 xxxx xxxx 1xxx xxxx xxxx */ |
| 367 | /* LDRH (immediate) 1111 1000 0011 xxxx xxxx 1xxx xxxx xxxx */ |
| 368 | /* LDRSH (immediate) 1111 1001 0011 xxxx xxxx 1xxx xxxx xxxx */ |
| 369 | DECODE_OR (0xfec00800, 0xf8000800), |
| 370 | /* STRB (immediate) 1111 1000 1000 xxxx xxxx xxxx xxxx xxxx */ |
| 371 | /* STRH (immediate) 1111 1000 1010 xxxx xxxx xxxx xxxx xxxx */ |
| 372 | /* LDRB (immediate) 1111 1000 1001 xxxx xxxx xxxx xxxx xxxx */ |
| 373 | /* LDRSB (immediate) 1111 1001 1001 xxxx xxxx xxxx xxxx xxxx */ |
| 374 | /* LDRH (immediate) 1111 1000 1011 xxxx xxxx xxxx xxxx xxxx */ |
| 375 | /* LDRSH (immediate) 1111 1001 1011 xxxx xxxx xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 376 | DECODE_EMULATEX (0xfec00000, 0xf8800000, PROBES_T32_LDRSTR, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 377 | REGS(NOPCX, NOSPPCX, 0, 0, 0)), |
| 378 | |
| 379 | /* STRB (register) 1111 1000 0000 xxxx xxxx 0000 00xx xxxx */ |
| 380 | /* STRH (register) 1111 1000 0010 xxxx xxxx 0000 00xx xxxx */ |
| 381 | /* LDRB (register) 1111 1000 0001 xxxx xxxx 0000 00xx xxxx */ |
| 382 | /* LDRSB (register) 1111 1001 0001 xxxx xxxx 0000 00xx xxxx */ |
| 383 | /* LDRH (register) 1111 1000 0011 xxxx xxxx 0000 00xx xxxx */ |
| 384 | /* LDRSH (register) 1111 1001 0011 xxxx xxxx 0000 00xx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 385 | DECODE_EMULATEX (0xfe800fc0, 0xf8000000, PROBES_T32_LDRSTR, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 386 | REGS(NOPCX, NOSPPCX, 0, 0, NOSPPC)), |
| 387 | |
| 388 | /* Other unallocated instructions... */ |
| 389 | DECODE_END |
| 390 | }; |
| 391 | |
| 392 | static const union decode_item t32_table_1111_1010___1111[] = { |
| 393 | /* Data-processing (register) */ |
| 394 | |
| 395 | /* ??? 1111 1010 011x xxxx 1111 xxxx 1xxx xxxx */ |
| 396 | DECODE_REJECT (0xffe0f080, 0xfa60f080), |
| 397 | |
| 398 | /* SXTH 1111 1010 0000 1111 1111 xxxx 1xxx xxxx */ |
| 399 | /* UXTH 1111 1010 0001 1111 1111 xxxx 1xxx xxxx */ |
| 400 | /* SXTB16 1111 1010 0010 1111 1111 xxxx 1xxx xxxx */ |
| 401 | /* UXTB16 1111 1010 0011 1111 1111 xxxx 1xxx xxxx */ |
| 402 | /* SXTB 1111 1010 0100 1111 1111 xxxx 1xxx xxxx */ |
| 403 | /* UXTB 1111 1010 0101 1111 1111 xxxx 1xxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 404 | DECODE_EMULATEX (0xff8ff080, 0xfa0ff080, PROBES_T32_SIGN_EXTEND, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 405 | REGS(0, 0, NOSPPC, 0, NOSPPC)), |
| 406 | |
| 407 | |
| 408 | /* ??? 1111 1010 1xxx xxxx 1111 xxxx 0x11 xxxx */ |
| 409 | DECODE_REJECT (0xff80f0b0, 0xfa80f030), |
| 410 | /* ??? 1111 1010 1x11 xxxx 1111 xxxx 0xxx xxxx */ |
| 411 | DECODE_REJECT (0xffb0f080, 0xfab0f000), |
| 412 | |
| 413 | /* SADD16 1111 1010 1001 xxxx 1111 xxxx 0000 xxxx */ |
| 414 | /* SASX 1111 1010 1010 xxxx 1111 xxxx 0000 xxxx */ |
| 415 | /* SSAX 1111 1010 1110 xxxx 1111 xxxx 0000 xxxx */ |
| 416 | /* SSUB16 1111 1010 1101 xxxx 1111 xxxx 0000 xxxx */ |
| 417 | /* SADD8 1111 1010 1000 xxxx 1111 xxxx 0000 xxxx */ |
| 418 | /* SSUB8 1111 1010 1100 xxxx 1111 xxxx 0000 xxxx */ |
| 419 | |
| 420 | /* QADD16 1111 1010 1001 xxxx 1111 xxxx 0001 xxxx */ |
| 421 | /* QASX 1111 1010 1010 xxxx 1111 xxxx 0001 xxxx */ |
| 422 | /* QSAX 1111 1010 1110 xxxx 1111 xxxx 0001 xxxx */ |
| 423 | /* QSUB16 1111 1010 1101 xxxx 1111 xxxx 0001 xxxx */ |
| 424 | /* QADD8 1111 1010 1000 xxxx 1111 xxxx 0001 xxxx */ |
| 425 | /* QSUB8 1111 1010 1100 xxxx 1111 xxxx 0001 xxxx */ |
| 426 | |
| 427 | /* SHADD16 1111 1010 1001 xxxx 1111 xxxx 0010 xxxx */ |
| 428 | /* SHASX 1111 1010 1010 xxxx 1111 xxxx 0010 xxxx */ |
| 429 | /* SHSAX 1111 1010 1110 xxxx 1111 xxxx 0010 xxxx */ |
| 430 | /* SHSUB16 1111 1010 1101 xxxx 1111 xxxx 0010 xxxx */ |
| 431 | /* SHADD8 1111 1010 1000 xxxx 1111 xxxx 0010 xxxx */ |
| 432 | /* SHSUB8 1111 1010 1100 xxxx 1111 xxxx 0010 xxxx */ |
| 433 | |
| 434 | /* UADD16 1111 1010 1001 xxxx 1111 xxxx 0100 xxxx */ |
| 435 | /* UASX 1111 1010 1010 xxxx 1111 xxxx 0100 xxxx */ |
| 436 | /* USAX 1111 1010 1110 xxxx 1111 xxxx 0100 xxxx */ |
| 437 | /* USUB16 1111 1010 1101 xxxx 1111 xxxx 0100 xxxx */ |
| 438 | /* UADD8 1111 1010 1000 xxxx 1111 xxxx 0100 xxxx */ |
| 439 | /* USUB8 1111 1010 1100 xxxx 1111 xxxx 0100 xxxx */ |
| 440 | |
| 441 | /* UQADD16 1111 1010 1001 xxxx 1111 xxxx 0101 xxxx */ |
| 442 | /* UQASX 1111 1010 1010 xxxx 1111 xxxx 0101 xxxx */ |
| 443 | /* UQSAX 1111 1010 1110 xxxx 1111 xxxx 0101 xxxx */ |
| 444 | /* UQSUB16 1111 1010 1101 xxxx 1111 xxxx 0101 xxxx */ |
| 445 | /* UQADD8 1111 1010 1000 xxxx 1111 xxxx 0101 xxxx */ |
| 446 | /* UQSUB8 1111 1010 1100 xxxx 1111 xxxx 0101 xxxx */ |
| 447 | |
| 448 | /* UHADD16 1111 1010 1001 xxxx 1111 xxxx 0110 xxxx */ |
| 449 | /* UHASX 1111 1010 1010 xxxx 1111 xxxx 0110 xxxx */ |
| 450 | /* UHSAX 1111 1010 1110 xxxx 1111 xxxx 0110 xxxx */ |
| 451 | /* UHSUB16 1111 1010 1101 xxxx 1111 xxxx 0110 xxxx */ |
| 452 | /* UHADD8 1111 1010 1000 xxxx 1111 xxxx 0110 xxxx */ |
| 453 | /* UHSUB8 1111 1010 1100 xxxx 1111 xxxx 0110 xxxx */ |
| 454 | DECODE_OR (0xff80f080, 0xfa80f000), |
| 455 | |
| 456 | /* SXTAH 1111 1010 0000 xxxx 1111 xxxx 1xxx xxxx */ |
| 457 | /* UXTAH 1111 1010 0001 xxxx 1111 xxxx 1xxx xxxx */ |
| 458 | /* SXTAB16 1111 1010 0010 xxxx 1111 xxxx 1xxx xxxx */ |
| 459 | /* UXTAB16 1111 1010 0011 xxxx 1111 xxxx 1xxx xxxx */ |
| 460 | /* SXTAB 1111 1010 0100 xxxx 1111 xxxx 1xxx xxxx */ |
| 461 | /* UXTAB 1111 1010 0101 xxxx 1111 xxxx 1xxx xxxx */ |
| 462 | DECODE_OR (0xff80f080, 0xfa00f080), |
| 463 | |
| 464 | /* QADD 1111 1010 1000 xxxx 1111 xxxx 1000 xxxx */ |
| 465 | /* QDADD 1111 1010 1000 xxxx 1111 xxxx 1001 xxxx */ |
| 466 | /* QSUB 1111 1010 1000 xxxx 1111 xxxx 1010 xxxx */ |
| 467 | /* QDSUB 1111 1010 1000 xxxx 1111 xxxx 1011 xxxx */ |
| 468 | DECODE_OR (0xfff0f0c0, 0xfa80f080), |
| 469 | |
| 470 | /* SEL 1111 1010 1010 xxxx 1111 xxxx 1000 xxxx */ |
| 471 | DECODE_OR (0xfff0f0f0, 0xfaa0f080), |
| 472 | |
| 473 | /* LSL 1111 1010 000x xxxx 1111 xxxx 0000 xxxx */ |
| 474 | /* LSR 1111 1010 001x xxxx 1111 xxxx 0000 xxxx */ |
| 475 | /* ASR 1111 1010 010x xxxx 1111 xxxx 0000 xxxx */ |
| 476 | /* ROR 1111 1010 011x xxxx 1111 xxxx 0000 xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 477 | DECODE_EMULATEX (0xff80f0f0, 0xfa00f000, PROBES_T32_MEDIA, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 478 | REGS(NOSPPC, 0, NOSPPC, 0, NOSPPC)), |
| 479 | |
| 480 | /* CLZ 1111 1010 1010 xxxx 1111 xxxx 1000 xxxx */ |
| 481 | DECODE_OR (0xfff0f0f0, 0xfab0f080), |
| 482 | |
| 483 | /* REV 1111 1010 1001 xxxx 1111 xxxx 1000 xxxx */ |
| 484 | /* REV16 1111 1010 1001 xxxx 1111 xxxx 1001 xxxx */ |
| 485 | /* RBIT 1111 1010 1001 xxxx 1111 xxxx 1010 xxxx */ |
| 486 | /* REVSH 1111 1010 1001 xxxx 1111 xxxx 1011 xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 487 | DECODE_EMULATEX (0xfff0f0c0, 0xfa90f080, PROBES_T32_REVERSE, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 488 | REGS(NOSPPC, 0, NOSPPC, 0, SAMEAS16)), |
| 489 | |
| 490 | /* Other unallocated instructions... */ |
| 491 | DECODE_END |
| 492 | }; |
| 493 | |
| 494 | static const union decode_item t32_table_1111_1011_0[] = { |
| 495 | /* Multiply, multiply accumulate, and absolute difference */ |
| 496 | |
| 497 | /* ??? 1111 1011 0000 xxxx 1111 xxxx 0001 xxxx */ |
| 498 | DECODE_REJECT (0xfff0f0f0, 0xfb00f010), |
| 499 | /* ??? 1111 1011 0111 xxxx 1111 xxxx 0001 xxxx */ |
| 500 | DECODE_REJECT (0xfff0f0f0, 0xfb70f010), |
| 501 | |
| 502 | /* SMULxy 1111 1011 0001 xxxx 1111 xxxx 00xx xxxx */ |
| 503 | DECODE_OR (0xfff0f0c0, 0xfb10f000), |
| 504 | /* MUL 1111 1011 0000 xxxx 1111 xxxx 0000 xxxx */ |
| 505 | /* SMUAD{X} 1111 1011 0010 xxxx 1111 xxxx 000x xxxx */ |
| 506 | /* SMULWy 1111 1011 0011 xxxx 1111 xxxx 000x xxxx */ |
| 507 | /* SMUSD{X} 1111 1011 0100 xxxx 1111 xxxx 000x xxxx */ |
| 508 | /* SMMUL{R} 1111 1011 0101 xxxx 1111 xxxx 000x xxxx */ |
| 509 | /* USAD8 1111 1011 0111 xxxx 1111 xxxx 0000 xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 510 | DECODE_EMULATEX (0xff80f0e0, 0xfb00f000, PROBES_T32_MUL_ADD, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 511 | REGS(NOSPPC, 0, NOSPPC, 0, NOSPPC)), |
| 512 | |
| 513 | /* ??? 1111 1011 0111 xxxx xxxx xxxx 0001 xxxx */ |
| 514 | DECODE_REJECT (0xfff000f0, 0xfb700010), |
| 515 | |
| 516 | /* SMLAxy 1111 1011 0001 xxxx xxxx xxxx 00xx xxxx */ |
| 517 | DECODE_OR (0xfff000c0, 0xfb100000), |
| 518 | /* MLA 1111 1011 0000 xxxx xxxx xxxx 0000 xxxx */ |
| 519 | /* MLS 1111 1011 0000 xxxx xxxx xxxx 0001 xxxx */ |
| 520 | /* SMLAD{X} 1111 1011 0010 xxxx xxxx xxxx 000x xxxx */ |
| 521 | /* SMLAWy 1111 1011 0011 xxxx xxxx xxxx 000x xxxx */ |
| 522 | /* SMLSD{X} 1111 1011 0100 xxxx xxxx xxxx 000x xxxx */ |
| 523 | /* SMMLA{R} 1111 1011 0101 xxxx xxxx xxxx 000x xxxx */ |
| 524 | /* SMMLS{R} 1111 1011 0110 xxxx xxxx xxxx 000x xxxx */ |
| 525 | /* USADA8 1111 1011 0111 xxxx xxxx xxxx 0000 xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 526 | DECODE_EMULATEX (0xff8000c0, 0xfb000000, PROBES_T32_MUL_ADD2, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 527 | REGS(NOSPPC, NOSPPCX, NOSPPC, 0, NOSPPC)), |
| 528 | |
| 529 | /* Other unallocated instructions... */ |
| 530 | DECODE_END |
| 531 | }; |
| 532 | |
| 533 | static const union decode_item t32_table_1111_1011_1[] = { |
| 534 | /* Long multiply, long multiply accumulate, and divide */ |
| 535 | |
| 536 | /* UMAAL 1111 1011 1110 xxxx xxxx xxxx 0110 xxxx */ |
| 537 | DECODE_OR (0xfff000f0, 0xfbe00060), |
| 538 | /* SMLALxy 1111 1011 1100 xxxx xxxx xxxx 10xx xxxx */ |
| 539 | DECODE_OR (0xfff000c0, 0xfbc00080), |
| 540 | /* SMLALD{X} 1111 1011 1100 xxxx xxxx xxxx 110x xxxx */ |
| 541 | /* SMLSLD{X} 1111 1011 1101 xxxx xxxx xxxx 110x xxxx */ |
| 542 | DECODE_OR (0xffe000e0, 0xfbc000c0), |
| 543 | /* SMULL 1111 1011 1000 xxxx xxxx xxxx 0000 xxxx */ |
| 544 | /* UMULL 1111 1011 1010 xxxx xxxx xxxx 0000 xxxx */ |
| 545 | /* SMLAL 1111 1011 1100 xxxx xxxx xxxx 0000 xxxx */ |
| 546 | /* UMLAL 1111 1011 1110 xxxx xxxx xxxx 0000 xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 547 | DECODE_EMULATEX (0xff9000f0, 0xfb800000, PROBES_T32_MUL_ADD_LONG, |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 548 | REGS(NOSPPC, NOSPPC, NOSPPC, 0, NOSPPC)), |
| 549 | |
| 550 | /* SDIV 1111 1011 1001 xxxx xxxx xxxx 1111 xxxx */ |
| 551 | /* UDIV 1111 1011 1011 xxxx xxxx xxxx 1111 xxxx */ |
| 552 | /* Other unallocated instructions... */ |
| 553 | DECODE_END |
| 554 | }; |
| 555 | |
| 556 | const union decode_item kprobe_decode_thumb32_table[] = { |
| 557 | |
| 558 | /* |
| 559 | * Load/store multiple instructions |
| 560 | * 1110 100x x0xx xxxx xxxx xxxx xxxx xxxx |
| 561 | */ |
| 562 | DECODE_TABLE (0xfe400000, 0xe8000000, t32_table_1110_100x_x0xx), |
| 563 | |
| 564 | /* |
| 565 | * Load/store dual, load/store exclusive, table branch |
| 566 | * 1110 100x x1xx xxxx xxxx xxxx xxxx xxxx |
| 567 | */ |
| 568 | DECODE_TABLE (0xfe400000, 0xe8400000, t32_table_1110_100x_x1xx), |
| 569 | |
| 570 | /* |
| 571 | * Data-processing (shifted register) |
| 572 | * 1110 101x xxxx xxxx xxxx xxxx xxxx xxxx |
| 573 | */ |
| 574 | DECODE_TABLE (0xfe000000, 0xea000000, t32_table_1110_101x), |
| 575 | |
| 576 | /* |
| 577 | * Coprocessor instructions |
| 578 | * 1110 11xx xxxx xxxx xxxx xxxx xxxx xxxx |
| 579 | */ |
| 580 | DECODE_REJECT (0xfc000000, 0xec000000), |
| 581 | |
| 582 | /* |
| 583 | * Data-processing (modified immediate) |
| 584 | * 1111 0x0x xxxx xxxx 0xxx xxxx xxxx xxxx |
| 585 | */ |
| 586 | DECODE_TABLE (0xfa008000, 0xf0000000, t32_table_1111_0x0x___0), |
| 587 | |
| 588 | /* |
| 589 | * Data-processing (plain binary immediate) |
| 590 | * 1111 0x1x xxxx xxxx 0xxx xxxx xxxx xxxx |
| 591 | */ |
| 592 | DECODE_TABLE (0xfa008000, 0xf2000000, t32_table_1111_0x1x___0), |
| 593 | |
| 594 | /* |
| 595 | * Branches and miscellaneous control |
| 596 | * 1111 0xxx xxxx xxxx 1xxx xxxx xxxx xxxx |
| 597 | */ |
| 598 | DECODE_TABLE (0xf8008000, 0xf0008000, t32_table_1111_0xxx___1), |
| 599 | |
| 600 | /* |
| 601 | * Advanced SIMD element or structure load/store instructions |
| 602 | * 1111 1001 xxx0 xxxx xxxx xxxx xxxx xxxx |
| 603 | */ |
| 604 | DECODE_REJECT (0xff100000, 0xf9000000), |
| 605 | |
| 606 | /* |
| 607 | * Memory hints |
| 608 | * 1111 100x x0x1 xxxx 1111 xxxx xxxx xxxx |
| 609 | */ |
| 610 | DECODE_TABLE (0xfe50f000, 0xf810f000, t32_table_1111_100x_x0x1__1111), |
| 611 | |
| 612 | /* |
| 613 | * Store single data item |
| 614 | * 1111 1000 xxx0 xxxx xxxx xxxx xxxx xxxx |
| 615 | * Load single data items |
| 616 | * 1111 100x xxx1 xxxx xxxx xxxx xxxx xxxx |
| 617 | */ |
| 618 | DECODE_TABLE (0xfe000000, 0xf8000000, t32_table_1111_100x), |
| 619 | |
| 620 | /* |
| 621 | * Data-processing (register) |
| 622 | * 1111 1010 xxxx xxxx 1111 xxxx xxxx xxxx |
| 623 | */ |
| 624 | DECODE_TABLE (0xff00f000, 0xfa00f000, t32_table_1111_1010___1111), |
| 625 | |
| 626 | /* |
| 627 | * Multiply, multiply accumulate, and absolute difference |
| 628 | * 1111 1011 0xxx xxxx xxxx xxxx xxxx xxxx |
| 629 | */ |
| 630 | DECODE_TABLE (0xff800000, 0xfb000000, t32_table_1111_1011_0), |
| 631 | |
| 632 | /* |
| 633 | * Long multiply, long multiply accumulate, and divide |
| 634 | * 1111 1011 1xxx xxxx xxxx xxxx xxxx xxxx |
| 635 | */ |
| 636 | DECODE_TABLE (0xff800000, 0xfb800000, t32_table_1111_1011_1), |
| 637 | |
| 638 | /* |
| 639 | * Coprocessor instructions |
| 640 | * 1111 11xx xxxx xxxx xxxx xxxx xxxx xxxx |
| 641 | */ |
| 642 | DECODE_END |
| 643 | }; |
| 644 | #ifdef CONFIG_ARM_KPROBES_TEST_MODULE |
| 645 | EXPORT_SYMBOL_GPL(kprobe_decode_thumb32_table); |
| 646 | #endif |
| 647 | |
| 648 | static const union decode_item t16_table_1011[] = { |
| 649 | /* Miscellaneous 16-bit instructions */ |
| 650 | |
| 651 | /* ADD (SP plus immediate) 1011 0000 0xxx xxxx */ |
| 652 | /* SUB (SP minus immediate) 1011 0000 1xxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 653 | DECODE_SIMULATE (0xff00, 0xb000, PROBES_T16_ADD_SP), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 654 | |
| 655 | /* CBZ 1011 00x1 xxxx xxxx */ |
| 656 | /* CBNZ 1011 10x1 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 657 | DECODE_SIMULATE (0xf500, 0xb100, PROBES_T16_CBZ), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 658 | |
| 659 | /* SXTH 1011 0010 00xx xxxx */ |
| 660 | /* SXTB 1011 0010 01xx xxxx */ |
| 661 | /* UXTH 1011 0010 10xx xxxx */ |
| 662 | /* UXTB 1011 0010 11xx xxxx */ |
| 663 | /* REV 1011 1010 00xx xxxx */ |
| 664 | /* REV16 1011 1010 01xx xxxx */ |
| 665 | /* ??? 1011 1010 10xx xxxx */ |
| 666 | /* REVSH 1011 1010 11xx xxxx */ |
| 667 | DECODE_REJECT (0xffc0, 0xba80), |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 668 | DECODE_EMULATE (0xf500, 0xb000, PROBES_T16_SIGN_EXTEND), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 669 | |
| 670 | /* PUSH 1011 010x xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 671 | DECODE_CUSTOM (0xfe00, 0xb400, PROBES_T16_PUSH), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 672 | /* POP 1011 110x xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 673 | DECODE_CUSTOM (0xfe00, 0xbc00, PROBES_T16_POP), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 674 | |
| 675 | /* |
| 676 | * If-Then, and hints |
| 677 | * 1011 1111 xxxx xxxx |
| 678 | */ |
| 679 | |
| 680 | /* YIELD 1011 1111 0001 0000 */ |
| 681 | DECODE_OR (0xffff, 0xbf10), |
| 682 | /* SEV 1011 1111 0100 0000 */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 683 | DECODE_EMULATE (0xffff, 0xbf40, PROBES_T16_SEV), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 684 | /* NOP 1011 1111 0000 0000 */ |
| 685 | /* WFE 1011 1111 0010 0000 */ |
| 686 | /* WFI 1011 1111 0011 0000 */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 687 | DECODE_SIMULATE (0xffcf, 0xbf00, PROBES_T16_WFE), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 688 | /* Unassigned hints 1011 1111 xxxx 0000 */ |
| 689 | DECODE_REJECT (0xff0f, 0xbf00), |
| 690 | /* IT 1011 1111 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 691 | DECODE_CUSTOM (0xff00, 0xbf00, PROBES_T16_IT), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 692 | |
| 693 | /* SETEND 1011 0110 010x xxxx */ |
| 694 | /* CPS 1011 0110 011x xxxx */ |
| 695 | /* BKPT 1011 1110 xxxx xxxx */ |
| 696 | /* And unallocated instructions... */ |
| 697 | DECODE_END |
| 698 | }; |
| 699 | |
| 700 | const union decode_item kprobe_decode_thumb16_table[] = { |
| 701 | |
| 702 | /* |
| 703 | * Shift (immediate), add, subtract, move, and compare |
| 704 | * 00xx xxxx xxxx xxxx |
| 705 | */ |
| 706 | |
| 707 | /* CMP (immediate) 0010 1xxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 708 | DECODE_EMULATE (0xf800, 0x2800, PROBES_T16_CMP), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 709 | |
| 710 | /* ADD (register) 0001 100x xxxx xxxx */ |
| 711 | /* SUB (register) 0001 101x xxxx xxxx */ |
| 712 | /* LSL (immediate) 0000 0xxx xxxx xxxx */ |
| 713 | /* LSR (immediate) 0000 1xxx xxxx xxxx */ |
| 714 | /* ASR (immediate) 0001 0xxx xxxx xxxx */ |
| 715 | /* ADD (immediate, Thumb) 0001 110x xxxx xxxx */ |
| 716 | /* SUB (immediate, Thumb) 0001 111x xxxx xxxx */ |
| 717 | /* MOV (immediate) 0010 0xxx xxxx xxxx */ |
| 718 | /* ADD (immediate, Thumb) 0011 0xxx xxxx xxxx */ |
| 719 | /* SUB (immediate, Thumb) 0011 1xxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 720 | DECODE_EMULATE (0xc000, 0x0000, PROBES_T16_ADDSUB), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 721 | |
| 722 | /* |
| 723 | * 16-bit Thumb data-processing instructions |
| 724 | * 0100 00xx xxxx xxxx |
| 725 | */ |
| 726 | |
| 727 | /* TST (register) 0100 0010 00xx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 728 | DECODE_EMULATE (0xffc0, 0x4200, PROBES_T16_CMP), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 729 | /* CMP (register) 0100 0010 10xx xxxx */ |
| 730 | /* CMN (register) 0100 0010 11xx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 731 | DECODE_EMULATE (0xff80, 0x4280, PROBES_T16_CMP), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 732 | /* AND (register) 0100 0000 00xx xxxx */ |
| 733 | /* EOR (register) 0100 0000 01xx xxxx */ |
| 734 | /* LSL (register) 0100 0000 10xx xxxx */ |
| 735 | /* LSR (register) 0100 0000 11xx xxxx */ |
| 736 | /* ASR (register) 0100 0001 00xx xxxx */ |
| 737 | /* ADC (register) 0100 0001 01xx xxxx */ |
| 738 | /* SBC (register) 0100 0001 10xx xxxx */ |
| 739 | /* ROR (register) 0100 0001 11xx xxxx */ |
| 740 | /* RSB (immediate) 0100 0010 01xx xxxx */ |
| 741 | /* ORR (register) 0100 0011 00xx xxxx */ |
| 742 | /* MUL 0100 0011 00xx xxxx */ |
| 743 | /* BIC (register) 0100 0011 10xx xxxx */ |
| 744 | /* MVN (register) 0100 0011 10xx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 745 | DECODE_EMULATE (0xfc00, 0x4000, PROBES_T16_LOGICAL), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 746 | |
| 747 | /* |
| 748 | * Special data instructions and branch and exchange |
| 749 | * 0100 01xx xxxx xxxx |
| 750 | */ |
| 751 | |
| 752 | /* BLX pc 0100 0111 1111 1xxx */ |
| 753 | DECODE_REJECT (0xfff8, 0x47f8), |
| 754 | |
| 755 | /* BX (register) 0100 0111 0xxx xxxx */ |
| 756 | /* BLX (register) 0100 0111 1xxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 757 | DECODE_SIMULATE (0xff00, 0x4700, PROBES_T16_BLX), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 758 | |
| 759 | /* ADD pc, pc 0100 0100 1111 1111 */ |
| 760 | DECODE_REJECT (0xffff, 0x44ff), |
| 761 | |
| 762 | /* ADD (register) 0100 0100 xxxx xxxx */ |
| 763 | /* CMP (register) 0100 0101 xxxx xxxx */ |
| 764 | /* MOV (register) 0100 0110 xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 765 | DECODE_CUSTOM (0xfc00, 0x4400, PROBES_T16_HIREGOPS), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 766 | |
| 767 | /* |
| 768 | * Load from Literal Pool |
| 769 | * LDR (literal) 0100 1xxx xxxx xxxx |
| 770 | */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 771 | DECODE_SIMULATE (0xf800, 0x4800, PROBES_T16_LDR_LIT), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 772 | |
| 773 | /* |
| 774 | * 16-bit Thumb Load/store instructions |
| 775 | * 0101 xxxx xxxx xxxx |
| 776 | * 011x xxxx xxxx xxxx |
| 777 | * 100x xxxx xxxx xxxx |
| 778 | */ |
| 779 | |
| 780 | /* STR (register) 0101 000x xxxx xxxx */ |
| 781 | /* STRH (register) 0101 001x xxxx xxxx */ |
| 782 | /* STRB (register) 0101 010x xxxx xxxx */ |
| 783 | /* LDRSB (register) 0101 011x xxxx xxxx */ |
| 784 | /* LDR (register) 0101 100x xxxx xxxx */ |
| 785 | /* LDRH (register) 0101 101x xxxx xxxx */ |
| 786 | /* LDRB (register) 0101 110x xxxx xxxx */ |
| 787 | /* LDRSH (register) 0101 111x xxxx xxxx */ |
| 788 | /* STR (immediate, Thumb) 0110 0xxx xxxx xxxx */ |
| 789 | /* LDR (immediate, Thumb) 0110 1xxx xxxx xxxx */ |
| 790 | /* STRB (immediate, Thumb) 0111 0xxx xxxx xxxx */ |
| 791 | /* LDRB (immediate, Thumb) 0111 1xxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 792 | DECODE_EMULATE (0xc000, 0x4000, PROBES_T16_LDRHSTRH), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 793 | /* STRH (immediate, Thumb) 1000 0xxx xxxx xxxx */ |
| 794 | /* LDRH (immediate, Thumb) 1000 1xxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 795 | DECODE_EMULATE (0xf000, 0x8000, PROBES_T16_LDRHSTRH), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 796 | /* STR (immediate, Thumb) 1001 0xxx xxxx xxxx */ |
| 797 | /* LDR (immediate, Thumb) 1001 1xxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 798 | DECODE_SIMULATE (0xf000, 0x9000, PROBES_T16_LDRSTR), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 799 | |
| 800 | /* |
| 801 | * Generate PC-/SP-relative address |
| 802 | * ADR (literal) 1010 0xxx xxxx xxxx |
| 803 | * ADD (SP plus immediate) 1010 1xxx xxxx xxxx |
| 804 | */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 805 | DECODE_SIMULATE (0xf000, 0xa000, PROBES_T16_ADR), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 806 | |
| 807 | /* |
| 808 | * Miscellaneous 16-bit instructions |
| 809 | * 1011 xxxx xxxx xxxx |
| 810 | */ |
| 811 | DECODE_TABLE (0xf000, 0xb000, t16_table_1011), |
| 812 | |
| 813 | /* STM 1100 0xxx xxxx xxxx */ |
| 814 | /* LDM 1100 1xxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 815 | DECODE_EMULATE (0xf000, 0xc000, PROBES_T16_LDMSTM), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 816 | |
| 817 | /* |
| 818 | * Conditional branch, and Supervisor Call |
| 819 | */ |
| 820 | |
| 821 | /* Permanently UNDEFINED 1101 1110 xxxx xxxx */ |
| 822 | /* SVC 1101 1111 xxxx xxxx */ |
| 823 | DECODE_REJECT (0xfe00, 0xde00), |
| 824 | |
| 825 | /* Conditional branch 1101 xxxx xxxx xxxx */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 826 | DECODE_CUSTOM (0xf000, 0xd000, PROBES_T16_BRANCH_COND), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 827 | |
| 828 | /* |
| 829 | * Unconditional branch |
| 830 | * B 1110 0xxx xxxx xxxx |
| 831 | */ |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 832 | DECODE_SIMULATE (0xf800, 0xe000, PROBES_T16_BRANCH), |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 833 | |
| 834 | DECODE_END |
| 835 | }; |
| 836 | #ifdef CONFIG_ARM_KPROBES_TEST_MODULE |
| 837 | EXPORT_SYMBOL_GPL(kprobe_decode_thumb16_table); |
| 838 | #endif |
| 839 | |
| 840 | static unsigned long __kprobes thumb_check_cc(unsigned long cpsr) |
| 841 | { |
| 842 | if (unlikely(in_it_block(cpsr))) |
| 843 | return kprobe_condition_checks[current_cond(cpsr)](cpsr); |
| 844 | return true; |
| 845 | } |
| 846 | |
| 847 | static void __kprobes thumb16_singlestep(struct kprobe *p, struct pt_regs *regs) |
| 848 | { |
| 849 | regs->ARM_pc += 2; |
| 850 | p->ainsn.insn_handler(p, regs); |
| 851 | regs->ARM_cpsr = it_advance(regs->ARM_cpsr); |
| 852 | } |
| 853 | |
| 854 | static void __kprobes thumb32_singlestep(struct kprobe *p, struct pt_regs *regs) |
| 855 | { |
| 856 | regs->ARM_pc += 4; |
| 857 | p->ainsn.insn_handler(p, regs); |
| 858 | regs->ARM_cpsr = it_advance(regs->ARM_cpsr); |
| 859 | } |
| 860 | |
| 861 | enum kprobe_insn __kprobes |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 862 | thumb16_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi, |
| 863 | const union decode_action *actions) |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 864 | { |
| 865 | asi->insn_singlestep = thumb16_singlestep; |
| 866 | asi->insn_check_cc = thumb_check_cc; |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 867 | return kprobe_decode_insn(insn, asi, kprobe_decode_thumb16_table, true, |
| 868 | actions); |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | enum kprobe_insn __kprobes |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 872 | thumb32_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi, |
| 873 | const union decode_action *actions) |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 874 | { |
| 875 | asi->insn_singlestep = thumb32_singlestep; |
| 876 | asi->insn_check_cc = thumb_check_cc; |
David A. Long | 3e6cd39 | 2014-03-06 18:06:43 -0500 | [diff] [blame^] | 877 | return kprobe_decode_insn(insn, asi, kprobe_decode_thumb32_table, true, |
| 878 | actions); |
David A. Long | 87abef6 | 2014-03-05 21:06:29 -0500 | [diff] [blame] | 879 | } |