aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/kprobes-thumb.c
diff options
context:
space:
mode:
authorJon Medhurst <tixy@yxit.co.uk>2011-07-02 11:00:09 -0400
committerTixy <tixy@medhuaa1.miniserver.com>2011-07-13 13:32:44 -0400
commitf8695142820f3cb3bc97444a240eec5375a2b107 (patch)
tree84f7d494f71bfa879ab501deba8487ddd1760cc5 /arch/arm/kernel/kprobes-thumb.c
parent3b5940e81182ff26d539dcf0ee8b2310f6965833 (diff)
ARM: kprobes: Decode 16-bit Thumb load and store instructions
Most of these instructions only operate on the low registers R0-R7 so they can make use of t16_emulate_loregs_rwflags. The instructions which use SP or PC for addressing have their own simulation functions. Signed-off-by: Jon Medhurst <tixy@yxit.co.uk> Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'arch/arm/kernel/kprobes-thumb.c')
-rw-r--r--arch/arm/kernel/kprobes-thumb.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c
index cd4d03d19950..632a5e8f5977 100644
--- a/arch/arm/kernel/kprobes-thumb.c
+++ b/arch/arm/kernel/kprobes-thumb.c
@@ -51,6 +51,29 @@ t16_simulate_bxblx(struct kprobe *p, struct pt_regs *regs)
51 bx_write_pc(rmv, regs); 51 bx_write_pc(rmv, regs);
52} 52}
53 53
54static void __kprobes
55t16_simulate_ldr_literal(struct kprobe *p, struct pt_regs *regs)
56{
57 kprobe_opcode_t insn = p->opcode;
58 unsigned long* base = (unsigned long *)(thumb_probe_pc(p) & ~3);
59 long index = insn & 0xff;
60 int rt = (insn >> 8) & 0x7;
61 regs->uregs[rt] = base[index];
62}
63
64static void __kprobes
65t16_simulate_ldrstr_sp_relative(struct kprobe *p, struct pt_regs *regs)
66{
67 kprobe_opcode_t insn = p->opcode;
68 unsigned long* base = (unsigned long *)regs->ARM_sp;
69 long index = insn & 0xff;
70 int rt = (insn >> 8) & 0x7;
71 if (insn & 0x800) /* LDR */
72 regs->uregs[rt] = base[index];
73 else /* STR */
74 base[index] = regs->uregs[rt];
75}
76
54static unsigned long __kprobes 77static unsigned long __kprobes
55t16_emulate_loregs(struct kprobe *p, struct pt_regs *regs) 78t16_emulate_loregs(struct kprobe *p, struct pt_regs *regs)
56{ 79{
@@ -218,11 +241,48 @@ const union decode_item kprobe_decode_thumb16_table[] = {
218 DECODE_CUSTOM (0xfc00, 0x4400, t16_decode_hiregs), 241 DECODE_CUSTOM (0xfc00, 0x4400, t16_decode_hiregs),
219 242
220 /* 243 /*
244 * Load from Literal Pool
245 * LDR (literal) 0100 1xxx xxxx xxxx
246 */
247 DECODE_SIMULATE (0xf800, 0x4800, t16_simulate_ldr_literal),
248
249 /*
250 * 16-bit Thumb Load/store instructions
251 * 0101 xxxx xxxx xxxx
252 * 011x xxxx xxxx xxxx
253 * 100x xxxx xxxx xxxx
254 */
255
256 /* STR (register) 0101 000x xxxx xxxx */
257 /* STRH (register) 0101 001x xxxx xxxx */
258 /* STRB (register) 0101 010x xxxx xxxx */
259 /* LDRSB (register) 0101 011x xxxx xxxx */
260 /* LDR (register) 0101 100x xxxx xxxx */
261 /* LDRH (register) 0101 101x xxxx xxxx */
262 /* LDRB (register) 0101 110x xxxx xxxx */
263 /* LDRSH (register) 0101 111x xxxx xxxx */
264 /* STR (immediate, Thumb) 0110 0xxx xxxx xxxx */
265 /* LDR (immediate, Thumb) 0110 1xxx xxxx xxxx */
266 /* STRB (immediate, Thumb) 0111 0xxx xxxx xxxx */
267 /* LDRB (immediate, Thumb) 0111 1xxx xxxx xxxx */
268 DECODE_EMULATE (0xc000, 0x4000, t16_emulate_loregs_rwflags),
269 /* STRH (immediate, Thumb) 1000 0xxx xxxx xxxx */
270 /* LDRH (immediate, Thumb) 1000 1xxx xxxx xxxx */
271 DECODE_EMULATE (0xf000, 0x8000, t16_emulate_loregs_rwflags),
272 /* STR (immediate, Thumb) 1001 0xxx xxxx xxxx */
273 /* LDR (immediate, Thumb) 1001 1xxx xxxx xxxx */
274 DECODE_SIMULATE (0xf000, 0x9000, t16_simulate_ldrstr_sp_relative),
275
276 /*
221 * Miscellaneous 16-bit instructions 277 * Miscellaneous 16-bit instructions
222 * 1011 xxxx xxxx xxxx 278 * 1011 xxxx xxxx xxxx
223 */ 279 */
224 DECODE_TABLE (0xf000, 0xb000, t16_table_1011), 280 DECODE_TABLE (0xf000, 0xb000, t16_table_1011),
225 281
282 /* STM 1100 0xxx xxxx xxxx */
283 /* LDM 1100 1xxx xxxx xxxx */
284 DECODE_EMULATE (0xf000, 0xc000, t16_emulate_loregs_rwflags),
285
226 DECODE_END 286 DECODE_END
227}; 287};
228 288