blob: cf2a184984255564e47eed16ba0ed2c748e635df [file] [log] [blame]
Srikar Dronamraju2b144492012-02-09 14:56:42 +05301/*
Ingo Molnar7b2d81d2012-02-17 09:27:41 +01002 * User-space Probes (UProbes) for x86
Srikar Dronamraju2b144492012-02-09 14:56:42 +05303 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright (C) IBM Corporation, 2008-2011
19 * Authors:
20 * Srikar Dronamraju
21 * Jim Keniston
22 */
Srikar Dronamraju2b144492012-02-09 14:56:42 +053023#include <linux/kernel.h>
24#include <linux/sched.h>
25#include <linux/ptrace.h>
26#include <linux/uprobes.h>
27
28#include <linux/kdebug.h>
29#include <asm/insn.h>
30
31/* Post-execution fixups. */
32
33/* No fixup needed */
34#define UPROBES_FIX_NONE 0x0
35/* Adjust IP back to vicinity of actual insn */
36#define UPROBES_FIX_IP 0x1
37/* Adjust the return address of a call insn */
38#define UPROBES_FIX_CALL 0x2
39
40#define UPROBES_FIX_RIP_AX 0x8000
41#define UPROBES_FIX_RIP_CX 0x4000
42
43/* Adaptations for mhiramat x86 decoder v14. */
Ingo Molnar7b2d81d2012-02-17 09:27:41 +010044#define OPCODE1(insn) ((insn)->opcode.bytes[0])
45#define OPCODE2(insn) ((insn)->opcode.bytes[1])
46#define OPCODE3(insn) ((insn)->opcode.bytes[2])
47#define MODRM_REG(insn) X86_MODRM_REG(insn->modrm.value)
Srikar Dronamraju2b144492012-02-09 14:56:42 +053048
49#define W(row, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf)\
50 (((b0##UL << 0x0)|(b1##UL << 0x1)|(b2##UL << 0x2)|(b3##UL << 0x3) | \
51 (b4##UL << 0x4)|(b5##UL << 0x5)|(b6##UL << 0x6)|(b7##UL << 0x7) | \
52 (b8##UL << 0x8)|(b9##UL << 0x9)|(ba##UL << 0xa)|(bb##UL << 0xb) | \
53 (bc##UL << 0xc)|(bd##UL << 0xd)|(be##UL << 0xe)|(bf##UL << 0xf)) \
54 << (row % 32))
55
56#ifdef CONFIG_X86_64
Ingo Molnar7b2d81d2012-02-17 09:27:41 +010057static u32 good_insns_64[256 / 32] = {
Srikar Dronamraju2b144492012-02-09 14:56:42 +053058 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
59 /* ---------------------------------------------- */
60 W(0x00, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) | /* 00 */
61 W(0x10, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) , /* 10 */
62 W(0x20, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) | /* 20 */
63 W(0x30, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) , /* 30 */
64 W(0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 40 */
65 W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */
66 W(0x60, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* 60 */
67 W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 70 */
68 W(0x80, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */
69 W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */
70 W(0xa0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* a0 */
71 W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* b0 */
72 W(0xc0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) | /* c0 */
73 W(0xd0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
74 W(0xe0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* e0 */
75 W(0xf0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1) /* f0 */
76 /* ---------------------------------------------- */
77 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
78};
79#endif
80
81/* Good-instruction tables for 32-bit apps */
82
Ingo Molnar7b2d81d2012-02-17 09:27:41 +010083static u32 good_insns_32[256 / 32] = {
Srikar Dronamraju2b144492012-02-09 14:56:42 +053084 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
85 /* ---------------------------------------------- */
86 W(0x00, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0) | /* 00 */
87 W(0x10, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0) , /* 10 */
88 W(0x20, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1) | /* 20 */
89 W(0x30, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1) , /* 30 */
90 W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
91 W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */
92 W(0x60, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* 60 */
93 W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 70 */
94 W(0x80, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */
95 W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */
96 W(0xa0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* a0 */
97 W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* b0 */
98 W(0xc0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) | /* c0 */
99 W(0xd0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
100 W(0xe0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* e0 */
101 W(0xf0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1) /* f0 */
102 /* ---------------------------------------------- */
103 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
104};
105
106/* Using this for both 64-bit and 32-bit apps */
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100107static u32 good_2byte_insns[256 / 32] = {
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530108 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
109 /* ---------------------------------------------- */
110 W(0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1) | /* 00 */
111 W(0x10, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1) , /* 10 */
112 W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) | /* 20 */
113 W(0x30, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
114 W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
115 W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */
116 W(0x60, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 60 */
117 W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1) , /* 70 */
118 W(0x80, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */
119 W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */
120 W(0xa0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1) | /* a0 */
121 W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1) , /* b0 */
122 W(0xc0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* c0 */
123 W(0xd0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */
124 W(0xe0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* e0 */
125 W(0xf0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0) /* f0 */
126 /* ---------------------------------------------- */
127 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
128};
129
130#undef W
131
132/*
133 * opcodes we'll probably never support:
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100134 *
135 * 6c-6d, e4-e5, ec-ed - in
136 * 6e-6f, e6-e7, ee-ef - out
137 * cc, cd - int3, int
138 * cf - iret
139 * d6 - illegal instruction
140 * f1 - int1/icebp
141 * f4 - hlt
142 * fa, fb - cli, sti
143 * 0f - lar, lsl, syscall, clts, sysret, sysenter, sysexit, invd, wbinvd, ud2
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530144 *
145 * invalid opcodes in 64-bit mode:
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530146 *
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100147 * 06, 0e, 16, 1e, 27, 2f, 37, 3f, 60-62, 82, c4-c5, d4-d5
148 * 63 - we support this opcode in x86_64 but not in i386.
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530149 *
150 * opcodes we may need to refine support for:
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100151 *
152 * 0f - 2-byte instructions: For many of these instructions, the validity
153 * depends on the prefix and/or the reg field. On such instructions, we
154 * just consider the opcode combination valid if it corresponds to any
155 * valid instruction.
156 *
157 * 8f - Group 1 - only reg = 0 is OK
158 * c6-c7 - Group 11 - only reg = 0 is OK
159 * d9-df - fpu insns with some illegal encodings
160 * f2, f3 - repnz, repz prefixes. These are also the first byte for
161 * certain floating-point instructions, such as addsd.
162 *
163 * fe - Group 4 - only reg = 0 or 1 is OK
164 * ff - Group 5 - only reg = 0-6 is OK
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530165 *
166 * others -- Do we need to support these?
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100167 *
168 * 0f - (floating-point?) prefetch instructions
169 * 07, 17, 1f - pop es, pop ss, pop ds
170 * 26, 2e, 36, 3e - es:, cs:, ss:, ds: segment prefixes --
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530171 * but 64 and 65 (fs: and gs:) seem to be used, so we support them
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100172 * 67 - addr16 prefix
173 * ce - into
174 * f0 - lock prefix
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530175 */
176
177/*
178 * TODO:
179 * - Where necessary, examine the modrm byte and allow only valid instructions
180 * in the different Groups and fpu instructions.
181 */
182
183static bool is_prefix_bad(struct insn *insn)
184{
185 int i;
186
187 for (i = 0; i < insn->prefixes.nbytes; i++) {
188 switch (insn->prefixes.bytes[i]) {
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100189 case 0x26: /* INAT_PFX_ES */
190 case 0x2E: /* INAT_PFX_CS */
191 case 0x36: /* INAT_PFX_DS */
192 case 0x3E: /* INAT_PFX_SS */
193 case 0xF0: /* INAT_PFX_LOCK */
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530194 return true;
195 }
196 }
197 return false;
198}
199
200static int validate_insn_32bits(struct uprobe *uprobe, struct insn *insn)
201{
202 insn_init(insn, uprobe->insn, false);
203
204 /* Skip good instruction prefixes; reject "bad" ones. */
205 insn_get_opcode(insn);
206 if (is_prefix_bad(insn))
207 return -ENOTSUPP;
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100208
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530209 if (test_bit(OPCODE1(insn), (unsigned long *)good_insns_32))
210 return 0;
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100211
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530212 if (insn->opcode.nbytes == 2) {
213 if (test_bit(OPCODE2(insn), (unsigned long *)good_2byte_insns))
214 return 0;
215 }
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100216
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530217 return -ENOTSUPP;
218}
219
220/*
221 * Figure out which fixups post_xol() will need to perform, and annotate
222 * uprobe->arch_info.fixups accordingly. To start with,
223 * uprobe->arch_info.fixups is either zero or it reflects rip-related
224 * fixups.
225 */
226static void prepare_fixups(struct uprobe *uprobe, struct insn *insn)
227{
228 bool fix_ip = true, fix_call = false; /* defaults */
229 int reg;
230
231 insn_get_opcode(insn); /* should be a nop */
232
233 switch (OPCODE1(insn)) {
234 case 0xc3: /* ret/lret */
235 case 0xcb:
236 case 0xc2:
237 case 0xca:
238 /* ip is correct */
239 fix_ip = false;
240 break;
241 case 0xe8: /* call relative - Fix return addr */
242 fix_call = true;
243 break;
244 case 0x9a: /* call absolute - Fix return addr, not ip */
245 fix_call = true;
246 fix_ip = false;
247 break;
248 case 0xff:
249 insn_get_modrm(insn);
250 reg = MODRM_REG(insn);
251 if (reg == 2 || reg == 3) {
252 /* call or lcall, indirect */
253 /* Fix return addr; ip is correct. */
254 fix_call = true;
255 fix_ip = false;
256 } else if (reg == 4 || reg == 5) {
257 /* jmp or ljmp, indirect */
258 /* ip is correct. */
259 fix_ip = false;
260 }
261 break;
262 case 0xea: /* jmp absolute -- ip is correct */
263 fix_ip = false;
264 break;
265 default:
266 break;
267 }
268 if (fix_ip)
269 uprobe->arch_info.fixups |= UPROBES_FIX_IP;
270 if (fix_call)
271 uprobe->arch_info.fixups |= UPROBES_FIX_CALL;
272}
273
274#ifdef CONFIG_X86_64
275/*
276 * If uprobe->insn doesn't use rip-relative addressing, return
277 * immediately. Otherwise, rewrite the instruction so that it accesses
278 * its memory operand indirectly through a scratch register. Set
279 * uprobe->arch_info.fixups and uprobe->arch_info.rip_rela_target_address
280 * accordingly. (The contents of the scratch register will be saved
281 * before we single-step the modified instruction, and restored
282 * afterward.)
283 *
284 * We do this because a rip-relative instruction can access only a
285 * relatively small area (+/- 2 GB from the instruction), and the XOL
286 * area typically lies beyond that area. At least for instructions
287 * that store to memory, we can't execute the original instruction
288 * and "fix things up" later, because the misdirected store could be
289 * disastrous.
290 *
291 * Some useful facts about rip-relative instructions:
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100292 *
293 * - There's always a modrm byte.
294 * - There's never a SIB byte.
295 * - The displacement is always 4 bytes.
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530296 */
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100297static void handle_riprel_insn(struct mm_struct *mm, struct uprobe *uprobe, struct insn *insn)
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530298{
299 u8 *cursor;
300 u8 reg;
301
302 if (mm->context.ia32_compat)
303 return;
304
305 uprobe->arch_info.rip_rela_target_address = 0x0;
306 if (!insn_rip_relative(insn))
307 return;
308
309 /*
310 * insn_rip_relative() would have decoded rex_prefix, modrm.
311 * Clear REX.b bit (extension of MODRM.rm field):
312 * we want to encode rax/rcx, not r8/r9.
313 */
314 if (insn->rex_prefix.nbytes) {
315 cursor = uprobe->insn + insn_offset_rex_prefix(insn);
316 *cursor &= 0xfe; /* Clearing REX.B bit */
317 }
318
319 /*
320 * Point cursor at the modrm byte. The next 4 bytes are the
321 * displacement. Beyond the displacement, for some instructions,
322 * is the immediate operand.
323 */
324 cursor = uprobe->insn + insn_offset_modrm(insn);
325 insn_get_length(insn);
326
327 /*
328 * Convert from rip-relative addressing to indirect addressing
329 * via a scratch register. Change the r/m field from 0x5 (%rip)
330 * to 0x0 (%rax) or 0x1 (%rcx), and squeeze out the offset field.
331 */
332 reg = MODRM_REG(insn);
333 if (reg == 0) {
334 /*
335 * The register operand (if any) is either the A register
336 * (%rax, %eax, etc.) or (if the 0x4 bit is set in the
337 * REX prefix) %r8. In any case, we know the C register
338 * is NOT the register operand, so we use %rcx (register
339 * #1) for the scratch register.
340 */
341 uprobe->arch_info.fixups = UPROBES_FIX_RIP_CX;
342 /* Change modrm from 00 000 101 to 00 000 001. */
343 *cursor = 0x1;
344 } else {
345 /* Use %rax (register #0) for the scratch register. */
346 uprobe->arch_info.fixups = UPROBES_FIX_RIP_AX;
347 /* Change modrm from 00 xxx 101 to 00 xxx 000 */
348 *cursor = (reg << 3);
349 }
350
351 /* Target address = address of next instruction + (signed) offset */
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100352 uprobe->arch_info.rip_rela_target_address = (long)insn->length + insn->displacement.value;
353
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530354 /* Displacement field is gone; slide immediate field (if any) over. */
355 if (insn->immediate.nbytes) {
356 cursor++;
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100357 memmove(cursor, cursor + insn->displacement.nbytes, insn->immediate.nbytes);
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530358 }
359 return;
360}
361
362static int validate_insn_64bits(struct uprobe *uprobe, struct insn *insn)
363{
364 insn_init(insn, uprobe->insn, true);
365
366 /* Skip good instruction prefixes; reject "bad" ones. */
367 insn_get_opcode(insn);
368 if (is_prefix_bad(insn))
369 return -ENOTSUPP;
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100370
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530371 if (test_bit(OPCODE1(insn), (unsigned long *)good_insns_64))
372 return 0;
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100373
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530374 if (insn->opcode.nbytes == 2) {
375 if (test_bit(OPCODE2(insn), (unsigned long *)good_2byte_insns))
376 return 0;
377 }
378 return -ENOTSUPP;
379}
380
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100381static int validate_insn_bits(struct mm_struct *mm, struct uprobe *uprobe, struct insn *insn)
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530382{
383 if (mm->context.ia32_compat)
384 return validate_insn_32bits(uprobe, insn);
385 return validate_insn_64bits(uprobe, insn);
386}
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100387#else /* 32-bit: */
388static void handle_riprel_insn(struct mm_struct *mm, struct uprobe *uprobe, struct insn *insn)
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530389{
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100390 /* No RIP-relative addressing on 32-bit */
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530391}
392
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100393static int validate_insn_bits(struct mm_struct *mm, struct uprobe *uprobe, struct insn *insn)
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530394{
395 return validate_insn_32bits(uprobe, insn);
396}
397#endif /* CONFIG_X86_64 */
398
399/**
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100400 * arch_uprobes_analyze_insn - instruction analysis including validity and fixups.
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530401 * @mm: the probed address space.
402 * @uprobe: the probepoint information.
403 * Return 0 on success or a -ve number on error.
404 */
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100405int arch_uprobes_analyze_insn(struct mm_struct *mm, struct uprobe *uprobe)
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530406{
407 int ret;
408 struct insn insn;
409
410 uprobe->arch_info.fixups = 0;
411 ret = validate_insn_bits(mm, uprobe, &insn);
412 if (ret != 0)
413 return ret;
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100414
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530415 handle_riprel_insn(mm, uprobe, &insn);
416 prepare_fixups(uprobe, &insn);
Ingo Molnar7b2d81d2012-02-17 09:27:41 +0100417
Srikar Dronamraju2b144492012-02-09 14:56:42 +0530418 return 0;
419}