aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/kprobes-thumb.c
diff options
context:
space:
mode:
authorJon Medhurst <tixy@yxit.co.uk>2011-07-03 09:23:21 -0400
committerTixy <tixy@medhuaa1.miniserver.com>2011-07-13 13:32:46 -0400
commitb48354d3584e93284fba2ee99f6f9f44d18e4f83 (patch)
tree52ba729846dd1a514d536dfaab78627b2e1b0d61 /arch/arm/kernel/kprobes-thumb.c
parenteaf1d06500c48109dcd37b7856773fdf608a8d21 (diff)
ARM: kprobes: Decode 32-bit Thumb load/store dual and load/store exclusive instructions
We reject probing of load/store exclusive instructions because any emulation routine could never succeed in gaining exclusive access as the exception framework clears the exclusivity monitor when a probes breakpoint is hit. 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.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/arch/arm/kernel/kprobes-thumb.c b/arch/arm/kernel/kprobes-thumb.c
index d25e5cbdd736..299dc3a33ad2 100644
--- a/arch/arm/kernel/kprobes-thumb.c
+++ b/arch/arm/kernel/kprobes-thumb.c
@@ -50,6 +50,33 @@ t32_decode_ldmstm(kprobe_opcode_t insn, struct arch_specific_insn *asi)
50 return ret; 50 return ret;
51} 51}
52 52
53static void __kprobes
54t32_emulate_ldrdstrd(struct kprobe *p, struct pt_regs *regs)
55{
56 kprobe_opcode_t insn = p->opcode;
57 unsigned long pc = thumb_probe_pc(p) & ~3;
58 int rt1 = (insn >> 12) & 0xf;
59 int rt2 = (insn >> 8) & 0xf;
60 int rn = (insn >> 16) & 0xf;
61
62 register unsigned long rt1v asm("r0") = regs->uregs[rt1];
63 register unsigned long rt2v asm("r1") = regs->uregs[rt2];
64 register unsigned long rnv asm("r2") = (rn == 15) ? pc
65 : regs->uregs[rn];
66
67 __asm__ __volatile__ (
68 "blx %[fn]"
69 : "=r" (rt1v), "=r" (rt2v), "=r" (rnv)
70 : "0" (rt1v), "1" (rt2v), "2" (rnv), [fn] "r" (p->ainsn.insn_fn)
71 : "lr", "memory", "cc"
72 );
73
74 if (rn != 15)
75 regs->uregs[rn] = rnv; /* Writeback base register */
76 regs->uregs[rt1] = rt1v;
77 regs->uregs[rt2] = rt2v;
78}
79
53static const union decode_item t32_table_1110_100x_x0xx[] = { 80static const union decode_item t32_table_1110_100x_x0xx[] = {
54 /* Load/store multiple instructions */ 81 /* Load/store multiple instructions */
55 82
@@ -79,6 +106,29 @@ static const union decode_item t32_table_1110_100x_x0xx[] = {
79 DECODE_END 106 DECODE_END
80}; 107};
81 108
109static const union decode_item t32_table_1110_100x_x1xx[] = {
110 /* Load/store dual, load/store exclusive, table branch */
111
112 /* STRD (immediate) 1110 1000 x110 xxxx xxxx xxxx xxxx xxxx */
113 /* LDRD (immediate) 1110 1000 x111 xxxx xxxx xxxx xxxx xxxx */
114 DECODE_OR (0xff600000, 0xe8600000),
115 /* STRD (immediate) 1110 1001 x1x0 xxxx xxxx xxxx xxxx xxxx */
116 /* LDRD (immediate) 1110 1001 x1x1 xxxx xxxx xxxx xxxx xxxx */
117 DECODE_EMULATEX (0xff400000, 0xe9400000, t32_emulate_ldrdstrd,
118 REGS(NOPCWB, NOSPPC, NOSPPC, 0, 0)),
119
120 /* STREX 1110 1000 0100 xxxx xxxx xxxx xxxx xxxx */
121 /* LDREX 1110 1000 0101 xxxx xxxx xxxx xxxx xxxx */
122 /* STREXB 1110 1000 1100 xxxx xxxx xxxx 0100 xxxx */
123 /* STREXH 1110 1000 1100 xxxx xxxx xxxx 0101 xxxx */
124 /* STREXD 1110 1000 1100 xxxx xxxx xxxx 0111 xxxx */
125 /* LDREXB 1110 1000 1101 xxxx xxxx xxxx 0100 xxxx */
126 /* LDREXH 1110 1000 1101 xxxx xxxx xxxx 0101 xxxx */
127 /* LDREXD 1110 1000 1101 xxxx xxxx xxxx 0111 xxxx */
128 /* And unallocated instructions... */
129 DECODE_END
130};
131
82static const union decode_item t32_table_1111_0xxx___1[] = { 132static const union decode_item t32_table_1111_0xxx___1[] = {
83 /* Branches and miscellaneous control */ 133 /* Branches and miscellaneous control */
84 134
@@ -103,6 +153,12 @@ const union decode_item kprobe_decode_thumb32_table[] = {
103 DECODE_TABLE (0xfe400000, 0xe8000000, t32_table_1110_100x_x0xx), 153 DECODE_TABLE (0xfe400000, 0xe8000000, t32_table_1110_100x_x0xx),
104 154
105 /* 155 /*
156 * Load/store dual, load/store exclusive, table branch
157 * 1110 100x x1xx xxxx xxxx xxxx xxxx xxxx
158 */
159 DECODE_TABLE (0xfe400000, 0xe8400000, t32_table_1110_100x_x1xx),
160
161 /*
106 * Branches and miscellaneous control 162 * Branches and miscellaneous control
107 * 1111 0xxx xxxx xxxx 1xxx xxxx xxxx xxxx 163 * 1111 0xxx xxxx xxxx 1xxx xxxx xxxx xxxx
108 */ 164 */