Merge master.kernel.org:/pub/scm/linux/kernel/git/tglx/hrtimer-2.6
[linux-2.6] / arch / sparc64 / kernel / ptrace.c
1 /* ptrace.c: Sparc process tracing support.
2  *
3  * Copyright (C) 1996 David S. Miller (davem@caipfs.rutgers.edu)
4  * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5  *
6  * Based upon code written by Ross Biro, Linus Torvalds, Bob Manson,
7  * and David Mosberger.
8  *
9  * Added Linux support -miguel (weird, eh?, the original code was meant
10  * to emulate SunOS).
11  */
12
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/mm.h>
16 #include <linux/errno.h>
17 #include <linux/ptrace.h>
18 #include <linux/user.h>
19 #include <linux/smp.h>
20 #include <linux/smp_lock.h>
21 #include <linux/security.h>
22 #include <linux/seccomp.h>
23 #include <linux/audit.h>
24 #include <linux/signal.h>
25
26 #include <asm/asi.h>
27 #include <asm/pgtable.h>
28 #include <asm/system.h>
29 #include <asm/uaccess.h>
30 #include <asm/psrcompat.h>
31 #include <asm/visasm.h>
32 #include <asm/spitfire.h>
33 #include <asm/page.h>
34 #include <asm/cpudata.h>
35
36 /* Returning from ptrace is a bit tricky because the syscall return
37  * low level code assumes any value returned which is negative and
38  * is a valid errno will mean setting the condition codes to indicate
39  * an error return.  This doesn't work, so we have this hook.
40  */
41 static inline void pt_error_return(struct pt_regs *regs, unsigned long error)
42 {
43         regs->u_regs[UREG_I0] = error;
44         regs->tstate |= (TSTATE_ICARRY | TSTATE_XCARRY);
45         regs->tpc = regs->tnpc;
46         regs->tnpc += 4;
47 }
48
49 static inline void pt_succ_return(struct pt_regs *regs, unsigned long value)
50 {
51         regs->u_regs[UREG_I0] = value;
52         regs->tstate &= ~(TSTATE_ICARRY | TSTATE_XCARRY);
53         regs->tpc = regs->tnpc;
54         regs->tnpc += 4;
55 }
56
57 static inline void
58 pt_succ_return_linux(struct pt_regs *regs, unsigned long value, void __user *addr)
59 {
60         if (test_thread_flag(TIF_32BIT)) {
61                 if (put_user(value, (unsigned int __user *) addr)) {
62                         pt_error_return(regs, EFAULT);
63                         return;
64                 }
65         } else {
66                 if (put_user(value, (long __user *) addr)) {
67                         pt_error_return(regs, EFAULT);
68                         return;
69                 }
70         }
71         regs->u_regs[UREG_I0] = 0;
72         regs->tstate &= ~(TSTATE_ICARRY | TSTATE_XCARRY);
73         regs->tpc = regs->tnpc;
74         regs->tnpc += 4;
75 }
76
77 static void
78 pt_os_succ_return (struct pt_regs *regs, unsigned long val, void __user *addr)
79 {
80         if (current->personality == PER_SUNOS)
81                 pt_succ_return (regs, val);
82         else
83                 pt_succ_return_linux (regs, val, addr);
84 }
85
86 /* #define ALLOW_INIT_TRACING */
87 /* #define DEBUG_PTRACE */
88
89 #ifdef DEBUG_PTRACE
90 char *pt_rq [] = {
91         /* 0  */ "TRACEME", "PEEKTEXT", "PEEKDATA", "PEEKUSR",
92         /* 4  */ "POKETEXT", "POKEDATA", "POKEUSR", "CONT",
93         /* 8  */ "KILL", "SINGLESTEP", "SUNATTACH", "SUNDETACH",
94         /* 12 */ "GETREGS", "SETREGS", "GETFPREGS", "SETFPREGS",
95         /* 16 */ "READDATA", "WRITEDATA", "READTEXT", "WRITETEXT",
96         /* 20 */ "GETFPAREGS", "SETFPAREGS", "unknown", "unknown",
97         /* 24 */ "SYSCALL", ""
98 };
99 #endif
100
101 /*
102  * Called by kernel/ptrace.c when detaching..
103  *
104  * Make sure single step bits etc are not set.
105  */
106 void ptrace_disable(struct task_struct *child)
107 {
108         /* nothing to do */
109 }
110
111 /* To get the necessary page struct, access_process_vm() first calls
112  * get_user_pages().  This has done a flush_dcache_page() on the
113  * accessed page.  Then our caller (copy_{to,from}_user_page()) did
114  * to memcpy to read/write the data from that page.
115  *
116  * Now, the only thing we have to do is:
117  * 1) flush the D-cache if it's possible than an illegal alias
118  *    has been created
119  * 2) flush the I-cache if this is pre-cheetah and we did a write
120  */
121 void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
122                          unsigned long uaddr, void *kaddr,
123                          unsigned long len, int write)
124 {
125         BUG_ON(len > PAGE_SIZE);
126
127 #ifdef DCACHE_ALIASING_POSSIBLE
128         /* If bit 13 of the kernel address we used to access the
129          * user page is the same as the virtual address that page
130          * is mapped to in the user's address space, we can skip the
131          * D-cache flush.
132          */
133         if ((uaddr ^ (unsigned long) kaddr) & (1UL << 13)) {
134                 unsigned long start = __pa(kaddr);
135                 unsigned long end = start + len;
136                 unsigned long dcache_line_size;
137
138                 dcache_line_size = local_cpu_data().dcache_line_size;
139
140                 if (tlb_type == spitfire) {
141                         for (; start < end; start += dcache_line_size)
142                                 spitfire_put_dcache_tag(start & 0x3fe0, 0x0);
143                 } else {
144                         start &= ~(dcache_line_size - 1);
145                         for (; start < end; start += dcache_line_size)
146                                 __asm__ __volatile__(
147                                         "stxa %%g0, [%0] %1\n\t"
148                                         "membar #Sync"
149                                         : /* no outputs */
150                                         : "r" (start),
151                                         "i" (ASI_DCACHE_INVALIDATE));
152                 }
153         }
154 #endif
155         if (write && tlb_type == spitfire) {
156                 unsigned long start = (unsigned long) kaddr;
157                 unsigned long end = start + len;
158                 unsigned long icache_line_size;
159
160                 icache_line_size = local_cpu_data().icache_line_size;
161
162                 for (; start < end; start += icache_line_size)
163                         flushi(start);
164         }
165 }
166
167 asmlinkage void do_ptrace(struct pt_regs *regs)
168 {
169         int request = regs->u_regs[UREG_I0];
170         pid_t pid = regs->u_regs[UREG_I1];
171         unsigned long addr = regs->u_regs[UREG_I2];
172         unsigned long data = regs->u_regs[UREG_I3];
173         unsigned long addr2 = regs->u_regs[UREG_I4];
174         struct task_struct *child;
175         int ret;
176
177         if (test_thread_flag(TIF_32BIT)) {
178                 addr &= 0xffffffffUL;
179                 data &= 0xffffffffUL;
180                 addr2 &= 0xffffffffUL;
181         }
182         lock_kernel();
183 #ifdef DEBUG_PTRACE
184         {
185                 char *s;
186
187                 if ((request >= 0) && (request <= 24))
188                         s = pt_rq [request];
189                 else
190                         s = "unknown";
191
192                 if (request == PTRACE_POKEDATA && data == 0x91d02001){
193                         printk ("do_ptrace: breakpoint pid=%d, addr=%016lx addr2=%016lx\n",
194                                 pid, addr, addr2);
195                 } else 
196                         printk("do_ptrace: rq=%s(%d) pid=%d addr=%016lx data=%016lx addr2=%016lx\n",
197                                s, request, pid, addr, data, addr2);
198         }
199 #endif
200         if (request == PTRACE_TRACEME) {
201                 ret = ptrace_traceme();
202                 pt_succ_return(regs, 0);
203                 goto out;
204         }
205
206         child = ptrace_get_task_struct(pid);
207         if (IS_ERR(child)) {
208                 ret = PTR_ERR(child);
209                 pt_error_return(regs, -ret);
210                 goto out;
211         }
212
213         if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH)
214             || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) {
215                 if (ptrace_attach(child)) {
216                         pt_error_return(regs, EPERM);
217                         goto out_tsk;
218                 }
219                 pt_succ_return(regs, 0);
220                 goto out_tsk;
221         }
222
223         ret = ptrace_check_attach(child, request == PTRACE_KILL);
224         if (ret < 0) {
225                 pt_error_return(regs, -ret);
226                 goto out_tsk;
227         }
228
229         if (!(test_thread_flag(TIF_32BIT))      &&
230             ((request == PTRACE_READDATA64)             ||
231              (request == PTRACE_WRITEDATA64)            ||
232              (request == PTRACE_READTEXT64)             ||
233              (request == PTRACE_WRITETEXT64)            ||
234              (request == PTRACE_PEEKTEXT64)             ||
235              (request == PTRACE_POKETEXT64)             ||
236              (request == PTRACE_PEEKDATA64)             ||
237              (request == PTRACE_POKEDATA64))) {
238                 addr = regs->u_regs[UREG_G2];
239                 addr2 = regs->u_regs[UREG_G3];
240                 request -= 30; /* wheee... */
241         }
242
243         switch(request) {
244         case PTRACE_PEEKTEXT: /* read word at location addr. */ 
245         case PTRACE_PEEKDATA: {
246                 unsigned long tmp64;
247                 unsigned int tmp32;
248                 int res, copied;
249
250                 res = -EIO;
251                 if (test_thread_flag(TIF_32BIT)) {
252                         copied = access_process_vm(child, addr,
253                                                    &tmp32, sizeof(tmp32), 0);
254                         tmp64 = (unsigned long) tmp32;
255                         if (copied == sizeof(tmp32))
256                                 res = 0;
257                 } else {
258                         copied = access_process_vm(child, addr,
259                                                    &tmp64, sizeof(tmp64), 0);
260                         if (copied == sizeof(tmp64))
261                                 res = 0;
262                 }
263                 if (res < 0)
264                         pt_error_return(regs, -res);
265                 else
266                         pt_os_succ_return(regs, tmp64, (void __user *) data);
267                 goto out_tsk;
268         }
269
270         case PTRACE_POKETEXT: /* write the word at location addr. */
271         case PTRACE_POKEDATA: {
272                 unsigned long tmp64;
273                 unsigned int tmp32;
274                 int copied, res = -EIO;
275
276                 if (test_thread_flag(TIF_32BIT)) {
277                         tmp32 = data;
278                         copied = access_process_vm(child, addr,
279                                                    &tmp32, sizeof(tmp32), 1);
280                         if (copied == sizeof(tmp32))
281                                 res = 0;
282                 } else {
283                         tmp64 = data;
284                         copied = access_process_vm(child, addr,
285                                                    &tmp64, sizeof(tmp64), 1);
286                         if (copied == sizeof(tmp64))
287                                 res = 0;
288                 }
289                 if (res < 0)
290                         pt_error_return(regs, -res);
291                 else
292                         pt_succ_return(regs, res);
293                 goto out_tsk;
294         }
295
296         case PTRACE_GETREGS: {
297                 struct pt_regs32 __user *pregs =
298                         (struct pt_regs32 __user *) addr;
299                 struct pt_regs *cregs = task_pt_regs(child);
300                 int rval;
301
302                 if (__put_user(tstate_to_psr(cregs->tstate), (&pregs->psr)) ||
303                     __put_user(cregs->tpc, (&pregs->pc)) ||
304                     __put_user(cregs->tnpc, (&pregs->npc)) ||
305                     __put_user(cregs->y, (&pregs->y))) {
306                         pt_error_return(regs, EFAULT);
307                         goto out_tsk;
308                 }
309                 for (rval = 1; rval < 16; rval++)
310                         if (__put_user(cregs->u_regs[rval], (&pregs->u_regs[rval - 1]))) {
311                                 pt_error_return(regs, EFAULT);
312                                 goto out_tsk;
313                         }
314                 pt_succ_return(regs, 0);
315 #ifdef DEBUG_PTRACE
316                 printk ("PC=%lx nPC=%lx o7=%lx\n", cregs->tpc, cregs->tnpc, cregs->u_regs [15]);
317 #endif
318                 goto out_tsk;
319         }
320
321         case PTRACE_GETREGS64: {
322                 struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
323                 struct pt_regs *cregs = task_pt_regs(child);
324                 unsigned long tpc = cregs->tpc;
325                 int rval;
326
327                 if ((task_thread_info(child)->flags & _TIF_32BIT) != 0)
328                         tpc &= 0xffffffff;
329                 if (__put_user(cregs->tstate, (&pregs->tstate)) ||
330                     __put_user(tpc, (&pregs->tpc)) ||
331                     __put_user(cregs->tnpc, (&pregs->tnpc)) ||
332                     __put_user(cregs->y, (&pregs->y))) {
333                         pt_error_return(regs, EFAULT);
334                         goto out_tsk;
335                 }
336                 for (rval = 1; rval < 16; rval++)
337                         if (__put_user(cregs->u_regs[rval], (&pregs->u_regs[rval - 1]))) {
338                                 pt_error_return(regs, EFAULT);
339                                 goto out_tsk;
340                         }
341                 pt_succ_return(regs, 0);
342 #ifdef DEBUG_PTRACE
343                 printk ("PC=%lx nPC=%lx o7=%lx\n", cregs->tpc, cregs->tnpc, cregs->u_regs [15]);
344 #endif
345                 goto out_tsk;
346         }
347
348         case PTRACE_SETREGS: {
349                 struct pt_regs32 __user *pregs =
350                         (struct pt_regs32 __user *) addr;
351                 struct pt_regs *cregs = task_pt_regs(child);
352                 unsigned int psr, pc, npc, y;
353                 int i;
354
355                 /* Must be careful, tracing process can only set certain
356                  * bits in the psr.
357                  */
358                 if (__get_user(psr, (&pregs->psr)) ||
359                     __get_user(pc, (&pregs->pc)) ||
360                     __get_user(npc, (&pregs->npc)) ||
361                     __get_user(y, (&pregs->y))) {
362                         pt_error_return(regs, EFAULT);
363                         goto out_tsk;
364                 }
365                 cregs->tstate &= ~(TSTATE_ICC);
366                 cregs->tstate |= psr_to_tstate_icc(psr);
367                 if (!((pc | npc) & 3)) {
368                         cregs->tpc = pc;
369                         cregs->tnpc = npc;
370                 }
371                 cregs->y = y;
372                 for (i = 1; i < 16; i++) {
373                         if (__get_user(cregs->u_regs[i], (&pregs->u_regs[i-1]))) {
374                                 pt_error_return(regs, EFAULT);
375                                 goto out_tsk;
376                         }
377                 }
378                 pt_succ_return(regs, 0);
379                 goto out_tsk;
380         }
381
382         case PTRACE_SETREGS64: {
383                 struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
384                 struct pt_regs *cregs = task_pt_regs(child);
385                 unsigned long tstate, tpc, tnpc, y;
386                 int i;
387
388                 /* Must be careful, tracing process can only set certain
389                  * bits in the psr.
390                  */
391                 if (__get_user(tstate, (&pregs->tstate)) ||
392                     __get_user(tpc, (&pregs->tpc)) ||
393                     __get_user(tnpc, (&pregs->tnpc)) ||
394                     __get_user(y, (&pregs->y))) {
395                         pt_error_return(regs, EFAULT);
396                         goto out_tsk;
397                 }
398                 if ((task_thread_info(child)->flags & _TIF_32BIT) != 0) {
399                         tpc &= 0xffffffff;
400                         tnpc &= 0xffffffff;
401                 }
402                 tstate &= (TSTATE_ICC | TSTATE_XCC);
403                 cregs->tstate &= ~(TSTATE_ICC | TSTATE_XCC);
404                 cregs->tstate |= tstate;
405                 if (!((tpc | tnpc) & 3)) {
406                         cregs->tpc = tpc;
407                         cregs->tnpc = tnpc;
408                 }
409                 cregs->y = y;
410                 for (i = 1; i < 16; i++) {
411                         if (__get_user(cregs->u_regs[i], (&pregs->u_regs[i-1]))) {
412                                 pt_error_return(regs, EFAULT);
413                                 goto out_tsk;
414                         }
415                 }
416                 pt_succ_return(regs, 0);
417                 goto out_tsk;
418         }
419
420         case PTRACE_GETFPREGS: {
421                 struct fps {
422                         unsigned int regs[32];
423                         unsigned int fsr;
424                         unsigned int flags;
425                         unsigned int extra;
426                         unsigned int fpqd;
427                         struct fq {
428                                 unsigned int insnaddr;
429                                 unsigned int insn;
430                         } fpq[16];
431                 };
432                 struct fps __user *fps = (struct fps __user *) addr;
433                 unsigned long *fpregs = task_thread_info(child)->fpregs;
434
435                 if (copy_to_user(&fps->regs[0], fpregs,
436                                  (32 * sizeof(unsigned int))) ||
437                     __put_user(task_thread_info(child)->xfsr[0], (&fps->fsr)) ||
438                     __put_user(0, (&fps->fpqd)) ||
439                     __put_user(0, (&fps->flags)) ||
440                     __put_user(0, (&fps->extra)) ||
441                     clear_user(&fps->fpq[0], 32 * sizeof(unsigned int))) {
442                         pt_error_return(regs, EFAULT);
443                         goto out_tsk;
444                 }
445                 pt_succ_return(regs, 0);
446                 goto out_tsk;
447         }
448
449         case PTRACE_GETFPREGS64: {
450                 struct fps {
451                         unsigned int regs[64];
452                         unsigned long fsr;
453                 };
454                 struct fps __user *fps = (struct fps __user *) addr;
455                 unsigned long *fpregs = task_thread_info(child)->fpregs;
456
457                 if (copy_to_user(&fps->regs[0], fpregs,
458                                  (64 * sizeof(unsigned int))) ||
459                     __put_user(task_thread_info(child)->xfsr[0], (&fps->fsr))) {
460                         pt_error_return(regs, EFAULT);
461                         goto out_tsk;
462                 }
463                 pt_succ_return(regs, 0);
464                 goto out_tsk;
465         }
466
467         case PTRACE_SETFPREGS: {
468                 struct fps {
469                         unsigned int regs[32];
470                         unsigned int fsr;
471                         unsigned int flags;
472                         unsigned int extra;
473                         unsigned int fpqd;
474                         struct fq {
475                                 unsigned int insnaddr;
476                                 unsigned int insn;
477                         } fpq[16];
478                 };
479                 struct fps __user *fps = (struct fps __user *) addr;
480                 unsigned long *fpregs = task_thread_info(child)->fpregs;
481                 unsigned fsr;
482
483                 if (copy_from_user(fpregs, &fps->regs[0],
484                                    (32 * sizeof(unsigned int))) ||
485                     __get_user(fsr, (&fps->fsr))) {
486                         pt_error_return(regs, EFAULT);
487                         goto out_tsk;
488                 }
489                 task_thread_info(child)->xfsr[0] &= 0xffffffff00000000UL;
490                 task_thread_info(child)->xfsr[0] |= fsr;
491                 if (!(task_thread_info(child)->fpsaved[0] & FPRS_FEF))
492                         task_thread_info(child)->gsr[0] = 0;
493                 task_thread_info(child)->fpsaved[0] |= (FPRS_FEF | FPRS_DL);
494                 pt_succ_return(regs, 0);
495                 goto out_tsk;
496         }
497
498         case PTRACE_SETFPREGS64: {
499                 struct fps {
500                         unsigned int regs[64];
501                         unsigned long fsr;
502                 };
503                 struct fps __user *fps = (struct fps __user *) addr;
504                 unsigned long *fpregs = task_thread_info(child)->fpregs;
505
506                 if (copy_from_user(fpregs, &fps->regs[0],
507                                    (64 * sizeof(unsigned int))) ||
508                     __get_user(task_thread_info(child)->xfsr[0], (&fps->fsr))) {
509                         pt_error_return(regs, EFAULT);
510                         goto out_tsk;
511                 }
512                 if (!(task_thread_info(child)->fpsaved[0] & FPRS_FEF))
513                         task_thread_info(child)->gsr[0] = 0;
514                 task_thread_info(child)->fpsaved[0] |= (FPRS_FEF | FPRS_DL | FPRS_DU);
515                 pt_succ_return(regs, 0);
516                 goto out_tsk;
517         }
518
519         case PTRACE_READTEXT:
520         case PTRACE_READDATA: {
521                 int res = ptrace_readdata(child, addr,
522                                           (char __user *)addr2, data);
523                 if (res == data) {
524                         pt_succ_return(regs, 0);
525                         goto out_tsk;
526                 }
527                 if (res >= 0)
528                         res = -EIO;
529                 pt_error_return(regs, -res);
530                 goto out_tsk;
531         }
532
533         case PTRACE_WRITETEXT:
534         case PTRACE_WRITEDATA: {
535                 int res = ptrace_writedata(child, (char __user *) addr2,
536                                            addr, data);
537                 if (res == data) {
538                         pt_succ_return(regs, 0);
539                         goto out_tsk;
540                 }
541                 if (res >= 0)
542                         res = -EIO;
543                 pt_error_return(regs, -res);
544                 goto out_tsk;
545         }
546         case PTRACE_SYSCALL: /* continue and stop at (return from) syscall */
547                 addr = 1;
548
549         case PTRACE_CONT: { /* restart after signal. */
550                 if (!valid_signal(data)) {
551                         pt_error_return(regs, EIO);
552                         goto out_tsk;
553                 }
554
555                 if (request == PTRACE_SYSCALL) {
556                         set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
557                 } else {
558                         clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
559                 }
560
561                 child->exit_code = data;
562 #ifdef DEBUG_PTRACE
563                 printk("CONT: %s [%d]: set exit_code = %x %lx %lx\n", child->comm,
564                         child->pid, child->exit_code,
565                         task_pt_regs(child)->tpc,
566                         task_pt_regs(child)->tnpc);
567                        
568 #endif
569                 wake_up_process(child);
570                 pt_succ_return(regs, 0);
571                 goto out_tsk;
572         }
573
574 /*
575  * make the child exit.  Best I can do is send it a sigkill. 
576  * perhaps it should be put in the status that it wants to 
577  * exit.
578  */
579         case PTRACE_KILL: {
580                 if (child->exit_state == EXIT_ZOMBIE) { /* already dead */
581                         pt_succ_return(regs, 0);
582                         goto out_tsk;
583                 }
584                 child->exit_code = SIGKILL;
585                 wake_up_process(child);
586                 pt_succ_return(regs, 0);
587                 goto out_tsk;
588         }
589
590         case PTRACE_SUNDETACH: { /* detach a process that was attached. */
591                 int error = ptrace_detach(child, data);
592                 if (error) {
593                         pt_error_return(regs, EIO);
594                         goto out_tsk;
595                 }
596                 pt_succ_return(regs, 0);
597                 goto out_tsk;
598         }
599
600         /* PTRACE_DUMPCORE unsupported... */
601
602         default: {
603                 int err = ptrace_request(child, request, addr, data);
604                 if (err)
605                         pt_error_return(regs, -err);
606                 else
607                         pt_succ_return(regs, 0);
608                 goto out_tsk;
609         }
610         }
611 out_tsk:
612         if (child)
613                 put_task_struct(child);
614 out:
615         unlock_kernel();
616 }
617
618 asmlinkage void syscall_trace(struct pt_regs *regs, int syscall_exit_p)
619 {
620         /* do the secure computing check first */
621         secure_computing(regs->u_regs[UREG_G1]);
622
623         if (unlikely(current->audit_context) && syscall_exit_p) {
624                 unsigned long tstate = regs->tstate;
625                 int result = AUDITSC_SUCCESS;
626
627                 if (unlikely(tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
628                         result = AUDITSC_FAILURE;
629
630                 audit_syscall_exit(current, result, regs->u_regs[UREG_I0]);
631         }
632
633         if (!(current->ptrace & PT_PTRACED))
634                 goto out;
635
636         if (!test_thread_flag(TIF_SYSCALL_TRACE))
637                 goto out;
638
639         ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
640                                  ? 0x80 : 0));
641
642         /*
643          * this isn't the same as continuing with a signal, but it will do
644          * for normal use.  strace only continues with a signal if the
645          * stopping signal is not SIGTRAP.  -brl
646          */
647         if (current->exit_code) {
648                 send_sig(current->exit_code, current, 1);
649                 current->exit_code = 0;
650         }
651
652 out:
653         if (unlikely(current->audit_context) && !syscall_exit_p)
654                 audit_syscall_entry(current,
655                                     (test_thread_flag(TIF_32BIT) ?
656                                      AUDIT_ARCH_SPARC :
657                                      AUDIT_ARCH_SPARC64),
658                                     regs->u_regs[UREG_G1],
659                                     regs->u_regs[UREG_I0],
660                                     regs->u_regs[UREG_I1],
661                                     regs->u_regs[UREG_I2],
662                                     regs->u_regs[UREG_I3]);
663 }