Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/kernel/kprobes-decode.c |
| 3 | * |
| 4 | * Copyright (C) 2006, 2007 Motorola Inc. |
| 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 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | /* |
| 17 | * We do not have hardware single-stepping on ARM, This |
| 18 | * effort is further complicated by the ARM not having a |
| 19 | * "next PC" register. Instructions that change the PC |
| 20 | * can't be safely single-stepped in a MP environment, so |
| 21 | * we have a lot of work to do: |
| 22 | * |
| 23 | * In the prepare phase: |
| 24 | * *) If it is an instruction that does anything |
| 25 | * with the CPU mode, we reject it for a kprobe. |
| 26 | * (This is out of laziness rather than need. The |
| 27 | * instructions could be simulated.) |
| 28 | * |
| 29 | * *) Otherwise, decode the instruction rewriting its |
| 30 | * registers to take fixed, ordered registers and |
| 31 | * setting a handler for it to run the instruction. |
| 32 | * |
| 33 | * In the execution phase by an instruction's handler: |
| 34 | * |
| 35 | * *) If the PC is written to by the instruction, the |
| 36 | * instruction must be fully simulated in software. |
| 37 | * If it is a conditional instruction, the handler |
| 38 | * will use insn[0] to copy its condition code to |
| 39 | * set r0 to 1 and insn[1] to "mov pc, lr" to return. |
| 40 | * |
| 41 | * *) Otherwise, a modified form of the instruction is |
| 42 | * directly executed. Its handler calls the |
| 43 | * instruction in insn[0]. In insn[1] is a |
| 44 | * "mov pc, lr" to return. |
| 45 | * |
| 46 | * Before calling, load up the reordered registers |
| 47 | * from the original instruction's registers. If one |
| 48 | * of the original input registers is the PC, compute |
| 49 | * and adjust the appropriate input register. |
| 50 | * |
| 51 | * After call completes, copy the output registers to |
| 52 | * the original instruction's original registers. |
| 53 | * |
| 54 | * We don't use a real breakpoint instruction since that |
| 55 | * would have us in the kernel go from SVC mode to SVC |
| 56 | * mode losing the link register. Instead we use an |
| 57 | * undefined instruction. To simplify processing, the |
| 58 | * undefined instruction used for kprobes must be reserved |
| 59 | * exclusively for kprobes use. |
| 60 | * |
| 61 | * TODO: ifdef out some instruction decoding based on architecture. |
| 62 | */ |
| 63 | |
| 64 | #include <linux/kernel.h> |
| 65 | #include <linux/kprobes.h> |
| 66 | |
| 67 | #define sign_extend(x, signbit) ((x) | (0 - ((x) & (1 << (signbit))))) |
| 68 | |
| 69 | #define branch_displacement(insn) sign_extend(((insn) & 0xffffff) << 2, 25) |
| 70 | |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 71 | #define is_r15(insn, bitpos) (((insn) & (0xf << bitpos)) == (0xf << bitpos)) |
| 72 | |
Jon Medhurst | 54823ac | 2011-04-08 15:32:55 +0100 | [diff] [blame] | 73 | /* |
| 74 | * Test if load/store instructions writeback the address register. |
| 75 | * if P (bit 24) == 0 or W (bit 21) == 1 |
| 76 | */ |
| 77 | #define is_writeback(insn) ((insn ^ 0x01000000) & 0x01200000) |
| 78 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 79 | #define PSR_fs (PSR_f|PSR_s) |
| 80 | |
| 81 | #define KPROBE_RETURN_INSTRUCTION 0xe1a0f00e /* mov pc, lr */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 82 | |
| 83 | typedef long (insn_0arg_fn_t)(void); |
| 84 | typedef long (insn_1arg_fn_t)(long); |
| 85 | typedef long (insn_2arg_fn_t)(long, long); |
| 86 | typedef long (insn_3arg_fn_t)(long, long, long); |
| 87 | typedef long (insn_4arg_fn_t)(long, long, long, long); |
| 88 | typedef long long (insn_llret_0arg_fn_t)(void); |
| 89 | typedef long long (insn_llret_3arg_fn_t)(long, long, long); |
| 90 | typedef long long (insn_llret_4arg_fn_t)(long, long, long, long); |
| 91 | |
| 92 | union reg_pair { |
| 93 | long long dr; |
| 94 | #ifdef __LITTLE_ENDIAN |
| 95 | struct { long r0, r1; }; |
| 96 | #else |
| 97 | struct { long r1, r0; }; |
| 98 | #endif |
| 99 | }; |
| 100 | |
| 101 | /* |
| 102 | * For STR and STM instructions, an ARM core may choose to use either |
| 103 | * a +8 or a +12 displacement from the current instruction's address. |
| 104 | * Whichever value is chosen for a given core, it must be the same for |
| 105 | * both instructions and may not change. This function measures it. |
| 106 | */ |
| 107 | |
| 108 | static int str_pc_offset; |
| 109 | |
| 110 | static void __init find_str_pc_offset(void) |
| 111 | { |
| 112 | int addr, scratch, ret; |
| 113 | |
| 114 | __asm__ ( |
| 115 | "sub %[ret], pc, #4 \n\t" |
| 116 | "str pc, %[addr] \n\t" |
| 117 | "ldr %[scr], %[addr] \n\t" |
| 118 | "sub %[ret], %[scr], %[ret] \n\t" |
| 119 | : [ret] "=r" (ret), [scr] "=r" (scratch), [addr] "+m" (addr)); |
| 120 | |
| 121 | str_pc_offset = ret; |
| 122 | } |
| 123 | |
| 124 | /* |
| 125 | * The insnslot_?arg_r[w]flags() functions below are to keep the |
| 126 | * msr -> *fn -> mrs instruction sequences indivisible so that |
| 127 | * the state of the CPSR flags aren't inadvertently modified |
| 128 | * just before or just after the call. |
| 129 | */ |
| 130 | |
| 131 | static inline long __kprobes |
| 132 | insnslot_0arg_rflags(long cpsr, insn_0arg_fn_t *fn) |
| 133 | { |
| 134 | register long ret asm("r0"); |
| 135 | |
| 136 | __asm__ __volatile__ ( |
| 137 | "msr cpsr_fs, %[cpsr] \n\t" |
| 138 | "mov lr, pc \n\t" |
| 139 | "mov pc, %[fn] \n\t" |
| 140 | : "=r" (ret) |
| 141 | : [cpsr] "r" (cpsr), [fn] "r" (fn) |
| 142 | : "lr", "cc" |
| 143 | ); |
| 144 | return ret; |
| 145 | } |
| 146 | |
| 147 | static inline long long __kprobes |
| 148 | insnslot_llret_0arg_rflags(long cpsr, insn_llret_0arg_fn_t *fn) |
| 149 | { |
| 150 | register long ret0 asm("r0"); |
| 151 | register long ret1 asm("r1"); |
| 152 | union reg_pair fnr; |
| 153 | |
| 154 | __asm__ __volatile__ ( |
| 155 | "msr cpsr_fs, %[cpsr] \n\t" |
| 156 | "mov lr, pc \n\t" |
| 157 | "mov pc, %[fn] \n\t" |
| 158 | : "=r" (ret0), "=r" (ret1) |
| 159 | : [cpsr] "r" (cpsr), [fn] "r" (fn) |
| 160 | : "lr", "cc" |
| 161 | ); |
| 162 | fnr.r0 = ret0; |
| 163 | fnr.r1 = ret1; |
| 164 | return fnr.dr; |
| 165 | } |
| 166 | |
| 167 | static inline long __kprobes |
| 168 | insnslot_1arg_rflags(long r0, long cpsr, insn_1arg_fn_t *fn) |
| 169 | { |
| 170 | register long rr0 asm("r0") = r0; |
| 171 | register long ret asm("r0"); |
| 172 | |
| 173 | __asm__ __volatile__ ( |
| 174 | "msr cpsr_fs, %[cpsr] \n\t" |
| 175 | "mov lr, pc \n\t" |
| 176 | "mov pc, %[fn] \n\t" |
| 177 | : "=r" (ret) |
| 178 | : "0" (rr0), [cpsr] "r" (cpsr), [fn] "r" (fn) |
| 179 | : "lr", "cc" |
| 180 | ); |
| 181 | return ret; |
| 182 | } |
| 183 | |
| 184 | static inline long __kprobes |
| 185 | insnslot_2arg_rflags(long r0, long r1, long cpsr, insn_2arg_fn_t *fn) |
| 186 | { |
| 187 | register long rr0 asm("r0") = r0; |
| 188 | register long rr1 asm("r1") = r1; |
| 189 | register long ret asm("r0"); |
| 190 | |
| 191 | __asm__ __volatile__ ( |
| 192 | "msr cpsr_fs, %[cpsr] \n\t" |
| 193 | "mov lr, pc \n\t" |
| 194 | "mov pc, %[fn] \n\t" |
| 195 | : "=r" (ret) |
| 196 | : "0" (rr0), "r" (rr1), |
| 197 | [cpsr] "r" (cpsr), [fn] "r" (fn) |
| 198 | : "lr", "cc" |
| 199 | ); |
| 200 | return ret; |
| 201 | } |
| 202 | |
| 203 | static inline long __kprobes |
| 204 | insnslot_3arg_rflags(long r0, long r1, long r2, long cpsr, insn_3arg_fn_t *fn) |
| 205 | { |
| 206 | register long rr0 asm("r0") = r0; |
| 207 | register long rr1 asm("r1") = r1; |
| 208 | register long rr2 asm("r2") = r2; |
| 209 | register long ret asm("r0"); |
| 210 | |
| 211 | __asm__ __volatile__ ( |
| 212 | "msr cpsr_fs, %[cpsr] \n\t" |
| 213 | "mov lr, pc \n\t" |
| 214 | "mov pc, %[fn] \n\t" |
| 215 | : "=r" (ret) |
| 216 | : "0" (rr0), "r" (rr1), "r" (rr2), |
| 217 | [cpsr] "r" (cpsr), [fn] "r" (fn) |
| 218 | : "lr", "cc" |
| 219 | ); |
| 220 | return ret; |
| 221 | } |
| 222 | |
| 223 | static inline long long __kprobes |
| 224 | insnslot_llret_3arg_rflags(long r0, long r1, long r2, long cpsr, |
| 225 | insn_llret_3arg_fn_t *fn) |
| 226 | { |
| 227 | register long rr0 asm("r0") = r0; |
| 228 | register long rr1 asm("r1") = r1; |
| 229 | register long rr2 asm("r2") = r2; |
| 230 | register long ret0 asm("r0"); |
| 231 | register long ret1 asm("r1"); |
| 232 | union reg_pair fnr; |
| 233 | |
| 234 | __asm__ __volatile__ ( |
| 235 | "msr cpsr_fs, %[cpsr] \n\t" |
| 236 | "mov lr, pc \n\t" |
| 237 | "mov pc, %[fn] \n\t" |
| 238 | : "=r" (ret0), "=r" (ret1) |
| 239 | : "0" (rr0), "r" (rr1), "r" (rr2), |
| 240 | [cpsr] "r" (cpsr), [fn] "r" (fn) |
| 241 | : "lr", "cc" |
| 242 | ); |
| 243 | fnr.r0 = ret0; |
| 244 | fnr.r1 = ret1; |
| 245 | return fnr.dr; |
| 246 | } |
| 247 | |
| 248 | static inline long __kprobes |
| 249 | insnslot_4arg_rflags(long r0, long r1, long r2, long r3, long cpsr, |
| 250 | insn_4arg_fn_t *fn) |
| 251 | { |
| 252 | register long rr0 asm("r0") = r0; |
| 253 | register long rr1 asm("r1") = r1; |
| 254 | register long rr2 asm("r2") = r2; |
| 255 | register long rr3 asm("r3") = r3; |
| 256 | register long ret asm("r0"); |
| 257 | |
| 258 | __asm__ __volatile__ ( |
| 259 | "msr cpsr_fs, %[cpsr] \n\t" |
| 260 | "mov lr, pc \n\t" |
| 261 | "mov pc, %[fn] \n\t" |
| 262 | : "=r" (ret) |
| 263 | : "0" (rr0), "r" (rr1), "r" (rr2), "r" (rr3), |
| 264 | [cpsr] "r" (cpsr), [fn] "r" (fn) |
| 265 | : "lr", "cc" |
| 266 | ); |
| 267 | return ret; |
| 268 | } |
| 269 | |
| 270 | static inline long __kprobes |
| 271 | insnslot_1arg_rwflags(long r0, long *cpsr, insn_1arg_fn_t *fn) |
| 272 | { |
| 273 | register long rr0 asm("r0") = r0; |
| 274 | register long ret asm("r0"); |
| 275 | long oldcpsr = *cpsr; |
| 276 | long newcpsr; |
| 277 | |
| 278 | __asm__ __volatile__ ( |
| 279 | "msr cpsr_fs, %[oldcpsr] \n\t" |
| 280 | "mov lr, pc \n\t" |
| 281 | "mov pc, %[fn] \n\t" |
| 282 | "mrs %[newcpsr], cpsr \n\t" |
| 283 | : "=r" (ret), [newcpsr] "=r" (newcpsr) |
| 284 | : "0" (rr0), [oldcpsr] "r" (oldcpsr), [fn] "r" (fn) |
| 285 | : "lr", "cc" |
| 286 | ); |
| 287 | *cpsr = (oldcpsr & ~PSR_fs) | (newcpsr & PSR_fs); |
| 288 | return ret; |
| 289 | } |
| 290 | |
| 291 | static inline long __kprobes |
| 292 | insnslot_2arg_rwflags(long r0, long r1, long *cpsr, insn_2arg_fn_t *fn) |
| 293 | { |
| 294 | register long rr0 asm("r0") = r0; |
| 295 | register long rr1 asm("r1") = r1; |
| 296 | register long ret asm("r0"); |
| 297 | long oldcpsr = *cpsr; |
| 298 | long newcpsr; |
| 299 | |
| 300 | __asm__ __volatile__ ( |
| 301 | "msr cpsr_fs, %[oldcpsr] \n\t" |
| 302 | "mov lr, pc \n\t" |
| 303 | "mov pc, %[fn] \n\t" |
| 304 | "mrs %[newcpsr], cpsr \n\t" |
| 305 | : "=r" (ret), [newcpsr] "=r" (newcpsr) |
| 306 | : "0" (rr0), "r" (rr1), [oldcpsr] "r" (oldcpsr), [fn] "r" (fn) |
| 307 | : "lr", "cc" |
| 308 | ); |
| 309 | *cpsr = (oldcpsr & ~PSR_fs) | (newcpsr & PSR_fs); |
| 310 | return ret; |
| 311 | } |
| 312 | |
| 313 | static inline long __kprobes |
| 314 | insnslot_3arg_rwflags(long r0, long r1, long r2, long *cpsr, |
| 315 | insn_3arg_fn_t *fn) |
| 316 | { |
| 317 | register long rr0 asm("r0") = r0; |
| 318 | register long rr1 asm("r1") = r1; |
| 319 | register long rr2 asm("r2") = r2; |
| 320 | register long ret asm("r0"); |
| 321 | long oldcpsr = *cpsr; |
| 322 | long newcpsr; |
| 323 | |
| 324 | __asm__ __volatile__ ( |
| 325 | "msr cpsr_fs, %[oldcpsr] \n\t" |
| 326 | "mov lr, pc \n\t" |
| 327 | "mov pc, %[fn] \n\t" |
| 328 | "mrs %[newcpsr], cpsr \n\t" |
| 329 | : "=r" (ret), [newcpsr] "=r" (newcpsr) |
| 330 | : "0" (rr0), "r" (rr1), "r" (rr2), |
| 331 | [oldcpsr] "r" (oldcpsr), [fn] "r" (fn) |
| 332 | : "lr", "cc" |
| 333 | ); |
| 334 | *cpsr = (oldcpsr & ~PSR_fs) | (newcpsr & PSR_fs); |
| 335 | return ret; |
| 336 | } |
| 337 | |
| 338 | static inline long __kprobes |
| 339 | insnslot_4arg_rwflags(long r0, long r1, long r2, long r3, long *cpsr, |
| 340 | insn_4arg_fn_t *fn) |
| 341 | { |
| 342 | register long rr0 asm("r0") = r0; |
| 343 | register long rr1 asm("r1") = r1; |
| 344 | register long rr2 asm("r2") = r2; |
| 345 | register long rr3 asm("r3") = r3; |
| 346 | register long ret asm("r0"); |
| 347 | long oldcpsr = *cpsr; |
| 348 | long newcpsr; |
| 349 | |
| 350 | __asm__ __volatile__ ( |
| 351 | "msr cpsr_fs, %[oldcpsr] \n\t" |
| 352 | "mov lr, pc \n\t" |
| 353 | "mov pc, %[fn] \n\t" |
| 354 | "mrs %[newcpsr], cpsr \n\t" |
| 355 | : "=r" (ret), [newcpsr] "=r" (newcpsr) |
| 356 | : "0" (rr0), "r" (rr1), "r" (rr2), "r" (rr3), |
| 357 | [oldcpsr] "r" (oldcpsr), [fn] "r" (fn) |
| 358 | : "lr", "cc" |
| 359 | ); |
| 360 | *cpsr = (oldcpsr & ~PSR_fs) | (newcpsr & PSR_fs); |
| 361 | return ret; |
| 362 | } |
| 363 | |
| 364 | static inline long long __kprobes |
| 365 | insnslot_llret_4arg_rwflags(long r0, long r1, long r2, long r3, long *cpsr, |
| 366 | insn_llret_4arg_fn_t *fn) |
| 367 | { |
| 368 | register long rr0 asm("r0") = r0; |
| 369 | register long rr1 asm("r1") = r1; |
| 370 | register long rr2 asm("r2") = r2; |
| 371 | register long rr3 asm("r3") = r3; |
| 372 | register long ret0 asm("r0"); |
| 373 | register long ret1 asm("r1"); |
| 374 | long oldcpsr = *cpsr; |
| 375 | long newcpsr; |
| 376 | union reg_pair fnr; |
| 377 | |
| 378 | __asm__ __volatile__ ( |
| 379 | "msr cpsr_fs, %[oldcpsr] \n\t" |
| 380 | "mov lr, pc \n\t" |
| 381 | "mov pc, %[fn] \n\t" |
| 382 | "mrs %[newcpsr], cpsr \n\t" |
| 383 | : "=r" (ret0), "=r" (ret1), [newcpsr] "=r" (newcpsr) |
| 384 | : "0" (rr0), "r" (rr1), "r" (rr2), "r" (rr3), |
| 385 | [oldcpsr] "r" (oldcpsr), [fn] "r" (fn) |
| 386 | : "lr", "cc" |
| 387 | ); |
| 388 | *cpsr = (oldcpsr & ~PSR_fs) | (newcpsr & PSR_fs); |
| 389 | fnr.r0 = ret0; |
| 390 | fnr.r1 = ret1; |
| 391 | return fnr.dr; |
| 392 | } |
| 393 | |
| 394 | /* |
| 395 | * To avoid the complications of mimicing single-stepping on a |
| 396 | * processor without a Next-PC or a single-step mode, and to |
| 397 | * avoid having to deal with the side-effects of boosting, we |
| 398 | * simulate or emulate (almost) all ARM instructions. |
| 399 | * |
| 400 | * "Simulation" is where the instruction's behavior is duplicated in |
| 401 | * C code. "Emulation" is where the original instruction is rewritten |
| 402 | * and executed, often by altering its registers. |
| 403 | * |
| 404 | * By having all behavior of the kprobe'd instruction completed before |
| 405 | * returning from the kprobe_handler(), all locks (scheduler and |
| 406 | * interrupt) can safely be released. There is no need for secondary |
| 407 | * breakpoints, no race with MP or preemptable kernels, nor having to |
| 408 | * clean up resources counts at a later time impacting overall system |
| 409 | * performance. By rewriting the instruction, only the minimum registers |
| 410 | * need to be loaded and saved back optimizing performance. |
| 411 | * |
| 412 | * Calling the insnslot_*_rwflags version of a function doesn't hurt |
| 413 | * anything even when the CPSR flags aren't updated by the |
| 414 | * instruction. It's just a little slower in return for saving |
| 415 | * a little space by not having a duplicate function that doesn't |
| 416 | * update the flags. (The same optimization can be said for |
| 417 | * instructions that do or don't perform register writeback) |
| 418 | * Also, instructions can either read the flags, only write the |
| 419 | * flags, or read and write the flags. To save combinations |
| 420 | * rather than for sheer performance, flag functions just assume |
| 421 | * read and write of flags. |
| 422 | */ |
| 423 | |
| 424 | static void __kprobes simulate_bbl(struct kprobe *p, struct pt_regs *regs) |
| 425 | { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 426 | kprobe_opcode_t insn = p->opcode; |
| 427 | long iaddr = (long)p->addr; |
| 428 | int disp = branch_displacement(insn); |
| 429 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 430 | if (insn & (1 << 24)) |
| 431 | regs->ARM_lr = iaddr + 4; |
| 432 | |
| 433 | regs->ARM_pc = iaddr + 8 + disp; |
| 434 | } |
| 435 | |
| 436 | static void __kprobes simulate_blx1(struct kprobe *p, struct pt_regs *regs) |
| 437 | { |
| 438 | kprobe_opcode_t insn = p->opcode; |
| 439 | long iaddr = (long)p->addr; |
| 440 | int disp = branch_displacement(insn); |
| 441 | |
| 442 | regs->ARM_lr = iaddr + 4; |
| 443 | regs->ARM_pc = iaddr + 8 + disp + ((insn >> 23) & 0x2); |
| 444 | regs->ARM_cpsr |= PSR_T_BIT; |
| 445 | } |
| 446 | |
| 447 | static void __kprobes simulate_blx2bx(struct kprobe *p, struct pt_regs *regs) |
| 448 | { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 449 | kprobe_opcode_t insn = p->opcode; |
| 450 | int rm = insn & 0xf; |
| 451 | long rmv = regs->uregs[rm]; |
| 452 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 453 | if (insn & (1 << 5)) |
| 454 | regs->ARM_lr = (long)p->addr + 4; |
| 455 | |
| 456 | regs->ARM_pc = rmv & ~0x1; |
| 457 | regs->ARM_cpsr &= ~PSR_T_BIT; |
| 458 | if (rmv & 0x1) |
| 459 | regs->ARM_cpsr |= PSR_T_BIT; |
| 460 | } |
| 461 | |
Jon Medhurst | c412aba | 2011-04-07 13:25:16 +0100 | [diff] [blame] | 462 | static void __kprobes simulate_mrs(struct kprobe *p, struct pt_regs *regs) |
| 463 | { |
| 464 | kprobe_opcode_t insn = p->opcode; |
| 465 | int rd = (insn >> 12) & 0xf; |
| 466 | unsigned long mask = 0xf8ff03df; /* Mask out execution state */ |
| 467 | regs->uregs[rd] = regs->ARM_cpsr & mask; |
| 468 | } |
| 469 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 470 | static void __kprobes simulate_ldm1stm1(struct kprobe *p, struct pt_regs *regs) |
| 471 | { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 472 | kprobe_opcode_t insn = p->opcode; |
| 473 | int rn = (insn >> 16) & 0xf; |
| 474 | int lbit = insn & (1 << 20); |
| 475 | int wbit = insn & (1 << 21); |
| 476 | int ubit = insn & (1 << 23); |
| 477 | int pbit = insn & (1 << 24); |
| 478 | long *addr = (long *)regs->uregs[rn]; |
| 479 | int reg_bit_vector; |
| 480 | int reg_count; |
| 481 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 482 | reg_count = 0; |
| 483 | reg_bit_vector = insn & 0xffff; |
| 484 | while (reg_bit_vector) { |
| 485 | reg_bit_vector &= (reg_bit_vector - 1); |
| 486 | ++reg_count; |
| 487 | } |
| 488 | |
| 489 | if (!ubit) |
| 490 | addr -= reg_count; |
Nicolas Pitre | 2d4b6c9 | 2008-08-21 23:22:49 +0100 | [diff] [blame] | 491 | addr += (!pbit == !ubit); |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 492 | |
| 493 | reg_bit_vector = insn & 0xffff; |
| 494 | while (reg_bit_vector) { |
| 495 | int reg = __ffs(reg_bit_vector); |
| 496 | reg_bit_vector &= (reg_bit_vector - 1); |
| 497 | if (lbit) |
| 498 | regs->uregs[reg] = *addr++; |
| 499 | else |
| 500 | *addr++ = regs->uregs[reg]; |
| 501 | } |
| 502 | |
| 503 | if (wbit) { |
| 504 | if (!ubit) |
| 505 | addr -= reg_count; |
Nicolas Pitre | 2d4b6c9 | 2008-08-21 23:22:49 +0100 | [diff] [blame] | 506 | addr -= (!pbit == !ubit); |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 507 | regs->uregs[rn] = (long)addr; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | static void __kprobes simulate_stm1_pc(struct kprobe *p, struct pt_regs *regs) |
| 512 | { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 513 | regs->ARM_pc = (long)p->addr + str_pc_offset; |
| 514 | simulate_ldm1stm1(p, regs); |
| 515 | regs->ARM_pc = (long)p->addr + 4; |
| 516 | } |
| 517 | |
| 518 | static void __kprobes simulate_mov_ipsp(struct kprobe *p, struct pt_regs *regs) |
| 519 | { |
| 520 | regs->uregs[12] = regs->uregs[13]; |
| 521 | } |
| 522 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 523 | static void __kprobes emulate_ldrd(struct kprobe *p, struct pt_regs *regs) |
| 524 | { |
| 525 | insn_2arg_fn_t *i_fn = (insn_2arg_fn_t *)&p->ainsn.insn[0]; |
| 526 | kprobe_opcode_t insn = p->opcode; |
Viktor Rosendahl | cf3cc1a | 2011-03-28 18:56:05 +0300 | [diff] [blame] | 527 | long ppc = (long)p->addr + 8; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 528 | int rd = (insn >> 12) & 0xf; |
| 529 | int rn = (insn >> 16) & 0xf; |
| 530 | int rm = insn & 0xf; /* rm may be invalid, don't care. */ |
Viktor Rosendahl | cf3cc1a | 2011-03-28 18:56:05 +0300 | [diff] [blame] | 531 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; |
| 532 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 533 | |
| 534 | /* Not following the C calling convention here, so need asm(). */ |
| 535 | __asm__ __volatile__ ( |
| 536 | "ldr r0, %[rn] \n\t" |
| 537 | "ldr r1, %[rm] \n\t" |
| 538 | "msr cpsr_fs, %[cpsr]\n\t" |
| 539 | "mov lr, pc \n\t" |
| 540 | "mov pc, %[i_fn] \n\t" |
| 541 | "str r0, %[rn] \n\t" /* in case of writeback */ |
| 542 | "str r2, %[rd0] \n\t" |
| 543 | "str r3, %[rd1] \n\t" |
Viktor Rosendahl | cf3cc1a | 2011-03-28 18:56:05 +0300 | [diff] [blame] | 544 | : [rn] "+m" (rnv), |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 545 | [rd0] "=m" (regs->uregs[rd]), |
| 546 | [rd1] "=m" (regs->uregs[rd+1]) |
Viktor Rosendahl | cf3cc1a | 2011-03-28 18:56:05 +0300 | [diff] [blame] | 547 | : [rm] "m" (rmv), |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 548 | [cpsr] "r" (regs->ARM_cpsr), |
| 549 | [i_fn] "r" (i_fn) |
| 550 | : "r0", "r1", "r2", "r3", "lr", "cc" |
| 551 | ); |
Jon Medhurst | 5c6b76f | 2011-04-08 15:32:56 +0100 | [diff] [blame] | 552 | if (is_writeback(insn)) |
| 553 | regs->uregs[rn] = rnv; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | static void __kprobes emulate_strd(struct kprobe *p, struct pt_regs *regs) |
| 557 | { |
| 558 | insn_4arg_fn_t *i_fn = (insn_4arg_fn_t *)&p->ainsn.insn[0]; |
| 559 | kprobe_opcode_t insn = p->opcode; |
Viktor Rosendahl | cf3cc1a | 2011-03-28 18:56:05 +0300 | [diff] [blame] | 560 | long ppc = (long)p->addr + 8; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 561 | int rd = (insn >> 12) & 0xf; |
| 562 | int rn = (insn >> 16) & 0xf; |
| 563 | int rm = insn & 0xf; |
Viktor Rosendahl | cf3cc1a | 2011-03-28 18:56:05 +0300 | [diff] [blame] | 564 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; |
| 565 | /* rm/rmv may be invalid, don't care. */ |
| 566 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; |
| 567 | long rnv_wb; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 568 | |
Viktor Rosendahl | cf3cc1a | 2011-03-28 18:56:05 +0300 | [diff] [blame] | 569 | rnv_wb = insnslot_4arg_rflags(rnv, rmv, regs->uregs[rd], |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 570 | regs->uregs[rd+1], |
| 571 | regs->ARM_cpsr, i_fn); |
Jon Medhurst | 5c6b76f | 2011-04-08 15:32:56 +0100 | [diff] [blame] | 572 | if (is_writeback(insn)) |
| 573 | regs->uregs[rn] = rnv_wb; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | static void __kprobes emulate_ldr(struct kprobe *p, struct pt_regs *regs) |
| 577 | { |
| 578 | insn_llret_3arg_fn_t *i_fn = (insn_llret_3arg_fn_t *)&p->ainsn.insn[0]; |
| 579 | kprobe_opcode_t insn = p->opcode; |
Nicolas Pitre | 0ebe25f | 2010-07-14 05:21:22 +0100 | [diff] [blame] | 580 | long ppc = (long)p->addr + 8; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 581 | union reg_pair fnr; |
| 582 | int rd = (insn >> 12) & 0xf; |
| 583 | int rn = (insn >> 16) & 0xf; |
| 584 | int rm = insn & 0xf; |
| 585 | long rdv; |
Nicolas Pitre | 0ebe25f | 2010-07-14 05:21:22 +0100 | [diff] [blame] | 586 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; |
| 587 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 588 | long cpsr = regs->ARM_cpsr; |
| 589 | |
| 590 | fnr.dr = insnslot_llret_3arg_rflags(rnv, 0, rmv, cpsr, i_fn); |
Viktor Rosendahl | 0652f06 | 2011-03-26 18:11:01 +0100 | [diff] [blame] | 591 | if (rn != 15) |
| 592 | regs->uregs[rn] = fnr.r0; /* Save Rn in case of writeback. */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 593 | rdv = fnr.r1; |
| 594 | |
| 595 | if (rd == 15) { |
| 596 | #if __LINUX_ARM_ARCH__ >= 5 |
| 597 | cpsr &= ~PSR_T_BIT; |
| 598 | if (rdv & 0x1) |
| 599 | cpsr |= PSR_T_BIT; |
| 600 | regs->ARM_cpsr = cpsr; |
| 601 | rdv &= ~0x1; |
| 602 | #else |
| 603 | rdv &= ~0x2; |
| 604 | #endif |
| 605 | } |
| 606 | regs->uregs[rd] = rdv; |
| 607 | } |
| 608 | |
| 609 | static void __kprobes emulate_str(struct kprobe *p, struct pt_regs *regs) |
| 610 | { |
| 611 | insn_3arg_fn_t *i_fn = (insn_3arg_fn_t *)&p->ainsn.insn[0]; |
| 612 | kprobe_opcode_t insn = p->opcode; |
| 613 | long iaddr = (long)p->addr; |
| 614 | int rd = (insn >> 12) & 0xf; |
| 615 | int rn = (insn >> 16) & 0xf; |
| 616 | int rm = insn & 0xf; |
| 617 | long rdv = (rd == 15) ? iaddr + str_pc_offset : regs->uregs[rd]; |
| 618 | long rnv = (rn == 15) ? iaddr + 8 : regs->uregs[rn]; |
| 619 | long rmv = regs->uregs[rm]; /* rm/rmv may be invalid, don't care. */ |
Viktor Rosendahl | 0652f06 | 2011-03-26 18:11:01 +0100 | [diff] [blame] | 620 | long rnv_wb; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 621 | |
Viktor Rosendahl | 0652f06 | 2011-03-26 18:11:01 +0100 | [diff] [blame] | 622 | rnv_wb = insnslot_3arg_rflags(rnv, rdv, rmv, regs->ARM_cpsr, i_fn); |
| 623 | if (rn != 15) |
| 624 | regs->uregs[rn] = rnv_wb; /* Save Rn in case of writeback. */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 625 | } |
| 626 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 627 | static void __kprobes emulate_sat(struct kprobe *p, struct pt_regs *regs) |
| 628 | { |
| 629 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; |
| 630 | kprobe_opcode_t insn = p->opcode; |
| 631 | int rd = (insn >> 12) & 0xf; |
| 632 | int rm = insn & 0xf; |
| 633 | long rmv = regs->uregs[rm]; |
| 634 | |
| 635 | /* Writes Q flag */ |
| 636 | regs->uregs[rd] = insnslot_1arg_rwflags(rmv, ®s->ARM_cpsr, i_fn); |
| 637 | } |
| 638 | |
| 639 | static void __kprobes emulate_sel(struct kprobe *p, struct pt_regs *regs) |
| 640 | { |
| 641 | insn_2arg_fn_t *i_fn = (insn_2arg_fn_t *)&p->ainsn.insn[0]; |
| 642 | kprobe_opcode_t insn = p->opcode; |
| 643 | int rd = (insn >> 12) & 0xf; |
| 644 | int rn = (insn >> 16) & 0xf; |
| 645 | int rm = insn & 0xf; |
| 646 | long rnv = regs->uregs[rn]; |
| 647 | long rmv = regs->uregs[rm]; |
| 648 | |
| 649 | /* Reads GE bits */ |
| 650 | regs->uregs[rd] = insnslot_2arg_rflags(rnv, rmv, regs->ARM_cpsr, i_fn); |
| 651 | } |
| 652 | |
| 653 | static void __kprobes emulate_none(struct kprobe *p, struct pt_regs *regs) |
| 654 | { |
| 655 | insn_0arg_fn_t *i_fn = (insn_0arg_fn_t *)&p->ainsn.insn[0]; |
| 656 | |
| 657 | insnslot_0arg_rflags(regs->ARM_cpsr, i_fn); |
| 658 | } |
| 659 | |
Jon Medhurst | 41713d1 | 2011-04-18 08:53:57 +0100 | [diff] [blame] | 660 | static void __kprobes emulate_nop(struct kprobe *p, struct pt_regs *regs) |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 661 | { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | static void __kprobes emulate_rd12rm0(struct kprobe *p, struct pt_regs *regs) |
| 665 | { |
| 666 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; |
| 667 | kprobe_opcode_t insn = p->opcode; |
| 668 | int rd = (insn >> 12) & 0xf; |
| 669 | int rm = insn & 0xf; |
| 670 | long rmv = regs->uregs[rm]; |
| 671 | |
| 672 | regs->uregs[rd] = insnslot_1arg_rflags(rmv, regs->ARM_cpsr, i_fn); |
| 673 | } |
| 674 | |
| 675 | static void __kprobes |
| 676 | emulate_rd12rn16rm0_rwflags(struct kprobe *p, struct pt_regs *regs) |
| 677 | { |
| 678 | insn_2arg_fn_t *i_fn = (insn_2arg_fn_t *)&p->ainsn.insn[0]; |
| 679 | kprobe_opcode_t insn = p->opcode; |
| 680 | int rd = (insn >> 12) & 0xf; |
| 681 | int rn = (insn >> 16) & 0xf; |
| 682 | int rm = insn & 0xf; |
| 683 | long rnv = regs->uregs[rn]; |
| 684 | long rmv = regs->uregs[rm]; |
| 685 | |
| 686 | regs->uregs[rd] = |
| 687 | insnslot_2arg_rwflags(rnv, rmv, ®s->ARM_cpsr, i_fn); |
| 688 | } |
| 689 | |
| 690 | static void __kprobes |
| 691 | emulate_rd16rn12rs8rm0_rwflags(struct kprobe *p, struct pt_regs *regs) |
| 692 | { |
| 693 | insn_3arg_fn_t *i_fn = (insn_3arg_fn_t *)&p->ainsn.insn[0]; |
| 694 | kprobe_opcode_t insn = p->opcode; |
| 695 | int rd = (insn >> 16) & 0xf; |
| 696 | int rn = (insn >> 12) & 0xf; |
| 697 | int rs = (insn >> 8) & 0xf; |
| 698 | int rm = insn & 0xf; |
| 699 | long rnv = regs->uregs[rn]; |
| 700 | long rsv = regs->uregs[rs]; |
| 701 | long rmv = regs->uregs[rm]; |
| 702 | |
| 703 | regs->uregs[rd] = |
| 704 | insnslot_3arg_rwflags(rnv, rsv, rmv, ®s->ARM_cpsr, i_fn); |
| 705 | } |
| 706 | |
| 707 | static void __kprobes |
| 708 | emulate_rd16rs8rm0_rwflags(struct kprobe *p, struct pt_regs *regs) |
| 709 | { |
| 710 | insn_2arg_fn_t *i_fn = (insn_2arg_fn_t *)&p->ainsn.insn[0]; |
| 711 | kprobe_opcode_t insn = p->opcode; |
| 712 | int rd = (insn >> 16) & 0xf; |
| 713 | int rs = (insn >> 8) & 0xf; |
| 714 | int rm = insn & 0xf; |
| 715 | long rsv = regs->uregs[rs]; |
| 716 | long rmv = regs->uregs[rm]; |
| 717 | |
| 718 | regs->uregs[rd] = |
| 719 | insnslot_2arg_rwflags(rsv, rmv, ®s->ARM_cpsr, i_fn); |
| 720 | } |
| 721 | |
| 722 | static void __kprobes |
| 723 | emulate_rdhi16rdlo12rs8rm0_rwflags(struct kprobe *p, struct pt_regs *regs) |
| 724 | { |
| 725 | insn_llret_4arg_fn_t *i_fn = (insn_llret_4arg_fn_t *)&p->ainsn.insn[0]; |
| 726 | kprobe_opcode_t insn = p->opcode; |
| 727 | union reg_pair fnr; |
| 728 | int rdhi = (insn >> 16) & 0xf; |
| 729 | int rdlo = (insn >> 12) & 0xf; |
| 730 | int rs = (insn >> 8) & 0xf; |
| 731 | int rm = insn & 0xf; |
| 732 | long rsv = regs->uregs[rs]; |
| 733 | long rmv = regs->uregs[rm]; |
| 734 | |
| 735 | fnr.dr = insnslot_llret_4arg_rwflags(regs->uregs[rdhi], |
| 736 | regs->uregs[rdlo], rsv, rmv, |
| 737 | ®s->ARM_cpsr, i_fn); |
| 738 | regs->uregs[rdhi] = fnr.r0; |
| 739 | regs->uregs[rdlo] = fnr.r1; |
| 740 | } |
| 741 | |
| 742 | static void __kprobes |
| 743 | emulate_alu_imm_rflags(struct kprobe *p, struct pt_regs *regs) |
| 744 | { |
| 745 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; |
| 746 | kprobe_opcode_t insn = p->opcode; |
| 747 | int rd = (insn >> 12) & 0xf; |
| 748 | int rn = (insn >> 16) & 0xf; |
| 749 | long rnv = (rn == 15) ? (long)p->addr + 8 : regs->uregs[rn]; |
| 750 | |
| 751 | regs->uregs[rd] = insnslot_1arg_rflags(rnv, regs->ARM_cpsr, i_fn); |
| 752 | } |
| 753 | |
| 754 | static void __kprobes |
| 755 | emulate_alu_imm_rwflags(struct kprobe *p, struct pt_regs *regs) |
| 756 | { |
| 757 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; |
| 758 | kprobe_opcode_t insn = p->opcode; |
| 759 | int rd = (insn >> 12) & 0xf; |
| 760 | int rn = (insn >> 16) & 0xf; |
| 761 | long rnv = (rn == 15) ? (long)p->addr + 8 : regs->uregs[rn]; |
| 762 | |
| 763 | regs->uregs[rd] = insnslot_1arg_rwflags(rnv, ®s->ARM_cpsr, i_fn); |
| 764 | } |
| 765 | |
| 766 | static void __kprobes |
Jon Medhurst | ad111ce | 2011-04-06 11:17:11 +0100 | [diff] [blame] | 767 | emulate_alu_tests_imm(struct kprobe *p, struct pt_regs *regs) |
| 768 | { |
| 769 | insn_1arg_fn_t *i_fn = (insn_1arg_fn_t *)&p->ainsn.insn[0]; |
| 770 | kprobe_opcode_t insn = p->opcode; |
| 771 | int rn = (insn >> 16) & 0xf; |
| 772 | long rnv = (rn == 15) ? (long)p->addr + 8 : regs->uregs[rn]; |
| 773 | |
| 774 | insnslot_1arg_rwflags(rnv, ®s->ARM_cpsr, i_fn); |
| 775 | } |
| 776 | |
| 777 | static void __kprobes |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 778 | emulate_alu_rflags(struct kprobe *p, struct pt_regs *regs) |
| 779 | { |
| 780 | insn_3arg_fn_t *i_fn = (insn_3arg_fn_t *)&p->ainsn.insn[0]; |
| 781 | kprobe_opcode_t insn = p->opcode; |
| 782 | long ppc = (long)p->addr + 8; |
| 783 | int rd = (insn >> 12) & 0xf; |
| 784 | int rn = (insn >> 16) & 0xf; /* rn/rnv/rs/rsv may be */ |
| 785 | int rs = (insn >> 8) & 0xf; /* invalid, don't care. */ |
| 786 | int rm = insn & 0xf; |
| 787 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; |
| 788 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; |
| 789 | long rsv = regs->uregs[rs]; |
| 790 | |
| 791 | regs->uregs[rd] = |
| 792 | insnslot_3arg_rflags(rnv, rmv, rsv, regs->ARM_cpsr, i_fn); |
| 793 | } |
| 794 | |
| 795 | static void __kprobes |
| 796 | emulate_alu_rwflags(struct kprobe *p, struct pt_regs *regs) |
| 797 | { |
| 798 | insn_3arg_fn_t *i_fn = (insn_3arg_fn_t *)&p->ainsn.insn[0]; |
| 799 | kprobe_opcode_t insn = p->opcode; |
| 800 | long ppc = (long)p->addr + 8; |
| 801 | int rd = (insn >> 12) & 0xf; |
| 802 | int rn = (insn >> 16) & 0xf; /* rn/rnv/rs/rsv may be */ |
| 803 | int rs = (insn >> 8) & 0xf; /* invalid, don't care. */ |
| 804 | int rm = insn & 0xf; |
| 805 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; |
| 806 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; |
| 807 | long rsv = regs->uregs[rs]; |
| 808 | |
| 809 | regs->uregs[rd] = |
| 810 | insnslot_3arg_rwflags(rnv, rmv, rsv, ®s->ARM_cpsr, i_fn); |
| 811 | } |
| 812 | |
Jon Medhurst | ad111ce | 2011-04-06 11:17:11 +0100 | [diff] [blame] | 813 | static void __kprobes |
| 814 | emulate_alu_tests(struct kprobe *p, struct pt_regs *regs) |
| 815 | { |
| 816 | insn_3arg_fn_t *i_fn = (insn_3arg_fn_t *)&p->ainsn.insn[0]; |
| 817 | kprobe_opcode_t insn = p->opcode; |
| 818 | long ppc = (long)p->addr + 8; |
| 819 | int rn = (insn >> 16) & 0xf; |
| 820 | int rs = (insn >> 8) & 0xf; /* rs/rsv may be invalid, don't care. */ |
| 821 | int rm = insn & 0xf; |
| 822 | long rnv = (rn == 15) ? ppc : regs->uregs[rn]; |
| 823 | long rmv = (rm == 15) ? ppc : regs->uregs[rm]; |
| 824 | long rsv = regs->uregs[rs]; |
| 825 | |
| 826 | insnslot_3arg_rwflags(rnv, rmv, rsv, ®s->ARM_cpsr, i_fn); |
| 827 | } |
| 828 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 829 | static enum kprobe_insn __kprobes |
| 830 | prep_emulate_ldr_str(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 831 | { |
Jon Medhurst | 6823fc8 | 2011-04-08 15:32:54 +0100 | [diff] [blame] | 832 | int not_imm = (insn & (1 << 26)) ? (insn & (1 << 25)) |
| 833 | : (~insn & (1 << 22)); |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 834 | |
Jon Medhurst | 54823ac | 2011-04-08 15:32:55 +0100 | [diff] [blame] | 835 | if (is_writeback(insn) && is_r15(insn, 16)) |
| 836 | return INSN_REJECTED; /* Writeback to PC */ |
| 837 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 838 | insn &= 0xfff00fff; |
| 839 | insn |= 0x00001000; /* Rn = r0, Rd = r1 */ |
Jon Medhurst | 6823fc8 | 2011-04-08 15:32:54 +0100 | [diff] [blame] | 840 | if (not_imm) { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 841 | insn &= ~0xf; |
| 842 | insn |= 2; /* Rm = r2 */ |
| 843 | } |
| 844 | asi->insn[0] = insn; |
| 845 | asi->insn_handler = (insn & (1 << 20)) ? emulate_ldr : emulate_str; |
| 846 | return INSN_GOOD; |
| 847 | } |
| 848 | |
| 849 | static enum kprobe_insn __kprobes |
| 850 | prep_emulate_rd12rm0(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 851 | { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 852 | if (is_r15(insn, 12)) |
| 853 | return INSN_REJECTED; /* Rd is PC */ |
| 854 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 855 | insn &= 0xffff0ff0; /* Rd = r0, Rm = r0 */ |
| 856 | asi->insn[0] = insn; |
| 857 | asi->insn_handler = emulate_rd12rm0; |
| 858 | return INSN_GOOD; |
| 859 | } |
| 860 | |
| 861 | static enum kprobe_insn __kprobes |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 862 | prep_emulate_rd12rn16rm0_wflags(kprobe_opcode_t insn, |
| 863 | struct arch_specific_insn *asi) |
| 864 | { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 865 | if (is_r15(insn, 12)) |
| 866 | return INSN_REJECTED; /* Rd is PC */ |
| 867 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 868 | insn &= 0xfff00ff0; /* Rd = r0, Rn = r0 */ |
| 869 | insn |= 0x00000001; /* Rm = r1 */ |
| 870 | asi->insn[0] = insn; |
| 871 | asi->insn_handler = emulate_rd12rn16rm0_rwflags; |
| 872 | return INSN_GOOD; |
| 873 | } |
| 874 | |
| 875 | static enum kprobe_insn __kprobes |
| 876 | prep_emulate_rd16rs8rm0_wflags(kprobe_opcode_t insn, |
| 877 | struct arch_specific_insn *asi) |
| 878 | { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 879 | if (is_r15(insn, 16)) |
| 880 | return INSN_REJECTED; /* Rd is PC */ |
| 881 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 882 | insn &= 0xfff0f0f0; /* Rd = r0, Rs = r0 */ |
| 883 | insn |= 0x00000001; /* Rm = r1 */ |
| 884 | asi->insn[0] = insn; |
| 885 | asi->insn_handler = emulate_rd16rs8rm0_rwflags; |
| 886 | return INSN_GOOD; |
| 887 | } |
| 888 | |
| 889 | static enum kprobe_insn __kprobes |
| 890 | prep_emulate_rd16rn12rs8rm0_wflags(kprobe_opcode_t insn, |
| 891 | struct arch_specific_insn *asi) |
| 892 | { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 893 | if (is_r15(insn, 16)) |
| 894 | return INSN_REJECTED; /* Rd is PC */ |
| 895 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 896 | insn &= 0xfff000f0; /* Rd = r0, Rn = r0 */ |
| 897 | insn |= 0x00000102; /* Rs = r1, Rm = r2 */ |
| 898 | asi->insn[0] = insn; |
| 899 | asi->insn_handler = emulate_rd16rn12rs8rm0_rwflags; |
| 900 | return INSN_GOOD; |
| 901 | } |
| 902 | |
| 903 | static enum kprobe_insn __kprobes |
| 904 | prep_emulate_rdhi16rdlo12rs8rm0_wflags(kprobe_opcode_t insn, |
| 905 | struct arch_specific_insn *asi) |
| 906 | { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 907 | if (is_r15(insn, 16) || is_r15(insn, 12)) |
| 908 | return INSN_REJECTED; /* RdHi or RdLo is PC */ |
| 909 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 910 | insn &= 0xfff000f0; /* RdHi = r0, RdLo = r1 */ |
| 911 | insn |= 0x00001203; /* Rs = r2, Rm = r3 */ |
| 912 | asi->insn[0] = insn; |
| 913 | asi->insn_handler = emulate_rdhi16rdlo12rs8rm0_rwflags; |
| 914 | return INSN_GOOD; |
| 915 | } |
| 916 | |
| 917 | /* |
| 918 | * For the instruction masking and comparisons in all the "space_*" |
| 919 | * functions below, Do _not_ rearrange the order of tests unless |
| 920 | * you're very, very sure of what you are doing. For the sake of |
| 921 | * efficiency, the masks for some tests sometimes assume other test |
| 922 | * have been done prior to them so the number of patterns to test |
| 923 | * for an instruction set can be as broad as possible to reduce the |
| 924 | * number of tests needed. |
| 925 | */ |
| 926 | |
| 927 | static enum kprobe_insn __kprobes |
| 928 | space_1111(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 929 | { |
Jon Medhurst | 41713d1 | 2011-04-18 08:53:57 +0100 | [diff] [blame] | 930 | /* memory hint : 1111 0100 x001 xxxx xxxx xxxx xxxx xxxx : */ |
| 931 | /* PLDI : 1111 0100 x101 xxxx xxxx xxxx xxxx xxxx : */ |
| 932 | /* PLDW : 1111 0101 x001 xxxx xxxx xxxx xxxx xxxx : */ |
| 933 | /* PLD : 1111 0101 x101 xxxx xxxx xxxx xxxx xxxx : */ |
| 934 | if ((insn & 0xfe300000) == 0xf4100000) { |
| 935 | asi->insn_handler = emulate_nop; |
| 936 | return INSN_GOOD_NO_SLOT; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | /* BLX(1) : 1111 101x xxxx xxxx xxxx xxxx xxxx xxxx : */ |
| 940 | if ((insn & 0xfe000000) == 0xfa000000) { |
| 941 | asi->insn_handler = simulate_blx1; |
| 942 | return INSN_GOOD_NO_SLOT; |
| 943 | } |
| 944 | |
Jon Medhurst | 72c2bab | 2011-04-18 08:53:58 +0100 | [diff] [blame] | 945 | /* CPS : 1111 0001 0000 xxx0 xxxx xxxx xx0x xxxx */ |
| 946 | /* SETEND: 1111 0001 0000 0001 xxxx xxxx 0000 xxxx */ |
| 947 | |
| 948 | /* SRS : 1111 100x x1x0 xxxx xxxx xxxx xxxx xxxx */ |
| 949 | /* RFE : 1111 100x x0x1 xxxx xxxx xxxx xxxx xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 950 | |
Jon Medhurst | fa1a03b | 2011-04-18 08:53:54 +0100 | [diff] [blame] | 951 | /* Coprocessor instructions... */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 952 | /* MCRR2 : 1111 1100 0100 xxxx xxxx xxxx xxxx xxxx : (Rd != Rn) */ |
| 953 | /* MRRC2 : 1111 1100 0101 xxxx xxxx xxxx xxxx xxxx : (Rd != Rn) */ |
Jon Medhurst | fa1a03b | 2011-04-18 08:53:54 +0100 | [diff] [blame] | 954 | /* LDC2 : 1111 110x xxx1 xxxx xxxx xxxx xxxx xxxx */ |
| 955 | /* STC2 : 1111 110x xxx0 xxxx xxxx xxxx xxxx xxxx */ |
| 956 | /* CDP2 : 1111 1110 xxxx xxxx xxxx xxxx xxx0 xxxx */ |
| 957 | /* MCR2 : 1111 1110 xxx0 xxxx xxxx xxxx xxx1 xxxx */ |
| 958 | /* MRC2 : 1111 1110 xxx1 xxxx xxxx xxxx xxx1 xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 959 | |
Jon Medhurst | fa1a03b | 2011-04-18 08:53:54 +0100 | [diff] [blame] | 960 | return INSN_REJECTED; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 961 | } |
| 962 | |
| 963 | static enum kprobe_insn __kprobes |
| 964 | space_cccc_000x(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 965 | { |
| 966 | /* cccc 0001 0xx0 xxxx xxxx xxxx xxxx xxx0 xxxx */ |
| 967 | if ((insn & 0x0f900010) == 0x01000000) { |
| 968 | |
Jon Medhurst | 51468ea | 2011-04-07 13:25:15 +0100 | [diff] [blame] | 969 | /* MRS cpsr : cccc 0001 0000 xxxx xxxx xxxx 0000 xxxx */ |
Jon Medhurst | c412aba | 2011-04-07 13:25:16 +0100 | [diff] [blame] | 970 | if ((insn & 0x0ff000f0) == 0x01000000) { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 971 | if (is_r15(insn, 12)) |
| 972 | return INSN_REJECTED; /* Rd is PC */ |
Jon Medhurst | c412aba | 2011-04-07 13:25:16 +0100 | [diff] [blame] | 973 | asi->insn_handler = simulate_mrs; |
| 974 | return INSN_GOOD_NO_SLOT; |
| 975 | } |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 976 | |
| 977 | /* SMLALxy : cccc 0001 0100 xxxx xxxx xxxx 1xx0 xxxx */ |
| 978 | if ((insn & 0x0ff00090) == 0x01400080) |
| 979 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, asi); |
| 980 | |
| 981 | /* SMULWy : cccc 0001 0010 xxxx xxxx xxxx 1x10 xxxx */ |
| 982 | /* SMULxy : cccc 0001 0110 xxxx xxxx xxxx 1xx0 xxxx */ |
| 983 | if ((insn & 0x0ff000b0) == 0x012000a0 || |
| 984 | (insn & 0x0ff00090) == 0x01600080) |
| 985 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); |
| 986 | |
| 987 | /* SMLAxy : cccc 0001 0000 xxxx xxxx xxxx 1xx0 xxxx : Q */ |
Jon Medhurst | 75539ae | 2011-04-07 13:25:18 +0100 | [diff] [blame] | 988 | /* SMLAWy : cccc 0001 0010 xxxx xxxx xxxx 1x00 xxxx : Q */ |
Jon Medhurst | f704a6e | 2011-04-19 10:52:16 +0100 | [diff] [blame^] | 989 | if ((insn & 0x0ff00090) == 0x01000080 || |
| 990 | (insn & 0x0ff000b0) == 0x01200080) |
| 991 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 992 | |
Jon Medhurst | f704a6e | 2011-04-19 10:52:16 +0100 | [diff] [blame^] | 993 | /* BXJ : cccc 0001 0010 xxxx xxxx xxxx 0010 xxxx */ |
| 994 | /* MSR : cccc 0001 0x10 xxxx xxxx xxxx 0000 xxxx */ |
| 995 | /* MRS spsr : cccc 0001 0100 xxxx xxxx xxxx 0000 xxxx */ |
| 996 | |
| 997 | /* Other instruction encodings aren't yet defined */ |
| 998 | return INSN_REJECTED; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | /* cccc 0001 0xx0 xxxx xxxx xxxx xxxx 0xx1 xxxx */ |
| 1002 | else if ((insn & 0x0f900090) == 0x01000010) { |
| 1003 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1004 | /* BLX(2) : cccc 0001 0010 xxxx xxxx xxxx 0011 xxxx */ |
| 1005 | /* BX : cccc 0001 0010 xxxx xxxx xxxx 0001 xxxx */ |
| 1006 | if ((insn & 0x0ff000d0) == 0x01200010) { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 1007 | if ((insn & 0x0ff000ff) == 0x0120003f) |
| 1008 | return INSN_REJECTED; /* BLX pc */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1009 | asi->insn_handler = simulate_blx2bx; |
Jon Medhurst | a539f5d | 2011-04-06 11:17:10 +0100 | [diff] [blame] | 1010 | return INSN_GOOD_NO_SLOT; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | /* CLZ : cccc 0001 0110 xxxx xxxx xxxx 0001 xxxx */ |
| 1014 | if ((insn & 0x0ff000f0) == 0x01600010) |
| 1015 | return prep_emulate_rd12rm0(insn, asi); |
| 1016 | |
| 1017 | /* QADD : cccc 0001 0000 xxxx xxxx xxxx 0101 xxxx :Q */ |
| 1018 | /* QSUB : cccc 0001 0010 xxxx xxxx xxxx 0101 xxxx :Q */ |
| 1019 | /* QDADD : cccc 0001 0100 xxxx xxxx xxxx 0101 xxxx :Q */ |
| 1020 | /* QDSUB : cccc 0001 0110 xxxx xxxx xxxx 0101 xxxx :Q */ |
Jon Medhurst | f704a6e | 2011-04-19 10:52:16 +0100 | [diff] [blame^] | 1021 | if ((insn & 0x0f9000f0) == 0x01000050) |
| 1022 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); |
| 1023 | |
| 1024 | /* BKPT : 1110 0001 0010 xxxx xxxx xxxx 0111 xxxx */ |
| 1025 | /* SMC : cccc 0001 0110 xxxx xxxx xxxx 0111 xxxx */ |
| 1026 | |
| 1027 | /* Other instruction encodings aren't yet defined */ |
| 1028 | return INSN_REJECTED; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | /* cccc 0000 xxxx xxxx xxxx xxxx xxxx 1001 xxxx */ |
Jon Medhurst | ba48d40 | 2011-04-07 13:25:19 +0100 | [diff] [blame] | 1032 | else if ((insn & 0x0f0000f0) == 0x00000090) { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1033 | |
| 1034 | /* MUL : cccc 0000 0000 xxxx xxxx xxxx 1001 xxxx : */ |
| 1035 | /* MULS : cccc 0000 0001 xxxx xxxx xxxx 1001 xxxx :cc */ |
| 1036 | /* MLA : cccc 0000 0010 xxxx xxxx xxxx 1001 xxxx : */ |
| 1037 | /* MLAS : cccc 0000 0011 xxxx xxxx xxxx 1001 xxxx :cc */ |
| 1038 | /* UMAAL : cccc 0000 0100 xxxx xxxx xxxx 1001 xxxx : */ |
Jon Medhurst | ba48d40 | 2011-04-07 13:25:19 +0100 | [diff] [blame] | 1039 | /* undef : cccc 0000 0101 xxxx xxxx xxxx 1001 xxxx : */ |
| 1040 | /* MLS : cccc 0000 0110 xxxx xxxx xxxx 1001 xxxx : */ |
| 1041 | /* undef : cccc 0000 0111 xxxx xxxx xxxx 1001 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1042 | /* UMULL : cccc 0000 1000 xxxx xxxx xxxx 1001 xxxx : */ |
| 1043 | /* UMULLS : cccc 0000 1001 xxxx xxxx xxxx 1001 xxxx :cc */ |
| 1044 | /* UMLAL : cccc 0000 1010 xxxx xxxx xxxx 1001 xxxx : */ |
| 1045 | /* UMLALS : cccc 0000 1011 xxxx xxxx xxxx 1001 xxxx :cc */ |
| 1046 | /* SMULL : cccc 0000 1100 xxxx xxxx xxxx 1001 xxxx : */ |
| 1047 | /* SMULLS : cccc 0000 1101 xxxx xxxx xxxx 1001 xxxx :cc */ |
| 1048 | /* SMLAL : cccc 0000 1110 xxxx xxxx xxxx 1001 xxxx : */ |
| 1049 | /* SMLALS : cccc 0000 1111 xxxx xxxx xxxx 1001 xxxx :cc */ |
Jon Medhurst | ba48d40 | 2011-04-07 13:25:19 +0100 | [diff] [blame] | 1050 | if ((insn & 0x00d00000) == 0x00500000) { |
| 1051 | return INSN_REJECTED; |
| 1052 | } else if ((insn & 0x00e00000) == 0x00000000) { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1053 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); |
Jon Medhurst | ba48d40 | 2011-04-07 13:25:19 +0100 | [diff] [blame] | 1054 | } else if ((insn & 0x00a00000) == 0x00200000) { |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1055 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); |
| 1056 | } else { |
| 1057 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, asi); |
| 1058 | } |
| 1059 | } |
| 1060 | |
| 1061 | /* cccc 000x xxxx xxxx xxxx xxxx xxxx 1xx1 xxxx */ |
| 1062 | else if ((insn & 0x0e000090) == 0x00000090) { |
| 1063 | |
| 1064 | /* SWP : cccc 0001 0000 xxxx xxxx xxxx 1001 xxxx */ |
| 1065 | /* SWPB : cccc 0001 0100 xxxx xxxx xxxx 1001 xxxx */ |
Jon Medhurst | ec58d7f | 2011-04-08 15:32:53 +0100 | [diff] [blame] | 1066 | /* ??? : cccc 0001 0x01 xxxx xxxx xxxx 1001 xxxx */ |
| 1067 | /* ??? : cccc 0001 0x10 xxxx xxxx xxxx 1001 xxxx */ |
| 1068 | /* ??? : cccc 0001 0x11 xxxx xxxx xxxx 1001 xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1069 | /* STREX : cccc 0001 1000 xxxx xxxx xxxx 1001 xxxx */ |
| 1070 | /* LDREX : cccc 0001 1001 xxxx xxxx xxxx 1001 xxxx */ |
Jon Medhurst | ec58d7f | 2011-04-08 15:32:53 +0100 | [diff] [blame] | 1071 | /* STREXD: cccc 0001 1010 xxxx xxxx xxxx 1001 xxxx */ |
| 1072 | /* LDREXD: cccc 0001 1011 xxxx xxxx xxxx 1001 xxxx */ |
| 1073 | /* STREXB: cccc 0001 1100 xxxx xxxx xxxx 1001 xxxx */ |
| 1074 | /* LDREXB: cccc 0001 1101 xxxx xxxx xxxx 1001 xxxx */ |
| 1075 | /* STREXH: cccc 0001 1110 xxxx xxxx xxxx 1001 xxxx */ |
| 1076 | /* LDREXH: cccc 0001 1111 xxxx xxxx xxxx 1001 xxxx */ |
| 1077 | |
| 1078 | /* LDRD : cccc 000x xxx0 xxxx xxxx xxxx 1101 xxxx */ |
| 1079 | /* STRD : cccc 000x xxx0 xxxx xxxx xxxx 1111 xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1080 | /* LDRH : cccc 000x xxx1 xxxx xxxx xxxx 1011 xxxx */ |
| 1081 | /* STRH : cccc 000x xxx0 xxxx xxxx xxxx 1011 xxxx */ |
| 1082 | /* LDRSB : cccc 000x xxx1 xxxx xxxx xxxx 1101 xxxx */ |
| 1083 | /* LDRSH : cccc 000x xxx1 xxxx xxxx xxxx 1111 xxxx */ |
Jon Medhurst | ec58d7f | 2011-04-08 15:32:53 +0100 | [diff] [blame] | 1084 | if ((insn & 0x0f0000f0) == 0x01000090) { |
| 1085 | if ((insn & 0x0fb000f0) == 0x01000090) { |
| 1086 | /* SWP/SWPB */ |
| 1087 | return prep_emulate_rd12rn16rm0_wflags(insn, |
| 1088 | asi); |
| 1089 | } else { |
| 1090 | /* STREX/LDREX variants and unallocaed space */ |
| 1091 | return INSN_REJECTED; |
| 1092 | } |
| 1093 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1094 | } else if ((insn & 0x0e1000d0) == 0x00000d0) { |
| 1095 | /* STRD/LDRD */ |
Jon Medhurst | 54823ac | 2011-04-08 15:32:55 +0100 | [diff] [blame] | 1096 | if ((insn & 0x0000e000) == 0x0000e000) |
| 1097 | return INSN_REJECTED; /* Rd is LR or PC */ |
| 1098 | if (is_writeback(insn) && is_r15(insn, 16)) |
| 1099 | return INSN_REJECTED; /* Writeback to PC */ |
| 1100 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1101 | insn &= 0xfff00fff; |
| 1102 | insn |= 0x00002000; /* Rn = r0, Rd = r2 */ |
Jon Medhurst | 5c6b76f | 2011-04-08 15:32:56 +0100 | [diff] [blame] | 1103 | if (!(insn & (1 << 22))) { |
| 1104 | /* Register index */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1105 | insn &= ~0xf; |
| 1106 | insn |= 1; /* Rm = r1 */ |
| 1107 | } |
| 1108 | asi->insn[0] = insn; |
| 1109 | asi->insn_handler = |
| 1110 | (insn & (1 << 5)) ? emulate_strd : emulate_ldrd; |
| 1111 | return INSN_GOOD; |
| 1112 | } |
| 1113 | |
Jon Medhurst | 54823ac | 2011-04-08 15:32:55 +0100 | [diff] [blame] | 1114 | /* LDRH/STRH/LDRSB/LDRSH */ |
| 1115 | if (is_r15(insn, 12)) |
| 1116 | return INSN_REJECTED; /* Rd is PC */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1117 | return prep_emulate_ldr_str(insn, asi); |
| 1118 | } |
| 1119 | |
| 1120 | /* cccc 000x xxxx xxxx xxxx xxxx xxxx xxxx xxxx */ |
| 1121 | |
| 1122 | /* |
| 1123 | * ALU op with S bit and Rd == 15 : |
| 1124 | * cccc 000x xxx1 xxxx 1111 xxxx xxxx xxxx |
| 1125 | */ |
| 1126 | if ((insn & 0x0e10f000) == 0x0010f000) |
| 1127 | return INSN_REJECTED; |
| 1128 | |
| 1129 | /* |
| 1130 | * "mov ip, sp" is the most common kprobe'd instruction by far. |
| 1131 | * Check and optimize for it explicitly. |
| 1132 | */ |
| 1133 | if (insn == 0xe1a0c00d) { |
| 1134 | asi->insn_handler = simulate_mov_ipsp; |
| 1135 | return INSN_GOOD_NO_SLOT; |
| 1136 | } |
| 1137 | |
| 1138 | /* |
| 1139 | * Data processing: Immediate-shift / Register-shift |
| 1140 | * ALU op : cccc 000x xxxx xxxx xxxx xxxx xxxx xxxx |
| 1141 | * CPY : cccc 0001 1010 xxxx xxxx 0000 0000 xxxx |
| 1142 | * MOV : cccc 0001 101x xxxx xxxx xxxx xxxx xxxx |
| 1143 | * *S (bit 20) updates condition codes |
| 1144 | * ADC/SBC/RSC reads the C flag |
| 1145 | */ |
| 1146 | insn &= 0xfff00ff0; /* Rn = r0, Rd = r0 */ |
| 1147 | insn |= 0x00000001; /* Rm = r1 */ |
| 1148 | if (insn & 0x010) { |
| 1149 | insn &= 0xfffff0ff; /* register shift */ |
| 1150 | insn |= 0x00000200; /* Rs = r2 */ |
| 1151 | } |
| 1152 | asi->insn[0] = insn; |
Jon Medhurst | ad111ce | 2011-04-06 11:17:11 +0100 | [diff] [blame] | 1153 | |
| 1154 | if ((insn & 0x0f900000) == 0x01100000) { |
| 1155 | /* |
| 1156 | * TST : cccc 0001 0001 xxxx xxxx xxxx xxxx xxxx |
| 1157 | * TEQ : cccc 0001 0011 xxxx xxxx xxxx xxxx xxxx |
| 1158 | * CMP : cccc 0001 0101 xxxx xxxx xxxx xxxx xxxx |
| 1159 | * CMN : cccc 0001 0111 xxxx xxxx xxxx xxxx xxxx |
| 1160 | */ |
| 1161 | asi->insn_handler = emulate_alu_tests; |
| 1162 | } else { |
| 1163 | /* ALU ops which write to Rd */ |
| 1164 | asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1165 | emulate_alu_rwflags : emulate_alu_rflags; |
Jon Medhurst | ad111ce | 2011-04-06 11:17:11 +0100 | [diff] [blame] | 1166 | } |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1167 | return INSN_GOOD; |
| 1168 | } |
| 1169 | |
| 1170 | static enum kprobe_insn __kprobes |
| 1171 | space_cccc_001x(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 1172 | { |
| 1173 | /* |
| 1174 | * MSR : cccc 0011 0x10 xxxx xxxx xxxx xxxx xxxx |
Will Deacon | ccdf2e1 | 2010-09-27 18:12:12 +0100 | [diff] [blame] | 1175 | * Undef : cccc 0011 0100 xxxx xxxx xxxx xxxx xxxx |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1176 | * ALU op with S bit and Rd == 15 : |
| 1177 | * cccc 001x xxx1 xxxx 1111 xxxx xxxx xxxx |
| 1178 | */ |
Will Deacon | ccdf2e1 | 2010-09-27 18:12:12 +0100 | [diff] [blame] | 1179 | if ((insn & 0x0fb00000) == 0x03200000 || /* MSR */ |
| 1180 | (insn & 0x0ff00000) == 0x03400000 || /* Undef */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1181 | (insn & 0x0e10f000) == 0x0210f000) /* ALU s-bit, R15 */ |
| 1182 | return INSN_REJECTED; |
| 1183 | |
| 1184 | /* |
| 1185 | * Data processing: 32-bit Immediate |
| 1186 | * ALU op : cccc 001x xxxx xxxx xxxx xxxx xxxx xxxx |
| 1187 | * MOV : cccc 0011 101x xxxx xxxx xxxx xxxx xxxx |
| 1188 | * *S (bit 20) updates condition codes |
| 1189 | * ADC/SBC/RSC reads the C flag |
| 1190 | */ |
Jon Medhurst | 896a74e | 2011-04-06 11:17:12 +0100 | [diff] [blame] | 1191 | insn &= 0xfff00fff; /* Rn = r0 and Rd = r0 */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1192 | asi->insn[0] = insn; |
Jon Medhurst | ad111ce | 2011-04-06 11:17:11 +0100 | [diff] [blame] | 1193 | |
| 1194 | if ((insn & 0x0f900000) == 0x03100000) { |
| 1195 | /* |
| 1196 | * TST : cccc 0011 0001 xxxx xxxx xxxx xxxx xxxx |
| 1197 | * TEQ : cccc 0011 0011 xxxx xxxx xxxx xxxx xxxx |
| 1198 | * CMP : cccc 0011 0101 xxxx xxxx xxxx xxxx xxxx |
| 1199 | * CMN : cccc 0011 0111 xxxx xxxx xxxx xxxx xxxx |
| 1200 | */ |
| 1201 | asi->insn_handler = emulate_alu_tests_imm; |
| 1202 | } else { |
| 1203 | /* ALU ops which write to Rd */ |
| 1204 | asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1205 | emulate_alu_imm_rwflags : emulate_alu_imm_rflags; |
Jon Medhurst | ad111ce | 2011-04-06 11:17:11 +0100 | [diff] [blame] | 1206 | } |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1207 | return INSN_GOOD; |
| 1208 | } |
| 1209 | |
| 1210 | static enum kprobe_insn __kprobes |
| 1211 | space_cccc_0110__1(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 1212 | { |
| 1213 | /* SEL : cccc 0110 1000 xxxx xxxx xxxx 1011 xxxx GE: !!! */ |
| 1214 | if ((insn & 0x0ff000f0) == 0x068000b0) { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 1215 | if (is_r15(insn, 12)) |
| 1216 | return INSN_REJECTED; /* Rd is PC */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1217 | insn &= 0xfff00ff0; /* Rd = r0, Rn = r0 */ |
| 1218 | insn |= 0x00000001; /* Rm = r1 */ |
| 1219 | asi->insn[0] = insn; |
| 1220 | asi->insn_handler = emulate_sel; |
| 1221 | return INSN_GOOD; |
| 1222 | } |
| 1223 | |
| 1224 | /* SSAT : cccc 0110 101x xxxx xxxx xxxx xx01 xxxx :Q */ |
| 1225 | /* USAT : cccc 0110 111x xxxx xxxx xxxx xx01 xxxx :Q */ |
| 1226 | /* SSAT16 : cccc 0110 1010 xxxx xxxx xxxx 0011 xxxx :Q */ |
| 1227 | /* USAT16 : cccc 0110 1110 xxxx xxxx xxxx 0011 xxxx :Q */ |
| 1228 | if ((insn & 0x0fa00030) == 0x06a00010 || |
| 1229 | (insn & 0x0fb000f0) == 0x06a00030) { |
Jon Medhurst | 983ebd9 | 2011-04-07 13:25:17 +0100 | [diff] [blame] | 1230 | if (is_r15(insn, 12)) |
| 1231 | return INSN_REJECTED; /* Rd is PC */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1232 | insn &= 0xffff0ff0; /* Rd = r0, Rm = r0 */ |
| 1233 | asi->insn[0] = insn; |
| 1234 | asi->insn_handler = emulate_sat; |
| 1235 | return INSN_GOOD; |
| 1236 | } |
| 1237 | |
| 1238 | /* REV : cccc 0110 1011 xxxx xxxx xxxx 0011 xxxx */ |
| 1239 | /* REV16 : cccc 0110 1011 xxxx xxxx xxxx 1011 xxxx */ |
Jon Medhurst | 0e384ed | 2011-04-12 07:45:22 +0100 | [diff] [blame] | 1240 | /* RBIT : cccc 0110 1111 xxxx xxxx xxxx 0011 xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1241 | /* REVSH : cccc 0110 1111 xxxx xxxx xxxx 1011 xxxx */ |
| 1242 | if ((insn & 0x0ff00070) == 0x06b00030 || |
Jon Medhurst | 0e384ed | 2011-04-12 07:45:22 +0100 | [diff] [blame] | 1243 | (insn & 0x0ff00070) == 0x06f00030) |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1244 | return prep_emulate_rd12rm0(insn, asi); |
| 1245 | |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1246 | /* ??? : cccc 0110 0000 xxxx xxxx xxxx xxx1 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1247 | /* SADD16 : cccc 0110 0001 xxxx xxxx xxxx 0001 xxxx :GE */ |
| 1248 | /* SADDSUBX : cccc 0110 0001 xxxx xxxx xxxx 0011 xxxx :GE */ |
| 1249 | /* SSUBADDX : cccc 0110 0001 xxxx xxxx xxxx 0101 xxxx :GE */ |
| 1250 | /* SSUB16 : cccc 0110 0001 xxxx xxxx xxxx 0111 xxxx :GE */ |
| 1251 | /* SADD8 : cccc 0110 0001 xxxx xxxx xxxx 1001 xxxx :GE */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1252 | /* ??? : cccc 0110 0001 xxxx xxxx xxxx 1011 xxxx : */ |
| 1253 | /* ??? : cccc 0110 0001 xxxx xxxx xxxx 1101 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1254 | /* SSUB8 : cccc 0110 0001 xxxx xxxx xxxx 1111 xxxx :GE */ |
| 1255 | /* QADD16 : cccc 0110 0010 xxxx xxxx xxxx 0001 xxxx : */ |
| 1256 | /* QADDSUBX : cccc 0110 0010 xxxx xxxx xxxx 0011 xxxx : */ |
| 1257 | /* QSUBADDX : cccc 0110 0010 xxxx xxxx xxxx 0101 xxxx : */ |
| 1258 | /* QSUB16 : cccc 0110 0010 xxxx xxxx xxxx 0111 xxxx : */ |
| 1259 | /* QADD8 : cccc 0110 0010 xxxx xxxx xxxx 1001 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1260 | /* ??? : cccc 0110 0010 xxxx xxxx xxxx 1011 xxxx : */ |
| 1261 | /* ??? : cccc 0110 0010 xxxx xxxx xxxx 1101 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1262 | /* QSUB8 : cccc 0110 0010 xxxx xxxx xxxx 1111 xxxx : */ |
| 1263 | /* SHADD16 : cccc 0110 0011 xxxx xxxx xxxx 0001 xxxx : */ |
| 1264 | /* SHADDSUBX : cccc 0110 0011 xxxx xxxx xxxx 0011 xxxx : */ |
| 1265 | /* SHSUBADDX : cccc 0110 0011 xxxx xxxx xxxx 0101 xxxx : */ |
| 1266 | /* SHSUB16 : cccc 0110 0011 xxxx xxxx xxxx 0111 xxxx : */ |
| 1267 | /* SHADD8 : cccc 0110 0011 xxxx xxxx xxxx 1001 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1268 | /* ??? : cccc 0110 0011 xxxx xxxx xxxx 1011 xxxx : */ |
| 1269 | /* ??? : cccc 0110 0011 xxxx xxxx xxxx 1101 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1270 | /* SHSUB8 : cccc 0110 0011 xxxx xxxx xxxx 1111 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1271 | /* ??? : cccc 0110 0100 xxxx xxxx xxxx xxx1 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1272 | /* UADD16 : cccc 0110 0101 xxxx xxxx xxxx 0001 xxxx :GE */ |
| 1273 | /* UADDSUBX : cccc 0110 0101 xxxx xxxx xxxx 0011 xxxx :GE */ |
| 1274 | /* USUBADDX : cccc 0110 0101 xxxx xxxx xxxx 0101 xxxx :GE */ |
| 1275 | /* USUB16 : cccc 0110 0101 xxxx xxxx xxxx 0111 xxxx :GE */ |
| 1276 | /* UADD8 : cccc 0110 0101 xxxx xxxx xxxx 1001 xxxx :GE */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1277 | /* ??? : cccc 0110 0101 xxxx xxxx xxxx 1011 xxxx : */ |
| 1278 | /* ??? : cccc 0110 0101 xxxx xxxx xxxx 1101 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1279 | /* USUB8 : cccc 0110 0101 xxxx xxxx xxxx 1111 xxxx :GE */ |
| 1280 | /* UQADD16 : cccc 0110 0110 xxxx xxxx xxxx 0001 xxxx : */ |
| 1281 | /* UQADDSUBX : cccc 0110 0110 xxxx xxxx xxxx 0011 xxxx : */ |
| 1282 | /* UQSUBADDX : cccc 0110 0110 xxxx xxxx xxxx 0101 xxxx : */ |
| 1283 | /* UQSUB16 : cccc 0110 0110 xxxx xxxx xxxx 0111 xxxx : */ |
| 1284 | /* UQADD8 : cccc 0110 0110 xxxx xxxx xxxx 1001 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1285 | /* ??? : cccc 0110 0110 xxxx xxxx xxxx 1011 xxxx : */ |
| 1286 | /* ??? : cccc 0110 0110 xxxx xxxx xxxx 1101 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1287 | /* UQSUB8 : cccc 0110 0110 xxxx xxxx xxxx 1111 xxxx : */ |
| 1288 | /* UHADD16 : cccc 0110 0111 xxxx xxxx xxxx 0001 xxxx : */ |
| 1289 | /* UHADDSUBX : cccc 0110 0111 xxxx xxxx xxxx 0011 xxxx : */ |
| 1290 | /* UHSUBADDX : cccc 0110 0111 xxxx xxxx xxxx 0101 xxxx : */ |
| 1291 | /* UHSUB16 : cccc 0110 0111 xxxx xxxx xxxx 0111 xxxx : */ |
| 1292 | /* UHADD8 : cccc 0110 0111 xxxx xxxx xxxx 1001 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1293 | /* ??? : cccc 0110 0111 xxxx xxxx xxxx 1011 xxxx : */ |
| 1294 | /* ??? : cccc 0110 0111 xxxx xxxx xxxx 1101 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1295 | /* UHSUB8 : cccc 0110 0111 xxxx xxxx xxxx 1111 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1296 | if ((insn & 0x0f800010) == 0x06000010) { |
| 1297 | if ((insn & 0x00300000) == 0x00000000 || |
| 1298 | (insn & 0x000000e0) == 0x000000a0 || |
| 1299 | (insn & 0x000000e0) == 0x000000c0) |
| 1300 | return INSN_REJECTED; /* Unallocated space */ |
| 1301 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); |
| 1302 | } |
| 1303 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1304 | /* PKHBT : cccc 0110 1000 xxxx xxxx xxxx x001 xxxx : */ |
| 1305 | /* PKHTB : cccc 0110 1000 xxxx xxxx xxxx x101 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1306 | if ((insn & 0x0ff00030) == 0x06800010) |
| 1307 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); |
| 1308 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1309 | /* SXTAB16 : cccc 0110 1000 xxxx xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 8dd7cfb | 2011-04-12 07:45:24 +0100 | [diff] [blame] | 1310 | /* SXTB16 : cccc 0110 1000 1111 xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1311 | /* ??? : cccc 0110 1001 xxxx xxxx xxxx 0111 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1312 | /* SXTAB : cccc 0110 1010 xxxx xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 8dd7cfb | 2011-04-12 07:45:24 +0100 | [diff] [blame] | 1313 | /* SXTB : cccc 0110 1010 1111 xxxx xxxx 0111 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1314 | /* SXTAH : cccc 0110 1011 xxxx xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 8dd7cfb | 2011-04-12 07:45:24 +0100 | [diff] [blame] | 1315 | /* SXTH : cccc 0110 1011 1111 xxxx xxxx 0111 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1316 | /* UXTAB16 : cccc 0110 1100 xxxx xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 8dd7cfb | 2011-04-12 07:45:24 +0100 | [diff] [blame] | 1317 | /* UXTB16 : cccc 0110 1100 1111 xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1318 | /* ??? : cccc 0110 1101 xxxx xxxx xxxx 0111 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1319 | /* UXTAB : cccc 0110 1110 xxxx xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 8dd7cfb | 2011-04-12 07:45:24 +0100 | [diff] [blame] | 1320 | /* UXTB : cccc 0110 1110 1111 xxxx xxxx 0111 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1321 | /* UXTAH : cccc 0110 1111 xxxx xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 8dd7cfb | 2011-04-12 07:45:24 +0100 | [diff] [blame] | 1322 | /* UXTH : cccc 0110 1111 1111 xxxx xxxx 0111 xxxx : */ |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1323 | if ((insn & 0x0f8000f0) == 0x06800070) { |
| 1324 | if ((insn & 0x00300000) == 0x00100000) |
| 1325 | return INSN_REJECTED; /* Unallocated space */ |
Jon Medhurst | 8dd7cfb | 2011-04-12 07:45:24 +0100 | [diff] [blame] | 1326 | |
| 1327 | if ((insn & 0x000f0000) == 0x000f0000) { |
| 1328 | return prep_emulate_rd12rm0(insn, asi); |
| 1329 | } else { |
| 1330 | return prep_emulate_rd12rn16rm0_wflags(insn, asi); |
| 1331 | } |
Jon Medhurst | 780b5c1 | 2011-04-12 07:45:23 +0100 | [diff] [blame] | 1332 | } |
| 1333 | |
| 1334 | /* Other instruction encodings aren't yet defined */ |
| 1335 | return INSN_REJECTED; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1336 | } |
| 1337 | |
| 1338 | static enum kprobe_insn __kprobes |
| 1339 | space_cccc_0111__1(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 1340 | { |
| 1341 | /* Undef : cccc 0111 1111 xxxx xxxx xxxx 1111 xxxx */ |
| 1342 | if ((insn & 0x0ff000f0) == 0x03f000f0) |
| 1343 | return INSN_REJECTED; |
| 1344 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1345 | /* SMLALD : cccc 0111 0100 xxxx xxxx xxxx 00x1 xxxx */ |
| 1346 | /* SMLSLD : cccc 0111 0100 xxxx xxxx xxxx 01x1 xxxx */ |
| 1347 | if ((insn & 0x0ff00090) == 0x07400010) |
| 1348 | return prep_emulate_rdhi16rdlo12rs8rm0_wflags(insn, asi); |
| 1349 | |
| 1350 | /* SMLAD : cccc 0111 0000 xxxx xxxx xxxx 00x1 xxxx :Q */ |
Jon Medhurst | 038c383 | 2011-04-12 07:45:25 +0100 | [diff] [blame] | 1351 | /* SMUAD : cccc 0111 0000 xxxx 1111 xxxx 00x1 xxxx :Q */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1352 | /* SMLSD : cccc 0111 0000 xxxx xxxx xxxx 01x1 xxxx :Q */ |
Jon Medhurst | 038c383 | 2011-04-12 07:45:25 +0100 | [diff] [blame] | 1353 | /* SMUSD : cccc 0111 0000 xxxx 1111 xxxx 01x1 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1354 | /* SMMLA : cccc 0111 0101 xxxx xxxx xxxx 00x1 xxxx : */ |
Jon Medhurst | 038c383 | 2011-04-12 07:45:25 +0100 | [diff] [blame] | 1355 | /* SMMUL : cccc 0111 0101 xxxx 1111 xxxx 00x1 xxxx : */ |
Jon Medhurst | c6e4ae3 | 2011-04-12 07:45:26 +0100 | [diff] [blame] | 1356 | /* USADA8 : cccc 0111 1000 xxxx xxxx xxxx 0001 xxxx : */ |
| 1357 | /* USAD8 : cccc 0111 1000 xxxx 1111 xxxx 0001 xxxx : */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1358 | if ((insn & 0x0ff00090) == 0x07000010 || |
Jon Medhurst | c6e4ae3 | 2011-04-12 07:45:26 +0100 | [diff] [blame] | 1359 | (insn & 0x0ff000d0) == 0x07500010 || |
| 1360 | (insn & 0x0ff000f0) == 0x07800010) { |
Jon Medhurst | 038c383 | 2011-04-12 07:45:25 +0100 | [diff] [blame] | 1361 | |
| 1362 | if ((insn & 0x0000f000) == 0x0000f000) { |
| 1363 | return prep_emulate_rd16rs8rm0_wflags(insn, asi); |
| 1364 | } else { |
| 1365 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | /* SMMLS : cccc 0111 0101 xxxx xxxx xxxx 11x1 xxxx : */ |
| 1370 | if ((insn & 0x0ff000d0) == 0x075000d0) |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1371 | return prep_emulate_rd16rn12rs8rm0_wflags(insn, asi); |
| 1372 | |
Jon Medhurst | 038c383 | 2011-04-12 07:45:25 +0100 | [diff] [blame] | 1373 | return INSN_REJECTED; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1374 | } |
| 1375 | |
| 1376 | static enum kprobe_insn __kprobes |
| 1377 | space_cccc_01xx(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 1378 | { |
| 1379 | /* LDR : cccc 01xx x0x1 xxxx xxxx xxxx xxxx xxxx */ |
| 1380 | /* LDRB : cccc 01xx x1x1 xxxx xxxx xxxx xxxx xxxx */ |
| 1381 | /* LDRBT : cccc 01x0 x111 xxxx xxxx xxxx xxxx xxxx */ |
| 1382 | /* LDRT : cccc 01x0 x011 xxxx xxxx xxxx xxxx xxxx */ |
| 1383 | /* STR : cccc 01xx x0x0 xxxx xxxx xxxx xxxx xxxx */ |
| 1384 | /* STRB : cccc 01xx x1x0 xxxx xxxx xxxx xxxx xxxx */ |
| 1385 | /* STRBT : cccc 01x0 x110 xxxx xxxx xxxx xxxx xxxx */ |
| 1386 | /* STRT : cccc 01x0 x010 xxxx xxxx xxxx xxxx xxxx */ |
Jon Medhurst | 81ff572 | 2011-04-12 07:45:21 +0100 | [diff] [blame] | 1387 | |
| 1388 | if ((insn & 0x00500000) == 0x00500000 && is_r15(insn, 12)) |
| 1389 | return INSN_REJECTED; /* LDRB into PC */ |
| 1390 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1391 | return prep_emulate_ldr_str(insn, asi); |
| 1392 | } |
| 1393 | |
| 1394 | static enum kprobe_insn __kprobes |
| 1395 | space_cccc_100x(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 1396 | { |
| 1397 | /* LDM(2) : cccc 100x x101 xxxx 0xxx xxxx xxxx xxxx */ |
| 1398 | /* LDM(3) : cccc 100x x1x1 xxxx 1xxx xxxx xxxx xxxx */ |
| 1399 | if ((insn & 0x0e708000) == 0x85000000 || |
| 1400 | (insn & 0x0e508000) == 0x85010000) |
| 1401 | return INSN_REJECTED; |
| 1402 | |
| 1403 | /* LDM(1) : cccc 100x x0x1 xxxx xxxx xxxx xxxx xxxx */ |
| 1404 | /* STM(1) : cccc 100x x0x0 xxxx xxxx xxxx xxxx xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1405 | asi->insn_handler = ((insn & 0x108000) == 0x008000) ? /* STM & R15 */ |
| 1406 | simulate_stm1_pc : simulate_ldm1stm1; |
Jon Medhurst | a539f5d | 2011-04-06 11:17:10 +0100 | [diff] [blame] | 1407 | return INSN_GOOD_NO_SLOT; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1408 | } |
| 1409 | |
| 1410 | static enum kprobe_insn __kprobes |
| 1411 | space_cccc_101x(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 1412 | { |
| 1413 | /* B : cccc 1010 xxxx xxxx xxxx xxxx xxxx xxxx */ |
| 1414 | /* BL : cccc 1011 xxxx xxxx xxxx xxxx xxxx xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1415 | asi->insn_handler = simulate_bbl; |
Jon Medhurst | a539f5d | 2011-04-06 11:17:10 +0100 | [diff] [blame] | 1416 | return INSN_GOOD_NO_SLOT; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1417 | } |
| 1418 | |
| 1419 | static enum kprobe_insn __kprobes |
Jon Medhurst | ac211c6 | 2011-04-18 08:53:55 +0100 | [diff] [blame] | 1420 | space_cccc_11xx(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1421 | { |
Jon Medhurst | ac211c6 | 2011-04-18 08:53:55 +0100 | [diff] [blame] | 1422 | /* Coprocessor instructions... */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1423 | /* MCRR : cccc 1100 0100 xxxx xxxx xxxx xxxx xxxx : (Rd!=Rn) */ |
| 1424 | /* MRRC : cccc 1100 0101 xxxx xxxx xxxx xxxx xxxx : (Rd!=Rn) */ |
Jon Medhurst | ac211c6 | 2011-04-18 08:53:55 +0100 | [diff] [blame] | 1425 | /* LDC : cccc 110x xxx1 xxxx xxxx xxxx xxxx xxxx */ |
| 1426 | /* STC : cccc 110x xxx0 xxxx xxxx xxxx xxxx xxxx */ |
| 1427 | /* CDP : cccc 1110 xxxx xxxx xxxx xxxx xxx0 xxxx */ |
| 1428 | /* MCR : cccc 1110 xxx0 xxxx xxxx xxxx xxx1 xxxx */ |
| 1429 | /* MRC : cccc 1110 xxx1 xxxx xxxx xxxx xxx1 xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1430 | |
Jon Medhurst | ac211c6 | 2011-04-18 08:53:55 +0100 | [diff] [blame] | 1431 | /* SVC : cccc 1111 xxxx xxxx xxxx xxxx xxxx xxxx */ |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1432 | |
Jon Medhurst | fa1a03b | 2011-04-18 08:53:54 +0100 | [diff] [blame] | 1433 | return INSN_REJECTED; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1434 | } |
| 1435 | |
Jon Medhurst | 073090c | 2011-04-06 11:17:09 +0100 | [diff] [blame] | 1436 | static unsigned long __kprobes __check_eq(unsigned long cpsr) |
| 1437 | { |
| 1438 | return cpsr & PSR_Z_BIT; |
| 1439 | } |
| 1440 | |
| 1441 | static unsigned long __kprobes __check_ne(unsigned long cpsr) |
| 1442 | { |
| 1443 | return (~cpsr) & PSR_Z_BIT; |
| 1444 | } |
| 1445 | |
| 1446 | static unsigned long __kprobes __check_cs(unsigned long cpsr) |
| 1447 | { |
| 1448 | return cpsr & PSR_C_BIT; |
| 1449 | } |
| 1450 | |
| 1451 | static unsigned long __kprobes __check_cc(unsigned long cpsr) |
| 1452 | { |
| 1453 | return (~cpsr) & PSR_C_BIT; |
| 1454 | } |
| 1455 | |
| 1456 | static unsigned long __kprobes __check_mi(unsigned long cpsr) |
| 1457 | { |
| 1458 | return cpsr & PSR_N_BIT; |
| 1459 | } |
| 1460 | |
| 1461 | static unsigned long __kprobes __check_pl(unsigned long cpsr) |
| 1462 | { |
| 1463 | return (~cpsr) & PSR_N_BIT; |
| 1464 | } |
| 1465 | |
| 1466 | static unsigned long __kprobes __check_vs(unsigned long cpsr) |
| 1467 | { |
| 1468 | return cpsr & PSR_V_BIT; |
| 1469 | } |
| 1470 | |
| 1471 | static unsigned long __kprobes __check_vc(unsigned long cpsr) |
| 1472 | { |
| 1473 | return (~cpsr) & PSR_V_BIT; |
| 1474 | } |
| 1475 | |
| 1476 | static unsigned long __kprobes __check_hi(unsigned long cpsr) |
| 1477 | { |
| 1478 | cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ |
| 1479 | return cpsr & PSR_C_BIT; |
| 1480 | } |
| 1481 | |
| 1482 | static unsigned long __kprobes __check_ls(unsigned long cpsr) |
| 1483 | { |
| 1484 | cpsr &= ~(cpsr >> 1); /* PSR_C_BIT &= ~PSR_Z_BIT */ |
| 1485 | return (~cpsr) & PSR_C_BIT; |
| 1486 | } |
| 1487 | |
| 1488 | static unsigned long __kprobes __check_ge(unsigned long cpsr) |
| 1489 | { |
| 1490 | cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ |
| 1491 | return (~cpsr) & PSR_N_BIT; |
| 1492 | } |
| 1493 | |
| 1494 | static unsigned long __kprobes __check_lt(unsigned long cpsr) |
| 1495 | { |
| 1496 | cpsr ^= (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ |
| 1497 | return cpsr & PSR_N_BIT; |
| 1498 | } |
| 1499 | |
| 1500 | static unsigned long __kprobes __check_gt(unsigned long cpsr) |
| 1501 | { |
| 1502 | unsigned long temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ |
| 1503 | temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */ |
| 1504 | return (~temp) & PSR_N_BIT; |
| 1505 | } |
| 1506 | |
| 1507 | static unsigned long __kprobes __check_le(unsigned long cpsr) |
| 1508 | { |
| 1509 | unsigned long temp = cpsr ^ (cpsr << 3); /* PSR_N_BIT ^= PSR_V_BIT */ |
| 1510 | temp |= (cpsr << 1); /* PSR_N_BIT |= PSR_Z_BIT */ |
| 1511 | return temp & PSR_N_BIT; |
| 1512 | } |
| 1513 | |
| 1514 | static unsigned long __kprobes __check_al(unsigned long cpsr) |
| 1515 | { |
| 1516 | return true; |
| 1517 | } |
| 1518 | |
| 1519 | static kprobe_check_cc * const condition_checks[16] = { |
| 1520 | &__check_eq, &__check_ne, &__check_cs, &__check_cc, |
| 1521 | &__check_mi, &__check_pl, &__check_vs, &__check_vc, |
| 1522 | &__check_hi, &__check_ls, &__check_ge, &__check_lt, |
| 1523 | &__check_gt, &__check_le, &__check_al, &__check_al |
| 1524 | }; |
| 1525 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1526 | /* Return: |
| 1527 | * INSN_REJECTED If instruction is one not allowed to kprobe, |
| 1528 | * INSN_GOOD If instruction is supported and uses instruction slot, |
| 1529 | * INSN_GOOD_NO_SLOT If instruction is supported but doesn't use its slot. |
| 1530 | * |
| 1531 | * For instructions we don't want to kprobe (INSN_REJECTED return result): |
| 1532 | * These are generally ones that modify the processor state making |
| 1533 | * them "hard" to simulate such as switches processor modes or |
| 1534 | * make accesses in alternate modes. Any of these could be simulated |
| 1535 | * if the work was put into it, but low return considering they |
| 1536 | * should also be very rare. |
| 1537 | */ |
| 1538 | enum kprobe_insn __kprobes |
| 1539 | arm_kprobe_decode_insn(kprobe_opcode_t insn, struct arch_specific_insn *asi) |
| 1540 | { |
Jon Medhurst | 073090c | 2011-04-06 11:17:09 +0100 | [diff] [blame] | 1541 | asi->insn_check_cc = condition_checks[insn>>28]; |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1542 | asi->insn[1] = KPROBE_RETURN_INSTRUCTION; |
| 1543 | |
| 1544 | if ((insn & 0xf0000000) == 0xf0000000) { |
| 1545 | |
| 1546 | return space_1111(insn, asi); |
| 1547 | |
| 1548 | } else if ((insn & 0x0e000000) == 0x00000000) { |
| 1549 | |
| 1550 | return space_cccc_000x(insn, asi); |
| 1551 | |
| 1552 | } else if ((insn & 0x0e000000) == 0x02000000) { |
| 1553 | |
| 1554 | return space_cccc_001x(insn, asi); |
| 1555 | |
| 1556 | } else if ((insn & 0x0f000010) == 0x06000010) { |
| 1557 | |
| 1558 | return space_cccc_0110__1(insn, asi); |
| 1559 | |
| 1560 | } else if ((insn & 0x0f000010) == 0x07000010) { |
| 1561 | |
| 1562 | return space_cccc_0111__1(insn, asi); |
| 1563 | |
| 1564 | } else if ((insn & 0x0c000000) == 0x04000000) { |
| 1565 | |
| 1566 | return space_cccc_01xx(insn, asi); |
| 1567 | |
| 1568 | } else if ((insn & 0x0e000000) == 0x08000000) { |
| 1569 | |
| 1570 | return space_cccc_100x(insn, asi); |
| 1571 | |
| 1572 | } else if ((insn & 0x0e000000) == 0x0a000000) { |
| 1573 | |
| 1574 | return space_cccc_101x(insn, asi); |
| 1575 | |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1576 | } |
| 1577 | |
Jon Medhurst | ac211c6 | 2011-04-18 08:53:55 +0100 | [diff] [blame] | 1578 | return space_cccc_11xx(insn, asi); |
Quentin Barnes | 35aa1df | 2007-06-11 22:20:10 +0000 | [diff] [blame] | 1579 | } |
| 1580 | |
| 1581 | void __init arm_kprobe_decode_init(void) |
| 1582 | { |
| 1583 | find_str_pc_offset(); |
| 1584 | } |
| 1585 | |
| 1586 | |
| 1587 | /* |
| 1588 | * All ARM instructions listed below. |
| 1589 | * |
| 1590 | * Instructions and their general purpose registers are given. |
| 1591 | * If a particular register may not use R15, it is prefixed with a "!". |
| 1592 | * If marked with a "*" means the value returned by reading R15 |
| 1593 | * is implementation defined. |
| 1594 | * |
| 1595 | * ADC/ADD/AND/BIC/CMN/CMP/EOR/MOV/MVN/ORR/RSB/RSC/SBC/SUB/TEQ |
| 1596 | * TST: Rd, Rn, Rm, !Rs |
| 1597 | * BX: Rm |
| 1598 | * BLX(2): !Rm |
| 1599 | * BX: Rm (R15 legal, but discouraged) |
| 1600 | * BXJ: !Rm, |
| 1601 | * CLZ: !Rd, !Rm |
| 1602 | * CPY: Rd, Rm |
| 1603 | * LDC/2,STC/2 immediate offset & unindex: Rn |
| 1604 | * LDC/2,STC/2 immediate pre/post-indexed: !Rn |
| 1605 | * LDM(1/3): !Rn, register_list |
| 1606 | * LDM(2): !Rn, !register_list |
| 1607 | * LDR,STR,PLD immediate offset: Rd, Rn |
| 1608 | * LDR,STR,PLD register offset: Rd, Rn, !Rm |
| 1609 | * LDR,STR,PLD scaled register offset: Rd, !Rn, !Rm |
| 1610 | * LDR,STR immediate pre/post-indexed: Rd, !Rn |
| 1611 | * LDR,STR register pre/post-indexed: Rd, !Rn, !Rm |
| 1612 | * LDR,STR scaled register pre/post-indexed: Rd, !Rn, !Rm |
| 1613 | * LDRB,STRB immediate offset: !Rd, Rn |
| 1614 | * LDRB,STRB register offset: !Rd, Rn, !Rm |
| 1615 | * LDRB,STRB scaled register offset: !Rd, !Rn, !Rm |
| 1616 | * LDRB,STRB immediate pre/post-indexed: !Rd, !Rn |
| 1617 | * LDRB,STRB register pre/post-indexed: !Rd, !Rn, !Rm |
| 1618 | * LDRB,STRB scaled register pre/post-indexed: !Rd, !Rn, !Rm |
| 1619 | * LDRT,LDRBT,STRBT immediate pre/post-indexed: !Rd, !Rn |
| 1620 | * LDRT,LDRBT,STRBT register pre/post-indexed: !Rd, !Rn, !Rm |
| 1621 | * LDRT,LDRBT,STRBT scaled register pre/post-indexed: !Rd, !Rn, !Rm |
| 1622 | * LDRH/SH/SB/D,STRH/SH/SB/D immediate offset: !Rd, Rn |
| 1623 | * LDRH/SH/SB/D,STRH/SH/SB/D register offset: !Rd, Rn, !Rm |
| 1624 | * LDRH/SH/SB/D,STRH/SH/SB/D immediate pre/post-indexed: !Rd, !Rn |
| 1625 | * LDRH/SH/SB/D,STRH/SH/SB/D register pre/post-indexed: !Rd, !Rn, !Rm |
| 1626 | * LDREX: !Rd, !Rn |
| 1627 | * MCR/2: !Rd |
| 1628 | * MCRR/2,MRRC/2: !Rd, !Rn |
| 1629 | * MLA: !Rd, !Rn, !Rm, !Rs |
| 1630 | * MOV: Rd |
| 1631 | * MRC/2: !Rd (if Rd==15, only changes cond codes, not the register) |
| 1632 | * MRS,MSR: !Rd |
| 1633 | * MUL: !Rd, !Rm, !Rs |
| 1634 | * PKH{BT,TB}: !Rd, !Rn, !Rm |
| 1635 | * QDADD,[U]QADD/16/8/SUBX: !Rd, !Rm, !Rn |
| 1636 | * QDSUB,[U]QSUB/16/8/ADDX: !Rd, !Rm, !Rn |
| 1637 | * REV/16/SH: !Rd, !Rm |
| 1638 | * RFE: !Rn |
| 1639 | * {S,U}[H]ADD{16,8,SUBX},{S,U}[H]SUB{16,8,ADDX}: !Rd, !Rn, !Rm |
| 1640 | * SEL: !Rd, !Rn, !Rm |
| 1641 | * SMLA<x><y>,SMLA{D,W<y>},SMLSD,SMML{A,S}: !Rd, !Rn, !Rm, !Rs |
| 1642 | * SMLAL<x><y>,SMLA{D,LD},SMLSLD,SMMULL,SMULW<y>: !RdHi, !RdLo, !Rm, !Rs |
| 1643 | * SMMUL,SMUAD,SMUL<x><y>,SMUSD: !Rd, !Rm, !Rs |
| 1644 | * SSAT/16: !Rd, !Rm |
| 1645 | * STM(1/2): !Rn, register_list* (R15 in reg list not recommended) |
| 1646 | * STRT immediate pre/post-indexed: Rd*, !Rn |
| 1647 | * STRT register pre/post-indexed: Rd*, !Rn, !Rm |
| 1648 | * STRT scaled register pre/post-indexed: Rd*, !Rn, !Rm |
| 1649 | * STREX: !Rd, !Rn, !Rm |
| 1650 | * SWP/B: !Rd, !Rn, !Rm |
| 1651 | * {S,U}XTA{B,B16,H}: !Rd, !Rn, !Rm |
| 1652 | * {S,U}XT{B,B16,H}: !Rd, !Rm |
| 1653 | * UM{AA,LA,UL}L: !RdHi, !RdLo, !Rm, !Rs |
| 1654 | * USA{D8,A8,T,T16}: !Rd, !Rm, !Rs |
| 1655 | * |
| 1656 | * May transfer control by writing R15 (possible mode changes or alternate |
| 1657 | * mode accesses marked by "*"): |
| 1658 | * ALU op (* with s-bit), B, BL, BKPT, BLX(1/2), BX, BXJ, CPS*, CPY, |
| 1659 | * LDM(1), LDM(2/3)*, LDR, MOV, RFE*, SWI* |
| 1660 | * |
| 1661 | * Instructions that do not take general registers, nor transfer control: |
| 1662 | * CDP/2, SETEND, SRS* |
| 1663 | */ |