blob: f41fdc98efb14388bf6a4eb8b7f4f8f7efebcc7f [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/user.h>
Roland McGrath070459d2008-01-30 13:31:53 +010018#include <linux/elf.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/security.h>
20#include <linux/audit.h>
21#include <linux/seccomp.h>
Jesper Juhl7ed20e12005-05-01 08:59:14 -070022#include <linux/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include <asm/uaccess.h>
25#include <asm/pgtable.h>
26#include <asm/system.h>
27#include <asm/processor.h>
28#include <asm/i387.h>
29#include <asm/debugreg.h>
30#include <asm/ldt.h>
31#include <asm/desc.h>
Roland McGrath2047b082008-01-30 13:31:01 +010032#include <asm/prctl.h>
33#include <asm/proto.h>
Markus Metzgereee3af42008-01-30 13:31:09 +010034#include <asm/ds.h>
35
Roland McGrath070459d2008-01-30 13:31:53 +010036#include "tls.h"
37
38enum x86_regset {
39 REGSET_GENERAL,
40 REGSET_FP,
41 REGSET_XFP,
42 REGSET_TLS,
43};
Markus Metzgereee3af42008-01-30 13:31:09 +010044
45/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 * does not yet catch signals sent when the child dies.
47 * in exit.c or in signal.c.
48 */
49
Chuck Ebbert9f155b92006-01-05 23:11:29 -050050/*
51 * Determines which flags the user has access to [1 = access, 0 = no access].
Chuck Ebbert9f155b92006-01-05 23:11:29 -050052 */
Roland McGrathe39c2892008-01-30 13:31:01 +010053#define FLAG_MASK_32 ((unsigned long) \
54 (X86_EFLAGS_CF | X86_EFLAGS_PF | \
55 X86_EFLAGS_AF | X86_EFLAGS_ZF | \
56 X86_EFLAGS_SF | X86_EFLAGS_TF | \
57 X86_EFLAGS_DF | X86_EFLAGS_OF | \
58 X86_EFLAGS_RF | X86_EFLAGS_AC))
59
Roland McGrath2047b082008-01-30 13:31:01 +010060/*
61 * Determines whether a value may be installed in a segment register.
62 */
63static inline bool invalid_selector(u16 value)
64{
65 return unlikely(value != 0 && (value & SEGMENT_RPL_MASK) != USER_RPL);
66}
67
68#ifdef CONFIG_X86_32
69
Roland McGrathe39c2892008-01-30 13:31:01 +010070#define FLAG_MASK FLAG_MASK_32
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Roland McGrath62a97d42008-01-30 13:30:52 +010072static long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010074 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
Roland McGrath06ee1b62008-01-30 13:31:01 +010075 regno >>= 2;
Roland McGrath62a97d42008-01-30 13:30:52 +010076 if (regno > FS)
77 --regno;
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010078 return &regs->bx + regno;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
Roland McGrath06ee1b62008-01-30 13:31:01 +010081static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
Roland McGrath06ee1b62008-01-30 13:31:01 +010083 /*
84 * Returning the value truncates it to 16 bits.
85 */
86 unsigned int retval;
87 if (offset != offsetof(struct user_regs_struct, gs))
88 retval = *pt_regs_access(task_pt_regs(task), offset);
89 else {
90 retval = task->thread.gs;
91 if (task == current)
92 savesegment(gs, retval);
93 }
94 return retval;
95}
96
97static int set_segment_reg(struct task_struct *task,
98 unsigned long offset, u16 value)
99{
100 /*
101 * The value argument was already truncated to 16 bits.
102 */
Roland McGrath2047b082008-01-30 13:31:01 +0100103 if (invalid_selector(value))
Roland McGrath06ee1b62008-01-30 13:31:01 +0100104 return -EIO;
105
Roland McGrathc63855d2008-02-06 22:39:44 +0100106 /*
107 * For %cs and %ss we cannot permit a null selector.
108 * We can permit a bogus selector as long as it has USER_RPL.
109 * Null selectors are fine for other segment registers, but
110 * we will never get back to user mode with invalid %cs or %ss
111 * and will take the trap in iret instead. Much code relies
112 * on user_mode() to distinguish a user trap frame (which can
113 * safely use invalid selectors) from a kernel trap frame.
114 */
115 switch (offset) {
116 case offsetof(struct user_regs_struct, cs):
117 case offsetof(struct user_regs_struct, ss):
118 if (unlikely(value == 0))
119 return -EIO;
120
121 default:
Roland McGrath06ee1b62008-01-30 13:31:01 +0100122 *pt_regs_access(task_pt_regs(task), offset) = value;
Roland McGrathc63855d2008-02-06 22:39:44 +0100123 break;
124
125 case offsetof(struct user_regs_struct, gs):
Roland McGrath06ee1b62008-01-30 13:31:01 +0100126 task->thread.gs = value;
127 if (task == current)
Roland McGrath5fd4d162008-01-30 13:30:58 +0100128 /*
129 * The user-mode %gs is not affected by
130 * kernel entry, so we must update the CPU.
131 */
132 loadsegment(gs, 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
273 return TASK_SIZE64 - 7;
274}
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
326 case offsetof(struct user_regs_struct,fs_base):
327 if (value >= TASK_SIZE_OF(child))
328 return -EIO;
329 /*
330 * When changing the segment base, use do_arch_prctl
331 * to set either thread.fs or thread.fsindex and the
332 * corresponding GDT slot.
333 */
334 if (child->thread.fs != value)
335 return do_arch_prctl(child, ARCH_SET_FS, value);
336 return 0;
337 case offsetof(struct user_regs_struct,gs_base):
338 /*
339 * Exactly the same here as the %fs handling above.
340 */
341 if (value >= TASK_SIZE_OF(child))
342 return -EIO;
343 if (child->thread.gs != value)
344 return do_arch_prctl(child, ARCH_SET_GS, value);
345 return 0;
346#endif
Roland McGrath06ee1b62008-01-30 13:31:01 +0100347 }
348
349 *pt_regs_access(task_pt_regs(child), offset) = value;
350 return 0;
351}
352
353static unsigned long getreg(struct task_struct *task, unsigned long offset)
354{
355 switch (offset) {
356 case offsetof(struct user_regs_struct, cs):
357 case offsetof(struct user_regs_struct, ds):
358 case offsetof(struct user_regs_struct, es):
359 case offsetof(struct user_regs_struct, fs):
360 case offsetof(struct user_regs_struct, gs):
361 case offsetof(struct user_regs_struct, ss):
362 return get_segment_reg(task, offset);
363
364 case offsetof(struct user_regs_struct, flags):
365 return get_flags(task);
Roland McGrath2047b082008-01-30 13:31:01 +0100366
367#ifdef CONFIG_X86_64
368 case offsetof(struct user_regs_struct, fs_base): {
369 /*
370 * do_arch_prctl may have used a GDT slot instead of
371 * the MSR. To userland, it appears the same either
372 * way, except the %fs segment selector might not be 0.
373 */
374 unsigned int seg = task->thread.fsindex;
375 if (task->thread.fs != 0)
376 return task->thread.fs;
377 if (task == current)
378 asm("movl %%fs,%0" : "=r" (seg));
379 if (seg != FS_TLS_SEL)
380 return 0;
381 return get_desc_base(&task->thread.tls_array[FS_TLS]);
382 }
383 case offsetof(struct user_regs_struct, gs_base): {
384 /*
385 * Exactly the same here as the %fs handling above.
386 */
387 unsigned int seg = task->thread.gsindex;
388 if (task->thread.gs != 0)
389 return task->thread.gs;
390 if (task == current)
391 asm("movl %%gs,%0" : "=r" (seg));
392 if (seg != GS_TLS_SEL)
393 return 0;
394 return get_desc_base(&task->thread.tls_array[GS_TLS]);
395 }
396#endif
Roland McGrath06ee1b62008-01-30 13:31:01 +0100397 }
398
399 return *pt_regs_access(task_pt_regs(task), offset);
400}
401
Roland McGrath91e7b702008-01-30 13:31:52 +0100402static int genregs_get(struct task_struct *target,
403 const struct user_regset *regset,
404 unsigned int pos, unsigned int count,
405 void *kbuf, void __user *ubuf)
406{
407 if (kbuf) {
408 unsigned long *k = kbuf;
409 while (count > 0) {
410 *k++ = getreg(target, pos);
411 count -= sizeof(*k);
412 pos += sizeof(*k);
413 }
414 } else {
415 unsigned long __user *u = ubuf;
416 while (count > 0) {
417 if (__put_user(getreg(target, pos), u++))
418 return -EFAULT;
419 count -= sizeof(*u);
420 pos += sizeof(*u);
421 }
422 }
423
424 return 0;
425}
426
427static int genregs_set(struct task_struct *target,
428 const struct user_regset *regset,
429 unsigned int pos, unsigned int count,
430 const void *kbuf, const void __user *ubuf)
431{
432 int ret = 0;
433 if (kbuf) {
434 const unsigned long *k = kbuf;
435 while (count > 0 && !ret) {
436 ret = putreg(target, pos, *k++);
437 count -= sizeof(*k);
438 pos += sizeof(*k);
439 }
440 } else {
441 const unsigned long __user *u = ubuf;
442 while (count > 0 && !ret) {
443 unsigned long word;
444 ret = __get_user(word, u++);
445 if (ret)
446 break;
447 ret = putreg(target, pos, word);
448 count -= sizeof(*u);
449 pos += sizeof(*u);
450 }
451 }
452 return ret;
453}
454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455/*
Roland McGrathd9771e82008-01-30 13:30:52 +0100456 * This function is trivial and will be inlined by the compiler.
457 * Having it separates the implementation details of debug
458 * registers from the interface details of ptrace.
459 */
460static unsigned long ptrace_get_debugreg(struct task_struct *child, int n)
461{
Roland McGrath0f534092008-01-30 13:30:59 +0100462 switch (n) {
463 case 0: return child->thread.debugreg0;
464 case 1: return child->thread.debugreg1;
465 case 2: return child->thread.debugreg2;
466 case 3: return child->thread.debugreg3;
467 case 6: return child->thread.debugreg6;
468 case 7: return child->thread.debugreg7;
469 }
470 return 0;
Roland McGrathd9771e82008-01-30 13:30:52 +0100471}
472
473static int ptrace_set_debugreg(struct task_struct *child,
474 int n, unsigned long data)
475{
Roland McGrath0f534092008-01-30 13:30:59 +0100476 int i;
477
Roland McGrathd9771e82008-01-30 13:30:52 +0100478 if (unlikely(n == 4 || n == 5))
479 return -EIO;
480
Roland McGrath2047b082008-01-30 13:31:01 +0100481 if (n < 4 && unlikely(data >= debugreg_addr_limit(child)))
Roland McGrathd9771e82008-01-30 13:30:52 +0100482 return -EIO;
483
Roland McGrath0f534092008-01-30 13:30:59 +0100484 switch (n) {
485 case 0: child->thread.debugreg0 = data; break;
486 case 1: child->thread.debugreg1 = data; break;
487 case 2: child->thread.debugreg2 = data; break;
488 case 3: child->thread.debugreg3 = data; break;
489
490 case 6:
Roland McGrath2047b082008-01-30 13:31:01 +0100491 if ((data & ~0xffffffffUL) != 0)
492 return -EIO;
Roland McGrath0f534092008-01-30 13:30:59 +0100493 child->thread.debugreg6 = data;
494 break;
495
496 case 7:
Roland McGrathd9771e82008-01-30 13:30:52 +0100497 /*
498 * Sanity-check data. Take one half-byte at once with
499 * check = (val >> (16 + 4*i)) & 0xf. It contains the
500 * R/Wi and LENi bits; bits 0 and 1 are R/Wi, and bits
501 * 2 and 3 are LENi. Given a list of invalid values,
502 * we do mask |= 1 << invalid_value, so that
503 * (mask >> check) & 1 is a correct test for invalid
504 * values.
505 *
506 * R/Wi contains the type of the breakpoint /
507 * watchpoint, LENi contains the length of the watched
508 * data in the watchpoint case.
509 *
510 * The invalid values are:
Roland McGrath2047b082008-01-30 13:31:01 +0100511 * - LENi == 0x10 (undefined), so mask |= 0x0f00. [32-bit]
Roland McGrathd9771e82008-01-30 13:30:52 +0100512 * - R/Wi == 0x10 (break on I/O reads or writes), so
513 * mask |= 0x4444.
514 * - R/Wi == 0x00 && LENi != 0x00, so we have mask |=
515 * 0x1110.
516 *
517 * Finally, mask = 0x0f00 | 0x4444 | 0x1110 == 0x5f54.
518 *
519 * See the Intel Manual "System Programming Guide",
520 * 15.2.4
521 *
522 * Note that LENi == 0x10 is defined on x86_64 in long
523 * mode (i.e. even for 32-bit userspace software, but
524 * 64-bit kernel), so the x86_64 mask value is 0x5454.
525 * See the AMD manual no. 24593 (AMD64 System Programming)
526 */
Roland McGrath2047b082008-01-30 13:31:01 +0100527#ifdef CONFIG_X86_32
528#define DR7_MASK 0x5f54
529#else
530#define DR7_MASK 0x5554
531#endif
Roland McGrathd9771e82008-01-30 13:30:52 +0100532 data &= ~DR_CONTROL_RESERVED;
533 for (i = 0; i < 4; i++)
Roland McGrath2047b082008-01-30 13:31:01 +0100534 if ((DR7_MASK >> ((data >> (16 + 4*i)) & 0xf)) & 1)
Roland McGrathd9771e82008-01-30 13:30:52 +0100535 return -EIO;
Roland McGrath0f534092008-01-30 13:30:59 +0100536 child->thread.debugreg7 = data;
Roland McGrathd9771e82008-01-30 13:30:52 +0100537 if (data)
538 set_tsk_thread_flag(child, TIF_DEBUG);
539 else
540 clear_tsk_thread_flag(child, TIF_DEBUG);
Roland McGrath0f534092008-01-30 13:30:59 +0100541 break;
Roland McGrathd9771e82008-01-30 13:30:52 +0100542 }
543
Roland McGrathd9771e82008-01-30 13:30:52 +0100544 return 0;
545}
546
Ingo Molnarb4ef95d2008-02-26 09:40:27 +0100547#ifdef X86_BTS
548
Markus Metzgera95d67f2008-01-30 13:31:20 +0100549static int ptrace_bts_get_size(struct task_struct *child)
Markus Metzgereee3af42008-01-30 13:31:09 +0100550{
551 if (!child->thread.ds_area_msr)
552 return -ENXIO;
553
Markus Metzgera95d67f2008-01-30 13:31:20 +0100554 return ds_get_bts_index((void *)child->thread.ds_area_msr);
Markus Metzgereee3af42008-01-30 13:31:09 +0100555}
556
Markus Metzgereee3af42008-01-30 13:31:09 +0100557static int ptrace_bts_read_record(struct task_struct *child,
558 long index,
559 struct bts_struct __user *out)
560{
561 struct bts_struct ret;
562 int retval;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100563 int bts_end;
Markus Metzgere4811f22008-01-30 13:31:20 +0100564 int bts_index;
Markus Metzgereee3af42008-01-30 13:31:09 +0100565
566 if (!child->thread.ds_area_msr)
567 return -ENXIO;
568
Markus Metzgere4811f22008-01-30 13:31:20 +0100569 if (index < 0)
570 return -EINVAL;
571
Markus Metzgera95d67f2008-01-30 13:31:20 +0100572 bts_end = ds_get_bts_end((void *)child->thread.ds_area_msr);
573 if (bts_end <= index)
Markus Metzgere4811f22008-01-30 13:31:20 +0100574 return -EINVAL;
575
576 /* translate the ptrace bts index into the ds bts index */
577 bts_index = ds_get_bts_index((void *)child->thread.ds_area_msr);
578 bts_index -= (index + 1);
579 if (bts_index < 0)
Markus Metzgera95d67f2008-01-30 13:31:20 +0100580 bts_index += bts_end;
Markus Metzgere4811f22008-01-30 13:31:20 +0100581
Markus Metzgereee3af42008-01-30 13:31:09 +0100582 retval = ds_read_bts((void *)child->thread.ds_area_msr,
Markus Metzgere4811f22008-01-30 13:31:20 +0100583 bts_index, &ret);
Markus Metzgere6ae5d92008-01-30 13:32:03 +0100584 if (retval < 0)
Markus Metzgereee3af42008-01-30 13:31:09 +0100585 return retval;
586
587 if (copy_to_user(out, &ret, sizeof(ret)))
588 return -EFAULT;
589
590 return sizeof(ret);
591}
592
593static int ptrace_bts_write_record(struct task_struct *child,
594 const struct bts_struct *in)
595{
596 int retval;
597
598 if (!child->thread.ds_area_msr)
599 return -ENXIO;
600
601 retval = ds_write_bts((void *)child->thread.ds_area_msr, in);
602 if (retval)
603 return retval;
604
605 return sizeof(*in);
606}
607
Markus Metzgera95d67f2008-01-30 13:31:20 +0100608static int ptrace_bts_clear(struct task_struct *child)
Markus Metzgereee3af42008-01-30 13:31:09 +0100609{
Markus Metzgera95d67f2008-01-30 13:31:20 +0100610 if (!child->thread.ds_area_msr)
Markus Metzgereee3af42008-01-30 13:31:09 +0100611 return -ENXIO;
612
Markus Metzgera95d67f2008-01-30 13:31:20 +0100613 return ds_clear((void *)child->thread.ds_area_msr);
614}
615
616static int ptrace_bts_drain(struct task_struct *child,
Markus Metzgercba4b652008-01-30 13:32:03 +0100617 long size,
Markus Metzgera95d67f2008-01-30 13:31:20 +0100618 struct bts_struct __user *out)
619{
620 int end, i;
621 void *ds = (void *)child->thread.ds_area_msr;
622
623 if (!ds)
624 return -ENXIO;
625
626 end = ds_get_bts_index(ds);
627 if (end <= 0)
628 return end;
629
Markus Metzgercba4b652008-01-30 13:32:03 +0100630 if (size < (end * sizeof(struct bts_struct)))
631 return -EIO;
632
Markus Metzgera95d67f2008-01-30 13:31:20 +0100633 for (i = 0; i < end; i++, out++) {
634 struct bts_struct ret;
635 int retval;
636
637 retval = ds_read_bts(ds, i, &ret);
638 if (retval < 0)
639 return retval;
640
641 if (copy_to_user(out, &ret, sizeof(ret)))
642 return -EFAULT;
643 }
644
645 ds_clear(ds);
646
Markus Metzgercba4b652008-01-30 13:32:03 +0100647 return end;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100648}
649
Markus Metzgerda35c372008-01-30 13:32:03 +0100650static int ptrace_bts_realloc(struct task_struct *child,
651 int size, int reduce_size)
652{
653 unsigned long rlim, vm;
654 int ret, old_size;
655
656 if (size < 0)
657 return -EINVAL;
658
659 old_size = ds_get_bts_size((void *)child->thread.ds_area_msr);
660 if (old_size < 0)
661 return old_size;
662
663 ret = ds_free((void **)&child->thread.ds_area_msr);
664 if (ret < 0)
665 goto out;
666
667 size >>= PAGE_SHIFT;
668 old_size >>= PAGE_SHIFT;
669
670 current->mm->total_vm -= old_size;
671 current->mm->locked_vm -= old_size;
672
673 if (size == 0)
674 goto out;
675
676 rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
677 vm = current->mm->total_vm + size;
678 if (rlim < vm) {
679 ret = -ENOMEM;
680
681 if (!reduce_size)
682 goto out;
683
684 size = rlim - current->mm->total_vm;
685 if (size <= 0)
686 goto out;
687 }
688
689 rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
690 vm = current->mm->locked_vm + size;
691 if (rlim < vm) {
692 ret = -ENOMEM;
693
694 if (!reduce_size)
695 goto out;
696
697 size = rlim - current->mm->locked_vm;
698 if (size <= 0)
699 goto out;
700 }
701
702 ret = ds_allocate((void **)&child->thread.ds_area_msr,
703 size << PAGE_SHIFT);
704 if (ret < 0)
705 goto out;
706
707 current->mm->total_vm += size;
708 current->mm->locked_vm += size;
709
710out:
711 if (child->thread.ds_area_msr)
712 set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
713 else
714 clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);
715
716 return ret;
717}
718
Markus Metzgera95d67f2008-01-30 13:31:20 +0100719static int ptrace_bts_config(struct task_struct *child,
Markus Metzgercba4b652008-01-30 13:32:03 +0100720 long cfg_size,
Markus Metzgera95d67f2008-01-30 13:31:20 +0100721 const struct ptrace_bts_config __user *ucfg)
722{
723 struct ptrace_bts_config cfg;
Markus Metzgerda35c372008-01-30 13:32:03 +0100724 int bts_size, ret = 0;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100725 void *ds;
726
Markus Metzgercba4b652008-01-30 13:32:03 +0100727 if (cfg_size < sizeof(cfg))
728 return -EIO;
729
Markus Metzgera95d67f2008-01-30 13:31:20 +0100730 if (copy_from_user(&cfg, ucfg, sizeof(cfg)))
731 return -EFAULT;
732
Markus Metzgercba4b652008-01-30 13:32:03 +0100733 if ((int)cfg.size < 0)
734 return -EINVAL;
735
Markus Metzgera95d67f2008-01-30 13:31:20 +0100736 bts_size = 0;
737 ds = (void *)child->thread.ds_area_msr;
738 if (ds) {
739 bts_size = ds_get_bts_size(ds);
740 if (bts_size < 0)
741 return bts_size;
742 }
Markus Metzgerda35c372008-01-30 13:32:03 +0100743 cfg.size = PAGE_ALIGN(cfg.size);
Markus Metzgera95d67f2008-01-30 13:31:20 +0100744
745 if (bts_size != cfg.size) {
Markus Metzgerda35c372008-01-30 13:32:03 +0100746 ret = ptrace_bts_realloc(child, cfg.size,
747 cfg.flags & PTRACE_BTS_O_CUT_SIZE);
Markus Metzgera95d67f2008-01-30 13:31:20 +0100748 if (ret < 0)
Markus Metzgerda35c372008-01-30 13:32:03 +0100749 goto errout;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100750
Markus Metzgera95d67f2008-01-30 13:31:20 +0100751 ds = (void *)child->thread.ds_area_msr;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100752 }
753
Markus Metzgerda35c372008-01-30 13:32:03 +0100754 if (cfg.flags & PTRACE_BTS_O_SIGNAL)
755 ret = ds_set_overflow(ds, DS_O_SIGNAL);
756 else
757 ret = ds_set_overflow(ds, DS_O_WRAP);
758 if (ret < 0)
759 goto errout;
Markus Metzgera95d67f2008-01-30 13:31:20 +0100760
Markus Metzgerda35c372008-01-30 13:32:03 +0100761 if (cfg.flags & PTRACE_BTS_O_TRACE)
762 child->thread.debugctlmsr |= ds_debugctl_mask();
763 else
764 child->thread.debugctlmsr &= ~ds_debugctl_mask();
Markus Metzgereee3af42008-01-30 13:31:09 +0100765
Markus Metzgerda35c372008-01-30 13:32:03 +0100766 if (cfg.flags & PTRACE_BTS_O_SCHED)
Markus Metzgereee3af42008-01-30 13:31:09 +0100767 set_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
768 else
769 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
770
Markus Metzgercba4b652008-01-30 13:32:03 +0100771 ret = sizeof(cfg);
772
Markus Metzgerda35c372008-01-30 13:32:03 +0100773out:
774 if (child->thread.debugctlmsr)
775 set_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
776 else
777 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
778
779 return ret;
780
781errout:
782 child->thread.debugctlmsr &= ~ds_debugctl_mask();
783 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
784 goto out;
Markus Metzgereee3af42008-01-30 13:31:09 +0100785}
786
Markus Metzgera95d67f2008-01-30 13:31:20 +0100787static int ptrace_bts_status(struct task_struct *child,
Markus Metzgercba4b652008-01-30 13:32:03 +0100788 long cfg_size,
Markus Metzgera95d67f2008-01-30 13:31:20 +0100789 struct ptrace_bts_config __user *ucfg)
Markus Metzgereee3af42008-01-30 13:31:09 +0100790{
Markus Metzgera95d67f2008-01-30 13:31:20 +0100791 void *ds = (void *)child->thread.ds_area_msr;
792 struct ptrace_bts_config cfg;
Markus Metzgereee3af42008-01-30 13:31:09 +0100793
Markus Metzgercba4b652008-01-30 13:32:03 +0100794 if (cfg_size < sizeof(cfg))
795 return -EIO;
796
Markus Metzgera95d67f2008-01-30 13:31:20 +0100797 memset(&cfg, 0, sizeof(cfg));
Markus Metzgereee3af42008-01-30 13:31:09 +0100798
Markus Metzgera95d67f2008-01-30 13:31:20 +0100799 if (ds) {
800 cfg.size = ds_get_bts_size(ds);
Markus Metzgereee3af42008-01-30 13:31:09 +0100801
Markus Metzgera95d67f2008-01-30 13:31:20 +0100802 if (ds_get_overflow(ds) == DS_O_SIGNAL)
803 cfg.flags |= PTRACE_BTS_O_SIGNAL;
Markus Metzgereee3af42008-01-30 13:31:09 +0100804
Markus Metzgera95d67f2008-01-30 13:31:20 +0100805 if (test_tsk_thread_flag(child, TIF_DEBUGCTLMSR) &&
806 child->thread.debugctlmsr & ds_debugctl_mask())
807 cfg.flags |= PTRACE_BTS_O_TRACE;
Markus Metzgereee3af42008-01-30 13:31:09 +0100808
Markus Metzgera95d67f2008-01-30 13:31:20 +0100809 if (test_tsk_thread_flag(child, TIF_BTS_TRACE_TS))
810 cfg.flags |= PTRACE_BTS_O_SCHED;
Markus Metzgereee3af42008-01-30 13:31:09 +0100811 }
812
Markus Metzger87e84072008-01-30 13:32:54 +0100813 cfg.bts_size = sizeof(struct bts_struct);
814
Markus Metzgera95d67f2008-01-30 13:31:20 +0100815 if (copy_to_user(ucfg, &cfg, sizeof(cfg)))
816 return -EFAULT;
Markus Metzgereee3af42008-01-30 13:31:09 +0100817
Markus Metzgera95d67f2008-01-30 13:31:20 +0100818 return sizeof(cfg);
Markus Metzgereee3af42008-01-30 13:31:09 +0100819}
820
821void ptrace_bts_take_timestamp(struct task_struct *tsk,
822 enum bts_qualifier qualifier)
823{
824 struct bts_struct rec = {
825 .qualifier = qualifier,
Markus Metzgerda35c372008-01-30 13:32:03 +0100826 .variant.jiffies = jiffies_64
Markus Metzgereee3af42008-01-30 13:31:09 +0100827 };
828
Markus Metzgereee3af42008-01-30 13:31:09 +0100829 ptrace_bts_write_record(tsk, &rec);
830}
Ingo Molnarb4ef95d2008-02-26 09:40:27 +0100831#endif /* X86_BTS */
Markus Metzgereee3af42008-01-30 13:31:09 +0100832
Roland McGrathd9771e82008-01-30 13:30:52 +0100833/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 * Called by kernel/ptrace.c when detaching..
835 *
836 * Make sure the single step bit is not set.
837 */
838void ptrace_disable(struct task_struct *child)
Roland McGrath9e714be2008-01-30 13:30:58 +0100839{
Roland McGrath7f232342008-01-30 13:30:48 +0100840 user_disable_single_step(child);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100841#ifdef TIF_SYSCALL_EMU
Bodo Stroesserab1c23c2005-09-03 15:57:21 -0700842 clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100843#endif
Markus Metzgereee3af42008-01-30 13:31:09 +0100844 if (child->thread.ds_area_msr) {
Ingo Molnarb4ef95d2008-02-26 09:40:27 +0100845#ifdef X86_BTS
Markus Metzgerda35c372008-01-30 13:32:03 +0100846 ptrace_bts_realloc(child, 0, 0);
Ingo Molnarb4ef95d2008-02-26 09:40:27 +0100847#endif
Markus Metzgerda35c372008-01-30 13:32:03 +0100848 child->thread.debugctlmsr &= ~ds_debugctl_mask();
849 if (!child->thread.debugctlmsr)
850 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
851 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
Markus Metzgereee3af42008-01-30 13:31:09 +0100852 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853}
854
Roland McGrath5a4646a2008-01-30 13:31:54 +0100855#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
856static const struct user_regset_view user_x86_32_view; /* Initialized below. */
857#endif
858
Christoph Hellwig481bed42005-11-07 00:59:47 -0800859long arch_ptrace(struct task_struct *child, long request, long addr, long data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860{
Roland McGrath5a4646a2008-01-30 13:31:54 +0100861 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 unsigned long __user *datap = (unsigned long __user *)data;
863
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 switch (request) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 /* read the word at location addr in the USER area. */
866 case PTRACE_PEEKUSR: {
867 unsigned long tmp;
868
869 ret = -EIO;
Roland McGrathe9c86c72008-01-30 13:31:01 +0100870 if ((addr & (sizeof(data) - 1)) || addr < 0 ||
871 addr >= sizeof(struct user))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 break;
873
874 tmp = 0; /* Default return condition */
Roland McGrathe9c86c72008-01-30 13:31:01 +0100875 if (addr < sizeof(struct user_regs_struct))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 tmp = getreg(child, addr);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100877 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
878 addr <= offsetof(struct user, u_debugreg[7])) {
879 addr -= offsetof(struct user, u_debugreg[0]);
880 tmp = ptrace_get_debugreg(child, addr / sizeof(data));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 }
882 ret = put_user(tmp, datap);
883 break;
884 }
885
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
887 ret = -EIO;
Roland McGrathe9c86c72008-01-30 13:31:01 +0100888 if ((addr & (sizeof(data) - 1)) || addr < 0 ||
889 addr >= sizeof(struct user))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 break;
891
Roland McGrathe9c86c72008-01-30 13:31:01 +0100892 if (addr < sizeof(struct user_regs_struct))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 ret = putreg(child, addr, data);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100894 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
895 addr <= offsetof(struct user, u_debugreg[7])) {
896 addr -= offsetof(struct user, u_debugreg[0]);
897 ret = ptrace_set_debugreg(child,
898 addr / sizeof(data), data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 }
Roland McGrathe9c86c72008-01-30 13:31:01 +0100900 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901
Roland McGrath5a4646a2008-01-30 13:31:54 +0100902 case PTRACE_GETREGS: /* Get all gp regs from the child. */
903 return copy_regset_to_user(child,
904 task_user_regset_view(current),
905 REGSET_GENERAL,
906 0, sizeof(struct user_regs_struct),
907 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908
Roland McGrath5a4646a2008-01-30 13:31:54 +0100909 case PTRACE_SETREGS: /* Set all gp regs in the child. */
910 return copy_regset_from_user(child,
911 task_user_regset_view(current),
912 REGSET_GENERAL,
913 0, sizeof(struct user_regs_struct),
914 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915
Roland McGrath5a4646a2008-01-30 13:31:54 +0100916 case PTRACE_GETFPREGS: /* Get the child FPU state. */
917 return copy_regset_to_user(child,
918 task_user_regset_view(current),
919 REGSET_FP,
920 0, sizeof(struct user_i387_struct),
921 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922
Roland McGrath5a4646a2008-01-30 13:31:54 +0100923 case PTRACE_SETFPREGS: /* Set the child FPU state. */
924 return copy_regset_from_user(child,
925 task_user_regset_view(current),
926 REGSET_FP,
927 0, sizeof(struct user_i387_struct),
928 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929
Roland McGrathe9c86c72008-01-30 13:31:01 +0100930#ifdef CONFIG_X86_32
Roland McGrath5a4646a2008-01-30 13:31:54 +0100931 case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
932 return copy_regset_to_user(child, &user_x86_32_view,
933 REGSET_XFP,
934 0, sizeof(struct user_fxsr_struct),
935 datap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936
Roland McGrath5a4646a2008-01-30 13:31:54 +0100937 case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
938 return copy_regset_from_user(child, &user_x86_32_view,
939 REGSET_XFP,
940 0, sizeof(struct user_fxsr_struct),
941 datap);
Roland McGrathe9c86c72008-01-30 13:31:01 +0100942#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943
Roland McGrathe9c86c72008-01-30 13:31:01 +0100944#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 case PTRACE_GET_THREAD_AREA:
Roland McGrathefd1ca52008-01-30 13:30:46 +0100946 if (addr < 0)
947 return -EIO;
948 ret = do_get_thread_area(child, addr,
949 (struct user_desc __user *) data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 break;
951
952 case PTRACE_SET_THREAD_AREA:
Roland McGrathefd1ca52008-01-30 13:30:46 +0100953 if (addr < 0)
954 return -EIO;
955 ret = do_set_thread_area(child, addr,
956 (struct user_desc __user *) data, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 break;
Roland McGrathe9c86c72008-01-30 13:31:01 +0100958#endif
959
960#ifdef CONFIG_X86_64
961 /* normal 64bit interface to access TLS data.
962 Works just like arch_prctl, except that the arguments
963 are reversed. */
964 case PTRACE_ARCH_PRCTL:
965 ret = do_arch_prctl(child, data, addr);
966 break;
967#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968
Ingo Molnarb4ef95d2008-02-26 09:40:27 +0100969 /*
970 * These bits need more cooking - not enabled yet:
971 */
972#ifdef X86_BTS
Markus Metzgereee3af42008-01-30 13:31:09 +0100973 case PTRACE_BTS_CONFIG:
Markus Metzgera95d67f2008-01-30 13:31:20 +0100974 ret = ptrace_bts_config
Markus Metzgercba4b652008-01-30 13:32:03 +0100975 (child, data, (struct ptrace_bts_config __user *)addr);
Markus Metzgereee3af42008-01-30 13:31:09 +0100976 break;
977
978 case PTRACE_BTS_STATUS:
Markus Metzgera95d67f2008-01-30 13:31:20 +0100979 ret = ptrace_bts_status
Markus Metzgercba4b652008-01-30 13:32:03 +0100980 (child, data, (struct ptrace_bts_config __user *)addr);
Markus Metzgera95d67f2008-01-30 13:31:20 +0100981 break;
982
983 case PTRACE_BTS_SIZE:
984 ret = ptrace_bts_get_size(child);
985 break;
986
987 case PTRACE_BTS_GET:
988 ret = ptrace_bts_read_record
989 (child, data, (struct bts_struct __user *) addr);
990 break;
991
992 case PTRACE_BTS_CLEAR:
993 ret = ptrace_bts_clear(child);
994 break;
995
996 case PTRACE_BTS_DRAIN:
997 ret = ptrace_bts_drain
Markus Metzgercba4b652008-01-30 13:32:03 +0100998 (child, data, (struct bts_struct __user *) addr);
Markus Metzgereee3af42008-01-30 13:31:09 +0100999 break;
Ingo Molnarb4ef95d2008-02-26 09:40:27 +01001000#endif
Markus Metzgereee3af42008-01-30 13:31:09 +01001001
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 default:
1003 ret = ptrace_request(child, request, addr, data);
1004 break;
1005 }
Roland McGrathd9771e82008-01-30 13:30:52 +01001006
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007 return ret;
1008}
1009
Roland McGrathcb757c42008-01-30 13:31:01 +01001010#ifdef CONFIG_IA32_EMULATION
1011
Roland McGrath099cd6e2008-01-30 13:31:01 +01001012#include <linux/compat.h>
1013#include <linux/syscalls.h>
1014#include <asm/ia32.h>
Roland McGrathcb757c42008-01-30 13:31:01 +01001015#include <asm/user32.h>
1016
1017#define R32(l,q) \
1018 case offsetof(struct user32, regs.l): \
1019 regs->q = value; break
1020
1021#define SEG32(rs) \
1022 case offsetof(struct user32, regs.rs): \
1023 return set_segment_reg(child, \
1024 offsetof(struct user_regs_struct, rs), \
1025 value); \
1026 break
1027
1028static int putreg32(struct task_struct *child, unsigned regno, u32 value)
1029{
1030 struct pt_regs *regs = task_pt_regs(child);
1031
1032 switch (regno) {
1033
1034 SEG32(cs);
1035 SEG32(ds);
1036 SEG32(es);
1037 SEG32(fs);
1038 SEG32(gs);
1039 SEG32(ss);
1040
1041 R32(ebx, bx);
1042 R32(ecx, cx);
1043 R32(edx, dx);
1044 R32(edi, di);
1045 R32(esi, si);
1046 R32(ebp, bp);
1047 R32(eax, ax);
1048 R32(orig_eax, orig_ax);
1049 R32(eip, ip);
1050 R32(esp, sp);
1051
1052 case offsetof(struct user32, regs.eflags):
1053 return set_flags(child, value);
1054
1055 case offsetof(struct user32, u_debugreg[0]) ...
1056 offsetof(struct user32, u_debugreg[7]):
1057 regno -= offsetof(struct user32, u_debugreg[0]);
1058 return ptrace_set_debugreg(child, regno / 4, value);
1059
1060 default:
1061 if (regno > sizeof(struct user32) || (regno & 3))
1062 return -EIO;
1063
1064 /*
1065 * Other dummy fields in the virtual user structure
1066 * are ignored
1067 */
1068 break;
1069 }
1070 return 0;
1071}
1072
1073#undef R32
1074#undef SEG32
1075
1076#define R32(l,q) \
1077 case offsetof(struct user32, regs.l): \
1078 *val = regs->q; break
1079
1080#define SEG32(rs) \
1081 case offsetof(struct user32, regs.rs): \
1082 *val = get_segment_reg(child, \
1083 offsetof(struct user_regs_struct, rs)); \
1084 break
1085
1086static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
1087{
1088 struct pt_regs *regs = task_pt_regs(child);
1089
1090 switch (regno) {
1091
1092 SEG32(ds);
1093 SEG32(es);
1094 SEG32(fs);
1095 SEG32(gs);
1096
1097 R32(cs, cs);
1098 R32(ss, ss);
1099 R32(ebx, bx);
1100 R32(ecx, cx);
1101 R32(edx, dx);
1102 R32(edi, di);
1103 R32(esi, si);
1104 R32(ebp, bp);
1105 R32(eax, ax);
1106 R32(orig_eax, orig_ax);
1107 R32(eip, ip);
1108 R32(esp, sp);
1109
1110 case offsetof(struct user32, regs.eflags):
1111 *val = get_flags(child);
1112 break;
1113
1114 case offsetof(struct user32, u_debugreg[0]) ...
1115 offsetof(struct user32, u_debugreg[7]):
1116 regno -= offsetof(struct user32, u_debugreg[0]);
1117 *val = ptrace_get_debugreg(child, regno / 4);
1118 break;
1119
1120 default:
1121 if (regno > sizeof(struct user32) || (regno & 3))
1122 return -EIO;
1123
1124 /*
1125 * Other dummy fields in the virtual user structure
1126 * are ignored
1127 */
1128 *val = 0;
1129 break;
1130 }
1131 return 0;
1132}
1133
1134#undef R32
1135#undef SEG32
1136
Roland McGrath91e7b702008-01-30 13:31:52 +01001137static int genregs32_get(struct task_struct *target,
1138 const struct user_regset *regset,
1139 unsigned int pos, unsigned int count,
1140 void *kbuf, void __user *ubuf)
1141{
1142 if (kbuf) {
1143 compat_ulong_t *k = kbuf;
1144 while (count > 0) {
1145 getreg32(target, pos, k++);
1146 count -= sizeof(*k);
1147 pos += sizeof(*k);
1148 }
1149 } else {
1150 compat_ulong_t __user *u = ubuf;
1151 while (count > 0) {
1152 compat_ulong_t word;
1153 getreg32(target, pos, &word);
1154 if (__put_user(word, u++))
1155 return -EFAULT;
1156 count -= sizeof(*u);
1157 pos += sizeof(*u);
1158 }
1159 }
1160
1161 return 0;
1162}
1163
1164static int genregs32_set(struct task_struct *target,
1165 const struct user_regset *regset,
1166 unsigned int pos, unsigned int count,
1167 const void *kbuf, const void __user *ubuf)
1168{
1169 int ret = 0;
1170 if (kbuf) {
1171 const compat_ulong_t *k = kbuf;
1172 while (count > 0 && !ret) {
Roland McGrathf9cb02b2008-02-21 20:37:24 -08001173 ret = putreg32(target, pos, *k++);
Roland McGrath91e7b702008-01-30 13:31:52 +01001174 count -= sizeof(*k);
1175 pos += sizeof(*k);
1176 }
1177 } else {
1178 const compat_ulong_t __user *u = ubuf;
1179 while (count > 0 && !ret) {
1180 compat_ulong_t word;
1181 ret = __get_user(word, u++);
1182 if (ret)
1183 break;
Roland McGrathf9cb02b2008-02-21 20:37:24 -08001184 ret = putreg32(target, pos, word);
Roland McGrath91e7b702008-01-30 13:31:52 +01001185 count -= sizeof(*u);
1186 pos += sizeof(*u);
1187 }
1188 }
1189 return ret;
1190}
1191
Roland McGrath099cd6e2008-01-30 13:31:01 +01001192static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
1193{
1194 siginfo_t __user *si = compat_alloc_user_space(sizeof(siginfo_t));
1195 compat_siginfo_t __user *si32 = compat_ptr(data);
1196 siginfo_t ssi;
1197 int ret;
1198
1199 if (request == PTRACE_SETSIGINFO) {
1200 memset(&ssi, 0, sizeof(siginfo_t));
1201 ret = copy_siginfo_from_user32(&ssi, si32);
1202 if (ret)
1203 return ret;
1204 if (copy_to_user(si, &ssi, sizeof(siginfo_t)))
1205 return -EFAULT;
1206 }
1207 ret = sys_ptrace(request, pid, addr, (unsigned long)si);
1208 if (ret)
1209 return ret;
1210 if (request == PTRACE_GETSIGINFO) {
1211 if (copy_from_user(&ssi, si, sizeof(siginfo_t)))
1212 return -EFAULT;
1213 ret = copy_siginfo_to_user32(si32, &ssi);
1214 }
1215 return ret;
1216}
1217
1218asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
1219{
1220 struct task_struct *child;
1221 struct pt_regs *childregs;
1222 void __user *datap = compat_ptr(data);
1223 int ret;
1224 __u32 val;
1225
1226 switch (request) {
1227 case PTRACE_TRACEME:
1228 case PTRACE_ATTACH:
1229 case PTRACE_KILL:
1230 case PTRACE_CONT:
1231 case PTRACE_SINGLESTEP:
1232 case PTRACE_SINGLEBLOCK:
1233 case PTRACE_DETACH:
1234 case PTRACE_SYSCALL:
1235 case PTRACE_OLDSETOPTIONS:
1236 case PTRACE_SETOPTIONS:
1237 case PTRACE_SET_THREAD_AREA:
1238 case PTRACE_GET_THREAD_AREA:
Ingo Molnarb4ef95d2008-02-26 09:40:27 +01001239#ifdef X86_BTS
Markus Metzgereee3af42008-01-30 13:31:09 +01001240 case PTRACE_BTS_CONFIG:
1241 case PTRACE_BTS_STATUS:
Markus Metzgera95d67f2008-01-30 13:31:20 +01001242 case PTRACE_BTS_SIZE:
1243 case PTRACE_BTS_GET:
1244 case PTRACE_BTS_CLEAR:
1245 case PTRACE_BTS_DRAIN:
Ingo Molnarb4ef95d2008-02-26 09:40:27 +01001246#endif
Roland McGrath099cd6e2008-01-30 13:31:01 +01001247 return sys_ptrace(request, pid, addr, data);
1248
1249 default:
1250 return -EINVAL;
1251
1252 case PTRACE_PEEKTEXT:
1253 case PTRACE_PEEKDATA:
1254 case PTRACE_POKEDATA:
1255 case PTRACE_POKETEXT:
1256 case PTRACE_POKEUSR:
1257 case PTRACE_PEEKUSR:
1258 case PTRACE_GETREGS:
1259 case PTRACE_SETREGS:
1260 case PTRACE_SETFPREGS:
1261 case PTRACE_GETFPREGS:
1262 case PTRACE_SETFPXREGS:
1263 case PTRACE_GETFPXREGS:
1264 case PTRACE_GETEVENTMSG:
1265 break;
1266
1267 case PTRACE_SETSIGINFO:
1268 case PTRACE_GETSIGINFO:
1269 return ptrace32_siginfo(request, pid, addr, data);
1270 }
1271
1272 child = ptrace_get_task_struct(pid);
1273 if (IS_ERR(child))
1274 return PTR_ERR(child);
1275
1276 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1277 if (ret < 0)
1278 goto out;
1279
1280 childregs = task_pt_regs(child);
1281
1282 switch (request) {
Roland McGrath099cd6e2008-01-30 13:31:01 +01001283 case PTRACE_PEEKUSR:
1284 ret = getreg32(child, addr, &val);
1285 if (ret == 0)
1286 ret = put_user(val, (__u32 __user *)datap);
1287 break;
1288
1289 case PTRACE_POKEUSR:
1290 ret = putreg32(child, addr, data);
1291 break;
1292
Roland McGrath5a4646a2008-01-30 13:31:54 +01001293 case PTRACE_GETREGS: /* Get all gp regs from the child. */
1294 return copy_regset_to_user(child, &user_x86_32_view,
1295 REGSET_GENERAL,
1296 0, sizeof(struct user_regs_struct32),
1297 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001298
Roland McGrath5a4646a2008-01-30 13:31:54 +01001299 case PTRACE_SETREGS: /* Set all gp regs in the child. */
1300 return copy_regset_from_user(child, &user_x86_32_view,
1301 REGSET_GENERAL, 0,
1302 sizeof(struct user_regs_struct32),
1303 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001304
Roland McGrath5a4646a2008-01-30 13:31:54 +01001305 case PTRACE_GETFPREGS: /* Get the child FPU state. */
1306 return copy_regset_to_user(child, &user_x86_32_view,
1307 REGSET_FP, 0,
1308 sizeof(struct user_i387_ia32_struct),
1309 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001310
Roland McGrath5a4646a2008-01-30 13:31:54 +01001311 case PTRACE_SETFPREGS: /* Set the child FPU state. */
1312 return copy_regset_from_user(
1313 child, &user_x86_32_view, REGSET_FP,
1314 0, sizeof(struct user_i387_ia32_struct), datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001315
Roland McGrath5a4646a2008-01-30 13:31:54 +01001316 case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
1317 return copy_regset_to_user(child, &user_x86_32_view,
1318 REGSET_XFP, 0,
1319 sizeof(struct user32_fxsr_struct),
1320 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001321
Roland McGrath5a4646a2008-01-30 13:31:54 +01001322 case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
1323 return copy_regset_from_user(child, &user_x86_32_view,
1324 REGSET_XFP, 0,
1325 sizeof(struct user32_fxsr_struct),
1326 datap);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001327
Roland McGrath099cd6e2008-01-30 13:31:01 +01001328 default:
Roland McGrathfdadd542008-01-30 13:31:56 +01001329 return compat_ptrace_request(child, request, addr, data);
Roland McGrath099cd6e2008-01-30 13:31:01 +01001330 }
1331
1332 out:
1333 put_task_struct(child);
1334 return ret;
1335}
1336
Roland McGrathcb757c42008-01-30 13:31:01 +01001337#endif /* CONFIG_IA32_EMULATION */
1338
Roland McGrath070459d2008-01-30 13:31:53 +01001339#ifdef CONFIG_X86_64
1340
1341static const struct user_regset x86_64_regsets[] = {
1342 [REGSET_GENERAL] = {
1343 .core_note_type = NT_PRSTATUS,
1344 .n = sizeof(struct user_regs_struct) / sizeof(long),
1345 .size = sizeof(long), .align = sizeof(long),
1346 .get = genregs_get, .set = genregs_set
1347 },
1348 [REGSET_FP] = {
1349 .core_note_type = NT_PRFPREG,
1350 .n = sizeof(struct user_i387_struct) / sizeof(long),
1351 .size = sizeof(long), .align = sizeof(long),
1352 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
1353 },
1354};
1355
1356static const struct user_regset_view user_x86_64_view = {
1357 .name = "x86_64", .e_machine = EM_X86_64,
1358 .regsets = x86_64_regsets, .n = ARRAY_SIZE(x86_64_regsets)
1359};
1360
1361#else /* CONFIG_X86_32 */
1362
1363#define user_regs_struct32 user_regs_struct
1364#define genregs32_get genregs_get
1365#define genregs32_set genregs_set
1366
1367#endif /* CONFIG_X86_64 */
1368
1369#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1370static const struct user_regset x86_32_regsets[] = {
1371 [REGSET_GENERAL] = {
1372 .core_note_type = NT_PRSTATUS,
1373 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
1374 .size = sizeof(u32), .align = sizeof(u32),
1375 .get = genregs32_get, .set = genregs32_set
1376 },
1377 [REGSET_FP] = {
1378 .core_note_type = NT_PRFPREG,
1379 .n = sizeof(struct user_i387_struct) / sizeof(u32),
1380 .size = sizeof(u32), .align = sizeof(u32),
1381 .active = fpregs_active, .get = fpregs_get, .set = fpregs_set
1382 },
1383 [REGSET_XFP] = {
1384 .core_note_type = NT_PRXFPREG,
1385 .n = sizeof(struct user_i387_struct) / sizeof(u32),
1386 .size = sizeof(u32), .align = sizeof(u32),
1387 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
1388 },
1389 [REGSET_TLS] = {
Roland McGrathbb616822008-01-30 13:31:56 +01001390 .core_note_type = NT_386_TLS,
Roland McGrath070459d2008-01-30 13:31:53 +01001391 .n = GDT_ENTRY_TLS_ENTRIES, .bias = GDT_ENTRY_TLS_MIN,
1392 .size = sizeof(struct user_desc),
1393 .align = sizeof(struct user_desc),
1394 .active = regset_tls_active,
1395 .get = regset_tls_get, .set = regset_tls_set
1396 },
1397};
1398
1399static const struct user_regset_view user_x86_32_view = {
1400 .name = "i386", .e_machine = EM_386,
1401 .regsets = x86_32_regsets, .n = ARRAY_SIZE(x86_32_regsets)
1402};
1403#endif
1404
1405const struct user_regset_view *task_user_regset_view(struct task_struct *task)
1406{
1407#ifdef CONFIG_IA32_EMULATION
1408 if (test_tsk_thread_flag(task, TIF_IA32))
1409#endif
1410#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1411 return &user_x86_32_view;
1412#endif
1413#ifdef CONFIG_X86_64
1414 return &user_x86_64_view;
1415#endif
1416}
1417
Roland McGrath86976cd2008-01-30 13:31:01 +01001418#ifdef CONFIG_X86_32
1419
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
1421{
1422 struct siginfo info;
1423
1424 tsk->thread.trap_no = 1;
1425 tsk->thread.error_code = error_code;
1426
1427 memset(&info, 0, sizeof(info));
1428 info.si_signo = SIGTRAP;
1429 info.si_code = TRAP_BRKPT;
1430
H. Peter Anvin65ea5b02008-01-30 13:30:56 +01001431 /* User-mode ip? */
1432 info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433
Simon Arlott27b46d72007-10-20 01:13:56 +02001434 /* Send us the fake SIGTRAP */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 force_sig_info(SIGTRAP, &info, tsk);
1436}
1437
1438/* notification of system call entry/exit
1439 * - triggered by current->work.syscall_trace
1440 */
1441__attribute__((regparm(3)))
Laurent Viviered75e8d2005-09-03 15:57:18 -07001442int do_syscall_trace(struct pt_regs *regs, int entryexit)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443{
Andrea Arcangeli4c7fc722005-09-09 13:01:51 -07001444 int is_sysemu = test_thread_flag(TIF_SYSCALL_EMU);
1445 /*
1446 * With TIF_SYSCALL_EMU set we want to ignore TIF_SINGLESTEP for syscall
1447 * interception
1448 */
Bodo Stroesser1b38f002005-09-03 15:57:20 -07001449 int is_singlestep = !is_sysemu && test_thread_flag(TIF_SINGLESTEP);
Andrea Arcangeli4c7fc722005-09-09 13:01:51 -07001450 int ret = 0;
Bodo Stroesser1b38f002005-09-03 15:57:20 -07001451
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 /* do the secure computing check first */
Andrea Arcangeli4c7fc722005-09-09 13:01:51 -07001453 if (!entryexit)
H. Peter Anvin65ea5b02008-01-30 13:30:56 +01001454 secure_computing(regs->orig_ax);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455
Bodo Stroesserab1c23c2005-09-03 15:57:21 -07001456 if (unlikely(current->audit_context)) {
1457 if (entryexit)
H. Peter Anvin65ea5b02008-01-30 13:30:56 +01001458 audit_syscall_exit(AUDITSC_RESULT(regs->ax),
1459 regs->ax);
Bodo Stroesserab1c23c2005-09-03 15:57:21 -07001460 /* Debug traps, when using PTRACE_SINGLESTEP, must be sent only
1461 * on the syscall exit path. Normally, when TIF_SYSCALL_AUDIT is
1462 * not used, entry.S will call us only on syscall exit, not
1463 * entry; so when TIF_SYSCALL_AUDIT is used we must avoid
1464 * calling send_sigtrap() on syscall entry.
1465 *
1466 * Note that when PTRACE_SYSEMU_SINGLESTEP is used,
1467 * is_singlestep is false, despite his name, so we will still do
1468 * the correct thing.
1469 */
1470 else if (is_singlestep)
1471 goto out;
1472 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473
1474 if (!(current->ptrace & PT_PTRACED))
2fd6f582005-04-29 16:08:28 +01001475 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476
Bodo Stroesser1b38f002005-09-03 15:57:20 -07001477 /* If a process stops on the 1st tracepoint with SYSCALL_TRACE
1478 * and then is resumed with SYSEMU_SINGLESTEP, it will come in
1479 * here. We have to check this and return */
1480 if (is_sysemu && entryexit)
1481 return 0;
Laurent Viviered75e8d2005-09-03 15:57:18 -07001482
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 /* Fake a debug trap */
Bodo Stroesserc8c86ce2005-09-03 15:57:19 -07001484 if (is_singlestep)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 send_sigtrap(current, regs, 0);
1486
Bodo Stroesserc8c86ce2005-09-03 15:57:19 -07001487 if (!test_thread_flag(TIF_SYSCALL_TRACE) && !is_sysemu)
2fd6f582005-04-29 16:08:28 +01001488 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489
1490 /* the 0x80 provides a way for the tracing parent to distinguish
1491 between a syscall stop and SIGTRAP delivery */
Laurent Viviered75e8d2005-09-03 15:57:18 -07001492 /* Note that the debugger could change the result of test_thread_flag!*/
Andrea Arcangeli4c7fc722005-09-09 13:01:51 -07001493 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80:0));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494
1495 /*
1496 * this isn't the same as continuing with a signal, but it will do
1497 * for normal use. strace only continues with a signal if the
1498 * stopping signal is not SIGTRAP. -brl
1499 */
1500 if (current->exit_code) {
1501 send_sig(current->exit_code, current, 1);
1502 current->exit_code = 0;
1503 }
Laurent Viviered75e8d2005-09-03 15:57:18 -07001504 ret = is_sysemu;
Andrea Arcangeli4c7fc722005-09-09 13:01:51 -07001505out:
2fd6f582005-04-29 16:08:28 +01001506 if (unlikely(current->audit_context) && !entryexit)
H. Peter Anvin65ea5b02008-01-30 13:30:56 +01001507 audit_syscall_entry(AUDIT_ARCH_I386, regs->orig_ax,
1508 regs->bx, regs->cx, regs->dx, regs->si);
Bodo Stroesserc8c86ce2005-09-03 15:57:19 -07001509 if (ret == 0)
1510 return 0;
1511
H. Peter Anvin65ea5b02008-01-30 13:30:56 +01001512 regs->orig_ax = -1; /* force skip of syscall restarting */
Bodo Stroesserc8c86ce2005-09-03 15:57:19 -07001513 if (unlikely(current->audit_context))
H. Peter Anvin65ea5b02008-01-30 13:30:56 +01001514 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
Bodo Stroesserc8c86ce2005-09-03 15:57:19 -07001515 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516}
Roland McGrath86976cd2008-01-30 13:31:01 +01001517
1518#else /* CONFIG_X86_64 */
1519
1520static void syscall_trace(struct pt_regs *regs)
1521{
1522
1523#if 0
1524 printk("trace %s ip %lx sp %lx ax %d origrax %d caller %lx tiflags %x ptrace %x\n",
1525 current->comm,
1526 regs->ip, regs->sp, regs->ax, regs->orig_ax, __builtin_return_address(0),
1527 current_thread_info()->flags, current->ptrace);
1528#endif
1529
1530 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1531 ? 0x80 : 0));
1532 /*
1533 * this isn't the same as continuing with a signal, but it will do
1534 * for normal use. strace only continues with a signal if the
1535 * stopping signal is not SIGTRAP. -brl
1536 */
1537 if (current->exit_code) {
1538 send_sig(current->exit_code, current, 1);
1539 current->exit_code = 0;
1540 }
1541}
1542
1543asmlinkage void syscall_trace_enter(struct pt_regs *regs)
1544{
1545 /* do the secure computing check first */
1546 secure_computing(regs->orig_ax);
1547
1548 if (test_thread_flag(TIF_SYSCALL_TRACE)
1549 && (current->ptrace & PT_PTRACED))
1550 syscall_trace(regs);
1551
1552 if (unlikely(current->audit_context)) {
1553 if (test_thread_flag(TIF_IA32)) {
1554 audit_syscall_entry(AUDIT_ARCH_I386,
1555 regs->orig_ax,
1556 regs->bx, regs->cx,
1557 regs->dx, regs->si);
1558 } else {
1559 audit_syscall_entry(AUDIT_ARCH_X86_64,
1560 regs->orig_ax,
1561 regs->di, regs->si,
1562 regs->dx, regs->r10);
1563 }
1564 }
1565}
1566
1567asmlinkage void syscall_trace_leave(struct pt_regs *regs)
1568{
1569 if (unlikely(current->audit_context))
1570 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
1571
1572 if ((test_thread_flag(TIF_SYSCALL_TRACE)
1573 || test_thread_flag(TIF_SINGLESTEP))
1574 && (current->ptrace & PT_PTRACED))
1575 syscall_trace(regs);
1576}
1577
1578#endif /* CONFIG_X86_32 */