Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* ptrace.c: Sparc process tracing support. |
| 2 | * |
David S. Miller | d09c2a2 | 2008-02-06 23:02:08 -0800 | [diff] [blame] | 3 | * Copyright (C) 1996, 2008 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
David S. Miller | f7ceba3 | 2005-07-10 19:29:45 -0700 | [diff] [blame] | 22 | #include <linux/seccomp.h> |
| 23 | #include <linux/audit.h> |
Jesper Juhl | 7ed20e1 | 2005-05-01 08:59:14 -0700 | [diff] [blame] | 24 | #include <linux/signal.h> |
David S. Miller | d09c2a2 | 2008-02-06 23:02:08 -0800 | [diff] [blame] | 25 | #include <linux/regset.h> |
| 26 | #include <linux/compat.h> |
| 27 | #include <linux/elf.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
| 29 | #include <asm/asi.h> |
| 30 | #include <asm/pgtable.h> |
| 31 | #include <asm/system.h> |
| 32 | #include <asm/uaccess.h> |
| 33 | #include <asm/psrcompat.h> |
| 34 | #include <asm/visasm.h> |
| 35 | #include <asm/spitfire.h> |
David S. Miller | 6a9b490 | 2005-09-19 20:11:57 -0700 | [diff] [blame] | 36 | #include <asm/page.h> |
David S. Miller | 717463d | 2005-09-29 18:50:34 -0700 | [diff] [blame] | 37 | #include <asm/cpudata.h> |
David S. Miller | bfdf9eb | 2008-03-26 00:46:21 -0700 | [diff] [blame] | 38 | #include <asm/cacheflush.h> |
| 39 | |
| 40 | #include "entry.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | /* #define ALLOW_INIT_TRACING */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | /* |
| 45 | * Called by kernel/ptrace.c when detaching.. |
| 46 | * |
| 47 | * Make sure single step bits etc are not set. |
| 48 | */ |
| 49 | void ptrace_disable(struct task_struct *child) |
| 50 | { |
| 51 | /* nothing to do */ |
| 52 | } |
| 53 | |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 54 | /* To get the necessary page struct, access_process_vm() first calls |
| 55 | * get_user_pages(). This has done a flush_dcache_page() on the |
| 56 | * accessed page. Then our caller (copy_{to,from}_user_page()) did |
| 57 | * to memcpy to read/write the data from that page. |
| 58 | * |
| 59 | * Now, the only thing we have to do is: |
| 60 | * 1) flush the D-cache if it's possible than an illegal alias |
| 61 | * has been created |
| 62 | * 2) flush the I-cache if this is pre-cheetah and we did a write |
| 63 | */ |
| 64 | void flush_ptrace_access(struct vm_area_struct *vma, struct page *page, |
| 65 | unsigned long uaddr, void *kaddr, |
| 66 | unsigned long len, int write) |
| 67 | { |
| 68 | BUG_ON(len > PAGE_SIZE); |
| 69 | |
David S. Miller | 7adb37f | 2006-02-17 15:07:43 -0800 | [diff] [blame] | 70 | if (tlb_type == hypervisor) |
| 71 | return; |
| 72 | |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 73 | #ifdef DCACHE_ALIASING_POSSIBLE |
| 74 | /* If bit 13 of the kernel address we used to access the |
| 75 | * user page is the same as the virtual address that page |
| 76 | * is mapped to in the user's address space, we can skip the |
| 77 | * D-cache flush. |
| 78 | */ |
David S. Miller | 6a9b490 | 2005-09-19 20:11:57 -0700 | [diff] [blame] | 79 | if ((uaddr ^ (unsigned long) kaddr) & (1UL << 13)) { |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 80 | unsigned long start = __pa(kaddr); |
| 81 | unsigned long end = start + len; |
David S. Miller | 717463d | 2005-09-29 18:50:34 -0700 | [diff] [blame] | 82 | unsigned long dcache_line_size; |
| 83 | |
| 84 | dcache_line_size = local_cpu_data().dcache_line_size; |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 85 | |
| 86 | if (tlb_type == spitfire) { |
David S. Miller | 717463d | 2005-09-29 18:50:34 -0700 | [diff] [blame] | 87 | for (; start < end; start += dcache_line_size) |
David S. Miller | 6a9b490 | 2005-09-19 20:11:57 -0700 | [diff] [blame] | 88 | spitfire_put_dcache_tag(start & 0x3fe0, 0x0); |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 89 | } else { |
David S. Miller | 717463d | 2005-09-29 18:50:34 -0700 | [diff] [blame] | 90 | start &= ~(dcache_line_size - 1); |
| 91 | for (; start < end; start += dcache_line_size) |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 92 | __asm__ __volatile__( |
| 93 | "stxa %%g0, [%0] %1\n\t" |
| 94 | "membar #Sync" |
| 95 | : /* no outputs */ |
David S. Miller | 6a9b490 | 2005-09-19 20:11:57 -0700 | [diff] [blame] | 96 | : "r" (start), |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 97 | "i" (ASI_DCACHE_INVALIDATE)); |
| 98 | } |
| 99 | } |
| 100 | #endif |
| 101 | if (write && tlb_type == spitfire) { |
| 102 | unsigned long start = (unsigned long) kaddr; |
| 103 | unsigned long end = start + len; |
David S. Miller | 717463d | 2005-09-29 18:50:34 -0700 | [diff] [blame] | 104 | unsigned long icache_line_size; |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 105 | |
David S. Miller | 717463d | 2005-09-29 18:50:34 -0700 | [diff] [blame] | 106 | icache_line_size = local_cpu_data().icache_line_size; |
| 107 | |
| 108 | for (; start < end; start += icache_line_size) |
David S. Miller | dadeafd | 2005-04-17 18:03:11 -0700 | [diff] [blame] | 109 | flushi(start); |
| 110 | } |
| 111 | } |
| 112 | |
David S. Miller | d09c2a2 | 2008-02-06 23:02:08 -0800 | [diff] [blame] | 113 | enum sparc_regset { |
| 114 | REGSET_GENERAL, |
| 115 | REGSET_FP, |
| 116 | }; |
| 117 | |
| 118 | static int genregs64_get(struct task_struct *target, |
| 119 | const struct user_regset *regset, |
| 120 | unsigned int pos, unsigned int count, |
| 121 | void *kbuf, void __user *ubuf) |
| 122 | { |
| 123 | const struct pt_regs *regs = task_pt_regs(target); |
| 124 | int ret; |
| 125 | |
| 126 | if (target == current) |
| 127 | flushw_user(); |
| 128 | |
| 129 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 130 | regs->u_regs, |
| 131 | 0, 16 * sizeof(u64)); |
| 132 | if (!ret) { |
| 133 | unsigned long __user *reg_window = (unsigned long __user *) |
| 134 | (regs->u_regs[UREG_I6] + STACK_BIAS); |
| 135 | unsigned long window[16]; |
| 136 | |
| 137 | if (copy_from_user(window, reg_window, sizeof(window))) |
| 138 | return -EFAULT; |
| 139 | |
| 140 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 141 | window, |
| 142 | 16 * sizeof(u64), |
| 143 | 32 * sizeof(u64)); |
| 144 | } |
| 145 | |
| 146 | if (!ret) { |
| 147 | /* TSTATE, TPC, TNPC */ |
| 148 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 149 | ®s->tstate, |
| 150 | 32 * sizeof(u64), |
| 151 | 35 * sizeof(u64)); |
| 152 | } |
| 153 | |
| 154 | if (!ret) { |
| 155 | unsigned long y = regs->y; |
| 156 | |
| 157 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 158 | &y, |
| 159 | 35 * sizeof(u64), |
| 160 | 36 * sizeof(u64)); |
| 161 | } |
| 162 | |
| 163 | if (!ret) |
| 164 | ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, |
| 165 | 36 * sizeof(u64), -1); |
| 166 | |
| 167 | return ret; |
| 168 | } |
| 169 | |
| 170 | static int genregs64_set(struct task_struct *target, |
| 171 | const struct user_regset *regset, |
| 172 | unsigned int pos, unsigned int count, |
| 173 | const void *kbuf, const void __user *ubuf) |
| 174 | { |
| 175 | struct pt_regs *regs = task_pt_regs(target); |
| 176 | int ret; |
| 177 | |
| 178 | if (target == current) |
| 179 | flushw_user(); |
| 180 | |
| 181 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 182 | regs->u_regs, |
| 183 | 0, 16 * sizeof(u64)); |
| 184 | if (!ret && count > 0) { |
| 185 | unsigned long __user *reg_window = (unsigned long __user *) |
| 186 | (regs->u_regs[UREG_I6] + STACK_BIAS); |
| 187 | unsigned long window[16]; |
| 188 | |
| 189 | if (copy_from_user(window, reg_window, sizeof(window))) |
| 190 | return -EFAULT; |
| 191 | |
| 192 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 193 | window, |
| 194 | 16 * sizeof(u64), |
| 195 | 32 * sizeof(u64)); |
| 196 | if (!ret && |
| 197 | copy_to_user(reg_window, window, sizeof(window))) |
| 198 | return -EFAULT; |
| 199 | } |
| 200 | |
| 201 | if (!ret && count > 0) { |
| 202 | unsigned long tstate; |
| 203 | |
| 204 | /* TSTATE */ |
| 205 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 206 | &tstate, |
| 207 | 32 * sizeof(u64), |
| 208 | 33 * sizeof(u64)); |
| 209 | if (!ret) { |
| 210 | /* Only the condition codes can be modified |
| 211 | * in the %tstate register. |
| 212 | */ |
| 213 | tstate &= (TSTATE_ICC | TSTATE_XCC); |
| 214 | regs->tstate &= ~(TSTATE_ICC | TSTATE_XCC); |
| 215 | regs->tstate |= tstate; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | if (!ret) { |
| 220 | /* TPC, TNPC */ |
| 221 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 222 | ®s->tpc, |
| 223 | 33 * sizeof(u64), |
| 224 | 35 * sizeof(u64)); |
| 225 | } |
| 226 | |
| 227 | if (!ret) { |
| 228 | unsigned long y; |
| 229 | |
| 230 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 231 | &y, |
| 232 | 35 * sizeof(u64), |
| 233 | 36 * sizeof(u64)); |
| 234 | if (!ret) |
| 235 | regs->y = y; |
| 236 | } |
| 237 | |
| 238 | if (!ret) |
| 239 | ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, |
| 240 | 36 * sizeof(u64), -1); |
| 241 | |
| 242 | return ret; |
| 243 | } |
| 244 | |
| 245 | static int fpregs64_get(struct task_struct *target, |
| 246 | const struct user_regset *regset, |
| 247 | unsigned int pos, unsigned int count, |
| 248 | void *kbuf, void __user *ubuf) |
| 249 | { |
| 250 | const unsigned long *fpregs = task_thread_info(target)->fpregs; |
| 251 | unsigned long fprs, fsr, gsr; |
| 252 | int ret; |
| 253 | |
| 254 | if (target == current) |
| 255 | save_and_clear_fpu(); |
| 256 | |
| 257 | fprs = task_thread_info(target)->fpsaved[0]; |
| 258 | |
| 259 | if (fprs & FPRS_DL) |
| 260 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 261 | fpregs, |
| 262 | 0, 16 * sizeof(u64)); |
| 263 | else |
| 264 | ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, |
| 265 | 0, |
| 266 | 16 * sizeof(u64)); |
| 267 | |
| 268 | if (!ret) { |
| 269 | if (fprs & FPRS_DU) |
| 270 | ret = user_regset_copyout(&pos, &count, |
| 271 | &kbuf, &ubuf, |
| 272 | fpregs + 16, |
| 273 | 16 * sizeof(u64), |
| 274 | 32 * sizeof(u64)); |
| 275 | else |
| 276 | ret = user_regset_copyout_zero(&pos, &count, |
| 277 | &kbuf, &ubuf, |
| 278 | 16 * sizeof(u64), |
| 279 | 32 * sizeof(u64)); |
| 280 | } |
| 281 | |
| 282 | if (fprs & FPRS_FEF) { |
| 283 | fsr = task_thread_info(target)->xfsr[0]; |
| 284 | gsr = task_thread_info(target)->gsr[0]; |
| 285 | } else { |
| 286 | fsr = gsr = 0; |
| 287 | } |
| 288 | |
| 289 | if (!ret) |
| 290 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 291 | &fsr, |
| 292 | 32 * sizeof(u64), |
| 293 | 33 * sizeof(u64)); |
| 294 | if (!ret) |
| 295 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 296 | &gsr, |
| 297 | 33 * sizeof(u64), |
| 298 | 34 * sizeof(u64)); |
| 299 | if (!ret) |
| 300 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 301 | &fprs, |
| 302 | 34 * sizeof(u64), |
| 303 | 35 * sizeof(u64)); |
| 304 | |
| 305 | if (!ret) |
| 306 | ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, |
| 307 | 35 * sizeof(u64), -1); |
| 308 | |
| 309 | return ret; |
| 310 | } |
| 311 | |
| 312 | static int fpregs64_set(struct task_struct *target, |
| 313 | const struct user_regset *regset, |
| 314 | unsigned int pos, unsigned int count, |
| 315 | const void *kbuf, const void __user *ubuf) |
| 316 | { |
| 317 | unsigned long *fpregs = task_thread_info(target)->fpregs; |
| 318 | unsigned long fprs; |
| 319 | int ret; |
| 320 | |
| 321 | if (target == current) |
| 322 | save_and_clear_fpu(); |
| 323 | |
| 324 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 325 | fpregs, |
| 326 | 0, 32 * sizeof(u64)); |
| 327 | if (!ret) |
| 328 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 329 | task_thread_info(target)->xfsr, |
| 330 | 32 * sizeof(u64), |
| 331 | 33 * sizeof(u64)); |
| 332 | if (!ret) |
| 333 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 334 | task_thread_info(target)->gsr, |
| 335 | 33 * sizeof(u64), |
| 336 | 34 * sizeof(u64)); |
| 337 | |
| 338 | fprs = task_thread_info(target)->fpsaved[0]; |
| 339 | if (!ret && count > 0) { |
| 340 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 341 | &fprs, |
| 342 | 34 * sizeof(u64), |
| 343 | 35 * sizeof(u64)); |
| 344 | } |
| 345 | |
| 346 | fprs |= (FPRS_FEF | FPRS_DL | FPRS_DU); |
| 347 | task_thread_info(target)->fpsaved[0] = fprs; |
| 348 | |
| 349 | if (!ret) |
| 350 | ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, |
| 351 | 35 * sizeof(u64), -1); |
| 352 | return ret; |
| 353 | } |
| 354 | |
| 355 | static const struct user_regset sparc64_regsets[] = { |
| 356 | /* Format is: |
| 357 | * G0 --> G7 |
| 358 | * O0 --> O7 |
| 359 | * L0 --> L7 |
| 360 | * I0 --> I7 |
| 361 | * TSTATE, TPC, TNPC, Y |
| 362 | */ |
| 363 | [REGSET_GENERAL] = { |
| 364 | .core_note_type = NT_PRSTATUS, |
| 365 | .n = 36 * sizeof(u64), |
| 366 | .size = sizeof(u64), .align = sizeof(u64), |
| 367 | .get = genregs64_get, .set = genregs64_set |
| 368 | }, |
| 369 | /* Format is: |
| 370 | * F0 --> F63 |
| 371 | * FSR |
| 372 | * GSR |
| 373 | * FPRS |
| 374 | */ |
| 375 | [REGSET_FP] = { |
| 376 | .core_note_type = NT_PRFPREG, |
| 377 | .n = 35 * sizeof(u64), |
| 378 | .size = sizeof(u64), .align = sizeof(u64), |
| 379 | .get = fpregs64_get, .set = fpregs64_set |
| 380 | }, |
| 381 | }; |
| 382 | |
| 383 | static const struct user_regset_view user_sparc64_view = { |
| 384 | .name = "sparc64", .e_machine = EM_SPARCV9, |
| 385 | .regsets = sparc64_regsets, .n = ARRAY_SIZE(sparc64_regsets) |
| 386 | }; |
| 387 | |
David S. Miller | 11cc8a3 | 2008-03-26 04:31:50 -0700 | [diff] [blame^] | 388 | #ifdef CONFIG_COMPAT |
David S. Miller | d09c2a2 | 2008-02-06 23:02:08 -0800 | [diff] [blame] | 389 | static int genregs32_get(struct task_struct *target, |
| 390 | const struct user_regset *regset, |
| 391 | unsigned int pos, unsigned int count, |
| 392 | void *kbuf, void __user *ubuf) |
| 393 | { |
| 394 | const struct pt_regs *regs = task_pt_regs(target); |
| 395 | compat_ulong_t __user *reg_window; |
| 396 | compat_ulong_t *k = kbuf; |
| 397 | compat_ulong_t __user *u = ubuf; |
| 398 | compat_ulong_t reg; |
| 399 | |
| 400 | if (target == current) |
| 401 | flushw_user(); |
| 402 | |
| 403 | pos /= sizeof(reg); |
| 404 | count /= sizeof(reg); |
| 405 | |
| 406 | if (kbuf) { |
| 407 | for (; count > 0 && pos < 16; count--) |
| 408 | *k++ = regs->u_regs[pos++]; |
| 409 | |
| 410 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; |
| 411 | for (; count > 0 && pos < 32; count--) { |
| 412 | if (get_user(*k++, ®_window[pos++])) |
| 413 | return -EFAULT; |
| 414 | } |
| 415 | } else { |
| 416 | for (; count > 0 && pos < 16; count--) { |
| 417 | if (put_user((compat_ulong_t) regs->u_regs[pos++], u++)) |
| 418 | return -EFAULT; |
| 419 | } |
| 420 | |
| 421 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; |
| 422 | for (; count > 0 && pos < 32; count--) { |
| 423 | if (get_user(reg, ®_window[pos++]) || |
| 424 | put_user(reg, u++)) |
| 425 | return -EFAULT; |
| 426 | } |
| 427 | } |
| 428 | while (count > 0) { |
| 429 | switch (pos) { |
| 430 | case 32: /* PSR */ |
| 431 | reg = tstate_to_psr(regs->tstate); |
| 432 | break; |
| 433 | case 33: /* PC */ |
| 434 | reg = regs->tpc; |
| 435 | break; |
| 436 | case 34: /* NPC */ |
| 437 | reg = regs->tnpc; |
| 438 | break; |
| 439 | case 35: /* Y */ |
| 440 | reg = regs->y; |
| 441 | break; |
| 442 | case 36: /* WIM */ |
| 443 | case 37: /* TBR */ |
| 444 | reg = 0; |
| 445 | break; |
| 446 | default: |
| 447 | goto finish; |
| 448 | } |
| 449 | |
| 450 | if (kbuf) |
| 451 | *k++ = reg; |
| 452 | else if (put_user(reg, u++)) |
| 453 | return -EFAULT; |
| 454 | pos++; |
| 455 | count--; |
| 456 | } |
| 457 | finish: |
| 458 | pos *= sizeof(reg); |
| 459 | count *= sizeof(reg); |
| 460 | |
| 461 | return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, |
| 462 | 38 * sizeof(reg), -1); |
| 463 | } |
| 464 | |
| 465 | static int genregs32_set(struct task_struct *target, |
| 466 | const struct user_regset *regset, |
| 467 | unsigned int pos, unsigned int count, |
| 468 | const void *kbuf, const void __user *ubuf) |
| 469 | { |
| 470 | struct pt_regs *regs = task_pt_regs(target); |
| 471 | compat_ulong_t __user *reg_window; |
| 472 | const compat_ulong_t *k = kbuf; |
| 473 | const compat_ulong_t __user *u = ubuf; |
| 474 | compat_ulong_t reg; |
| 475 | |
| 476 | if (target == current) |
| 477 | flushw_user(); |
| 478 | |
| 479 | pos /= sizeof(reg); |
| 480 | count /= sizeof(reg); |
| 481 | |
| 482 | if (kbuf) { |
| 483 | for (; count > 0 && pos < 16; count--) |
| 484 | regs->u_regs[pos++] = *k++; |
| 485 | |
| 486 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; |
| 487 | for (; count > 0 && pos < 32; count--) { |
| 488 | if (put_user(*k++, ®_window[pos++])) |
| 489 | return -EFAULT; |
| 490 | } |
| 491 | } else { |
| 492 | for (; count > 0 && pos < 16; count--) { |
| 493 | if (get_user(reg, u++)) |
| 494 | return -EFAULT; |
| 495 | regs->u_regs[pos++] = reg; |
| 496 | } |
| 497 | |
| 498 | reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; |
| 499 | for (; count > 0 && pos < 32; count--) { |
| 500 | if (get_user(reg, u++) || |
| 501 | put_user(reg, ®_window[pos++])) |
| 502 | return -EFAULT; |
| 503 | } |
| 504 | } |
| 505 | while (count > 0) { |
| 506 | unsigned long tstate; |
| 507 | |
| 508 | if (kbuf) |
| 509 | reg = *k++; |
| 510 | else if (get_user(reg, u++)) |
| 511 | return -EFAULT; |
| 512 | |
| 513 | switch (pos) { |
| 514 | case 32: /* PSR */ |
| 515 | tstate = regs->tstate; |
| 516 | tstate &= ~(TSTATE_ICC | TSTATE_XCC); |
| 517 | tstate |= psr_to_tstate_icc(reg); |
| 518 | regs->tstate = tstate; |
| 519 | break; |
| 520 | case 33: /* PC */ |
| 521 | regs->tpc = reg; |
| 522 | break; |
| 523 | case 34: /* NPC */ |
| 524 | regs->tnpc = reg; |
| 525 | break; |
| 526 | case 35: /* Y */ |
| 527 | regs->y = reg; |
| 528 | break; |
| 529 | case 36: /* WIM */ |
| 530 | case 37: /* TBR */ |
| 531 | break; |
| 532 | default: |
| 533 | goto finish; |
| 534 | } |
| 535 | |
| 536 | pos++; |
| 537 | count--; |
| 538 | } |
| 539 | finish: |
| 540 | pos *= sizeof(reg); |
| 541 | count *= sizeof(reg); |
| 542 | |
| 543 | return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, |
| 544 | 38 * sizeof(reg), -1); |
| 545 | } |
| 546 | |
| 547 | static int fpregs32_get(struct task_struct *target, |
| 548 | const struct user_regset *regset, |
| 549 | unsigned int pos, unsigned int count, |
| 550 | void *kbuf, void __user *ubuf) |
| 551 | { |
| 552 | const unsigned long *fpregs = task_thread_info(target)->fpregs; |
| 553 | compat_ulong_t enabled; |
| 554 | unsigned long fprs; |
| 555 | compat_ulong_t fsr; |
| 556 | int ret = 0; |
| 557 | |
| 558 | if (target == current) |
| 559 | save_and_clear_fpu(); |
| 560 | |
| 561 | fprs = task_thread_info(target)->fpsaved[0]; |
| 562 | if (fprs & FPRS_FEF) { |
| 563 | fsr = task_thread_info(target)->xfsr[0]; |
| 564 | enabled = 1; |
| 565 | } else { |
| 566 | fsr = 0; |
| 567 | enabled = 0; |
| 568 | } |
| 569 | |
| 570 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 571 | fpregs, |
| 572 | 0, 32 * sizeof(u32)); |
| 573 | |
| 574 | if (!ret) |
| 575 | ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, |
| 576 | 32 * sizeof(u32), |
| 577 | 33 * sizeof(u32)); |
| 578 | if (!ret) |
| 579 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 580 | &fsr, |
| 581 | 33 * sizeof(u32), |
| 582 | 34 * sizeof(u32)); |
| 583 | |
| 584 | if (!ret) { |
| 585 | compat_ulong_t val; |
| 586 | |
| 587 | val = (enabled << 8) | (8 << 16); |
| 588 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
| 589 | &val, |
| 590 | 34 * sizeof(u32), |
| 591 | 35 * sizeof(u32)); |
| 592 | } |
| 593 | |
| 594 | if (!ret) |
| 595 | ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, |
| 596 | 35 * sizeof(u32), -1); |
| 597 | |
| 598 | return ret; |
| 599 | } |
| 600 | |
| 601 | static int fpregs32_set(struct task_struct *target, |
| 602 | const struct user_regset *regset, |
| 603 | unsigned int pos, unsigned int count, |
| 604 | const void *kbuf, const void __user *ubuf) |
| 605 | { |
| 606 | unsigned long *fpregs = task_thread_info(target)->fpregs; |
| 607 | unsigned long fprs; |
| 608 | int ret; |
| 609 | |
| 610 | if (target == current) |
| 611 | save_and_clear_fpu(); |
| 612 | |
| 613 | fprs = task_thread_info(target)->fpsaved[0]; |
| 614 | |
| 615 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 616 | fpregs, |
| 617 | 0, 32 * sizeof(u32)); |
| 618 | if (!ret) |
| 619 | user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, |
| 620 | 32 * sizeof(u32), |
| 621 | 33 * sizeof(u32)); |
| 622 | if (!ret && count > 0) { |
| 623 | compat_ulong_t fsr; |
| 624 | unsigned long val; |
| 625 | |
| 626 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
| 627 | &fsr, |
| 628 | 33 * sizeof(u32), |
| 629 | 34 * sizeof(u32)); |
| 630 | if (!ret) { |
| 631 | val = task_thread_info(target)->xfsr[0]; |
| 632 | val &= 0xffffffff00000000UL; |
| 633 | val |= fsr; |
| 634 | task_thread_info(target)->xfsr[0] = val; |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | fprs |= (FPRS_FEF | FPRS_DL); |
| 639 | task_thread_info(target)->fpsaved[0] = fprs; |
| 640 | |
| 641 | if (!ret) |
| 642 | ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, |
| 643 | 34 * sizeof(u32), -1); |
| 644 | return ret; |
| 645 | } |
| 646 | |
| 647 | static const struct user_regset sparc32_regsets[] = { |
| 648 | /* Format is: |
| 649 | * G0 --> G7 |
| 650 | * O0 --> O7 |
| 651 | * L0 --> L7 |
| 652 | * I0 --> I7 |
| 653 | * PSR, PC, nPC, Y, WIM, TBR |
| 654 | */ |
| 655 | [REGSET_GENERAL] = { |
| 656 | .core_note_type = NT_PRSTATUS, |
| 657 | .n = 38 * sizeof(u32), |
| 658 | .size = sizeof(u32), .align = sizeof(u32), |
| 659 | .get = genregs32_get, .set = genregs32_set |
| 660 | }, |
| 661 | /* Format is: |
| 662 | * F0 --> F31 |
| 663 | * empty 32-bit word |
| 664 | * FSR (32--bit word) |
| 665 | * FPU QUEUE COUNT (8-bit char) |
| 666 | * FPU QUEUE ENTRYSIZE (8-bit char) |
| 667 | * FPU ENABLED (8-bit char) |
| 668 | * empty 8-bit char |
| 669 | * FPU QUEUE (64 32-bit ints) |
| 670 | */ |
| 671 | [REGSET_FP] = { |
| 672 | .core_note_type = NT_PRFPREG, |
| 673 | .n = 99 * sizeof(u32), |
| 674 | .size = sizeof(u32), .align = sizeof(u32), |
| 675 | .get = fpregs32_get, .set = fpregs32_set |
| 676 | }, |
| 677 | }; |
| 678 | |
| 679 | static const struct user_regset_view user_sparc32_view = { |
| 680 | .name = "sparc", .e_machine = EM_SPARC, |
| 681 | .regsets = sparc32_regsets, .n = ARRAY_SIZE(sparc32_regsets) |
| 682 | }; |
David S. Miller | 11cc8a3 | 2008-03-26 04:31:50 -0700 | [diff] [blame^] | 683 | #endif /* CONFIG_COMPAT */ |
David S. Miller | d09c2a2 | 2008-02-06 23:02:08 -0800 | [diff] [blame] | 684 | |
| 685 | const struct user_regset_view *task_user_regset_view(struct task_struct *task) |
| 686 | { |
David S. Miller | 11cc8a3 | 2008-03-26 04:31:50 -0700 | [diff] [blame^] | 687 | #ifdef CONFIG_COMPAT |
David S. Miller | d09c2a2 | 2008-02-06 23:02:08 -0800 | [diff] [blame] | 688 | if (test_tsk_thread_flag(task, TIF_32BIT)) |
| 689 | return &user_sparc32_view; |
David S. Miller | 11cc8a3 | 2008-03-26 04:31:50 -0700 | [diff] [blame^] | 690 | #endif |
David S. Miller | d09c2a2 | 2008-02-06 23:02:08 -0800 | [diff] [blame] | 691 | return &user_sparc64_view; |
| 692 | } |
| 693 | |
David S. Miller | 11cc8a3 | 2008-03-26 04:31:50 -0700 | [diff] [blame^] | 694 | #ifdef CONFIG_COMPAT |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 695 | struct compat_fps { |
| 696 | unsigned int regs[32]; |
| 697 | unsigned int fsr; |
| 698 | unsigned int flags; |
| 699 | unsigned int extra; |
| 700 | unsigned int fpqd; |
| 701 | struct compat_fq { |
| 702 | unsigned int insnaddr; |
| 703 | unsigned int insn; |
| 704 | } fpq[16]; |
| 705 | }; |
| 706 | |
| 707 | long compat_arch_ptrace(struct task_struct *child, compat_long_t request, |
| 708 | compat_ulong_t caddr, compat_ulong_t cdata) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | { |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 710 | const struct user_regset_view *view = task_user_regset_view(child); |
| 711 | compat_ulong_t caddr2 = task_pt_regs(current)->u_regs[UREG_I4]; |
| 712 | struct pt_regs32 __user *pregs; |
| 713 | struct compat_fps __user *fps; |
| 714 | unsigned long addr2 = caddr2; |
| 715 | unsigned long addr = caddr; |
| 716 | unsigned long data = cdata; |
David S. Miller | 9473272 | 2008-02-07 05:06:12 -0800 | [diff] [blame] | 717 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 719 | pregs = (struct pt_regs32 __user *) addr; |
| 720 | fps = (struct compat_fps __user *) addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 722 | switch (request) { |
David S. Miller | 1759e58 | 2006-04-01 23:28:10 -0800 | [diff] [blame] | 723 | case PTRACE_PEEKUSR: |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 724 | ret = (addr != 0) ? -EIO : 0; |
| 725 | break; |
David S. Miller | 1759e58 | 2006-04-01 23:28:10 -0800 | [diff] [blame] | 726 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 727 | case PTRACE_GETREGS: |
David S. Miller | 9473272 | 2008-02-07 05:06:12 -0800 | [diff] [blame] | 728 | ret = copy_regset_to_user(child, view, REGSET_GENERAL, |
| 729 | 32 * sizeof(u32), |
| 730 | 4 * sizeof(u32), |
| 731 | &pregs->psr); |
| 732 | if (!ret) |
| 733 | ret = copy_regset_to_user(child, view, REGSET_GENERAL, |
| 734 | 1 * sizeof(u32), |
| 735 | 15 * sizeof(u32), |
| 736 | &pregs->u_regs[0]); |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 737 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 739 | case PTRACE_SETREGS: |
David S. Miller | 9473272 | 2008-02-07 05:06:12 -0800 | [diff] [blame] | 740 | ret = copy_regset_from_user(child, view, REGSET_GENERAL, |
| 741 | 32 * sizeof(u32), |
| 742 | 4 * sizeof(u32), |
| 743 | &pregs->psr); |
| 744 | if (!ret) |
| 745 | ret = copy_regset_from_user(child, view, REGSET_GENERAL, |
| 746 | 1 * sizeof(u32), |
| 747 | 15 * sizeof(u32), |
| 748 | &pregs->u_regs[0]); |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 749 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 751 | case PTRACE_GETFPREGS: |
David S. Miller | 9473272 | 2008-02-07 05:06:12 -0800 | [diff] [blame] | 752 | ret = copy_regset_to_user(child, view, REGSET_FP, |
| 753 | 0 * sizeof(u32), |
| 754 | 32 * sizeof(u32), |
| 755 | &fps->regs[0]); |
| 756 | if (!ret) |
| 757 | ret = copy_regset_to_user(child, view, REGSET_FP, |
| 758 | 33 * sizeof(u32), |
| 759 | 1 * sizeof(u32), |
| 760 | &fps->fsr); |
| 761 | if (!ret) { |
| 762 | if (__put_user(0, &fps->flags) || |
| 763 | __put_user(0, &fps->extra) || |
| 764 | __put_user(0, &fps->fpqd) || |
| 765 | clear_user(&fps->fpq[0], 32 * sizeof(unsigned int))) |
| 766 | ret = -EFAULT; |
| 767 | } |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 768 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 770 | case PTRACE_SETFPREGS: |
David S. Miller | 9473272 | 2008-02-07 05:06:12 -0800 | [diff] [blame] | 771 | ret = copy_regset_from_user(child, view, REGSET_FP, |
| 772 | 0 * sizeof(u32), |
| 773 | 32 * sizeof(u32), |
| 774 | &fps->regs[0]); |
| 775 | if (!ret) |
| 776 | ret = copy_regset_from_user(child, view, REGSET_FP, |
| 777 | 33 * sizeof(u32), |
| 778 | 1 * sizeof(u32), |
| 779 | &fps->fsr); |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 780 | break; |
David S. Miller | 731bbe4 | 2006-04-04 16:54:40 -0700 | [diff] [blame] | 781 | |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 782 | case PTRACE_READTEXT: |
| 783 | case PTRACE_READDATA: |
| 784 | ret = ptrace_readdata(child, addr, |
| 785 | (char __user *)addr2, data); |
| 786 | if (ret == data) |
| 787 | ret = 0; |
| 788 | else if (ret >= 0) |
| 789 | ret = -EIO; |
| 790 | break; |
| 791 | |
| 792 | case PTRACE_WRITETEXT: |
| 793 | case PTRACE_WRITEDATA: |
| 794 | ret = ptrace_writedata(child, (char __user *) addr2, |
| 795 | addr, data); |
| 796 | if (ret == data) |
| 797 | ret = 0; |
| 798 | else if (ret >= 0) |
| 799 | ret = -EIO; |
| 800 | break; |
| 801 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 802 | default: |
| 803 | ret = compat_ptrace_request(child, request, addr, data); |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 804 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | } |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 806 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 807 | return ret; |
| 808 | } |
David S. Miller | 11cc8a3 | 2008-03-26 04:31:50 -0700 | [diff] [blame^] | 809 | #endif /* CONFIG_COMPAT */ |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 810 | |
| 811 | struct fps { |
| 812 | unsigned int regs[64]; |
| 813 | unsigned long fsr; |
| 814 | }; |
| 815 | |
| 816 | long arch_ptrace(struct task_struct *child, long request, long addr, long data) |
| 817 | { |
| 818 | const struct user_regset_view *view = task_user_regset_view(child); |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 819 | unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4]; |
David S. Miller | bfdf9eb | 2008-03-26 00:46:21 -0700 | [diff] [blame] | 820 | struct pt_regs __user *pregs; |
| 821 | struct fps __user *fps; |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 822 | int ret; |
| 823 | |
David S. Miller | bfdf9eb | 2008-03-26 00:46:21 -0700 | [diff] [blame] | 824 | pregs = (struct pt_regs __user *) (unsigned long) addr; |
| 825 | fps = (struct fps __user *) (unsigned long) addr; |
| 826 | |
David S. Miller | 2ba85f3 | 2008-02-07 22:46:09 -0800 | [diff] [blame] | 827 | switch (request) { |
| 828 | case PTRACE_PEEKUSR: |
| 829 | ret = (addr != 0) ? -EIO : 0; |
| 830 | break; |
| 831 | |
| 832 | case PTRACE_GETREGS64: |
| 833 | ret = copy_regset_to_user(child, view, REGSET_GENERAL, |
| 834 | 1 * sizeof(u64), |
| 835 | 15 * sizeof(u64), |
| 836 | &pregs->u_regs[0]); |
| 837 | if (!ret) { |
| 838 | /* XXX doesn't handle 'y' register correctly XXX */ |
| 839 | ret = copy_regset_to_user(child, view, REGSET_GENERAL, |
| 840 | 32 * sizeof(u64), |
| 841 | 4 * sizeof(u64), |
| 842 | &pregs->tstate); |
| 843 | } |
| 844 | break; |
| 845 | |
| 846 | case PTRACE_SETREGS64: |
| 847 | ret = copy_regset_from_user(child, view, REGSET_GENERAL, |
| 848 | 1 * sizeof(u64), |
| 849 | 15 * sizeof(u64), |
| 850 | &pregs->u_regs[0]); |
| 851 | if (!ret) { |
| 852 | /* XXX doesn't handle 'y' register correctly XXX */ |
| 853 | ret = copy_regset_from_user(child, view, REGSET_GENERAL, |
| 854 | 32 * sizeof(u64), |
| 855 | 4 * sizeof(u64), |
| 856 | &pregs->tstate); |
| 857 | } |
| 858 | break; |
| 859 | |
| 860 | case PTRACE_GETFPREGS64: |
| 861 | ret = copy_regset_to_user(child, view, REGSET_FP, |
| 862 | 0 * sizeof(u64), |
| 863 | 33 * sizeof(u64), |
| 864 | fps); |
| 865 | break; |
| 866 | |
| 867 | case PTRACE_SETFPREGS64: |
| 868 | ret = copy_regset_to_user(child, view, REGSET_FP, |
| 869 | 0 * sizeof(u64), |
| 870 | 33 * sizeof(u64), |
| 871 | fps); |
| 872 | break; |
| 873 | |
| 874 | case PTRACE_READTEXT: |
| 875 | case PTRACE_READDATA: |
| 876 | ret = ptrace_readdata(child, addr, |
| 877 | (char __user *)addr2, data); |
| 878 | if (ret == data) |
| 879 | ret = 0; |
| 880 | else if (ret >= 0) |
| 881 | ret = -EIO; |
| 882 | break; |
| 883 | |
| 884 | case PTRACE_WRITETEXT: |
| 885 | case PTRACE_WRITEDATA: |
| 886 | ret = ptrace_writedata(child, (char __user *) addr2, |
| 887 | addr, data); |
| 888 | if (ret == data) |
| 889 | ret = 0; |
| 890 | else if (ret >= 0) |
| 891 | ret = -EIO; |
| 892 | break; |
| 893 | |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 894 | default: |
| 895 | ret = ptrace_request(child, request, addr, data); |
| 896 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | } |
David S. Miller | 9775369 | 2008-02-07 03:00:17 -0800 | [diff] [blame] | 898 | |
| 899 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | } |
| 901 | |
David S. Miller | 8d8a647 | 2005-07-10 16:55:48 -0700 | [diff] [blame] | 902 | asmlinkage void syscall_trace(struct pt_regs *regs, int syscall_exit_p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | { |
David S. Miller | bb49bcd | 2005-07-10 16:49:28 -0700 | [diff] [blame] | 904 | /* do the secure computing check first */ |
David S. Miller | 8d8a647 | 2005-07-10 16:55:48 -0700 | [diff] [blame] | 905 | secure_computing(regs->u_regs[UREG_G1]); |
David S. Miller | bb49bcd | 2005-07-10 16:49:28 -0700 | [diff] [blame] | 906 | |
David S. Miller | f7ceba3 | 2005-07-10 19:29:45 -0700 | [diff] [blame] | 907 | if (unlikely(current->audit_context) && syscall_exit_p) { |
| 908 | unsigned long tstate = regs->tstate; |
| 909 | int result = AUDITSC_SUCCESS; |
| 910 | |
| 911 | if (unlikely(tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) |
| 912 | result = AUDITSC_FAILURE; |
| 913 | |
Al Viro | 5411be5 | 2006-03-29 20:23:36 -0500 | [diff] [blame] | 914 | audit_syscall_exit(result, regs->u_regs[UREG_I0]); |
David S. Miller | f7ceba3 | 2005-07-10 19:29:45 -0700 | [diff] [blame] | 915 | } |
| 916 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | if (!(current->ptrace & PT_PTRACED)) |
David S. Miller | f7ceba3 | 2005-07-10 19:29:45 -0700 | [diff] [blame] | 918 | goto out; |
| 919 | |
| 920 | if (!test_thread_flag(TIF_SYSCALL_TRACE)) |
| 921 | goto out; |
| 922 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) |
| 924 | ? 0x80 : 0)); |
| 925 | |
| 926 | /* |
| 927 | * this isn't the same as continuing with a signal, but it will do |
| 928 | * for normal use. strace only continues with a signal if the |
| 929 | * stopping signal is not SIGTRAP. -brl |
| 930 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | if (current->exit_code) { |
David S. Miller | bb49bcd | 2005-07-10 16:49:28 -0700 | [diff] [blame] | 932 | send_sig(current->exit_code, current, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | current->exit_code = 0; |
| 934 | } |
David S. Miller | f7ceba3 | 2005-07-10 19:29:45 -0700 | [diff] [blame] | 935 | |
| 936 | out: |
| 937 | if (unlikely(current->audit_context) && !syscall_exit_p) |
Al Viro | 5411be5 | 2006-03-29 20:23:36 -0500 | [diff] [blame] | 938 | audit_syscall_entry((test_thread_flag(TIF_32BIT) ? |
David S. Miller | f7ceba3 | 2005-07-10 19:29:45 -0700 | [diff] [blame] | 939 | AUDIT_ARCH_SPARC : |
| 940 | AUDIT_ARCH_SPARC64), |
| 941 | regs->u_regs[UREG_G1], |
| 942 | regs->u_regs[UREG_I0], |
| 943 | regs->u_regs[UREG_I1], |
| 944 | regs->u_regs[UREG_I2], |
| 945 | regs->u_regs[UREG_I3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | } |