~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/probes/kprobes/checkers-thumb.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  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_stack(probes_opcode_t insn,
 14                 struct arch_probes_insn *asi,
 15                 const struct decode_header *h)
 16 {
 17         /*
 18          * PROBES_T32_LDMSTM, PROBES_T32_LDRDSTRD and PROBES_T32_LDRSTR
 19          * may get here. Simply mark all normal insns as STACK_USE_NONE.
 20          */
 21         static const union decode_item table[] = {
 22 
 23                 /*
 24                  * First, filter out all ldr insns to make our life easier.
 25                  * Following load insns may come here:
 26                  * LDM, LDRD, LDR.
 27                  * In T32 encoding, bit 20 is enough for distinguishing
 28                  * load and store. All load insns have this bit set, when
 29                  * all store insns have this bit clear.
 30                  */
 31                 DECODE_CUSTOM   (0x00100000, 0x00100000, STACK_USE_NONE),
 32 
 33                 /*
 34                  * Mark all 'STR{,B,H}, Rt, [Rn, Rm]' as STACK_USE_UNKNOWN
 35                  * if Rn or Rm is SP. T32 doesn't encode STRD.
 36                  */
 37                 /*                                 xx | Rn | Rt |         | Rm |*/
 38                 /* STR (register)       1111 1000 0100 xxxx xxxx 0000 00xx xxxx */
 39                 /* STRB (register)      1111 1000 0000 xxxx xxxx 0000 00xx xxxx */
 40                 /* STRH (register)      1111 1000 0010 xxxx xxxx 0000 00xx xxxx */
 41                 /* INVALID INSN         1111 1000 0110 xxxx xxxx 0000 00xx xxxx */
 42                 /* By Introducing INVALID INSN, bit 21 and 22 can be ignored. */
 43                 DECODE_OR       (0xff9f0fc0, 0xf80d0000),
 44                 DECODE_CUSTOM   (0xff900fcf, 0xf800000d, STACK_USE_UNKNOWN),
 45 
 46 
 47                 /*                                 xx | Rn | Rt | PUW|   imm8  |*/
 48                 /* STR (imm 8)          1111 1000 0100 1101 xxxx 110x xxxx xxxx */
 49                 /* STRB (imm 8)         1111 1000 0000 1101 xxxx 110x xxxx xxxx */
 50                 /* STRH (imm 8)         1111 1000 0010 1101 xxxx 110x xxxx xxxx */
 51                 /* INVALID INSN         1111 1000 0110 1101 xxxx 110x xxxx xxxx */
 52                 /* Only consider U == 0 and P == 1: strx rx, [sp, #-<imm>] */
 53                 DECODE_CUSTOM   (0xff9f0e00, 0xf80d0c00, STACK_USE_FIXED_0XX),
 54 
 55                 /* For STR{,B,H} (imm 12), offset is always positive, so ignore them. */
 56 
 57                 /*                              P U W | Rn | Rt | Rt2|   imm8  |*/
 58                 /* STRD (immediate)     1110 1001 01x0 1101 xxxx xxxx xxxx xxxx */
 59                 /*
 60                  * Only consider U == 0 and P == 1.
 61                  * Also note that STRD in T32 encoding is special:
 62                  * imm = ZeroExtend(imm8:'00', 32)
 63                  */
 64                 DECODE_CUSTOM   (0xffdf0000, 0xe94d0000, STACK_USE_T32STRD),
 65 
 66                 /*                                    | Rn | */
 67                 /* STMDB                1110 1001 00x0 1101 xxxx xxxx xxxx xxxx */
 68                 DECODE_CUSTOM   (0xffdf0000, 0xe90d0000, STACK_USE_STMDX),
 69 
 70                 /* fall through */
 71                 DECODE_CUSTOM   (0, 0, STACK_USE_NONE),
 72                 DECODE_END
 73         };
 74 
 75         return probes_decode_insn(insn, asi, table, false, false, stack_check_actions, NULL);
 76 }
 77 
 78 const struct decode_checker t32_stack_checker[NUM_PROBES_T32_ACTIONS] = {
 79         [PROBES_T32_LDMSTM] = {.checker = t32_check_stack},
 80         [PROBES_T32_LDRDSTRD] = {.checker = t32_check_stack},
 81         [PROBES_T32_LDRSTR] = {.checker = t32_check_stack},
 82 };
 83 
 84 /*
 85  * See following comments. This insn must be 'push'.
 86  */
 87 static enum probes_insn __kprobes t16_check_stack(probes_opcode_t insn,
 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) * 4;
 93         return INSN_GOOD;
 94 }
 95 
 96 /*
 97  * T16 encoding is simple: only the 'push' insn can need extra stack space.
 98  * Other insns, like str, can only use r0-r7 as Rn.
 99  */
100 const struct decode_checker t16_stack_checker[NUM_PROBES_T16_ACTIONS] = {
101         [PROBES_T16_PUSH] = {.checker = t16_check_stack},
102 };
103 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php