blob: 23b7c8f017e2afa74194c81c7720724a2604751b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* By Ross Biro 1/23/92 */
2/*
3 * Pentium III FXSR, SSE support
4 * Gareth Hughes <gareth@valinux.com>, May 2000
Markus Metzgereee3af42008-01-30 13:31:09 +01005 *
6 * BTS tracing
7 * Markus Metzger <markus.t.metzger@intel.com>, Dec 2007
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 */
9
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/mm.h>
13#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/errno.h>
15#include <linux/ptrace.h>
Roland McGrath91e7b702008-01-30 13:31:52 +010016#include <linux/regset.h>
Roland McGratheeea3c32008-03-16 23:36:28 -070017#include <linux/tracehook.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/user.h>
Roland McGrath070459d2008-01-30 13:31:53 +010019#include <linux/elf.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/security.h>
21#include <linux/audit.h>
22#include <linux/seccomp.h>
Jesper Juhl7ed20e12005-05-01 08:59:14 -070023#include <linux/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#include <asm/uaccess.h>
26#include <asm/pgtable.h>
27#include <asm/system.h>
28#include <asm/processor.h>
29#include <asm/i387.h>
30#include <asm/debugreg.h>
31#include <asm/ldt.h>
32#include <asm/desc.h>
Roland McGrath2047b082008-01-30 13:31:01 +010033#include <asm/prctl.h>
34#include <asm/proto.h>
Markus Metzgereee3af42008-01-30 13:31:09 +010035#include <asm/ds.h>
36
Frederic Weisbecker47788c52009-04-08 20:40:59 +020037#include <trace/syscall.h>
38
Roland McGrath070459d2008-01-30 13:31:53 +010039#include "tls.h"
40
41enum x86_regset {
42 REGSET_GENERAL,
43 REGSET_FP,
44 REGSET_XFP,
Roland McGrath325af5f2008-08-08 15:58:39 -070045 REGSET_IOPERM64 = REGSET_XFP,
Roland McGrath070459d2008-01-30 13:31:53 +010046 REGSET_TLS,
Roland McGrath325af5f2008-08-08 15:58:39 -070047 REGSET_IOPERM32,
Roland McGrath070459d2008-01-30 13:31:53 +010048};
Markus Metzgereee3af42008-01-30 13:31:09 +010049
50/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 * does not yet catch signals sent when the child dies.
52 * in exit.c or in signal.c.
53 */
54
Chuck Ebbert9f155b92006-01-05 23:11:29 -050055/*
56 * Determines which flags the user has access to [1 = access, 0 = no access].
Chuck Ebbert9f155b92006-01-05 23:11:29 -050057 */
Roland McGrathe39c2892008-01-30 13:31:01 +010058#define FLAG_MASK_32 ((unsigned long) \
59 (X86_EFLAGS_CF | X86_EFLAGS_PF | \
60 X86_EFLAGS_AF | X86_EFLAGS_ZF | \
61 X86_EFLAGS_SF | X86_EFLAGS_TF | \
62 X86_EFLAGS_DF | X86_EFLAGS_OF | \
63 X86_EFLAGS_RF | X86_EFLAGS_AC))
64
Roland McGrath2047b082008-01-30 13:31:01 +010065/*
66 * Determines whether a value may be installed in a segment register.
67 */
68static inline bool invalid_selector(u16 value)
69{
70 return unlikely(value != 0 && (value & SEGMENT_RPL_MASK) != USER_RPL);
71}
72
73#ifdef CONFIG_X86_32
74
Roland McGrathe39c2892008-01-30 13:31:01 +010075#define FLAG_MASK FLAG_MASK_32
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Jaswinder Singh4fe702c2008-07-25 10:19:27 +053077static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010079 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
Tejun Heoccbeed32009-02-09 22:17:40 +090080 return &regs->bx + (regno >> 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
82
Roland McGrath06ee1b62008-01-30 13:31:01 +010083static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084{
Roland McGrath06ee1b62008-01-30 13:31:01 +010085 /*
86 * Returning the value truncates it to 16 bits.
87 */
88 unsigned int retval;
89 if (offset != offsetof(struct user_regs_struct, gs))
90 retval = *pt_regs_access(task_pt_regs(task), offset);
91 else {
Roland McGrath06ee1b62008-01-30 13:31:01 +010092 if (task == current)
Tejun Heod9a89a22009-02-09 22:17:40 +090093 retval = get_user_gs(task_pt_regs(task));
94 else
95 retval = task_user_gs(task);
Roland McGrath06ee1b62008-01-30 13:31:01 +010096 }
97 return retval;
98}
99
100static int set_segment_reg(struct task_struct *task,
101 unsigned long offset, u16 value)
102{
103 /*
104 * The value argument was already truncated to 16 bits.
105 */
Roland McGrath2047b082008-01-30 13:31:01 +0100106 if (invalid_selector(value))
Roland McGrath06ee1b62008-01-30 13:31:01 +0100107 return -EIO;
108
Roland McGrathc63855d2008-02-06 22:39:44 +0100109 /*
110 * For %cs and %ss we cannot permit a null selector.
111 * We can permit a bogus selector as long as it has USER_RPL.
112 * Null selectors are fine for other segment registers, but
113 * we will never get back to user mode with invalid %cs or %ss
114 * and will take the trap in iret instead. Much code relies
115 * on user_mode() to distinguish a user trap frame (which can
116 * safely use invalid selectors) from a kernel trap frame.
117 */
118 switch (offset) {
119 case offsetof(struct user_regs_struct, cs):
120 case offsetof(struct user_regs_struct, ss):
121 if (unlikely(value == 0))
122 return -EIO;
123
124 default:
Roland McGrath06ee1b62008-01-30 13:31:01 +0100125 *pt_regs_access(task_pt_regs(task), offset) = value;
Roland McGrathc63855d2008-02-06 22:39:44 +0100126 break;
127
128 case offsetof(struct user_regs_struct, gs):
Roland McGrath06ee1b62008-01-30 13:31:01 +0100129 if (task == current)
Tejun Heod9a89a22009-02-09 22:17:40 +0900130 set_user_gs(task_pt_regs(task), value);
131 else
132 task_user_gs(task) = value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 }
Roland McGrath06ee1b62008-01-30 13:31:01 +0100134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 return 0;
136}
137
Roland McGrath2047b082008-01-30 13:31:01 +0100138static unsigned long debugreg_addr_limit(struct task_struct *task)
139{
140 return TASK_SIZE - 3;
141}
142
143#else /* CONFIG_X86_64 */
144
145#define FLAG_MASK (FLAG_MASK_32 | X86_EFLAGS_NT)
146
147static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long offset)
148{
149 BUILD_BUG_ON(offsetof(struct pt_regs, r15) != 0);
150 return &regs->r15 + (offset / sizeof(regs->r15));
151}
152
153static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
154{
155 /*
156 * Returning the value truncates it to 16 bits.
157 */
158 unsigned int seg;
159
160 switch (offset) {
161 case offsetof(struct user_regs_struct, fs):
162 if (task == current) {
163 /* Older gas can't assemble movq %?s,%r?? */
164 asm("movl %%fs,%0" : "=r" (seg));
165 return seg;
166 }
167 return task->thread.fsindex;
168 case offsetof(struct user_regs_struct, gs):
169 if (task == current) {
170 asm("movl %%gs,%0" : "=r" (seg));
171 return seg;
172 }
173 return task->thread.gsindex;
174 case offsetof(struct user_regs_struct, ds):
175 if (task == current) {
176 asm("movl %%ds,%0" : "=r" (seg));
177 return seg;
178 }
179 return task->thread.ds;
180 case offsetof(struct user_regs_struct, es):
181 if (task == current) {
182 asm("movl %%es,%0" : "=r" (seg));
183 return seg;
184 }
185 return task->thread.es;
186
187 case offsetof(struct user_regs_struct, cs):
188 case offsetof(struct user_regs_struct, ss):
189 break;
190 }
191 return *pt_regs_access(task_pt_regs(task), offset);
192}
193
194static int set_segment_reg(struct task_struct *task,
195 unsigned long offset, u16 value)
196{
197 /*
198 * The value argument was already truncated to 16 bits.
199 */
200 if (invalid_selector(value))
201 return -EIO;
202
203 switch (offset) {
204 case offsetof(struct user_regs_struct,fs):
205 /*
206 * If this is setting fs as for normal 64-bit use but
207 * setting fs_base has implicitly changed it, leave it.
208 */
209 if ((value == FS_TLS_SEL && task->thread.fsindex == 0 &&
210 task->thread.fs != 0) ||
211 (value == 0 && task->thread.fsindex == FS_TLS_SEL &&
212 task->thread.fs == 0))
213 break;
214 task->thread.fsindex = value;
215 if (task == current)
216 loadsegment(fs, task->thread.fsindex);
217 break;
218 case offsetof(struct user_regs_struct,gs):
219 /*
220 * If this is setting gs as for normal 64-bit use but
221 * setting gs_base has implicitly changed it, leave it.
222 */
223 if ((value == GS_TLS_SEL && task->thread.gsindex == 0 &&
224 task->thread.gs != 0) ||
225 (value == 0 && task->thread.gsindex == GS_TLS_SEL &&
226 task->thread.gs == 0))
227 break;
228 task->thread.gsindex = value;
229 if (task == current)
230 load_gs_index(task->thread.gsindex);
231 break;
232 case offsetof(struct user_regs_struct,ds):
233 task->thread.ds = value;
234 if (task == current)
235 loadsegment(ds, task->thread.ds);
236 break;
237 case offsetof(struct user_regs_struct,es):
238 task->thread.es = value;
239 if (task == current)
240 loadsegment(es, task->thread.es);
241 break;
242
243 /*
244 * Can't actually change these in 64-bit mode.
245 */
246 case offsetof(struct user_regs_struct,cs):
Roland McGrathc63855d2008-02-06 22:39:44 +0100247 if (unlikely(value == 0))
248 return -EIO;
Roland McGrath2047b082008-01-30 13:31:01 +0100249#ifdef CONFIG_IA32_EMULATION
250 if (test_tsk_thread_flag(task, TIF_IA32))
251 task_pt_regs(task)->cs = value;
Roland McGrath2047b082008-01-30 13:31:01 +0100252#endif
Roland McGrathcb757c42008-01-30 13:31:01 +0100253 break;
Roland McGrath2047b082008-01-30 13:31:01 +0100254 case offsetof(struct user_regs_struct,ss):
Roland McGrathc63855d2008-02-06 22:39:44 +0100255 if (unlikely(value == 0))
256 return -EIO;
Roland McGrath2047b082008-01-30 13:31:01 +0100257#ifdef CONFIG_IA32_EMULATION
258 if (test_tsk_thread_flag(task, TIF_IA32))
259 task_pt_regs(task)->ss = value;
Roland McGrath2047b082008-01-30 13:31:01 +0100260#endif
Roland McGrathcb757c42008-01-30 13:31:01 +0100261 break;
Roland McGrath2047b082008-01-30 13:31:01 +0100262 }
263
264 return 0;
265}
266
267static unsigned long debugreg_addr_limit(struct task_struct *task)
268{
269#ifdef CONFIG_IA32_EMULATION
270 if (test_tsk_thread_flag(task, TIF_IA32))
271 return IA32_PAGE_OFFSET - 3;
272#endif
Ingo Molnard9517342009-02-20 23:32:28 +0100273 return TASK_SIZE_MAX - 7;
Roland McGrath2047b082008-01-30 13:31:01 +0100274}
275
276#endif /* CONFIG_X86_32 */
277
Roland McGrath06ee1b62008-01-30 13:31:01 +0100278static unsigned long get_flags(struct task_struct *task)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279{
Roland McGrath06ee1b62008-01-30 13:31:01 +0100280 unsigned long retval = task_pt_regs(task)->flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Roland McGrath06ee1b62008-01-30 13:31:01 +0100282 /*
283 * If the debugger set TF, hide it from the readout.
284 */
285 if (test_tsk_thread_flag(task, TIF_FORCED_TF))
286 retval &= ~X86_EFLAGS_TF;
287
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 return retval;
289}
290
Roland McGrath06ee1b62008-01-30 13:31:01 +0100291static int set_flags(struct task_struct *task, unsigned long value)
292{
293 struct pt_regs *regs = task_pt_regs(task);
294
295 /*
296 * If the user value contains TF, mark that
297 * it was not "us" (the debugger) that set it.
298 * If not, make sure it stays set if we had.
299 */
300 if (value & X86_EFLAGS_TF)
301 clear_tsk_thread_flag(task, TIF_FORCED_TF);
302 else if (test_tsk_thread_flag(task, TIF_FORCED_TF))
303 value |= X86_EFLAGS_TF;
304
305 regs->flags = (regs->flags & ~FLAG_MASK) | (value & FLAG_MASK);
306
307 return 0;
308}
309
310static int putreg(struct task_struct *child,
311 unsigned long offset, unsigned long value)
312{
313 switch (offset) {
314 case offsetof(struct user_regs_struct, cs):
315 case offsetof(struct user_regs_struct, ds):
316 case offsetof(struct user_regs_struct, es):
317 case offsetof(struct user_regs_struct, fs):
318 case offsetof(struct user_regs_struct, gs):
319 case offsetof(struct user_regs_struct, ss):
320 return set_segment_reg(child, offset, value);
321
322 case offsetof(struct user_regs_struct, flags):
323 return set_flags(child, value);
Roland McGrath2047b082008-01-30 13:31:01 +0100324
325#ifdef CONFIG_X86_64
Roland McGrath84c6f602008-03-07 14:56:02 -0800326 /*
327 * Orig_ax is really just a flag with small positive and
328 * negative values, so make sure to always sign-extend it
329 * from 32 bits so that it works correctly regardless of
330 * whether we come from a 32-bit environment or not.
331 */
332 case offsetof(struct user_regs_struct, orig_ax):
333 value = (long) (s32) value;
334 break;
335
Roland McGrath2047b082008-01-30 13:31:01 +0100336 case offsetof(struct user_regs_struct,fs_base):
337 if (value >= TASK_SIZE_OF(child))
338 return -EIO;
339 /*
340 * When changing the segment base, use do_arch_prctl
341 * to set either thread.fs or thread.fsindex and the
342 * corresponding GDT slot.
343 */
344 if (child->thread.fs != value)
345 return do_arch_prctl(child, ARCH_SET_FS, value);
346 return 0;
347 case offsetof(struct user_regs_struct,gs_base):
348 /*
349 * Exactly the same here as the %fs handling above.
350 */
351 if (value >= TASK_SIZE_OF(child))
352 return -EIO;
353 if (child->thread.gs != value)
354 return do_arch_prctl(child, ARCH_SET_GS, value);
355 return 0;
356#endif
Roland McGrath06ee1b62008-01-30 13:31:01 +0100357 }
358
359 *pt_regs_access(task_pt_regs(child), offset) = value;
360 return 0;
361}
362
363static unsigned long getreg(struct task_struct *task, unsigned long offset)
364{
365 switch (offset) {
366 case offsetof(struct user_regs_struct, cs):
367 case offsetof(struct user_regs_struct, ds):
368 case offsetof(struct user_regs_struct, es):
369 case offsetof(struct user_regs_struct, fs):
370 case offsetof(struct user_regs_struct, gs):
371 case offsetof(struct user_regs_struct, ss):
372 return get_segment_reg(task, offset);
373
374 case offsetof(struct user_regs_struct, flags):
375 return get_flags(task);
Roland McGrath2047b082008-01-30 13:31:01 +0100376
377#ifdef CONFIG_X86_64
378 case offsetof(struct user_regs_struct, fs_base): {
379 /*
380 * do_arch_prctl may have used a GDT slot instead of
381 * the MSR. To userland, it appears the same either
382 * way, except the %fs segment selector might not be 0.
383 */
384 unsigned int seg = task->thread.fsindex;
385 if (task->thread.fs != 0)
386 return task->thread.fs;
387 if (task == current)
388 asm("movl %%fs,%0" : "=r" (seg));
389 if (seg != FS_TLS_SEL)
390 return 0;
391 return get_desc_base(&task->thread.tls_array[FS_TLS]);
392 }
393 case offsetof(struct user_regs_struct, gs_base): {
394 /*
395 * Exactly the same here as the %fs handling above.
396 */
397 unsigned int seg = task->thread.gsindex;
398 if (task->thread.gs != 0)
399 return task->thread.gs;
400 if (task == current)
401 asm("movl %%gs,%0" : "=r" (seg));
402 if (seg != GS_TLS_SEL)
403 return 0;
404 return get_desc_base(&task->thread.tls_array[GS_TLS]);
405 }
406#endif
Roland McGrath06ee1b62008-01-30 13:31:01 +0100407 }
408
409 return *pt_regs_access(task_pt_regs(task), offset);
410}
411
Roland McGrath91e7b702008-01-30 13:31:52 +0100412static int genregs_get(struct task_struct *target,
413 const struct user_regset *regset,
414 unsigned int pos, unsigned int count,
415 void *kbuf, void __user *ubuf)
416{
417 if (kbuf) {
418 unsigned long *k = kbuf;
419 while (count > 0) {
420 *k++ = getreg(target, pos);
421 count -= sizeof(*k);
422 pos += sizeof(*k);
423 }
424 } else {
425 unsigned long __user *u = ubuf;
426 while (count > 0) {
427 if (__put_user(getreg(target, pos), u++))
428 return -EFAULT;
429 count -= sizeof(*u);
430 pos += sizeof(*u);
431 }
432 }
433
434 return 0;
435}
436
437static int genregs_set(struct task_struct *target,
438 const struct user_regset *regset,
439 unsigned int pos, unsigned int count,
440 const void *kbuf, const void __user *ubuf)
441{
442 int ret = 0;
443 if (kbuf) {
444 const unsigned long *k = kbuf;
445 while (count > 0 && !ret) {
446 ret = putreg(target, pos, *k++);
447 count -= sizeof(*k);
448 pos += sizeof(*k);
449 }
450 } else {
451 const unsigned long __user *u = ubuf;
452 while (count > 0 && !ret) {
453 unsigned long word;
454 ret = __get_user(word, u++);
455 if (ret)
456 break;
457 ret = putreg(target, pos, word);
458 count -= sizeof(*u);
459 pos += sizeof(*u);
460 }
461 }
462 return ret;
463}
464
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465/*
Roland McGrathd9771e82008-01-30 13:30:52 +0100466 * This function is trivial and will be inlined by the compiler.
467 * Having it separates the implementation details of debug
468 * registers from the interface details of ptrace.
469 */
470static unsigned long ptrace_get_debugreg(struct task_struct *child, int n)
471{
Roland McGrath0f534092008-01-30 13:30:59 +0100472 switch (n) {
473 case 0: return child->thread.debugreg0;
474 case 1: return child->thread.debugreg1;
475 case 2: return child->thread.debugreg2;
476 case 3: return child->thread.debugreg3;
477 case 6: return child->thread.debugreg6;
478 case 7: return child->thread.debugreg7;
479 }
480 return 0;
Roland McGrathd9771e82008-01-30 13:30:52 +0100481}
482
483static int ptrace_set_debugreg(struct task_struct *child,
484 int n, unsigned long data)
485{
Roland McGrath0f534092008-01-30 13:30:59 +0100486 int i;
487
Roland McGrathd9771e82008-01-30 13:30:52 +0100488 if (unlikely(n == 4 || n == 5))
489 return -EIO;
490
Roland McGrath2047b082008-01-30 13:31:01 +0100491 if (n < 4 && unlikely(data >= debugreg_addr_limit(child)))
Roland McGrathd9771e82008-01-30 13:30:52 +0100492 return -EIO;
493
Roland McGrath0f534092008-01-30 13:30:59 +0100494 switch (n) {
495 case 0: child->thread.debugreg0 = data; break;
496 case 1: child->thread.debugreg1 = data; break;
497 case 2: child->thread.debugreg2 = data; break;
498 case 3: child->thread.debugreg3 = data; break;
499
500 case 6:
Roland McGrath2047b082008-01-30 13:31:01 +0100501 if ((data & ~0xffffffffUL) != 0)
502 return -EIO;
Roland McGrath0f534092008-01-30 13:30:59 +0100503 child->thread.debugreg6 = data;
504 break;
505
506 case 7:
Roland McGrathd9771e82008-01-30 13:30:52 +0100507 /*
508 * Sanity-check data. Take one half-byte at once with
509 * check = (val >> (16 + 4*i)) & 0xf. It contains the
510 * R/Wi and LENi bits; bits 0 and 1 are R/Wi, and bits
511 * 2 and 3 are LENi. Given a list of invalid values,
512 * we do mask |= 1 << invalid_value, so that
513 * (mask >> check) & 1 is a correct test for invalid
514 * values.
515 *
516 * R/Wi contains the type of the breakpoint /
517 * watchpoint, LENi contains the length of the watched
518 * data in the watchpoint case.
519 *
520 * The invalid values are:
Roland McGrath2047b082008-01-30 13:31:01 +0100521 * - LENi == 0x10 (undefined), so mask |= 0x0f00. [32-bit]
Roland McGrathd9771e82008-01-30 13:30:52 +0100522 * - R/Wi == 0x10 (break on I/O reads or writes), so
523 * mask |= 0x4444.
524 * - R/Wi == 0x00 && LENi != 0x00, so we have mask |=
525 * 0x1110.
526 *
527 * Finally, mask = 0x0f00 | 0x4444 | 0x1110 == 0x5f54.
528 *
529 * See the Intel Manual "System Programming Guide",
530 * 15.2.4
531 *
532 * Note that LENi == 0x10 is defined on x86_64 in long
533 * mode (i.e. even for 32-bit userspace software, but
534 * 64-bit kernel), so the x86_64 mask value is 0x5454.
535 * See the AMD manual no. 24593 (AMD64 System Programming)
536 */
Roland McGrath2047b082008-01-30 13:31:01 +0100537#ifdef CONFIG_X86_32
538#define DR7_MASK 0x5f54
539#else
540#define DR7_MASK 0x5554
541#endif
Roland McGrathd9771e82008-01-30 13:30:52 +0100542 data &= ~DR_CONTROL_RESERVED;
543 for (i = 0; i < 4; i++)
Roland McGrath2047b082008-01-30 13:31:01 +0100544 if ((DR7_MASK >> ((data >> (16 + 4*i)) & 0xf)) & 1)
Roland McGrathd9771e82008-01-30 13:30:52 +0100545 return -EIO;
Roland McGrath0f534092008-01-30 13:30:59 +0100546 child->thread.debugreg7 = data;
Roland McGrathd9771e82008-01-30 13:30:52 +0100547 if (data)
548 set_tsk_thread_flag(child, TIF_DEBUG);
549 else
550 clear_tsk_thread_flag(child, TIF_DEBUG);
Roland McGrath0f534092008-01-30 13:30:59 +0100551 break;
Roland McGrathd9771e82008-01-30 13:30:52 +0100552 }
553
Roland McGrathd9771e82008-01-30 13:30:52 +0100554 return 0;
555}
556
Roland McGrath325af5f2008-08-08 15:58:39 -0700557/*
558 * These access the current or another (stopped) task's io permission
559 * bitmap for debugging or core dump.
560 */
561static int ioperm_active(struct task_struct *target,
562 const struct user_regset *regset)
Markus Metzgereee3af42008-01-30 13:31:09 +0100563{
Roland McGrath325af5f2008-08-08 15:58:39 -0700564 return target->thread.io_bitmap_max / regset->size;
Markus Metzgereee3af42008-01-30 13:31:09 +0100565}
566
Roland McGrath325af5f2008-08-08 15:58:39 -0700567static int ioperm_get(struct task_struct *target,
568 const struct user_regset *regset,
569 unsigned int pos, unsigned int count,
570 void *kbuf, void __user *ubuf)
571{
572 if (!target->thread.io_bitmap_ptr)
573 return -ENXIO;
574
575 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
576 target->thread.io_bitmap_ptr,
577 0, IO_BITMAP_BYTES);
578}
579
Markus Metzger93fa7632008-04-08 11:01:58 +0200580#ifdef CONFIG_X86_PTRACE_BTS
Markus Metzger93fa7632008-04-08 11:01:58 +0200581static int ptrace_bts_read_record(struct task_struct *child, size_t index,
Markus Metzgereee3af42008-01-30 13:31:09 +0100582 struct bts_struct __user *out)
583{
Markus Metzgerc2724772008-12-11 13:49:59 +0100584 const struct bts_trace *trace;
585 struct bts_struct bts;
586 const unsigned char *at;
Markus Metzger93fa7632008-04-08 11:01:58 +0200587 int error;
Markus Metzgereee3af42008-01-30 13:31:09 +0100588
Markus Metzgerc2724772008-12-11 13:49:59 +0100589 trace = ds_read_bts(child->bts);
590 if (!trace)
591 return -EPERM;
592
593 at = trace->ds.top - ((index + 1) * trace->ds.size);
594 if ((void *)at < trace->ds.begin)
595 at += (trace->ds.n * trace->ds.size);
596
597 if (!trace->read)
598 return -EOPNOTSUPP;
599
600 error = trace->read(child->bts, at, &bts);
Markus Metzger93fa7632008-04-08 11:01:58 +0200601 if (error < 0)
602 return error;
Markus Metzgereee3af42008-01-30 13:31:09 +0100603
Markus Metzgerc2724772008-12-11 13:49:59 +0100604 if (copy_to_user(out, &bts, sizeof(bts)))
Markus Metzgereee3af42008-01-30 13:31:09 +0100605 return -EFAULT;
606
Markus Metzgerc2724772008-12-11 13:49:59 +0100607 return sizeof(bts);
Markus Metzgereee3af42008-01-30 13:31:09 +0100608}
609
Markus Metzgera95d67f2008-01-30 13:31:20 +0100610static int ptrace_bts_drain(struct task_struct *child,
Markus Metzgercba4b652008-01-30 13:32:03 +0100611 long size,
Markus Metzgera95d67f2008-01-30 13:31:20 +0100612 struct bts_struct __user *out)
613{
Markus Metzgerc2724772008-12-11 13:49:59 +0100614 const struct bts_trace *trace;
615 const unsigned char *at;
616 int error, drained = 0;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100617
Markus Metzgerc2724772008-12-11 13:49:59 +0100618 trace = ds_read_bts(child->bts);
619 if (!trace)
620 return -EPERM;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100621
Markus Metzgerc2724772008-12-11 13:49:59 +0100622 if (!trace->read)
623 return -EOPNOTSUPP;
624
625 if (size < (trace->ds.top - trace->ds.begin))
Markus Metzgercba4b652008-01-30 13:32:03 +0100626 return -EIO;
627
Markus Metzgerc2724772008-12-11 13:49:59 +0100628 for (at = trace->ds.begin; (void *)at < trace->ds.top;
629 out++, drained++, at += trace->ds.size) {
630 struct bts_struct bts;
631 int error;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100632
Markus Metzgerc2724772008-12-11 13:49:59 +0100633 error = trace->read(child->bts, at, &bts);
634 if (error < 0)
635 return error;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100636
Markus Metzgerc2724772008-12-11 13:49:59 +0100637 if (copy_to_user(out, &bts, sizeof(bts)))
Markus Metzgera95d67f2008-01-30 13:31:20 +0100638 return -EFAULT;
639 }
640
Markus Metzgerc2724772008-12-11 13:49:59 +0100641 memset(trace->ds.begin, 0, trace->ds.n * trace->ds.size);
642
643 error = ds_reset_bts(child->bts);
Markus Metzger93fa7632008-04-08 11:01:58 +0200644 if (error < 0)
645 return error;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100646
Markus Metzgerc2724772008-12-11 13:49:59 +0100647 return drained;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100648}
649
Markus Metzgerc5dee612008-12-19 15:17:02 +0100650static int ptrace_bts_allocate_buffer(struct task_struct *child, size_t size)
651{
652 child->bts_buffer = alloc_locked_buffer(size);
653 if (!child->bts_buffer)
654 return -ENOMEM;
655
656 child->bts_size = size;
657
658 return 0;
659}
660
661static void ptrace_bts_free_buffer(struct task_struct *child)
662{
663 free_locked_buffer(child->bts_buffer, child->bts_size);
664 child->bts_buffer = NULL;
665 child->bts_size = 0;
666}
667
Markus Metzgera95d67f2008-01-30 13:31:20 +0100668static int ptrace_bts_config(struct task_struct *child,
Markus Metzgercba4b652008-01-30 13:32:03 +0100669 long cfg_size,
Markus Metzgera95d67f2008-01-30 13:31:20 +0100670 const struct ptrace_bts_config __user *ucfg)
671{
672 struct ptrace_bts_config cfg;
Markus Metzgerc2724772008-12-11 13:49:59 +0100673 unsigned int flags = 0;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100674
Markus Metzgercba4b652008-01-30 13:32:03 +0100675 if (cfg_size < sizeof(cfg))
Markus Metzgerc2724772008-12-11 13:49:59 +0100676 return -EIO;
Markus Metzgercba4b652008-01-30 13:32:03 +0100677
Markus Metzgera95d67f2008-01-30 13:31:20 +0100678 if (copy_from_user(&cfg, ucfg, sizeof(cfg)))
Markus Metzgerc2724772008-12-11 13:49:59 +0100679 return -EFAULT;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100680
Markus Metzgerc2724772008-12-11 13:49:59 +0100681 if (child->bts) {
682 ds_release_bts(child->bts);
683 child->bts = NULL;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100684 }
685
Markus Metzgerc2724772008-12-11 13:49:59 +0100686 if (cfg.flags & PTRACE_BTS_O_SIGNAL) {
687 if (!cfg.signal)
688 return -EINVAL;
689
Markus Metzgerc2724772008-12-11 13:49:59 +0100690 child->thread.bts_ovfl_signal = cfg.signal;
Américo Wang5a8ac9d2009-03-13 15:56:58 +0800691 return -EOPNOTSUPP;
Markus Metzgerc2724772008-12-11 13:49:59 +0100692 }
693
694 if ((cfg.flags & PTRACE_BTS_O_ALLOC) &&
695 (cfg.size != child->bts_size)) {
Markus Metzgerc5dee612008-12-19 15:17:02 +0100696 int error;
Markus Metzgerc2724772008-12-11 13:49:59 +0100697
Markus Metzgerc5dee612008-12-19 15:17:02 +0100698 ptrace_bts_free_buffer(child);
699
700 error = ptrace_bts_allocate_buffer(child, cfg.size);
701 if (error < 0)
702 return error;
Markus Metzgerc2724772008-12-11 13:49:59 +0100703 }
Markus Metzgera95d67f2008-01-30 13:31:20 +0100704
Markus Metzgerda35c372008-01-30 13:32:03 +0100705 if (cfg.flags & PTRACE_BTS_O_TRACE)
Markus Metzgerc2724772008-12-11 13:49:59 +0100706 flags |= BTS_USER;
Markus Metzgereee3af42008-01-30 13:31:09 +0100707
Markus Metzgerda35c372008-01-30 13:32:03 +0100708 if (cfg.flags & PTRACE_BTS_O_SCHED)
Markus Metzgerc2724772008-12-11 13:49:59 +0100709 flags |= BTS_TIMESTAMPS;
Markus Metzgereee3af42008-01-30 13:31:09 +0100710
Markus Metzgerc2724772008-12-11 13:49:59 +0100711 child->bts = ds_request_bts(child, child->bts_buffer, child->bts_size,
712 /* ovfl = */ NULL, /* th = */ (size_t)-1,
713 flags);
714 if (IS_ERR(child->bts)) {
715 int error = PTR_ERR(child->bts);
Markus Metzgercba4b652008-01-30 13:32:03 +0100716
Markus Metzgerc5dee612008-12-19 15:17:02 +0100717 ptrace_bts_free_buffer(child);
Markus Metzgerc2724772008-12-11 13:49:59 +0100718 child->bts = NULL;
Markus Metzgerda35c372008-01-30 13:32:03 +0100719
Markus Metzgerc2724772008-12-11 13:49:59 +0100720 return error;
721 }
Markus Metzgerda35c372008-01-30 13:32:03 +0100722
Markus Metzgerc2724772008-12-11 13:49:59 +0100723 return sizeof(cfg);
Markus Metzgereee3af42008-01-30 13:31:09 +0100724}
725
Markus Metzgera95d67f2008-01-30 13:31:20 +0100726static int ptrace_bts_status(struct task_struct *child,
Markus Metzgercba4b652008-01-30 13:32:03 +0100727 long cfg_size,
Markus Metzgera95d67f2008-01-30 13:31:20 +0100728 struct ptrace_bts_config __user *ucfg)
Markus Metzgereee3af42008-01-30 13:31:09 +0100729{
Markus Metzgerc2724772008-12-11 13:49:59 +0100730 const struct bts_trace *trace;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100731 struct ptrace_bts_config cfg;
Markus Metzgereee3af42008-01-30 13:31:09 +0100732
Markus Metzgercba4b652008-01-30 13:32:03 +0100733 if (cfg_size < sizeof(cfg))
734 return -EIO;
735
Markus Metzgerc2724772008-12-11 13:49:59 +0100736 trace = ds_read_bts(child->bts);
737 if (!trace)
738 return -EPERM;
Markus Metzger93fa7632008-04-08 11:01:58 +0200739
Markus Metzgera95d67f2008-01-30 13:31:20 +0100740 memset(&cfg, 0, sizeof(cfg));
Markus Metzgerc2724772008-12-11 13:49:59 +0100741 cfg.size = trace->ds.end - trace->ds.begin;
Markus Metzger93fa7632008-04-08 11:01:58 +0200742 cfg.signal = child->thread.bts_ovfl_signal;
Markus Metzger87e84072008-01-30 13:32:54 +0100743 cfg.bts_size = sizeof(struct bts_struct);
744
Markus Metzger93fa7632008-04-08 11:01:58 +0200745 if (cfg.signal)
746 cfg.flags |= PTRACE_BTS_O_SIGNAL;
747
Markus Metzgerc2724772008-12-11 13:49:59 +0100748 if (trace->ds.flags & BTS_USER)
Markus Metzger93fa7632008-04-08 11:01:58 +0200749 cfg.flags |= PTRACE_BTS_O_TRACE;
750
Markus Metzgerc2724772008-12-11 13:49:59 +0100751 if (trace->ds.flags & BTS_TIMESTAMPS)
Markus Metzger93fa7632008-04-08 11:01:58 +0200752 cfg.flags |= PTRACE_BTS_O_SCHED;
753
Markus Metzgera95d67f2008-01-30 13:31:20 +0100754 if (copy_to_user(ucfg, &cfg, sizeof(cfg)))
755 return -EFAULT;
Markus Metzgereee3af42008-01-30 13:31:09 +0100756
Markus Metzgera95d67f2008-01-30 13:31:20 +0100757 return sizeof(cfg);
Markus Metzgereee3af42008-01-30 13:31:09 +0100758}
759
Markus Metzgerc2724772008-12-11 13:49:59 +0100760static int ptrace_bts_clear(struct task_struct *child)
Andrew Mortond8d4f152008-03-04 15:05:39 -0800761{
Markus Metzgerc2724772008-12-11 13:49:59 +0100762 const struct bts_trace *trace;
Andrew Mortond8d4f152008-03-04 15:05:39 -0800763
Markus Metzgerc2724772008-12-11 13:49:59 +0100764 trace = ds_read_bts(child->bts);
765 if (!trace)
766 return -EPERM;
Andrew Mortond8d4f152008-03-04 15:05:39 -0800767
Markus Metzgerc2724772008-12-11 13:49:59 +0100768 memset(trace->ds.begin, 0, trace->ds.n * trace->ds.size);
Andrew Mortond8d4f152008-03-04 15:05:39 -0800769
Markus Metzgerc2724772008-12-11 13:49:59 +0100770 return ds_reset_bts(child->bts);
Andrew Mortond8d4f152008-03-04 15:05:39 -0800771}
772
Markus Metzgerc2724772008-12-11 13:49:59 +0100773static int ptrace_bts_size(struct task_struct *child)
Markus Metzgereee3af42008-01-30 13:31:09 +0100774{
Markus Metzgerc2724772008-12-11 13:49:59 +0100775 const struct bts_trace *trace;
Markus Metzgereee3af42008-01-30 13:31:09 +0100776
Markus Metzgerc2724772008-12-11 13:49:59 +0100777 trace = ds_read_bts(child->bts);
778 if (!trace)
779 return -EPERM;
Markus Metzger93fa7632008-04-08 11:01:58 +0200780
Markus Metzgerc2724772008-12-11 13:49:59 +0100781 return (trace->ds.top - trace->ds.begin) / trace->ds.size;
Markus Metzger93fa7632008-04-08 11:01:58 +0200782}
Markus Metzgerbf53de92008-12-19 15:10:24 +0100783
784static void ptrace_bts_fork(struct task_struct *tsk)
785{
786 tsk->bts = NULL;
787 tsk->bts_buffer = NULL;
788 tsk->bts_size = 0;
789 tsk->thread.bts_ovfl_signal = 0;
790}
791
792static void ptrace_bts_untrace(struct task_struct *child)
793{
794 if (unlikely(child->bts)) {
795 ds_release_bts(child->bts);
796 child->bts = NULL;
797
Markus Metzgerc5dee612008-12-19 15:17:02 +0100798 /* We cannot update total_vm and locked_vm since
799 child's mm is already gone. But we can reclaim the
800 memory. */
Markus Metzgerbf53de92008-12-19 15:10:24 +0100801 kfree(child->bts_buffer);
802 child->bts_buffer = NULL;
803 child->bts_size = 0;
804 }
805}
806
807static void ptrace_bts_detach(struct task_struct *child)
808{
Markus Metzger9f339e72009-02-11 15:10:27 +0100809 /*
810 * Ptrace_detach() races with ptrace_untrace() in case
811 * the child dies and is reaped by another thread.
812 *
813 * We only do the memory accounting at this point and
814 * leave the buffer deallocation and the bts tracer
815 * release to ptrace_bts_untrace() which will be called
816 * later on with tasklist_lock held.
817 */
818 release_locked_buffer(child->bts_buffer, child->bts_size);
Markus Metzgerbf53de92008-12-19 15:10:24 +0100819}
820#else
821static inline void ptrace_bts_fork(struct task_struct *tsk) {}
822static inline void ptrace_bts_detach(struct task_struct *child) {}
823static inline void ptrace_bts_untrace(struct task_struct *child) {}
Markus Metzger93fa7632008-04-08 11:01:58 +0200824#endif /* CONFIG_X86_PTRACE_BTS */
Markus Metzgereee3af42008-01-30 13:31:09 +0100825
Markus Metzgerbf53de92008-12-19 15:10:24 +0100826void x86_ptrace_fork(struct task_struct *child, unsigned long clone_flags)
827{
828 ptrace_bts_fork(child);
829}
830
831void x86_ptrace_untrace(struct task_struct *child)
832{
833 ptrace_bts_untrace(child);
834}
835
Roland McGrathd9771e82008-01-30 13:30:52 +0100836/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 * Called by kernel/ptrace.c when detaching..
838 *
839 * Make sure the single step bit is not set.
840 */
841void ptrace_disable(struct task_struct *child)
Roland McGrath9e714be2008-01-30 13:30:58 +0100842{
Roland McGrath7f232342008-01-30 13:30:48 +0100843 user_disable_single_step(child);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100844#ifdef TIF_SYSCALL_EMU
Bodo Stroesserab1c23c2005-09-03 15:57:21 -0700845 clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100846#endif
Markus Metzgerbf53de92008-12-19 15:10:24 +0100847 ptrace_bts_detach(child);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848}
849
Roland McGrath5a4646a2008-01-30 13:31:54 +0100850#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
851static const struct user_regset_view user_x86_32_view; /* Initialized below. */
852#endif
853
Christoph Hellwig481bed42005-11-07 00:59:47 -0800854long arch_ptrace(struct task_struct *child, long request, long addr, long data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855{
Roland McGrath5a4646a2008-01-30 13:31:54 +0100856 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 unsigned long __user *datap = (unsigned long __user *)data;
858
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 switch (request) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 /* read the word at location addr in the USER area. */
861 case PTRACE_PEEKUSR: {
862 unsigned long tmp;
863
864 ret = -EIO;
Roland McGrathe9c86c72008-01-30 13:31:01 +0100865 if ((addr & (sizeof(data) - 1)) || addr < 0 ||
866 addr >= sizeof(struct user))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 break;
868
869 tmp = 0; /* Default return condition */
Roland McGrathe9c86c72008-01-30 13:31:01 +0100870 if (addr < sizeof(struct user_regs_struct))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 tmp = getreg(child, addr);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100872 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
873 addr <= offsetof(struct user, u_debugreg[7])) {
874 addr -= offsetof(struct user, u_debugreg[0]);
875 tmp = ptrace_get_debugreg(child, addr / sizeof(data));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 }
877 ret = put_user(tmp, datap);
878 break;
879 }
880
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
882 ret = -EIO;
Roland McGrathe9c86c72008-01-30 13:31:01 +0100883 if ((addr & (sizeof(data) - 1)) || addr < 0 ||
884 addr >= sizeof(struct user))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 break;
886
Roland McGrathe9c86c72008-01-30 13:31:01 +0100887 if (addr < sizeof(struct user_regs_struct))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 ret = putreg(child, addr, data);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100889 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
890 addr <= offsetof(struct user, u_debugreg[7])) {
891 addr -= offsetof(struct user, u_debugreg[0]);
892 ret = ptrace_set_debugreg(child,
893 addr / sizeof(data), data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 }
Roland McGrathe9c86c72008-01-30 13:31:01 +0100895 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896
Roland McGrath5a4646a2008-01-30 13:31:54 +0100897 case PTRACE_GETREGS: /* Get all gp regs from the child. */
898 return copy_regset_to_user(child,
899 task_user_regset_view(current),
900 REGSET_GENERAL,
901 0, sizeof(struct user_regs_struct),
902 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903
Roland McGrath5a4646a2008-01-30 13:31:54 +0100904 case PTRACE_SETREGS: /* Set all gp regs in the child. */
905 return copy_regset_from_user(child,
906 task_user_regset_view(current),
907 REGSET_GENERAL,
908 0, sizeof(struct user_regs_struct),
909 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910
Roland McGrath5a4646a2008-01-30 13:31:54 +0100911 case PTRACE_GETFPREGS: /* Get the child FPU state. */
912 return copy_regset_to_user(child,
913 task_user_regset_view(current),
914 REGSET_FP,
915 0, sizeof(struct user_i387_struct),
916 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917
Roland McGrath5a4646a2008-01-30 13:31:54 +0100918 case PTRACE_SETFPREGS: /* Set the child FPU state. */
919 return copy_regset_from_user(child,
920 task_user_regset_view(current),
921 REGSET_FP,
922 0, sizeof(struct user_i387_struct),
923 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924
Roland McGrathe9c86c72008-01-30 13:31:01 +0100925#ifdef CONFIG_X86_32
Roland McGrath5a4646a2008-01-30 13:31:54 +0100926 case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
927 return copy_regset_to_user(child, &user_x86_32_view,
928 REGSET_XFP,
929 0, sizeof(struct user_fxsr_struct),
Roland McGrath45fdc3a2008-06-30 14:02:41 -0700930 datap) ? -EIO : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931
Roland McGrath5a4646a2008-01-30 13:31:54 +0100932 case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
933 return copy_regset_from_user(child, &user_x86_32_view,
934 REGSET_XFP,
935 0, sizeof(struct user_fxsr_struct),
Roland McGrath45fdc3a2008-06-30 14:02:41 -0700936 datap) ? -EIO : 0;
Roland McGrathe9c86c72008-01-30 13:31:01 +0100937#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938
Roland McGrathe9c86c72008-01-30 13:31:01 +0100939#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 case PTRACE_GET_THREAD_AREA:
Roland McGrathefd1ca52008-01-30 13:30:46 +0100941 if (addr < 0)
942 return -EIO;
943 ret = do_get_thread_area(child, addr,
944 (struct user_desc __user *) data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 break;
946
947 case PTRACE_SET_THREAD_AREA:
Roland McGrathefd1ca52008-01-30 13:30:46 +0100948 if (addr < 0)
949 return -EIO;
950 ret = do_set_thread_area(child, addr,
951 (struct user_desc __user *) data, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952 break;
Roland McGrathe9c86c72008-01-30 13:31:01 +0100953#endif
954
955#ifdef CONFIG_X86_64
956 /* normal 64bit interface to access TLS data.
957 Works just like arch_prctl, except that the arguments
958 are reversed. */
959 case PTRACE_ARCH_PRCTL:
960 ret = do_arch_prctl(child, data, addr);
961 break;
962#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963
Ingo Molnarb4ef95d2008-02-26 09:40:27 +0100964 /*
965 * These bits need more cooking - not enabled yet:
966 */
Markus Metzger93fa7632008-04-08 11:01:58 +0200967#ifdef CONFIG_X86_PTRACE_BTS
Markus Metzgereee3af42008-01-30 13:31:09 +0100968 case PTRACE_BTS_CONFIG:
Markus Metzgera95d67f2008-01-30 13:31:20 +0100969 ret = ptrace_bts_config
Markus Metzgercba4b652008-01-30 13:32:03 +0100970 (child, data, (struct ptrace_bts_config __user *)addr);
Markus Metzgereee3af42008-01-30 13:31:09 +0100971 break;
972
973 case PTRACE_BTS_STATUS:
Markus Metzgera95d67f2008-01-30 13:31:20 +0100974 ret = ptrace_bts_status
Markus Metzgercba4b652008-01-30 13:32:03 +0100975 (child, data, (struct ptrace_bts_config __user *)addr);
Markus Metzgera95d67f2008-01-30 13:31:20 +0100976 break;
977
Markus Metzgerc2724772008-12-11 13:49:59 +0100978 case PTRACE_BTS_SIZE:
979 ret = ptrace_bts_size(child);
Markus Metzgera95d67f2008-01-30 13:31:20 +0100980 break;
981
982 case PTRACE_BTS_GET:
983 ret = ptrace_bts_read_record
984 (child, data, (struct bts_struct __user *) addr);
985 break;
986
987 case PTRACE_BTS_CLEAR:
Markus Metzgerc2724772008-12-11 13:49:59 +0100988 ret = ptrace_bts_clear(child);
Markus Metzgera95d67f2008-01-30 13:31:20 +0100989 break;
990
991 case PTRACE_BTS_DRAIN:
992 ret = ptrace_bts_drain
Markus Metzgercba4b652008-01-30 13:32:03 +0100993 (child, data, (struct bts_struct __user *) addr);
Markus Metzgereee3af42008-01-30 13:31:09 +0100994 break;
Markus Metzger93fa7632008-04-08 11:01:58 +0200995#endif /* CONFIG_X86_PTRACE_BTS */
Markus Metzgereee3af42008-01-30 13:31:09 +0100996
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997 default:
998 ret = ptrace_request(child, request, addr, data);
999 break;
1000 }
Roland McGrathd9771e82008-01-30 13:30:52 +01001001
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 return ret;
1003}
1004
Roland McGrathcb757c42008-01-30 13:31:01 +01001005#ifdef CONFIG_IA32_EMULATION
1006
Roland McGrath099cd6e2008-01-30 13:31:01 +01001007#include <linux/compat.h>
1008#include <linux/syscalls.h>
1009#include <asm/ia32.h>
Roland McGrathcb757c42008-01-30 13:31:01 +01001010#include <asm/user32.h>
1011
1012#define R32(l,q) \
1013 case offsetof(struct user32, regs.l): \
1014 regs->q = value; break
1015
1016#define SEG32(rs) \
1017 case offsetof(struct user32, regs.rs): \
1018 return set_segment_reg(child, \
1019 offsetof(struct user_regs_struct, rs), \
1020 value); \
1021 break
1022
1023static int putreg32(struct task_struct *child, unsigned regno, u32 value)
1024{
1025 struct pt_regs *regs = task_pt_regs(child);
1026
1027 switch (regno) {
1028
1029 SEG32(cs);
1030 SEG32(ds);
1031 SEG32(es);
1032 SEG32(fs);
1033 SEG32(gs);
1034 SEG32(ss);
1035
1036 R32(ebx, bx);
1037 R32(ecx, cx);
1038 R32(edx, dx);
1039 R32(edi, di);
1040 R32(esi, si);
1041 R32(ebp, bp);
1042 R32(eax, ax);
Roland McGrathcb757c42008-01-30 13:31:01 +01001043 R32(eip, ip);
1044 R32(esp, sp);
1045
Roland McGrath40f09332008-02-28 19:57:07 -08001046 case offsetof(struct user32, regs.orig_eax):
1047 /*
1048 * Sign-extend the value so that orig_eax = -1
1049 * causes (long)orig_ax < 0 tests to fire correctly.
1050 */
1051 regs->orig_ax = (long) (s32) value;
1052 break;
1053
Roland McGrathcb757c42008-01-30 13:31:01 +01001054 case offsetof(struct user32, regs.eflags):
1055 return set_flags(child, value);
1056
1057 case offsetof(struct user32, u_debugreg[0]) ...
1058 offsetof(struct user32, u_debugreg[7]):
1059 regno -= offsetof(struct user32, u_debugreg[0]);
1060 return ptrace_set_debugreg(child, regno / 4, value);
1061
1062 default:
1063 if (regno > sizeof(struct user32) || (regno & 3))
1064 return -EIO;
1065
1066 /*
1067 * Other dummy fields in the virtual user structure
1068 * are ignored
1069 */
1070 break;
1071 }
1072 return 0;
1073}
1074
1075#undef R32
1076#undef SEG32
1077
1078#define R32(l,q) \
1079 case offsetof(struct user32, regs.l): \
1080 *val = regs->q; break
1081
1082#define SEG32(rs) \
1083 case offsetof(struct user32, regs.rs): \
1084 *val = get_segment_reg(child, \
1085 offsetof(struct user_regs_struct, rs)); \
1086 break
1087
1088static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
1089{
1090 struct pt_regs *regs = task_pt_regs(child);
1091
1092 switch (regno) {
1093
1094 SEG32(ds);
1095 SEG32(es);
1096 SEG32(fs);
1097 SEG32(gs);
1098
1099 R32(cs, cs);
1100 R32(ss, ss);
1101 R32(ebx, bx);
1102 R32(ecx, cx);
1103 R32(edx, dx);
1104 R32(edi, di);
1105 R32(esi, si);
1106 R32(ebp, bp);
1107 R32(eax, ax);
1108 R32(orig_eax, orig_ax);
1109 R32(eip, ip);
1110 R32(esp, sp);
1111
1112 case offsetof(struct user32, regs.eflags):
1113 *val = get_flags(child);
1114 break;
1115
1116 case offsetof(struct user32, u_debugreg[0]) ...
1117 offsetof(struct user32, u_debugreg[7]):
1118 regno -= offsetof(struct user32, u_debugreg[0]);
1119 *val = ptrace_get_debugreg(child, regno / 4);
1120 break;
1121
1122 default:
1123 if (regno > sizeof(struct user32) || (regno & 3))
1124 return -EIO;
1125
1126 /*
1127 * Other dummy fields in the virtual user structure
1128 * are ignored
1129 */
1130 *val = 0;
1131 break;
1132 }
1133 return 0;
1134}
1135
1136#undef R32
1137#undef SEG32
1138
Roland McGrath91e7b702008-01-30 13:31:52 +01001139static int genregs32_get(struct task_struct *target,
1140 const struct user_regset *regset,
1141 unsigned int pos, unsigned int count,
1142 void *kbuf, void __user *ubuf)
1143{
1144 if (kbuf) {
1145 compat_ulong_t *k = kbuf;
1146 while (count > 0) {
1147 getreg32(target, pos, k++);
1148 count -= sizeof(*k);
1149 pos += sizeof(*k);
1150 }
1151 } else {
1152 compat_ulong_t __user *u = ubuf;
1153 while (count > 0) {
1154 compat_ulong_t word;
1155 getreg32(target, pos, &word);
1156 if (__put_user(word, u++))
1157 return -EFAULT;
1158 count -= sizeof(*u);
1159 pos += sizeof(*u);
1160 }
1161 }
1162
1163 return 0;
1164}
1165
1166static int genregs32_set(struct task_struct *target,
1167 const struct user_regset *regset,
1168 unsigned int pos, unsigned int count,
1169 const void *kbuf, const void __user *ubuf)
1170{
1171 int ret = 0;
1172 if (kbuf) {
1173 const compat_ulong_t *k = kbuf;
1174 while (count > 0 && !ret) {
Roland McGrathf9cb02b2008-02-21 20:37:24 -08001175 ret = putreg32(target, pos, *k++);
Roland McGrath91e7b702008-01-30 13:31:52 +01001176 count -= sizeof(*k);
1177 pos += sizeof(*k);
1178 }
1179 } else {
1180 const compat_ulong_t __user *u = ubuf;
1181 while (count > 0 && !ret) {
1182 compat_ulong_t word;
1183 ret = __get_user(word, u++);
1184 if (ret)
1185 break;
Roland McGrathf9cb02b2008-02-21 20:37:24 -08001186 ret = putreg32(target, pos, word);
Roland McGrath91e7b702008-01-30 13:31:52 +01001187 count -= sizeof(*u);
1188 pos += sizeof(*u);
1189 }
1190 }
1191 return ret;
1192}
1193
Roland McGrath562b80b2008-04-22 12:21:25 -07001194long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
1195 compat_ulong_t caddr, compat_ulong_t cdata)
Roland McGrath099cd6e2008-01-30 13:31:01 +01001196{
Roland McGrath562b80b2008-04-22 12:21:25 -07001197 unsigned long addr = caddr;
1198 unsigned long data = cdata;
Roland McGrath099cd6e2008-01-30 13:31:01 +01001199 void __user *datap = compat_ptr(data);
1200 int ret;
1201 __u32 val;
1202
1203 switch (request) {
Roland McGrath099cd6e2008-01-30 13:31:01 +01001204 case PTRACE_PEEKUSR:
1205 ret = getreg32(child, addr, &val);
1206 if (ret == 0)
1207 ret = put_user(val, (__u32 __user *)datap);
1208 break;
1209
1210 case PTRACE_POKEUSR:
1211 ret = putreg32(child, addr, data);
1212 break;
1213
Roland McGrath5a4646a2008-01-30 13:31:54 +01001214 case PTRACE_GETREGS: /* Get all gp regs from the child. */
1215 return copy_regset_to_user(child, &user_x86_32_view,
1216 REGSET_GENERAL,
1217 0, sizeof(struct user_regs_struct32),
1218 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001219
Roland McGrath5a4646a2008-01-30 13:31:54 +01001220 case PTRACE_SETREGS: /* Set all gp regs in the child. */
1221 return copy_regset_from_user(child, &user_x86_32_view,
1222 REGSET_GENERAL, 0,
1223 sizeof(struct user_regs_struct32),
1224 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001225
Roland McGrath5a4646a2008-01-30 13:31:54 +01001226 case PTRACE_GETFPREGS: /* Get the child FPU state. */
1227 return copy_regset_to_user(child, &user_x86_32_view,
1228 REGSET_FP, 0,
1229 sizeof(struct user_i387_ia32_struct),
1230 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001231
Roland McGrath5a4646a2008-01-30 13:31:54 +01001232 case PTRACE_SETFPREGS: /* Set the child FPU state. */
1233 return copy_regset_from_user(
1234 child, &user_x86_32_view, REGSET_FP,
1235 0, sizeof(struct user_i387_ia32_struct), datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001236
Roland McGrath5a4646a2008-01-30 13:31:54 +01001237 case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
1238 return copy_regset_to_user(child, &user_x86_32_view,
1239 REGSET_XFP, 0,
1240 sizeof(struct user32_fxsr_struct),
1241 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001242
Roland McGrath5a4646a2008-01-30 13:31:54 +01001243 case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
1244 return copy_regset_from_user(child, &user_x86_32_view,
1245 REGSET_XFP, 0,
1246 sizeof(struct user32_fxsr_struct),
1247 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001248
Roland McGrath562b80b2008-04-22 12:21:25 -07001249 case PTRACE_GET_THREAD_AREA:
1250 case PTRACE_SET_THREAD_AREA:
Markus Metzgerc2724772008-12-11 13:49:59 +01001251#ifdef CONFIG_X86_PTRACE_BTS
1252 case PTRACE_BTS_CONFIG:
1253 case PTRACE_BTS_STATUS:
1254 case PTRACE_BTS_SIZE:
1255 case PTRACE_BTS_GET:
1256 case PTRACE_BTS_CLEAR:
1257 case PTRACE_BTS_DRAIN:
1258#endif /* CONFIG_X86_PTRACE_BTS */
Roland McGrath562b80b2008-04-22 12:21:25 -07001259 return arch_ptrace(child, request, addr, data);
1260
Roland McGrath099cd6e2008-01-30 13:31:01 +01001261 default:
Roland McGrathfdadd542008-01-30 13:31:56 +01001262 return compat_ptrace_request(child, request, addr, data);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001263 }
1264
Roland McGrath099cd6e2008-01-30 13:31:01 +01001265 return ret;
1266}
1267
Roland McGrathcb757c42008-01-30 13:31:01 +01001268#endif /* CONFIG_IA32_EMULATION */
1269
Roland McGrath070459d2008-01-30 13:31:53 +01001270#ifdef CONFIG_X86_64
1271
1272static const struct user_regset x86_64_regsets[] = {
1273 [REGSET_GENERAL] = {
1274 .core_note_type = NT_PRSTATUS,
1275 .n = sizeof(struct user_regs_struct) / sizeof(long),
1276 .size = sizeof(long), .align = sizeof(long),
1277 .get = genregs_get, .set = genregs_set
1278 },
1279 [REGSET_FP] = {
1280 .core_note_type = NT_PRFPREG,
1281 .n = sizeof(struct user_i387_struct) / sizeof(long),
1282 .size = sizeof(long), .align = sizeof(long),
1283 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
1284 },
Roland McGrath325af5f2008-08-08 15:58:39 -07001285 [REGSET_IOPERM64] = {
1286 .core_note_type = NT_386_IOPERM,
1287 .n = IO_BITMAP_LONGS,
1288 .size = sizeof(long), .align = sizeof(long),
1289 .active = ioperm_active, .get = ioperm_get
1290 },
Roland McGrath070459d2008-01-30 13:31:53 +01001291};
1292
1293static const struct user_regset_view user_x86_64_view = {
1294 .name = "x86_64", .e_machine = EM_X86_64,
1295 .regsets = x86_64_regsets, .n = ARRAY_SIZE(x86_64_regsets)
1296};
1297
1298#else /* CONFIG_X86_32 */
1299
1300#define user_regs_struct32 user_regs_struct
1301#define genregs32_get genregs_get
1302#define genregs32_set genregs_set
1303
Roland McGrath1f465f42008-05-09 15:43:44 -07001304#define user_i387_ia32_struct user_i387_struct
1305#define user32_fxsr_struct user_fxsr_struct
1306
Roland McGrath070459d2008-01-30 13:31:53 +01001307#endif /* CONFIG_X86_64 */
1308
1309#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1310static const struct user_regset x86_32_regsets[] = {
1311 [REGSET_GENERAL] = {
1312 .core_note_type = NT_PRSTATUS,
1313 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
1314 .size = sizeof(u32), .align = sizeof(u32),
1315 .get = genregs32_get, .set = genregs32_set
1316 },
1317 [REGSET_FP] = {
1318 .core_note_type = NT_PRFPREG,
Roland McGrath1f465f42008-05-09 15:43:44 -07001319 .n = sizeof(struct user_i387_ia32_struct) / sizeof(u32),
Roland McGrath070459d2008-01-30 13:31:53 +01001320 .size = sizeof(u32), .align = sizeof(u32),
1321 .active = fpregs_active, .get = fpregs_get, .set = fpregs_set
1322 },
1323 [REGSET_XFP] = {
1324 .core_note_type = NT_PRXFPREG,
Roland McGrath1f465f42008-05-09 15:43:44 -07001325 .n = sizeof(struct user32_fxsr_struct) / sizeof(u32),
Roland McGrath070459d2008-01-30 13:31:53 +01001326 .size = sizeof(u32), .align = sizeof(u32),
1327 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
1328 },
1329 [REGSET_TLS] = {
Roland McGrathbb616822008-01-30 13:31:56 +01001330 .core_note_type = NT_386_TLS,
Roland McGrath070459d2008-01-30 13:31:53 +01001331 .n = GDT_ENTRY_TLS_ENTRIES, .bias = GDT_ENTRY_TLS_MIN,
1332 .size = sizeof(struct user_desc),
1333 .align = sizeof(struct user_desc),
1334 .active = regset_tls_active,
1335 .get = regset_tls_get, .set = regset_tls_set
1336 },
Roland McGrath325af5f2008-08-08 15:58:39 -07001337 [REGSET_IOPERM32] = {
1338 .core_note_type = NT_386_IOPERM,
1339 .n = IO_BITMAP_BYTES / sizeof(u32),
1340 .size = sizeof(u32), .align = sizeof(u32),
1341 .active = ioperm_active, .get = ioperm_get
1342 },
Roland McGrath070459d2008-01-30 13:31:53 +01001343};
1344
1345static const struct user_regset_view user_x86_32_view = {
1346 .name = "i386", .e_machine = EM_386,
1347 .regsets = x86_32_regsets, .n = ARRAY_SIZE(x86_32_regsets)
1348};
1349#endif
1350
1351const struct user_regset_view *task_user_regset_view(struct task_struct *task)
1352{
1353#ifdef CONFIG_IA32_EMULATION
1354 if (test_tsk_thread_flag(task, TIF_IA32))
1355#endif
1356#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1357 return &user_x86_32_view;
1358#endif
1359#ifdef CONFIG_X86_64
1360 return &user_x86_64_view;
1361#endif
1362}
1363
Srinivasa Dsda654b72008-09-23 15:23:52 +05301364void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
1365 int error_code, int si_code)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366{
1367 struct siginfo info;
1368
1369 tsk->thread.trap_no = 1;
1370 tsk->thread.error_code = error_code;
1371
1372 memset(&info, 0, sizeof(info));
1373 info.si_signo = SIGTRAP;
Srinivasa Dsda654b72008-09-23 15:23:52 +05301374 info.si_code = si_code;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375
H. Peter Anvin65ea5b02008-01-30 13:30:56 +01001376 /* User-mode ip? */
1377 info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378
Simon Arlott27b46d72007-10-20 01:13:56 +02001379 /* Send us the fake SIGTRAP */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 force_sig_info(SIGTRAP, &info, tsk);
1381}
1382
Roland McGrath86976cd2008-01-30 13:31:01 +01001383
Roland McGrathd4d67152008-07-09 02:38:07 -07001384#ifdef CONFIG_X86_32
1385# define IS_IA32 1
1386#elif defined CONFIG_IA32_EMULATION
Roland McGrathccbe4952009-02-27 19:03:24 -08001387# define IS_IA32 is_compat_task()
Roland McGrathd4d67152008-07-09 02:38:07 -07001388#else
1389# define IS_IA32 0
1390#endif
1391
1392/*
1393 * We must return the syscall number to actually look up in the table.
1394 * This can be -1L to skip running any syscall at all.
1395 */
1396asmregparm long syscall_trace_enter(struct pt_regs *regs)
Roland McGrath86976cd2008-01-30 13:31:01 +01001397{
Roland McGrathd4d67152008-07-09 02:38:07 -07001398 long ret = 0;
1399
Roland McGrath380fdd72008-07-09 02:39:29 -07001400 /*
1401 * If we stepped into a sysenter/syscall insn, it trapped in
1402 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
1403 * If user-mode had set TF itself, then it's still clear from
1404 * do_debug() and we need to set it again to restore the user
1405 * state. If we entered on the slow path, TF was already set.
1406 */
1407 if (test_thread_flag(TIF_SINGLESTEP))
1408 regs->flags |= X86_EFLAGS_TF;
1409
Roland McGrath86976cd2008-01-30 13:31:01 +01001410 /* do the secure computing check first */
1411 secure_computing(regs->orig_ax);
1412
Roland McGrathd4d67152008-07-09 02:38:07 -07001413 if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
1414 ret = -1L;
1415
Roland McGratheeea3c32008-03-16 23:36:28 -07001416 if ((ret || test_thread_flag(TIF_SYSCALL_TRACE)) &&
1417 tracehook_report_syscall_entry(regs))
1418 ret = -1L;
Roland McGrath86976cd2008-01-30 13:31:01 +01001419
Frederic Weisbecker1b3fa2c2009-03-07 05:53:00 +01001420 if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
1421 ftrace_syscall_enter(regs);
1422
Roland McGrath86976cd2008-01-30 13:31:01 +01001423 if (unlikely(current->audit_context)) {
Roland McGrathd4d67152008-07-09 02:38:07 -07001424 if (IS_IA32)
Roland McGrath86976cd2008-01-30 13:31:01 +01001425 audit_syscall_entry(AUDIT_ARCH_I386,
1426 regs->orig_ax,
1427 regs->bx, regs->cx,
1428 regs->dx, regs->si);
Roland McGrathd4d67152008-07-09 02:38:07 -07001429#ifdef CONFIG_X86_64
1430 else
Roland McGrath86976cd2008-01-30 13:31:01 +01001431 audit_syscall_entry(AUDIT_ARCH_X86_64,
1432 regs->orig_ax,
1433 regs->di, regs->si,
1434 regs->dx, regs->r10);
Roland McGrathd4d67152008-07-09 02:38:07 -07001435#endif
Roland McGrath86976cd2008-01-30 13:31:01 +01001436 }
Roland McGrathd4d67152008-07-09 02:38:07 -07001437
1438 return ret ?: regs->orig_ax;
Roland McGrath86976cd2008-01-30 13:31:01 +01001439}
1440
Roland McGrathd4d67152008-07-09 02:38:07 -07001441asmregparm void syscall_trace_leave(struct pt_regs *regs)
Roland McGrath86976cd2008-01-30 13:31:01 +01001442{
1443 if (unlikely(current->audit_context))
1444 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
1445
Frederic Weisbecker1b3fa2c2009-03-07 05:53:00 +01001446 if (unlikely(test_thread_flag(TIF_SYSCALL_FTRACE)))
1447 ftrace_syscall_exit(regs);
1448
Roland McGrathd4d67152008-07-09 02:38:07 -07001449 if (test_thread_flag(TIF_SYSCALL_TRACE))
Roland McGratheeea3c32008-03-16 23:36:28 -07001450 tracehook_report_syscall_exit(regs, 0);
Roland McGrath86976cd2008-01-30 13:31:01 +01001451
Roland McGrathd4d67152008-07-09 02:38:07 -07001452 /*
1453 * If TIF_SYSCALL_EMU is set, we only get here because of
1454 * TIF_SINGLESTEP (i.e. this is PTRACE_SYSEMU_SINGLESTEP).
1455 * We already reported this syscall instruction in
1456 * syscall_trace_enter(), so don't do any more now.
1457 */
1458 if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
1459 return;
1460
1461 /*
1462 * If we are single-stepping, synthesize a trap to follow the
1463 * system call instruction.
1464 */
1465 if (test_thread_flag(TIF_SINGLESTEP) &&
Oleg Nesterov43918f22009-04-02 16:58:00 -07001466 tracehook_consider_fatal_signal(current, SIGTRAP))
Srinivasa Dsda654b72008-09-23 15:23:52 +05301467 send_sigtrap(current, regs, 0, TRAP_BRKPT);
Roland McGrathd4d67152008-07-09 02:38:07 -07001468}