Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / ia64 / kernel / ptrace.c
blob43c0b77040b01c830baf8c93bc117e13bd2fe460
1 /*
2 * Kernel support for the ptrace() and syscall tracing interfaces.
4 * Copyright (C) 1999-2005 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com>
7 * Derived from the x86 and Alpha versions.
8 */
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <linux/slab.h>
12 #include <linux/mm.h>
13 #include <linux/errno.h>
14 #include <linux/ptrace.h>
15 #include <linux/smp_lock.h>
16 #include <linux/user.h>
17 #include <linux/security.h>
18 #include <linux/audit.h>
19 #include <linux/signal.h>
21 #include <asm/pgtable.h>
22 #include <asm/processor.h>
23 #include <asm/ptrace_offsets.h>
24 #include <asm/rse.h>
25 #include <asm/system.h>
26 #include <asm/uaccess.h>
27 #include <asm/unwind.h>
28 #ifdef CONFIG_PERFMON
29 #include <asm/perfmon.h>
30 #endif
32 #include "entry.h"
35 * Bits in the PSR that we allow ptrace() to change:
36 * be, up, ac, mfl, mfh (the user mask; five bits total)
37 * db (debug breakpoint fault; one bit)
38 * id (instruction debug fault disable; one bit)
39 * dd (data debug fault disable; one bit)
40 * ri (restart instruction; two bits)
41 * is (instruction set; one bit)
43 #define IPSR_MASK (IA64_PSR_UM | IA64_PSR_DB | IA64_PSR_IS \
44 | IA64_PSR_ID | IA64_PSR_DD | IA64_PSR_RI)
46 #define MASK(nbits) ((1UL << (nbits)) - 1) /* mask with NBITS bits set */
47 #define PFM_MASK MASK(38)
49 #define PTRACE_DEBUG 0
51 #if PTRACE_DEBUG
52 # define dprintk(format...) printk(format)
53 # define inline
54 #else
55 # define dprintk(format...)
56 #endif
58 /* Return TRUE if PT was created due to kernel-entry via a system-call. */
60 static inline int
61 in_syscall (struct pt_regs *pt)
63 return (long) pt->cr_ifs >= 0;
67 * Collect the NaT bits for r1-r31 from scratch_unat and return a NaT
68 * bitset where bit i is set iff the NaT bit of register i is set.
70 unsigned long
71 ia64_get_scratch_nat_bits (struct pt_regs *pt, unsigned long scratch_unat)
73 # define GET_BITS(first, last, unat) \
74 ({ \
75 unsigned long bit = ia64_unat_pos(&pt->r##first); \
76 unsigned long nbits = (last - first + 1); \
77 unsigned long mask = MASK(nbits) << first; \
78 unsigned long dist; \
79 if (bit < first) \
80 dist = 64 + bit - first; \
81 else \
82 dist = bit - first; \
83 ia64_rotr(unat, dist) & mask; \
85 unsigned long val;
88 * Registers that are stored consecutively in struct pt_regs
89 * can be handled in parallel. If the register order in
90 * struct_pt_regs changes, this code MUST be updated.
92 val = GET_BITS( 1, 1, scratch_unat);
93 val |= GET_BITS( 2, 3, scratch_unat);
94 val |= GET_BITS(12, 13, scratch_unat);
95 val |= GET_BITS(14, 14, scratch_unat);
96 val |= GET_BITS(15, 15, scratch_unat);
97 val |= GET_BITS( 8, 11, scratch_unat);
98 val |= GET_BITS(16, 31, scratch_unat);
99 return val;
101 # undef GET_BITS
105 * Set the NaT bits for the scratch registers according to NAT and
106 * return the resulting unat (assuming the scratch registers are
107 * stored in PT).
109 unsigned long
110 ia64_put_scratch_nat_bits (struct pt_regs *pt, unsigned long nat)
112 # define PUT_BITS(first, last, nat) \
113 ({ \
114 unsigned long bit = ia64_unat_pos(&pt->r##first); \
115 unsigned long nbits = (last - first + 1); \
116 unsigned long mask = MASK(nbits) << first; \
117 long dist; \
118 if (bit < first) \
119 dist = 64 + bit - first; \
120 else \
121 dist = bit - first; \
122 ia64_rotl(nat & mask, dist); \
124 unsigned long scratch_unat;
127 * Registers that are stored consecutively in struct pt_regs
128 * can be handled in parallel. If the register order in
129 * struct_pt_regs changes, this code MUST be updated.
131 scratch_unat = PUT_BITS( 1, 1, nat);
132 scratch_unat |= PUT_BITS( 2, 3, nat);
133 scratch_unat |= PUT_BITS(12, 13, nat);
134 scratch_unat |= PUT_BITS(14, 14, nat);
135 scratch_unat |= PUT_BITS(15, 15, nat);
136 scratch_unat |= PUT_BITS( 8, 11, nat);
137 scratch_unat |= PUT_BITS(16, 31, nat);
139 return scratch_unat;
141 # undef PUT_BITS
144 #define IA64_MLX_TEMPLATE 0x2
145 #define IA64_MOVL_OPCODE 6
147 void
148 ia64_increment_ip (struct pt_regs *regs)
150 unsigned long w0, ri = ia64_psr(regs)->ri + 1;
152 if (ri > 2) {
153 ri = 0;
154 regs->cr_iip += 16;
155 } else if (ri == 2) {
156 get_user(w0, (char __user *) regs->cr_iip + 0);
157 if (((w0 >> 1) & 0xf) == IA64_MLX_TEMPLATE) {
159 * rfi'ing to slot 2 of an MLX bundle causes
160 * an illegal operation fault. We don't want
161 * that to happen...
163 ri = 0;
164 regs->cr_iip += 16;
167 ia64_psr(regs)->ri = ri;
170 void
171 ia64_decrement_ip (struct pt_regs *regs)
173 unsigned long w0, ri = ia64_psr(regs)->ri - 1;
175 if (ia64_psr(regs)->ri == 0) {
176 regs->cr_iip -= 16;
177 ri = 2;
178 get_user(w0, (char __user *) regs->cr_iip + 0);
179 if (((w0 >> 1) & 0xf) == IA64_MLX_TEMPLATE) {
181 * rfi'ing to slot 2 of an MLX bundle causes
182 * an illegal operation fault. We don't want
183 * that to happen...
185 ri = 1;
188 ia64_psr(regs)->ri = ri;
192 * This routine is used to read an rnat bits that are stored on the
193 * kernel backing store. Since, in general, the alignment of the user
194 * and kernel are different, this is not completely trivial. In
195 * essence, we need to construct the user RNAT based on up to two
196 * kernel RNAT values and/or the RNAT value saved in the child's
197 * pt_regs.
199 * user rbs
201 * +--------+ <-- lowest address
202 * | slot62 |
203 * +--------+
204 * | rnat | 0x....1f8
205 * +--------+
206 * | slot00 | \
207 * +--------+ |
208 * | slot01 | > child_regs->ar_rnat
209 * +--------+ |
210 * | slot02 | / kernel rbs
211 * +--------+ +--------+
212 * <- child_regs->ar_bspstore | slot61 | <-- krbs
213 * +- - - - + +--------+
214 * | slot62 |
215 * +- - - - + +--------+
216 * | rnat |
217 * +- - - - + +--------+
218 * vrnat | slot00 |
219 * +- - - - + +--------+
220 * = =
221 * +--------+
222 * | slot00 | \
223 * +--------+ |
224 * | slot01 | > child_stack->ar_rnat
225 * +--------+ |
226 * | slot02 | /
227 * +--------+
228 * <--- child_stack->ar_bspstore
230 * The way to think of this code is as follows: bit 0 in the user rnat
231 * corresponds to some bit N (0 <= N <= 62) in one of the kernel rnat
232 * value. The kernel rnat value holding this bit is stored in
233 * variable rnat0. rnat1 is loaded with the kernel rnat value that
234 * form the upper bits of the user rnat value.
236 * Boundary cases:
238 * o when reading the rnat "below" the first rnat slot on the kernel
239 * backing store, rnat0/rnat1 are set to 0 and the low order bits are
240 * merged in from pt->ar_rnat.
242 * o when reading the rnat "above" the last rnat slot on the kernel
243 * backing store, rnat0/rnat1 gets its value from sw->ar_rnat.
245 static unsigned long
246 get_rnat (struct task_struct *task, struct switch_stack *sw,
247 unsigned long *krbs, unsigned long *urnat_addr,
248 unsigned long *urbs_end)
250 unsigned long rnat0 = 0, rnat1 = 0, urnat = 0, *slot0_kaddr;
251 unsigned long umask = 0, mask, m;
252 unsigned long *kbsp, *ubspstore, *rnat0_kaddr, *rnat1_kaddr, shift;
253 long num_regs, nbits;
254 struct pt_regs *pt;
256 pt = task_pt_regs(task);
257 kbsp = (unsigned long *) sw->ar_bspstore;
258 ubspstore = (unsigned long *) pt->ar_bspstore;
260 if (urbs_end < urnat_addr)
261 nbits = ia64_rse_num_regs(urnat_addr - 63, urbs_end);
262 else
263 nbits = 63;
264 mask = MASK(nbits);
266 * First, figure out which bit number slot 0 in user-land maps
267 * to in the kernel rnat. Do this by figuring out how many
268 * register slots we're beyond the user's backingstore and
269 * then computing the equivalent address in kernel space.
271 num_regs = ia64_rse_num_regs(ubspstore, urnat_addr + 1);
272 slot0_kaddr = ia64_rse_skip_regs(krbs, num_regs);
273 shift = ia64_rse_slot_num(slot0_kaddr);
274 rnat1_kaddr = ia64_rse_rnat_addr(slot0_kaddr);
275 rnat0_kaddr = rnat1_kaddr - 64;
277 if (ubspstore + 63 > urnat_addr) {
278 /* some bits need to be merged in from pt->ar_rnat */
279 umask = MASK(ia64_rse_slot_num(ubspstore)) & mask;
280 urnat = (pt->ar_rnat & umask);
281 mask &= ~umask;
282 if (!mask)
283 return urnat;
286 m = mask << shift;
287 if (rnat0_kaddr >= kbsp)
288 rnat0 = sw->ar_rnat;
289 else if (rnat0_kaddr > krbs)
290 rnat0 = *rnat0_kaddr;
291 urnat |= (rnat0 & m) >> shift;
293 m = mask >> (63 - shift);
294 if (rnat1_kaddr >= kbsp)
295 rnat1 = sw->ar_rnat;
296 else if (rnat1_kaddr > krbs)
297 rnat1 = *rnat1_kaddr;
298 urnat |= (rnat1 & m) << (63 - shift);
299 return urnat;
303 * The reverse of get_rnat.
305 static void
306 put_rnat (struct task_struct *task, struct switch_stack *sw,
307 unsigned long *krbs, unsigned long *urnat_addr, unsigned long urnat,
308 unsigned long *urbs_end)
310 unsigned long rnat0 = 0, rnat1 = 0, *slot0_kaddr, umask = 0, mask, m;
311 unsigned long *kbsp, *ubspstore, *rnat0_kaddr, *rnat1_kaddr, shift;
312 long num_regs, nbits;
313 struct pt_regs *pt;
314 unsigned long cfm, *urbs_kargs;
316 pt = task_pt_regs(task);
317 kbsp = (unsigned long *) sw->ar_bspstore;
318 ubspstore = (unsigned long *) pt->ar_bspstore;
320 urbs_kargs = urbs_end;
321 if (in_syscall(pt)) {
323 * If entered via syscall, don't allow user to set rnat bits
324 * for syscall args.
326 cfm = pt->cr_ifs;
327 urbs_kargs = ia64_rse_skip_regs(urbs_end, -(cfm & 0x7f));
330 if (urbs_kargs >= urnat_addr)
331 nbits = 63;
332 else {
333 if ((urnat_addr - 63) >= urbs_kargs)
334 return;
335 nbits = ia64_rse_num_regs(urnat_addr - 63, urbs_kargs);
337 mask = MASK(nbits);
340 * First, figure out which bit number slot 0 in user-land maps
341 * to in the kernel rnat. Do this by figuring out how many
342 * register slots we're beyond the user's backingstore and
343 * then computing the equivalent address in kernel space.
345 num_regs = ia64_rse_num_regs(ubspstore, urnat_addr + 1);
346 slot0_kaddr = ia64_rse_skip_regs(krbs, num_regs);
347 shift = ia64_rse_slot_num(slot0_kaddr);
348 rnat1_kaddr = ia64_rse_rnat_addr(slot0_kaddr);
349 rnat0_kaddr = rnat1_kaddr - 64;
351 if (ubspstore + 63 > urnat_addr) {
352 /* some bits need to be place in pt->ar_rnat: */
353 umask = MASK(ia64_rse_slot_num(ubspstore)) & mask;
354 pt->ar_rnat = (pt->ar_rnat & ~umask) | (urnat & umask);
355 mask &= ~umask;
356 if (!mask)
357 return;
360 * Note: Section 11.1 of the EAS guarantees that bit 63 of an
361 * rnat slot is ignored. so we don't have to clear it here.
363 rnat0 = (urnat << shift);
364 m = mask << shift;
365 if (rnat0_kaddr >= kbsp)
366 sw->ar_rnat = (sw->ar_rnat & ~m) | (rnat0 & m);
367 else if (rnat0_kaddr > krbs)
368 *rnat0_kaddr = ((*rnat0_kaddr & ~m) | (rnat0 & m));
370 rnat1 = (urnat >> (63 - shift));
371 m = mask >> (63 - shift);
372 if (rnat1_kaddr >= kbsp)
373 sw->ar_rnat = (sw->ar_rnat & ~m) | (rnat1 & m);
374 else if (rnat1_kaddr > krbs)
375 *rnat1_kaddr = ((*rnat1_kaddr & ~m) | (rnat1 & m));
378 static inline int
379 on_kernel_rbs (unsigned long addr, unsigned long bspstore,
380 unsigned long urbs_end)
382 unsigned long *rnat_addr = ia64_rse_rnat_addr((unsigned long *)
383 urbs_end);
384 return (addr >= bspstore && addr <= (unsigned long) rnat_addr);
388 * Read a word from the user-level backing store of task CHILD. ADDR
389 * is the user-level address to read the word from, VAL a pointer to
390 * the return value, and USER_BSP gives the end of the user-level
391 * backing store (i.e., it's the address that would be in ar.bsp after
392 * the user executed a "cover" instruction).
394 * This routine takes care of accessing the kernel register backing
395 * store for those registers that got spilled there. It also takes
396 * care of calculating the appropriate RNaT collection words.
398 long
399 ia64_peek (struct task_struct *child, struct switch_stack *child_stack,
400 unsigned long user_rbs_end, unsigned long addr, long *val)
402 unsigned long *bspstore, *krbs, regnum, *laddr, *urbs_end, *rnat_addr;
403 struct pt_regs *child_regs;
404 size_t copied;
405 long ret;
407 urbs_end = (long *) user_rbs_end;
408 laddr = (unsigned long *) addr;
409 child_regs = task_pt_regs(child);
410 bspstore = (unsigned long *) child_regs->ar_bspstore;
411 krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
412 if (on_kernel_rbs(addr, (unsigned long) bspstore,
413 (unsigned long) urbs_end))
416 * Attempt to read the RBS in an area that's actually
417 * on the kernel RBS => read the corresponding bits in
418 * the kernel RBS.
420 rnat_addr = ia64_rse_rnat_addr(laddr);
421 ret = get_rnat(child, child_stack, krbs, rnat_addr, urbs_end);
423 if (laddr == rnat_addr) {
424 /* return NaT collection word itself */
425 *val = ret;
426 return 0;
429 if (((1UL << ia64_rse_slot_num(laddr)) & ret) != 0) {
431 * It is implementation dependent whether the
432 * data portion of a NaT value gets saved on a
433 * st8.spill or RSE spill (e.g., see EAS 2.6,
434 * 4.4.4.6 Register Spill and Fill). To get
435 * consistent behavior across all possible
436 * IA-64 implementations, we return zero in
437 * this case.
439 *val = 0;
440 return 0;
443 if (laddr < urbs_end) {
445 * The desired word is on the kernel RBS and
446 * is not a NaT.
448 regnum = ia64_rse_num_regs(bspstore, laddr);
449 *val = *ia64_rse_skip_regs(krbs, regnum);
450 return 0;
453 copied = access_process_vm(child, addr, &ret, sizeof(ret), 0);
454 if (copied != sizeof(ret))
455 return -EIO;
456 *val = ret;
457 return 0;
460 long
461 ia64_poke (struct task_struct *child, struct switch_stack *child_stack,
462 unsigned long user_rbs_end, unsigned long addr, long val)
464 unsigned long *bspstore, *krbs, regnum, *laddr;
465 unsigned long *urbs_end = (long *) user_rbs_end;
466 struct pt_regs *child_regs;
468 laddr = (unsigned long *) addr;
469 child_regs = task_pt_regs(child);
470 bspstore = (unsigned long *) child_regs->ar_bspstore;
471 krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
472 if (on_kernel_rbs(addr, (unsigned long) bspstore,
473 (unsigned long) urbs_end))
476 * Attempt to write the RBS in an area that's actually
477 * on the kernel RBS => write the corresponding bits
478 * in the kernel RBS.
480 if (ia64_rse_is_rnat_slot(laddr))
481 put_rnat(child, child_stack, krbs, laddr, val,
482 urbs_end);
483 else {
484 if (laddr < urbs_end) {
485 regnum = ia64_rse_num_regs(bspstore, laddr);
486 *ia64_rse_skip_regs(krbs, regnum) = val;
489 } else if (access_process_vm(child, addr, &val, sizeof(val), 1)
490 != sizeof(val))
491 return -EIO;
492 return 0;
496 * Calculate the address of the end of the user-level register backing
497 * store. This is the address that would have been stored in ar.bsp
498 * if the user had executed a "cover" instruction right before
499 * entering the kernel. If CFMP is not NULL, it is used to return the
500 * "current frame mask" that was active at the time the kernel was
501 * entered.
503 unsigned long
504 ia64_get_user_rbs_end (struct task_struct *child, struct pt_regs *pt,
505 unsigned long *cfmp)
507 unsigned long *krbs, *bspstore, cfm = pt->cr_ifs;
508 long ndirty;
510 krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
511 bspstore = (unsigned long *) pt->ar_bspstore;
512 ndirty = ia64_rse_num_regs(krbs, krbs + (pt->loadrs >> 19));
514 if (in_syscall(pt))
515 ndirty += (cfm & 0x7f);
516 else
517 cfm &= ~(1UL << 63); /* clear valid bit */
519 if (cfmp)
520 *cfmp = cfm;
521 return (unsigned long) ia64_rse_skip_regs(bspstore, ndirty);
525 * Synchronize (i.e, write) the RSE backing store living in kernel
526 * space to the VM of the CHILD task. SW and PT are the pointers to
527 * the switch_stack and pt_regs structures, respectively.
528 * USER_RBS_END is the user-level address at which the backing store
529 * ends.
531 long
532 ia64_sync_user_rbs (struct task_struct *child, struct switch_stack *sw,
533 unsigned long user_rbs_start, unsigned long user_rbs_end)
535 unsigned long addr, val;
536 long ret;
538 /* now copy word for word from kernel rbs to user rbs: */
539 for (addr = user_rbs_start; addr < user_rbs_end; addr += 8) {
540 ret = ia64_peek(child, sw, user_rbs_end, addr, &val);
541 if (ret < 0)
542 return ret;
543 if (access_process_vm(child, addr, &val, sizeof(val), 1)
544 != sizeof(val))
545 return -EIO;
547 return 0;
550 static long
551 ia64_sync_kernel_rbs (struct task_struct *child, struct switch_stack *sw,
552 unsigned long user_rbs_start, unsigned long user_rbs_end)
554 unsigned long addr, val;
555 long ret;
557 /* now copy word for word from user rbs to kernel rbs: */
558 for (addr = user_rbs_start; addr < user_rbs_end; addr += 8) {
559 if (access_process_vm(child, addr, &val, sizeof(val), 0)
560 != sizeof(val))
561 return -EIO;
563 ret = ia64_poke(child, sw, user_rbs_end, addr, val);
564 if (ret < 0)
565 return ret;
567 return 0;
570 typedef long (*syncfunc_t)(struct task_struct *, struct switch_stack *,
571 unsigned long, unsigned long);
573 static void do_sync_rbs(struct unw_frame_info *info, void *arg)
575 struct pt_regs *pt;
576 unsigned long urbs_end;
577 syncfunc_t fn = arg;
579 if (unw_unwind_to_user(info) < 0)
580 return;
581 pt = task_pt_regs(info->task);
582 urbs_end = ia64_get_user_rbs_end(info->task, pt, NULL);
584 fn(info->task, info->sw, pt->ar_bspstore, urbs_end);
588 * when a thread is stopped (ptraced), debugger might change thread's user
589 * stack (change memory directly), and we must avoid the RSE stored in kernel
590 * to override user stack (user space's RSE is newer than kernel's in the
591 * case). To workaround the issue, we copy kernel RSE to user RSE before the
592 * task is stopped, so user RSE has updated data. we then copy user RSE to
593 * kernel after the task is resummed from traced stop and kernel will use the
594 * newer RSE to return to user. TIF_RESTORE_RSE is the flag to indicate we need
595 * synchronize user RSE to kernel.
597 void ia64_ptrace_stop(void)
599 if (test_and_set_tsk_thread_flag(current, TIF_RESTORE_RSE))
600 return;
601 tsk_set_notify_resume(current);
602 unw_init_running(do_sync_rbs, ia64_sync_user_rbs);
606 * This is called to read back the register backing store.
608 void ia64_sync_krbs(void)
610 clear_tsk_thread_flag(current, TIF_RESTORE_RSE);
611 tsk_clear_notify_resume(current);
613 unw_init_running(do_sync_rbs, ia64_sync_kernel_rbs);
617 * After PTRACE_ATTACH, a thread's register backing store area in user
618 * space is assumed to contain correct data whenever the thread is
619 * stopped. arch_ptrace_stop takes care of this on tracing stops.
620 * But if the child was already stopped for job control when we attach
621 * to it, then it might not ever get into ptrace_stop by the time we
622 * want to examine the user memory containing the RBS.
624 void
625 ptrace_attach_sync_user_rbs (struct task_struct *child)
627 int stopped = 0;
628 struct unw_frame_info info;
631 * If the child is in TASK_STOPPED, we need to change that to
632 * TASK_TRACED momentarily while we operate on it. This ensures
633 * that the child won't be woken up and return to user mode while
634 * we are doing the sync. (It can only be woken up for SIGKILL.)
637 read_lock(&tasklist_lock);
638 if (child->signal) {
639 spin_lock_irq(&child->sighand->siglock);
640 if (child->state == TASK_STOPPED &&
641 !test_and_set_tsk_thread_flag(child, TIF_RESTORE_RSE)) {
642 tsk_set_notify_resume(child);
644 child->state = TASK_TRACED;
645 stopped = 1;
647 spin_unlock_irq(&child->sighand->siglock);
649 read_unlock(&tasklist_lock);
651 if (!stopped)
652 return;
654 unw_init_from_blocked_task(&info, child);
655 do_sync_rbs(&info, ia64_sync_user_rbs);
658 * Now move the child back into TASK_STOPPED if it should be in a
659 * job control stop, so that SIGCONT can be used to wake it up.
661 read_lock(&tasklist_lock);
662 if (child->signal) {
663 spin_lock_irq(&child->sighand->siglock);
664 if (child->state == TASK_TRACED &&
665 (child->signal->flags & SIGNAL_STOP_STOPPED)) {
666 child->state = TASK_STOPPED;
668 spin_unlock_irq(&child->sighand->siglock);
670 read_unlock(&tasklist_lock);
673 static inline int
674 thread_matches (struct task_struct *thread, unsigned long addr)
676 unsigned long thread_rbs_end;
677 struct pt_regs *thread_regs;
679 if (ptrace_check_attach(thread, 0) < 0)
681 * If the thread is not in an attachable state, we'll
682 * ignore it. The net effect is that if ADDR happens
683 * to overlap with the portion of the thread's
684 * register backing store that is currently residing
685 * on the thread's kernel stack, then ptrace() may end
686 * up accessing a stale value. But if the thread
687 * isn't stopped, that's a problem anyhow, so we're
688 * doing as well as we can...
690 return 0;
692 thread_regs = task_pt_regs(thread);
693 thread_rbs_end = ia64_get_user_rbs_end(thread, thread_regs, NULL);
694 if (!on_kernel_rbs(addr, thread_regs->ar_bspstore, thread_rbs_end))
695 return 0;
697 return 1; /* looks like we've got a winner */
701 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
702 * GDB apparently wants to be able to read the register-backing store
703 * of any thread when attached to a given process. If we are peeking
704 * or poking an address that happens to reside in the kernel-backing
705 * store of another thread, we need to attach to that thread, because
706 * otherwise we end up accessing stale data.
708 * task_list_lock must be read-locked before calling this routine!
710 static struct task_struct *
711 find_thread_for_addr (struct task_struct *child, unsigned long addr)
713 struct task_struct *p;
714 struct mm_struct *mm;
715 struct list_head *this, *next;
716 int mm_users;
718 if (!(mm = get_task_mm(child)))
719 return child;
721 /* -1 because of our get_task_mm(): */
722 mm_users = atomic_read(&mm->mm_users) - 1;
723 if (mm_users <= 1)
724 goto out; /* not multi-threaded */
727 * Traverse the current process' children list. Every task that
728 * one attaches to becomes a child. And it is only attached children
729 * of the debugger that are of interest (ptrace_check_attach checks
730 * for this).
732 list_for_each_safe(this, next, &current->children) {
733 p = list_entry(this, struct task_struct, sibling);
734 if (p->tgid != child->tgid)
735 continue;
736 if (thread_matches(p, addr)) {
737 child = p;
738 goto out;
742 out:
743 mmput(mm);
744 return child;
748 =======
749 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
750 * Write f32-f127 back to task->thread.fph if it has been modified.
752 inline void
753 ia64_flush_fph (struct task_struct *task)
755 struct ia64_psr *psr = ia64_psr(task_pt_regs(task));
758 * Prevent migrating this task while
759 * we're fiddling with the FPU state
761 preempt_disable();
762 if (ia64_is_local_fpu_owner(task) && psr->mfh) {
763 psr->mfh = 0;
764 task->thread.flags |= IA64_THREAD_FPH_VALID;
765 ia64_save_fpu(&task->thread.fph[0]);
767 preempt_enable();
771 * Sync the fph state of the task so that it can be manipulated
772 * through thread.fph. If necessary, f32-f127 are written back to
773 * thread.fph or, if the fph state hasn't been used before, thread.fph
774 * is cleared to zeroes. Also, access to f32-f127 is disabled to
775 * ensure that the task picks up the state from thread.fph when it
776 * executes again.
778 void
779 ia64_sync_fph (struct task_struct *task)
781 struct ia64_psr *psr = ia64_psr(task_pt_regs(task));
783 ia64_flush_fph(task);
784 if (!(task->thread.flags & IA64_THREAD_FPH_VALID)) {
785 task->thread.flags |= IA64_THREAD_FPH_VALID;
786 memset(&task->thread.fph, 0, sizeof(task->thread.fph));
788 ia64_drop_fpu(task);
789 psr->dfh = 1;
792 static int
793 access_fr (struct unw_frame_info *info, int regnum, int hi,
794 unsigned long *data, int write_access)
796 struct ia64_fpreg fpval;
797 int ret;
799 ret = unw_get_fr(info, regnum, &fpval);
800 if (ret < 0)
801 return ret;
803 if (write_access) {
804 fpval.u.bits[hi] = *data;
805 ret = unw_set_fr(info, regnum, fpval);
806 } else
807 *data = fpval.u.bits[hi];
808 return ret;
812 * Change the machine-state of CHILD such that it will return via the normal
813 * kernel exit-path, rather than the syscall-exit path.
815 static void
816 convert_to_non_syscall (struct task_struct *child, struct pt_regs *pt,
817 unsigned long cfm)
819 struct unw_frame_info info, prev_info;
820 unsigned long ip, sp, pr;
822 unw_init_from_blocked_task(&info, child);
823 while (1) {
824 prev_info = info;
825 if (unw_unwind(&info) < 0)
826 return;
828 unw_get_sp(&info, &sp);
829 if ((long)((unsigned long)child + IA64_STK_OFFSET - sp)
830 < IA64_PT_REGS_SIZE) {
831 dprintk("ptrace.%s: ran off the top of the kernel "
832 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
833 "stack\n", __FUNCTION__);
834 =======
835 "stack\n", __func__);
836 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
837 return;
839 if (unw_get_pr (&prev_info, &pr) < 0) {
840 unw_get_rp(&prev_info, &ip);
841 dprintk("ptrace.%s: failed to read "
842 "predicate register (ip=0x%lx)\n",
843 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
844 __FUNCTION__, ip);
845 =======
846 __func__, ip);
847 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
848 return;
850 if (unw_is_intr_frame(&info)
851 && (pr & (1UL << PRED_USER_STACK)))
852 break;
856 * Note: at the time of this call, the target task is blocked
857 * in notify_resume_user() and by clearling PRED_LEAVE_SYSCALL
858 * (aka, "pLvSys") we redirect execution from
859 * .work_pending_syscall_end to .work_processed_kernel.
861 unw_get_pr(&prev_info, &pr);
862 pr &= ~((1UL << PRED_SYSCALL) | (1UL << PRED_LEAVE_SYSCALL));
863 pr |= (1UL << PRED_NON_SYSCALL);
864 unw_set_pr(&prev_info, pr);
866 pt->cr_ifs = (1UL << 63) | cfm;
868 * Clear the memory that is NOT written on syscall-entry to
869 * ensure we do not leak kernel-state to user when execution
870 * resumes.
872 pt->r2 = 0;
873 pt->r3 = 0;
874 pt->r14 = 0;
875 memset(&pt->r16, 0, 16*8); /* clear r16-r31 */
876 memset(&pt->f6, 0, 6*16); /* clear f6-f11 */
877 pt->b7 = 0;
878 pt->ar_ccv = 0;
879 pt->ar_csd = 0;
880 pt->ar_ssd = 0;
883 static int
884 access_nat_bits (struct task_struct *child, struct pt_regs *pt,
885 struct unw_frame_info *info,
886 unsigned long *data, int write_access)
888 unsigned long regnum, nat_bits, scratch_unat, dummy = 0;
889 char nat = 0;
891 if (write_access) {
892 nat_bits = *data;
893 scratch_unat = ia64_put_scratch_nat_bits(pt, nat_bits);
894 if (unw_set_ar(info, UNW_AR_UNAT, scratch_unat) < 0) {
895 dprintk("ptrace: failed to set ar.unat\n");
896 return -1;
898 for (regnum = 4; regnum <= 7; ++regnum) {
899 unw_get_gr(info, regnum, &dummy, &nat);
900 unw_set_gr(info, regnum, dummy,
901 (nat_bits >> regnum) & 1);
903 } else {
904 if (unw_get_ar(info, UNW_AR_UNAT, &scratch_unat) < 0) {
905 dprintk("ptrace: failed to read ar.unat\n");
906 return -1;
908 nat_bits = ia64_get_scratch_nat_bits(pt, scratch_unat);
909 for (regnum = 4; regnum <= 7; ++regnum) {
910 unw_get_gr(info, regnum, &dummy, &nat);
911 nat_bits |= (nat != 0) << regnum;
913 *data = nat_bits;
915 return 0;
918 static int
919 access_uarea (struct task_struct *child, unsigned long addr,
920 unsigned long *data, int write_access)
922 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
923 unsigned long *ptr, regnum, urbs_end, rnat_addr, cfm;
924 =======
925 unsigned long *ptr, regnum, urbs_end, cfm;
926 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
927 struct switch_stack *sw;
928 struct pt_regs *pt;
929 # define pt_reg_addr(pt, reg) ((void *) \
930 ((unsigned long) (pt) \
931 + offsetof(struct pt_regs, reg)))
934 pt = task_pt_regs(child);
935 sw = (struct switch_stack *) (child->thread.ksp + 16);
937 if ((addr & 0x7) != 0) {
938 dprintk("ptrace: unaligned register address 0x%lx\n", addr);
939 return -1;
942 if (addr < PT_F127 + 16) {
943 /* accessing fph */
944 if (write_access)
945 ia64_sync_fph(child);
946 else
947 ia64_flush_fph(child);
948 ptr = (unsigned long *)
949 ((unsigned long) &child->thread.fph + addr);
950 } else if ((addr >= PT_F10) && (addr < PT_F11 + 16)) {
951 /* scratch registers untouched by kernel (saved in pt_regs) */
952 ptr = pt_reg_addr(pt, f10) + (addr - PT_F10);
953 } else if (addr >= PT_F12 && addr < PT_F15 + 16) {
955 * Scratch registers untouched by kernel (saved in
956 * switch_stack).
958 ptr = (unsigned long *) ((long) sw
959 + (addr - PT_NAT_BITS - 32));
960 } else if (addr < PT_AR_LC + 8) {
961 /* preserved state: */
962 struct unw_frame_info info;
963 char nat = 0;
964 int ret;
966 unw_init_from_blocked_task(&info, child);
967 if (unw_unwind_to_user(&info) < 0)
968 return -1;
970 switch (addr) {
971 case PT_NAT_BITS:
972 return access_nat_bits(child, pt, &info,
973 data, write_access);
975 case PT_R4: case PT_R5: case PT_R6: case PT_R7:
976 if (write_access) {
977 /* read NaT bit first: */
978 unsigned long dummy;
980 ret = unw_get_gr(&info, (addr - PT_R4)/8 + 4,
981 &dummy, &nat);
982 if (ret < 0)
983 return ret;
985 return unw_access_gr(&info, (addr - PT_R4)/8 + 4, data,
986 &nat, write_access);
988 case PT_B1: case PT_B2: case PT_B3:
989 case PT_B4: case PT_B5:
990 return unw_access_br(&info, (addr - PT_B1)/8 + 1, data,
991 write_access);
993 case PT_AR_EC:
994 return unw_access_ar(&info, UNW_AR_EC, data,
995 write_access);
997 case PT_AR_LC:
998 return unw_access_ar(&info, UNW_AR_LC, data,
999 write_access);
1001 default:
1002 if (addr >= PT_F2 && addr < PT_F5 + 16)
1003 return access_fr(&info, (addr - PT_F2)/16 + 2,
1004 (addr & 8) != 0, data,
1005 write_access);
1006 else if (addr >= PT_F16 && addr < PT_F31 + 16)
1007 return access_fr(&info,
1008 (addr - PT_F16)/16 + 16,
1009 (addr & 8) != 0,
1010 data, write_access);
1011 else {
1012 dprintk("ptrace: rejecting access to register "
1013 "address 0x%lx\n", addr);
1014 return -1;
1017 } else if (addr < PT_F9+16) {
1018 /* scratch state */
1019 switch (addr) {
1020 case PT_AR_BSP:
1022 * By convention, we use PT_AR_BSP to refer to
1023 * the end of the user-level backing store.
1024 * Use ia64_rse_skip_regs(PT_AR_BSP, -CFM.sof)
1025 * to get the real value of ar.bsp at the time
1026 * the kernel was entered.
1028 * Furthermore, when changing the contents of
1029 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1030 * PT_AR_BSP (or PT_CFM) we MUST copy any
1031 * users-level stacked registers that are
1032 * stored on the kernel stack back to
1033 * user-space because otherwise, we might end
1034 * up clobbering kernel stacked registers.
1035 * Also, if this happens while the task is
1036 * blocked in a system call, which convert the
1037 * state such that the non-system-call exit
1038 =======
1039 * PT_AR_BSP (or PT_CFM) while the task is
1040 * blocked in a system call, convert the state
1041 * so that the non-system-call exit
1042 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1043 * path is used. This ensures that the proper
1044 * state will be picked up when resuming
1045 * execution. However, it *also* means that
1046 * once we write PT_AR_BSP/PT_CFM, it won't be
1047 * possible to modify the syscall arguments of
1048 * the pending system call any longer. This
1049 * shouldn't be an issue because modifying
1050 * PT_AR_BSP/PT_CFM generally implies that
1051 * we're either abandoning the pending system
1052 * call or that we defer it's re-execution
1053 * (e.g., due to GDB doing an inferior
1054 * function call).
1056 urbs_end = ia64_get_user_rbs_end(child, pt, &cfm);
1057 if (write_access) {
1058 if (*data != urbs_end) {
1059 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1060 if (ia64_sync_user_rbs(child, sw,
1061 pt->ar_bspstore,
1062 urbs_end) < 0)
1063 return -1;
1064 =======
1065 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1066 if (in_syscall(pt))
1067 convert_to_non_syscall(child,
1069 cfm);
1071 * Simulate user-level write
1072 * of ar.bsp:
1074 pt->loadrs = 0;
1075 pt->ar_bspstore = *data;
1077 } else
1078 *data = urbs_end;
1079 return 0;
1081 case PT_CFM:
1082 urbs_end = ia64_get_user_rbs_end(child, pt, &cfm);
1083 if (write_access) {
1084 if (((cfm ^ *data) & PFM_MASK) != 0) {
1085 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1086 if (ia64_sync_user_rbs(child, sw,
1087 pt->ar_bspstore,
1088 urbs_end) < 0)
1089 return -1;
1090 =======
1091 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1092 if (in_syscall(pt))
1093 convert_to_non_syscall(child,
1095 cfm);
1096 pt->cr_ifs = ((pt->cr_ifs & ~PFM_MASK)
1097 | (*data & PFM_MASK));
1099 } else
1100 *data = cfm;
1101 return 0;
1103 case PT_CR_IPSR:
1104 if (write_access) {
1105 unsigned long tmp = *data;
1106 /* psr.ri==3 is a reserved value: SDM 2:25 */
1107 if ((tmp & IA64_PSR_RI) == IA64_PSR_RI)
1108 tmp &= ~IA64_PSR_RI;
1109 pt->cr_ipsr = ((tmp & IPSR_MASK)
1110 | (pt->cr_ipsr & ~IPSR_MASK));
1111 } else
1112 *data = (pt->cr_ipsr & IPSR_MASK);
1113 return 0;
1115 case PT_AR_RSC:
1116 if (write_access)
1117 pt->ar_rsc = *data | (3 << 2); /* force PL3 */
1118 else
1119 *data = pt->ar_rsc;
1120 return 0;
1122 case PT_AR_RNAT:
1123 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1124 urbs_end = ia64_get_user_rbs_end(child, pt, NULL);
1125 rnat_addr = (long) ia64_rse_rnat_addr((long *)
1126 urbs_end);
1127 if (write_access)
1128 return ia64_poke(child, sw, urbs_end,
1129 rnat_addr, *data);
1130 else
1131 return ia64_peek(child, sw, urbs_end,
1132 rnat_addr, data);
1134 =======
1135 ptr = pt_reg_addr(pt, ar_rnat);
1136 break;
1137 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1138 case PT_R1:
1139 ptr = pt_reg_addr(pt, r1);
1140 break;
1141 case PT_R2: case PT_R3:
1142 ptr = pt_reg_addr(pt, r2) + (addr - PT_R2);
1143 break;
1144 case PT_R8: case PT_R9: case PT_R10: case PT_R11:
1145 ptr = pt_reg_addr(pt, r8) + (addr - PT_R8);
1146 break;
1147 case PT_R12: case PT_R13:
1148 ptr = pt_reg_addr(pt, r12) + (addr - PT_R12);
1149 break;
1150 case PT_R14:
1151 ptr = pt_reg_addr(pt, r14);
1152 break;
1153 case PT_R15:
1154 ptr = pt_reg_addr(pt, r15);
1155 break;
1156 case PT_R16: case PT_R17: case PT_R18: case PT_R19:
1157 case PT_R20: case PT_R21: case PT_R22: case PT_R23:
1158 case PT_R24: case PT_R25: case PT_R26: case PT_R27:
1159 case PT_R28: case PT_R29: case PT_R30: case PT_R31:
1160 ptr = pt_reg_addr(pt, r16) + (addr - PT_R16);
1161 break;
1162 case PT_B0:
1163 ptr = pt_reg_addr(pt, b0);
1164 break;
1165 case PT_B6:
1166 ptr = pt_reg_addr(pt, b6);
1167 break;
1168 case PT_B7:
1169 ptr = pt_reg_addr(pt, b7);
1170 break;
1171 case PT_F6: case PT_F6+8: case PT_F7: case PT_F7+8:
1172 case PT_F8: case PT_F8+8: case PT_F9: case PT_F9+8:
1173 ptr = pt_reg_addr(pt, f6) + (addr - PT_F6);
1174 break;
1175 case PT_AR_BSPSTORE:
1176 ptr = pt_reg_addr(pt, ar_bspstore);
1177 break;
1178 case PT_AR_UNAT:
1179 ptr = pt_reg_addr(pt, ar_unat);
1180 break;
1181 case PT_AR_PFS:
1182 ptr = pt_reg_addr(pt, ar_pfs);
1183 break;
1184 case PT_AR_CCV:
1185 ptr = pt_reg_addr(pt, ar_ccv);
1186 break;
1187 case PT_AR_FPSR:
1188 ptr = pt_reg_addr(pt, ar_fpsr);
1189 break;
1190 case PT_CR_IIP:
1191 ptr = pt_reg_addr(pt, cr_iip);
1192 break;
1193 case PT_PR:
1194 ptr = pt_reg_addr(pt, pr);
1195 break;
1196 /* scratch register */
1198 default:
1199 /* disallow accessing anything else... */
1200 dprintk("ptrace: rejecting access to register "
1201 "address 0x%lx\n", addr);
1202 return -1;
1204 } else if (addr <= PT_AR_SSD) {
1205 ptr = pt_reg_addr(pt, ar_csd) + (addr - PT_AR_CSD);
1206 } else {
1207 /* access debug registers */
1209 if (addr >= PT_IBR) {
1210 regnum = (addr - PT_IBR) >> 3;
1211 ptr = &child->thread.ibr[0];
1212 } else {
1213 regnum = (addr - PT_DBR) >> 3;
1214 ptr = &child->thread.dbr[0];
1217 if (regnum >= 8) {
1218 dprintk("ptrace: rejecting access to register "
1219 "address 0x%lx\n", addr);
1220 return -1;
1222 #ifdef CONFIG_PERFMON
1224 * Check if debug registers are used by perfmon. This
1225 * test must be done once we know that we can do the
1226 * operation, i.e. the arguments are all valid, but
1227 * before we start modifying the state.
1229 * Perfmon needs to keep a count of how many processes
1230 * are trying to modify the debug registers for system
1231 * wide monitoring sessions.
1233 * We also include read access here, because they may
1234 * cause the PMU-installed debug register state
1235 * (dbr[], ibr[]) to be reset. The two arrays are also
1236 * used by perfmon, but we do not use
1237 * IA64_THREAD_DBG_VALID. The registers are restored
1238 * by the PMU context switch code.
1240 if (pfm_use_debug_registers(child)) return -1;
1241 #endif
1243 if (!(child->thread.flags & IA64_THREAD_DBG_VALID)) {
1244 child->thread.flags |= IA64_THREAD_DBG_VALID;
1245 memset(child->thread.dbr, 0,
1246 sizeof(child->thread.dbr));
1247 memset(child->thread.ibr, 0,
1248 sizeof(child->thread.ibr));
1251 ptr += regnum;
1253 if ((regnum & 1) && write_access) {
1254 /* don't let the user set kernel-level breakpoints: */
1255 *ptr = *data & ~(7UL << 56);
1256 return 0;
1259 if (write_access)
1260 *ptr = *data;
1261 else
1262 *data = *ptr;
1263 return 0;
1266 static long
1267 ptrace_getregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
1269 unsigned long psr, ec, lc, rnat, bsp, cfm, nat_bits, val;
1270 struct unw_frame_info info;
1271 struct ia64_fpreg fpval;
1272 struct switch_stack *sw;
1273 struct pt_regs *pt;
1274 long ret, retval = 0;
1275 char nat = 0;
1276 int i;
1278 if (!access_ok(VERIFY_WRITE, ppr, sizeof(struct pt_all_user_regs)))
1279 return -EIO;
1281 pt = task_pt_regs(child);
1282 sw = (struct switch_stack *) (child->thread.ksp + 16);
1283 unw_init_from_blocked_task(&info, child);
1284 if (unw_unwind_to_user(&info) < 0) {
1285 return -EIO;
1288 if (((unsigned long) ppr & 0x7) != 0) {
1289 dprintk("ptrace:unaligned register address %p\n", ppr);
1290 return -EIO;
1293 if (access_uarea(child, PT_CR_IPSR, &psr, 0) < 0
1294 || access_uarea(child, PT_AR_EC, &ec, 0) < 0
1295 || access_uarea(child, PT_AR_LC, &lc, 0) < 0
1296 || access_uarea(child, PT_AR_RNAT, &rnat, 0) < 0
1297 || access_uarea(child, PT_AR_BSP, &bsp, 0) < 0
1298 || access_uarea(child, PT_CFM, &cfm, 0)
1299 || access_uarea(child, PT_NAT_BITS, &nat_bits, 0))
1300 return -EIO;
1302 /* control regs */
1304 retval |= __put_user(pt->cr_iip, &ppr->cr_iip);
1305 retval |= __put_user(psr, &ppr->cr_ipsr);
1307 /* app regs */
1309 retval |= __put_user(pt->ar_pfs, &ppr->ar[PT_AUR_PFS]);
1310 retval |= __put_user(pt->ar_rsc, &ppr->ar[PT_AUR_RSC]);
1311 retval |= __put_user(pt->ar_bspstore, &ppr->ar[PT_AUR_BSPSTORE]);
1312 retval |= __put_user(pt->ar_unat, &ppr->ar[PT_AUR_UNAT]);
1313 retval |= __put_user(pt->ar_ccv, &ppr->ar[PT_AUR_CCV]);
1314 retval |= __put_user(pt->ar_fpsr, &ppr->ar[PT_AUR_FPSR]);
1316 retval |= __put_user(ec, &ppr->ar[PT_AUR_EC]);
1317 retval |= __put_user(lc, &ppr->ar[PT_AUR_LC]);
1318 retval |= __put_user(rnat, &ppr->ar[PT_AUR_RNAT]);
1319 retval |= __put_user(bsp, &ppr->ar[PT_AUR_BSP]);
1320 retval |= __put_user(cfm, &ppr->cfm);
1322 /* gr1-gr3 */
1324 retval |= __copy_to_user(&ppr->gr[1], &pt->r1, sizeof(long));
1325 retval |= __copy_to_user(&ppr->gr[2], &pt->r2, sizeof(long) *2);
1327 /* gr4-gr7 */
1329 for (i = 4; i < 8; i++) {
1330 if (unw_access_gr(&info, i, &val, &nat, 0) < 0)
1331 return -EIO;
1332 retval |= __put_user(val, &ppr->gr[i]);
1335 /* gr8-gr11 */
1337 retval |= __copy_to_user(&ppr->gr[8], &pt->r8, sizeof(long) * 4);
1339 /* gr12-gr15 */
1341 retval |= __copy_to_user(&ppr->gr[12], &pt->r12, sizeof(long) * 2);
1342 retval |= __copy_to_user(&ppr->gr[14], &pt->r14, sizeof(long));
1343 retval |= __copy_to_user(&ppr->gr[15], &pt->r15, sizeof(long));
1345 /* gr16-gr31 */
1347 retval |= __copy_to_user(&ppr->gr[16], &pt->r16, sizeof(long) * 16);
1349 /* b0 */
1351 retval |= __put_user(pt->b0, &ppr->br[0]);
1353 /* b1-b5 */
1355 for (i = 1; i < 6; i++) {
1356 if (unw_access_br(&info, i, &val, 0) < 0)
1357 return -EIO;
1358 __put_user(val, &ppr->br[i]);
1361 /* b6-b7 */
1363 retval |= __put_user(pt->b6, &ppr->br[6]);
1364 retval |= __put_user(pt->b7, &ppr->br[7]);
1366 /* fr2-fr5 */
1368 for (i = 2; i < 6; i++) {
1369 if (unw_get_fr(&info, i, &fpval) < 0)
1370 return -EIO;
1371 retval |= __copy_to_user(&ppr->fr[i], &fpval, sizeof (fpval));
1374 /* fr6-fr11 */
1376 retval |= __copy_to_user(&ppr->fr[6], &pt->f6,
1377 sizeof(struct ia64_fpreg) * 6);
1379 /* fp scratch regs(12-15) */
1381 retval |= __copy_to_user(&ppr->fr[12], &sw->f12,
1382 sizeof(struct ia64_fpreg) * 4);
1384 /* fr16-fr31 */
1386 for (i = 16; i < 32; i++) {
1387 if (unw_get_fr(&info, i, &fpval) < 0)
1388 return -EIO;
1389 retval |= __copy_to_user(&ppr->fr[i], &fpval, sizeof (fpval));
1392 /* fph */
1394 ia64_flush_fph(child);
1395 retval |= __copy_to_user(&ppr->fr[32], &child->thread.fph,
1396 sizeof(ppr->fr[32]) * 96);
1398 /* preds */
1400 retval |= __put_user(pt->pr, &ppr->pr);
1402 /* nat bits */
1404 retval |= __put_user(nat_bits, &ppr->nat);
1406 ret = retval ? -EIO : 0;
1407 return ret;
1410 static long
1411 ptrace_setregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
1413 unsigned long psr, rsc, ec, lc, rnat, bsp, cfm, nat_bits, val = 0;
1414 struct unw_frame_info info;
1415 struct switch_stack *sw;
1416 struct ia64_fpreg fpval;
1417 struct pt_regs *pt;
1418 long ret, retval = 0;
1419 int i;
1421 memset(&fpval, 0, sizeof(fpval));
1423 if (!access_ok(VERIFY_READ, ppr, sizeof(struct pt_all_user_regs)))
1424 return -EIO;
1426 pt = task_pt_regs(child);
1427 sw = (struct switch_stack *) (child->thread.ksp + 16);
1428 unw_init_from_blocked_task(&info, child);
1429 if (unw_unwind_to_user(&info) < 0) {
1430 return -EIO;
1433 if (((unsigned long) ppr & 0x7) != 0) {
1434 dprintk("ptrace:unaligned register address %p\n", ppr);
1435 return -EIO;
1438 /* control regs */
1440 retval |= __get_user(pt->cr_iip, &ppr->cr_iip);
1441 retval |= __get_user(psr, &ppr->cr_ipsr);
1443 /* app regs */
1445 retval |= __get_user(pt->ar_pfs, &ppr->ar[PT_AUR_PFS]);
1446 retval |= __get_user(rsc, &ppr->ar[PT_AUR_RSC]);
1447 retval |= __get_user(pt->ar_bspstore, &ppr->ar[PT_AUR_BSPSTORE]);
1448 retval |= __get_user(pt->ar_unat, &ppr->ar[PT_AUR_UNAT]);
1449 retval |= __get_user(pt->ar_ccv, &ppr->ar[PT_AUR_CCV]);
1450 retval |= __get_user(pt->ar_fpsr, &ppr->ar[PT_AUR_FPSR]);
1452 retval |= __get_user(ec, &ppr->ar[PT_AUR_EC]);
1453 retval |= __get_user(lc, &ppr->ar[PT_AUR_LC]);
1454 retval |= __get_user(rnat, &ppr->ar[PT_AUR_RNAT]);
1455 retval |= __get_user(bsp, &ppr->ar[PT_AUR_BSP]);
1456 retval |= __get_user(cfm, &ppr->cfm);
1458 /* gr1-gr3 */
1460 retval |= __copy_from_user(&pt->r1, &ppr->gr[1], sizeof(long));
1461 retval |= __copy_from_user(&pt->r2, &ppr->gr[2], sizeof(long) * 2);
1463 /* gr4-gr7 */
1465 for (i = 4; i < 8; i++) {
1466 retval |= __get_user(val, &ppr->gr[i]);
1467 /* NaT bit will be set via PT_NAT_BITS: */
1468 if (unw_set_gr(&info, i, val, 0) < 0)
1469 return -EIO;
1472 /* gr8-gr11 */
1474 retval |= __copy_from_user(&pt->r8, &ppr->gr[8], sizeof(long) * 4);
1476 /* gr12-gr15 */
1478 retval |= __copy_from_user(&pt->r12, &ppr->gr[12], sizeof(long) * 2);
1479 retval |= __copy_from_user(&pt->r14, &ppr->gr[14], sizeof(long));
1480 retval |= __copy_from_user(&pt->r15, &ppr->gr[15], sizeof(long));
1482 /* gr16-gr31 */
1484 retval |= __copy_from_user(&pt->r16, &ppr->gr[16], sizeof(long) * 16);
1486 /* b0 */
1488 retval |= __get_user(pt->b0, &ppr->br[0]);
1490 /* b1-b5 */
1492 for (i = 1; i < 6; i++) {
1493 retval |= __get_user(val, &ppr->br[i]);
1494 unw_set_br(&info, i, val);
1497 /* b6-b7 */
1499 retval |= __get_user(pt->b6, &ppr->br[6]);
1500 retval |= __get_user(pt->b7, &ppr->br[7]);
1502 /* fr2-fr5 */
1504 for (i = 2; i < 6; i++) {
1505 retval |= __copy_from_user(&fpval, &ppr->fr[i], sizeof(fpval));
1506 if (unw_set_fr(&info, i, fpval) < 0)
1507 return -EIO;
1510 /* fr6-fr11 */
1512 retval |= __copy_from_user(&pt->f6, &ppr->fr[6],
1513 sizeof(ppr->fr[6]) * 6);
1515 /* fp scratch regs(12-15) */
1517 retval |= __copy_from_user(&sw->f12, &ppr->fr[12],
1518 sizeof(ppr->fr[12]) * 4);
1520 /* fr16-fr31 */
1522 for (i = 16; i < 32; i++) {
1523 retval |= __copy_from_user(&fpval, &ppr->fr[i],
1524 sizeof(fpval));
1525 if (unw_set_fr(&info, i, fpval) < 0)
1526 return -EIO;
1529 /* fph */
1531 ia64_sync_fph(child);
1532 retval |= __copy_from_user(&child->thread.fph, &ppr->fr[32],
1533 sizeof(ppr->fr[32]) * 96);
1535 /* preds */
1537 retval |= __get_user(pt->pr, &ppr->pr);
1539 /* nat bits */
1541 retval |= __get_user(nat_bits, &ppr->nat);
1543 retval |= access_uarea(child, PT_CR_IPSR, &psr, 1);
1544 retval |= access_uarea(child, PT_AR_RSC, &rsc, 1);
1545 retval |= access_uarea(child, PT_AR_EC, &ec, 1);
1546 retval |= access_uarea(child, PT_AR_LC, &lc, 1);
1547 retval |= access_uarea(child, PT_AR_RNAT, &rnat, 1);
1548 retval |= access_uarea(child, PT_AR_BSP, &bsp, 1);
1549 retval |= access_uarea(child, PT_CFM, &cfm, 1);
1550 retval |= access_uarea(child, PT_NAT_BITS, &nat_bits, 1);
1552 ret = retval ? -EIO : 0;
1553 return ret;
1556 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1558 * Called by kernel/ptrace.c when detaching..
1560 * Make sure the single step bit is not set.
1562 =======
1563 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1564 void
1565 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1566 ptrace_disable (struct task_struct *child)
1567 =======
1568 user_enable_single_step (struct task_struct *child)
1569 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1571 struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
1573 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1574 /* make sure the single step/taken-branch trap bits are not set: */
1575 clear_tsk_thread_flag(child, TIF_SINGLESTEP);
1576 child_psr->ss = 0;
1577 child_psr->tb = 0;
1578 =======
1579 set_tsk_thread_flag(child, TIF_SINGLESTEP);
1580 child_psr->ss = 1;
1581 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1584 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1585 asmlinkage long
1586 sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data)
1587 =======
1588 void
1589 user_enable_block_step (struct task_struct *child)
1590 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1592 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1593 struct pt_regs *pt;
1594 unsigned long urbs_end, peek_or_poke;
1595 struct task_struct *child;
1596 struct switch_stack *sw;
1597 long ret;
1598 struct unw_frame_info info;
1599 =======
1600 struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
1601 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1603 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1604 lock_kernel();
1605 ret = -EPERM;
1606 if (request == PTRACE_TRACEME) {
1607 ret = ptrace_traceme();
1608 goto out;
1610 =======
1611 set_tsk_thread_flag(child, TIF_SINGLESTEP);
1612 child_psr->tb = 1;
1614 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1616 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1617 peek_or_poke = (request == PTRACE_PEEKTEXT
1618 || request == PTRACE_PEEKDATA
1619 || request == PTRACE_POKETEXT
1620 || request == PTRACE_POKEDATA);
1621 ret = -ESRCH;
1622 read_lock(&tasklist_lock);
1624 child = find_task_by_pid(pid);
1625 if (child) {
1626 if (peek_or_poke)
1627 child = find_thread_for_addr(child, addr);
1628 get_task_struct(child);
1631 read_unlock(&tasklist_lock);
1632 if (!child)
1633 goto out;
1634 ret = -EPERM;
1635 if (pid == 1) /* no messing around with init! */
1636 goto out_tsk;
1638 if (request == PTRACE_ATTACH) {
1639 ret = ptrace_attach(child);
1640 if (!ret)
1641 arch_ptrace_attach(child);
1642 goto out_tsk;
1644 =======
1645 void
1646 user_disable_single_step (struct task_struct *child)
1648 struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
1649 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1651 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1652 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1653 if (ret < 0)
1654 goto out_tsk;
1655 =======
1656 /* make sure the single step/taken-branch trap bits are not set: */
1657 clear_tsk_thread_flag(child, TIF_SINGLESTEP);
1658 child_psr->ss = 0;
1659 child_psr->tb = 0;
1661 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1663 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1664 pt = task_pt_regs(child);
1665 sw = (struct switch_stack *) (child->thread.ksp + 16);
1666 =======
1668 * Called by kernel/ptrace.c when detaching..
1670 * Make sure the single step bit is not set.
1672 void
1673 ptrace_disable (struct task_struct *child)
1675 user_disable_single_step(child);
1677 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1679 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1680 =======
1681 long
1682 arch_ptrace (struct task_struct *child, long request, long addr, long data)
1684 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1685 switch (request) {
1686 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1687 case PTRACE_PEEKTEXT:
1688 case PTRACE_PEEKDATA:
1689 =======
1690 case PTRACE_PEEKTEXT:
1691 case PTRACE_PEEKDATA:
1692 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1693 /* read word at location addr */
1694 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1695 urbs_end = ia64_get_user_rbs_end(child, pt, NULL);
1696 ret = ia64_peek(child, sw, urbs_end, addr, &data);
1697 if (ret == 0) {
1698 ret = data;
1699 /* ensure "ret" is not mistaken as an error code: */
1700 force_successful_syscall_return();
1702 goto out_tsk;
1704 case PTRACE_POKETEXT:
1705 case PTRACE_POKEDATA:
1706 /* write the word at location addr */
1707 urbs_end = ia64_get_user_rbs_end(child, pt, NULL);
1708 ret = ia64_poke(child, sw, urbs_end, addr, data);
1710 /* Make sure user RBS has the latest data */
1711 unw_init_from_blocked_task(&info, child);
1712 do_sync_rbs(&info, ia64_sync_user_rbs);
1713 =======
1714 if (access_process_vm(child, addr, &data, sizeof(data), 0)
1715 != sizeof(data))
1716 return -EIO;
1717 /* ensure return value is not mistaken for error code */
1718 force_successful_syscall_return();
1719 return data;
1720 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1722 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1723 goto out_tsk;
1724 =======
1725 /* PTRACE_POKETEXT and PTRACE_POKEDATA is handled
1726 * by the generic ptrace_request().
1728 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1730 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1731 case PTRACE_PEEKUSR:
1732 =======
1733 case PTRACE_PEEKUSR:
1734 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1735 /* read the word at addr in the USER area */
1736 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1737 if (access_uarea(child, addr, &data, 0) < 0) {
1738 ret = -EIO;
1739 goto out_tsk;
1741 ret = data;
1742 /* ensure "ret" is not mistaken as an error code */
1743 =======
1744 if (access_uarea(child, addr, &data, 0) < 0)
1745 return -EIO;
1746 /* ensure return value is not mistaken for error code */
1747 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1748 force_successful_syscall_return();
1749 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1750 goto out_tsk;
1751 =======
1752 return data;
1753 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1755 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1756 case PTRACE_POKEUSR:
1757 =======
1758 case PTRACE_POKEUSR:
1759 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1760 /* write the word at addr in the USER area */
1761 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1762 if (access_uarea(child, addr, &data, 1) < 0) {
1763 ret = -EIO;
1764 goto out_tsk;
1766 ret = 0;
1767 goto out_tsk;
1768 =======
1769 if (access_uarea(child, addr, &data, 1) < 0)
1770 return -EIO;
1771 return 0;
1772 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1774 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1775 case PTRACE_OLD_GETSIGINFO:
1776 =======
1777 case PTRACE_OLD_GETSIGINFO:
1778 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1779 /* for backwards-compatibility */
1780 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1781 ret = ptrace_request(child, PTRACE_GETSIGINFO, addr, data);
1782 goto out_tsk;
1783 =======
1784 return ptrace_request(child, PTRACE_GETSIGINFO, addr, data);
1785 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1787 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1788 case PTRACE_OLD_SETSIGINFO:
1789 =======
1790 case PTRACE_OLD_SETSIGINFO:
1791 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1792 /* for backwards-compatibility */
1793 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1794 ret = ptrace_request(child, PTRACE_SETSIGINFO, addr, data);
1795 goto out_tsk;
1797 case PTRACE_SYSCALL:
1798 /* continue and stop at next (return from) syscall */
1799 case PTRACE_CONT:
1800 /* restart after signal. */
1801 ret = -EIO;
1802 if (!valid_signal(data))
1803 goto out_tsk;
1804 if (request == PTRACE_SYSCALL)
1805 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
1806 else
1807 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
1808 child->exit_code = data;
1809 =======
1810 return ptrace_request(child, PTRACE_SETSIGINFO, addr, data);
1811 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1813 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1815 * Make sure the single step/taken-branch trap bits
1816 * are not set:
1818 clear_tsk_thread_flag(child, TIF_SINGLESTEP);
1819 ia64_psr(pt)->ss = 0;
1820 ia64_psr(pt)->tb = 0;
1821 =======
1822 case PTRACE_GETREGS:
1823 return ptrace_getregs(child,
1824 (struct pt_all_user_regs __user *) data);
1825 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1827 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1828 wake_up_process(child);
1829 ret = 0;
1830 goto out_tsk;
1831 =======
1832 case PTRACE_SETREGS:
1833 return ptrace_setregs(child,
1834 (struct pt_all_user_regs __user *) data);
1835 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1837 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1838 case PTRACE_KILL:
1840 * Make the child exit. Best I can do is send it a
1841 * sigkill. Perhaps it should be put in the status
1842 * that it wants to exit.
1844 if (child->exit_state == EXIT_ZOMBIE)
1845 /* already dead */
1846 goto out_tsk;
1847 child->exit_code = SIGKILL;
1849 ptrace_disable(child);
1850 wake_up_process(child);
1851 ret = 0;
1852 goto out_tsk;
1854 case PTRACE_SINGLESTEP:
1855 /* let child execute for one instruction */
1856 case PTRACE_SINGLEBLOCK:
1857 ret = -EIO;
1858 if (!valid_signal(data))
1859 goto out_tsk;
1861 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
1862 set_tsk_thread_flag(child, TIF_SINGLESTEP);
1863 if (request == PTRACE_SINGLESTEP) {
1864 ia64_psr(pt)->ss = 1;
1865 } else {
1866 ia64_psr(pt)->tb = 1;
1868 child->exit_code = data;
1870 /* give it a chance to run. */
1871 wake_up_process(child);
1872 ret = 0;
1873 goto out_tsk;
1875 case PTRACE_DETACH:
1876 /* detach a process that was attached. */
1877 ret = ptrace_detach(child, data);
1878 goto out_tsk;
1880 case PTRACE_GETREGS:
1881 ret = ptrace_getregs(child,
1882 (struct pt_all_user_regs __user *) data);
1883 goto out_tsk;
1885 case PTRACE_SETREGS:
1886 ret = ptrace_setregs(child,
1887 (struct pt_all_user_regs __user *) data);
1888 goto out_tsk;
1890 default:
1891 ret = ptrace_request(child, request, addr, data);
1892 goto out_tsk;
1893 =======
1894 default:
1895 return ptrace_request(child, request, addr, data);
1896 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1898 <<<<<<< HEAD:arch/ia64/kernel/ptrace.c
1899 out_tsk:
1900 put_task_struct(child);
1901 out:
1902 unlock_kernel();
1903 return ret;
1904 =======
1905 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/ia64/kernel/ptrace.c
1909 static void
1910 syscall_trace (void)
1913 * The 0x80 provides a way for the tracing parent to
1914 * distinguish between a syscall stop and SIGTRAP delivery.
1916 ptrace_notify(SIGTRAP
1917 | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
1920 * This isn't the same as continuing with a signal, but it
1921 * will do for normal use. strace only continues with a
1922 * signal if the stopping signal is not SIGTRAP. -brl
1924 if (current->exit_code) {
1925 send_sig(current->exit_code, current, 1);
1926 current->exit_code = 0;
1930 /* "asmlinkage" so the input arguments are preserved... */
1932 asmlinkage void
1933 syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
1934 long arg4, long arg5, long arg6, long arg7,
1935 struct pt_regs regs)
1937 if (test_thread_flag(TIF_SYSCALL_TRACE)
1938 && (current->ptrace & PT_PTRACED))
1939 syscall_trace();
1941 /* copy user rbs to kernel rbs */
1942 if (test_thread_flag(TIF_RESTORE_RSE))
1943 ia64_sync_krbs();
1945 if (unlikely(current->audit_context)) {
1946 long syscall;
1947 int arch;
1949 if (IS_IA32_PROCESS(&regs)) {
1950 syscall = regs.r1;
1951 arch = AUDIT_ARCH_I386;
1952 } else {
1953 syscall = regs.r15;
1954 arch = AUDIT_ARCH_IA64;
1957 audit_syscall_entry(arch, syscall, arg0, arg1, arg2, arg3);
1962 /* "asmlinkage" so the input arguments are preserved... */
1964 asmlinkage void
1965 syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
1966 long arg4, long arg5, long arg6, long arg7,
1967 struct pt_regs regs)
1969 if (unlikely(current->audit_context)) {
1970 int success = AUDITSC_RESULT(regs.r10);
1971 long result = regs.r8;
1973 if (success != AUDITSC_SUCCESS)
1974 result = -result;
1975 audit_syscall_exit(success, result);
1978 if ((test_thread_flag(TIF_SYSCALL_TRACE)
1979 || test_thread_flag(TIF_SINGLESTEP))
1980 && (current->ptrace & PT_PTRACED))
1981 syscall_trace();
1983 /* copy user rbs to kernel rbs */
1984 if (test_thread_flag(TIF_RESTORE_RSE))
1985 ia64_sync_krbs();