1 // SPDX-License-Identifier: GPL-2.0-only 1 2 /* 3 * arch/arm/probes/kprobes/checkers-thumb.c 4 * 5 * Copyright (C) 2014 Huawei Inc. 6 */ 7 8 #include <linux/kernel.h> 9 #include "../decode.h" 10 #include "../decode-thumb.h" 11 #include "checkers.h" 12 13 static enum probes_insn __kprobes t32_check_st 14 struct arch_probes_insn *asi, 15 const struct decode_header *h) 16 { 17 /* 18 * PROBES_T32_LDMSTM, PROBES_T32_LDRDS 19 * may get here. Simply mark all norma 20 */ 21 static const union decode_item table[] 22 23 /* 24 * First, filter out all ldr i 25 * Following load insns may co 26 * LDM, LDRD, LDR. 27 * In T32 encoding, bit 20 is 28 * load and store. All load in 29 * all store insns have this b 30 */ 31 DECODE_CUSTOM (0x00100000, 0 32 33 /* 34 * Mark all 'STR{,B,H}, Rt, [R 35 * if Rn or Rm is SP. T32 does 36 */ 37 /* 38 /* STR (register) 1111 1 39 /* STRB (register) 1111 1 40 /* STRH (register) 1111 1 41 /* INVALID INSN 1111 1 42 /* By Introducing INVALID INSN 43 DECODE_OR (0xff9f0fc0, 0 44 DECODE_CUSTOM (0xff900fcf, 0 45 46 47 /* 48 /* STR (imm 8) 1111 1 49 /* STRB (imm 8) 1111 1 50 /* STRH (imm 8) 1111 1 51 /* INVALID INSN 1111 1 52 /* Only consider U == 0 and P 53 DECODE_CUSTOM (0xff9f0e00, 0 54 55 /* For STR{,B,H} (imm 12), off 56 57 /* 58 /* STRD (immediate) 1110 1 59 /* 60 * Only consider U == 0 and P 61 * Also note that STRD in T32 62 * imm = ZeroExtend(imm8:'00', 63 */ 64 DECODE_CUSTOM (0xffdf0000, 0 65 66 /* 67 /* STMDB 1110 1 68 DECODE_CUSTOM (0xffdf0000, 0 69 70 /* fall through */ 71 DECODE_CUSTOM (0, 0, STACK_U 72 DECODE_END 73 }; 74 75 return probes_decode_insn(insn, asi, t 76 } 77 78 const struct decode_checker t32_stack_checker[ 79 [PROBES_T32_LDMSTM] = {.checker = t32_ 80 [PROBES_T32_LDRDSTRD] = {.checker = t3 81 [PROBES_T32_LDRSTR] = {.checker = t32_ 82 }; 83 84 /* 85 * See following comments. This insn must be ' 86 */ 87 static enum probes_insn __kprobes t16_check_st 88 struct arch_probes_insn *asi, 89 const struct decode_header *h) 90 { 91 unsigned int reglist = insn & 0x1ff; 92 asi->stack_space = hweight32(reglist) 93 return INSN_GOOD; 94 } 95 96 /* 97 * T16 encoding is simple: only the 'push' ins 98 * Other insns, like str, can only use r0-r7 a 99 */ 100 const struct decode_checker t16_stack_checker[ 101 [PROBES_T16_PUSH] = {.checker = t16_ch 102 }; 103
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.