3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
5 * Derived from "arch/m68k/kernel/ptrace.c"
6 * Copyright (C) 1994 by Hamish Macdonald
7 * Taken from linux/kernel/ptrace.c and modified for M680x0.
8 * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
10 * Modified by Cort Dougan (cort@hq.fsmlabs.com)
11 * and Paul Mackerras (paulus@samba.org).
13 * This file is subject to the terms and conditions of the GNU General
14 * Public License. See the file README.legal in the main directory of
15 * this archive for more details.
18 #include <linux/kernel.h>
19 #include <linux/sched.h>
21 #include <linux/smp.h>
22 #include <linux/errno.h>
23 #include <linux/ptrace.h>
24 #include <linux/regset.h>
25 #include <linux/elf.h>
26 #include <linux/user.h>
27 #include <linux/security.h>
28 #include <linux/signal.h>
29 #include <linux/seccomp.h>
30 #include <linux/audit.h>
32 #include <linux/module.h>
35 #include <asm/uaccess.h>
37 #include <asm/pgtable.h>
38 #include <asm/system.h>
41 * does not yet catch signals sent when the child dies.
42 * in exit.c or in signal.c.
46 * Set of msr bits that gdb can change on behalf of a process.
48 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
49 #define MSR_DEBUGCHANGE 0
51 #define MSR_DEBUGCHANGE (MSR_SE | MSR_BE)
55 * Max register writeable via put_reg
58 #define PT_MAX_PUT_REG PT_MQ
60 #define PT_MAX_PUT_REG PT_CCR
63 static unsigned long get_user_msr(struct task_struct *task)
65 return task->thread.regs->msr | task->thread.fpexc_mode;
68 static int set_user_msr(struct task_struct *task, unsigned long msr)
70 task->thread.regs->msr &= ~MSR_DEBUGCHANGE;
71 task->thread.regs->msr |= msr & MSR_DEBUGCHANGE;
76 * We prevent mucking around with the reserved area of trap
77 * which are used internally by the kernel.
79 static int set_user_trap(struct task_struct *task, unsigned long trap)
81 task->thread.regs->trap = trap & 0xfff0;
86 * Get contents of register REGNO in task TASK.
88 unsigned long ptrace_get_reg(struct task_struct *task, int regno)
90 if (task->thread.regs == NULL)
94 return get_user_msr(task);
96 if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long)))
97 return ((unsigned long *)task->thread.regs)[regno];
103 * Write contents of register REGNO in task TASK.
105 int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data)
107 if (task->thread.regs == NULL)
111 return set_user_msr(task, data);
112 if (regno == PT_TRAP)
113 return set_user_trap(task, data);
115 if (regno <= PT_MAX_PUT_REG) {
116 ((unsigned long *)task->thread.regs)[regno] = data;
122 static int gpr_get(struct task_struct *target, const struct user_regset *regset,
123 unsigned int pos, unsigned int count,
124 void *kbuf, void __user *ubuf)
128 if (target->thread.regs == NULL)
131 CHECK_FULL_REGS(target->thread.regs);
133 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
135 0, offsetof(struct pt_regs, msr));
137 unsigned long msr = get_user_msr(target);
138 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &msr,
139 offsetof(struct pt_regs, msr),
140 offsetof(struct pt_regs, msr) +
144 BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
145 offsetof(struct pt_regs, msr) + sizeof(long));
148 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
149 &target->thread.regs->orig_gpr3,
150 offsetof(struct pt_regs, orig_gpr3),
151 sizeof(struct pt_regs));
153 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
154 sizeof(struct pt_regs), -1);
159 static int gpr_set(struct task_struct *target, const struct user_regset *regset,
160 unsigned int pos, unsigned int count,
161 const void *kbuf, const void __user *ubuf)
166 if (target->thread.regs == NULL)
169 CHECK_FULL_REGS(target->thread.regs);
171 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
173 0, PT_MSR * sizeof(reg));
175 if (!ret && count > 0) {
176 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, ®,
177 PT_MSR * sizeof(reg),
178 (PT_MSR + 1) * sizeof(reg));
180 ret = set_user_msr(target, reg);
183 BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
184 offsetof(struct pt_regs, msr) + sizeof(long));
187 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
188 &target->thread.regs->orig_gpr3,
189 PT_ORIG_R3 * sizeof(reg),
190 (PT_MAX_PUT_REG + 1) * sizeof(reg));
192 if (PT_MAX_PUT_REG + 1 < PT_TRAP && !ret)
193 ret = user_regset_copyin_ignore(
194 &pos, &count, &kbuf, &ubuf,
195 (PT_MAX_PUT_REG + 1) * sizeof(reg),
196 PT_TRAP * sizeof(reg));
198 if (!ret && count > 0) {
199 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, ®,
200 PT_TRAP * sizeof(reg),
201 (PT_TRAP + 1) * sizeof(reg));
203 ret = set_user_trap(target, reg);
207 ret = user_regset_copyin_ignore(
208 &pos, &count, &kbuf, &ubuf,
209 (PT_TRAP + 1) * sizeof(reg), -1);
214 static int fpr_get(struct task_struct *target, const struct user_regset *regset,
215 unsigned int pos, unsigned int count,
216 void *kbuf, void __user *ubuf)
222 flush_fp_to_thread(target);
225 /* copy to local buffer then write that out */
226 for (i = 0; i < 32 ; i++)
227 buf[i] = target->thread.TS_FPR(i);
228 memcpy(&buf[32], &target->thread.fpscr, sizeof(double));
229 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
232 BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
233 offsetof(struct thread_struct, TS_FPR(32)));
235 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
236 &target->thread.fpr, 0, -1);
240 static int fpr_set(struct task_struct *target, const struct user_regset *regset,
241 unsigned int pos, unsigned int count,
242 const void *kbuf, const void __user *ubuf)
248 flush_fp_to_thread(target);
251 /* copy to local buffer then write that out */
252 i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
255 for (i = 0; i < 32 ; i++)
256 target->thread.TS_FPR(i) = buf[i];
257 memcpy(&target->thread.fpscr, &buf[32], sizeof(double));
260 BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
261 offsetof(struct thread_struct, TS_FPR(32)));
263 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
264 &target->thread.fpr, 0, -1);
268 #ifdef CONFIG_ALTIVEC
270 * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
271 * The transfer totals 34 quadword. Quadwords 0-31 contain the
272 * corresponding vector registers. Quadword 32 contains the vscr as the
273 * last word (offset 12) within that quadword. Quadword 33 contains the
274 * vrsave as the first word (offset 0) within the quadword.
276 * This definition of the VMX state is compatible with the current PPC32
277 * ptrace interface. This allows signal handling and ptrace to use the
278 * same structures. This also simplifies the implementation of a bi-arch
279 * (combined (32- and 64-bit) gdb.
282 static int vr_active(struct task_struct *target,
283 const struct user_regset *regset)
285 flush_altivec_to_thread(target);
286 return target->thread.used_vr ? regset->n : 0;
289 static int vr_get(struct task_struct *target, const struct user_regset *regset,
290 unsigned int pos, unsigned int count,
291 void *kbuf, void __user *ubuf)
295 flush_altivec_to_thread(target);
297 BUILD_BUG_ON(offsetof(struct thread_struct, vscr) !=
298 offsetof(struct thread_struct, vr[32]));
300 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
301 &target->thread.vr, 0,
302 33 * sizeof(vector128));
305 * Copy out only the low-order word of vrsave.
311 memset(&vrsave, 0, sizeof(vrsave));
312 vrsave.word = target->thread.vrsave;
313 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &vrsave,
314 33 * sizeof(vector128), -1);
320 static int vr_set(struct task_struct *target, const struct user_regset *regset,
321 unsigned int pos, unsigned int count,
322 const void *kbuf, const void __user *ubuf)
326 flush_altivec_to_thread(target);
328 BUILD_BUG_ON(offsetof(struct thread_struct, vscr) !=
329 offsetof(struct thread_struct, vr[32]));
331 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
332 &target->thread.vr, 0, 33 * sizeof(vector128));
333 if (!ret && count > 0) {
335 * We use only the first word of vrsave.
341 memset(&vrsave, 0, sizeof(vrsave));
342 vrsave.word = target->thread.vrsave;
343 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &vrsave,
344 33 * sizeof(vector128), -1);
346 target->thread.vrsave = vrsave.word;
351 #endif /* CONFIG_ALTIVEC */
355 * Currently to set and and get all the vsx state, you need to call
356 * the fp and VMX calls aswell. This only get/sets the lower 32
357 * 128bit VSX registers.
360 static int vsr_active(struct task_struct *target,
361 const struct user_regset *regset)
363 flush_vsx_to_thread(target);
364 return target->thread.used_vsr ? regset->n : 0;
367 static int vsr_get(struct task_struct *target, const struct user_regset *regset,
368 unsigned int pos, unsigned int count,
369 void *kbuf, void __user *ubuf)
374 flush_vsx_to_thread(target);
376 for (i = 0; i < 32 ; i++)
377 buf[i] = current->thread.fpr[i][TS_VSRLOWOFFSET];
378 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
379 buf, 0, 32 * sizeof(double));
384 static int vsr_set(struct task_struct *target, const struct user_regset *regset,
385 unsigned int pos, unsigned int count,
386 const void *kbuf, const void __user *ubuf)
391 flush_vsx_to_thread(target);
393 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
394 buf, 0, 32 * sizeof(double));
395 for (i = 0; i < 32 ; i++)
396 current->thread.fpr[i][TS_VSRLOWOFFSET] = buf[i];
401 #endif /* CONFIG_VSX */
406 * For get_evrregs/set_evrregs functions 'data' has the following layout:
415 static int evr_active(struct task_struct *target,
416 const struct user_regset *regset)
418 flush_spe_to_thread(target);
419 return target->thread.used_spe ? regset->n : 0;
422 static int evr_get(struct task_struct *target, const struct user_regset *regset,
423 unsigned int pos, unsigned int count,
424 void *kbuf, void __user *ubuf)
428 flush_spe_to_thread(target);
430 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
432 0, sizeof(target->thread.evr));
434 BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
435 offsetof(struct thread_struct, spefscr));
438 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
440 sizeof(target->thread.evr), -1);
445 static int evr_set(struct task_struct *target, const struct user_regset *regset,
446 unsigned int pos, unsigned int count,
447 const void *kbuf, const void __user *ubuf)
451 flush_spe_to_thread(target);
453 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
455 0, sizeof(target->thread.evr));
457 BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
458 offsetof(struct thread_struct, spefscr));
461 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
463 sizeof(target->thread.evr), -1);
467 #endif /* CONFIG_SPE */
471 * These are our native regset flavors.
473 enum powerpc_regset {
476 #ifdef CONFIG_ALTIVEC
487 static const struct user_regset native_regsets[] = {
489 .core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
490 .size = sizeof(long), .align = sizeof(long),
491 .get = gpr_get, .set = gpr_set
494 .core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
495 .size = sizeof(double), .align = sizeof(double),
496 .get = fpr_get, .set = fpr_set
498 #ifdef CONFIG_ALTIVEC
500 .core_note_type = NT_PPC_VMX, .n = 34,
501 .size = sizeof(vector128), .align = sizeof(vector128),
502 .active = vr_active, .get = vr_get, .set = vr_set
507 .core_note_type = NT_PPC_VSX, .n = 32,
508 .size = sizeof(double), .align = sizeof(double),
509 .active = vsr_active, .get = vsr_get, .set = vsr_set
515 .size = sizeof(u32), .align = sizeof(u32),
516 .active = evr_active, .get = evr_get, .set = evr_set
521 static const struct user_regset_view user_ppc_native_view = {
522 .name = UTS_MACHINE, .e_machine = ELF_ARCH, .ei_osabi = ELF_OSABI,
523 .regsets = native_regsets, .n = ARRAY_SIZE(native_regsets)
527 #include <linux/compat.h>
529 static int gpr32_get(struct task_struct *target,
530 const struct user_regset *regset,
531 unsigned int pos, unsigned int count,
532 void *kbuf, void __user *ubuf)
534 const unsigned long *regs = &target->thread.regs->gpr[0];
535 compat_ulong_t *k = kbuf;
536 compat_ulong_t __user *u = ubuf;
539 if (target->thread.regs == NULL)
542 CHECK_FULL_REGS(target->thread.regs);
545 count /= sizeof(reg);
548 for (; count > 0 && pos < PT_MSR; --count)
551 for (; count > 0 && pos < PT_MSR; --count)
552 if (__put_user((compat_ulong_t) regs[pos++], u++))
555 if (count > 0 && pos == PT_MSR) {
556 reg = get_user_msr(target);
559 else if (__put_user(reg, u++))
566 for (; count > 0 && pos < PT_REGS_COUNT; --count)
569 for (; count > 0 && pos < PT_REGS_COUNT; --count)
570 if (__put_user((compat_ulong_t) regs[pos++], u++))
576 count *= sizeof(reg);
577 return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
578 PT_REGS_COUNT * sizeof(reg), -1);
581 static int gpr32_set(struct task_struct *target,
582 const struct user_regset *regset,
583 unsigned int pos, unsigned int count,
584 const void *kbuf, const void __user *ubuf)
586 unsigned long *regs = &target->thread.regs->gpr[0];
587 const compat_ulong_t *k = kbuf;
588 const compat_ulong_t __user *u = ubuf;
591 if (target->thread.regs == NULL)
594 CHECK_FULL_REGS(target->thread.regs);
597 count /= sizeof(reg);
600 for (; count > 0 && pos < PT_MSR; --count)
603 for (; count > 0 && pos < PT_MSR; --count) {
604 if (__get_user(reg, u++))
610 if (count > 0 && pos == PT_MSR) {
613 else if (__get_user(reg, u++))
615 set_user_msr(target, reg);
621 for (; count > 0 && pos <= PT_MAX_PUT_REG; --count)
623 for (; count > 0 && pos < PT_TRAP; --count, ++pos)
626 for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) {
627 if (__get_user(reg, u++))
631 for (; count > 0 && pos < PT_TRAP; --count, ++pos)
632 if (__get_user(reg, u++))
636 if (count > 0 && pos == PT_TRAP) {
639 else if (__get_user(reg, u++))
641 set_user_trap(target, reg);
649 count *= sizeof(reg);
650 return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
651 (PT_TRAP + 1) * sizeof(reg), -1);
655 * These are the regset flavors matching the CONFIG_PPC32 native set.
657 static const struct user_regset compat_regsets[] = {
659 .core_note_type = NT_PRSTATUS, .n = ELF_NGREG,
660 .size = sizeof(compat_long_t), .align = sizeof(compat_long_t),
661 .get = gpr32_get, .set = gpr32_set
664 .core_note_type = NT_PRFPREG, .n = ELF_NFPREG,
665 .size = sizeof(double), .align = sizeof(double),
666 .get = fpr_get, .set = fpr_set
668 #ifdef CONFIG_ALTIVEC
670 .core_note_type = NT_PPC_VMX, .n = 34,
671 .size = sizeof(vector128), .align = sizeof(vector128),
672 .active = vr_active, .get = vr_get, .set = vr_set
677 .core_note_type = NT_PPC_SPE, .n = 35,
678 .size = sizeof(u32), .align = sizeof(u32),
679 .active = evr_active, .get = evr_get, .set = evr_set
684 static const struct user_regset_view user_ppc_compat_view = {
685 .name = "ppc", .e_machine = EM_PPC, .ei_osabi = ELF_OSABI,
686 .regsets = compat_regsets, .n = ARRAY_SIZE(compat_regsets)
688 #endif /* CONFIG_PPC64 */
690 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
693 if (test_tsk_thread_flag(task, TIF_32BIT))
694 return &user_ppc_compat_view;
696 return &user_ppc_native_view;
700 void user_enable_single_step(struct task_struct *task)
702 struct pt_regs *regs = task->thread.regs;
705 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
706 task->thread.dbcr0 = DBCR0_IDM | DBCR0_IC;
712 set_tsk_thread_flag(task, TIF_SINGLESTEP);
715 void user_disable_single_step(struct task_struct *task)
717 struct pt_regs *regs = task->thread.regs;
720 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
721 task->thread.dbcr0 = 0;
722 regs->msr &= ~MSR_DE;
724 regs->msr &= ~MSR_SE;
727 clear_tsk_thread_flag(task, TIF_SINGLESTEP);
730 static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
733 /* We only support one DABR and no IABRS at the moment */
737 /* The bottom 3 bits are flags */
738 if ((data & ~0x7UL) >= TASK_SIZE)
741 /* Ensure translation is on */
742 if (data && !(data & DABR_TRANSLATION))
745 task->thread.dabr = data;
750 * Called by kernel/ptrace.c when detaching..
752 * Make sure single step bits etc are not set.
754 void ptrace_disable(struct task_struct *child)
756 /* make sure the single step bit is not set. */
757 user_disable_single_step(child);
761 * Here are the old "legacy" powerpc specific getregs/setregs ptrace calls,
762 * we mark them as obsolete now, they will be removed in a future version
764 static long arch_ptrace_old(struct task_struct *child, long request, long addr,
768 case PPC_PTRACE_GETREGS: /* Get GPRs 0 - 31. */
769 return copy_regset_to_user(child, &user_ppc_native_view,
770 REGSET_GPR, 0, 32 * sizeof(long),
771 (void __user *) data);
773 case PPC_PTRACE_SETREGS: /* Set GPRs 0 - 31. */
774 return copy_regset_from_user(child, &user_ppc_native_view,
775 REGSET_GPR, 0, 32 * sizeof(long),
776 (const void __user *) data);
778 case PPC_PTRACE_GETFPREGS: /* Get FPRs 0 - 31. */
779 return copy_regset_to_user(child, &user_ppc_native_view,
780 REGSET_FPR, 0, 32 * sizeof(double),
781 (void __user *) data);
783 case PPC_PTRACE_SETFPREGS: /* Set FPRs 0 - 31. */
784 return copy_regset_from_user(child, &user_ppc_native_view,
785 REGSET_FPR, 0, 32 * sizeof(double),
786 (const void __user *) data);
792 long arch_ptrace(struct task_struct *child, long request, long addr, long data)
797 /* read the word at location addr in the USER area. */
798 case PTRACE_PEEKUSR: {
799 unsigned long index, tmp;
802 /* convert to index and check */
804 index = (unsigned long) addr >> 2;
805 if ((addr & 3) || (index > PT_FPSCR)
806 || (child->thread.regs == NULL))
808 index = (unsigned long) addr >> 3;
809 if ((addr & 7) || (index > PT_FPSCR))
813 CHECK_FULL_REGS(child->thread.regs);
814 if (index < PT_FPR0) {
815 tmp = ptrace_get_reg(child, (int) index);
817 flush_fp_to_thread(child);
818 tmp = ((unsigned long *)child->thread.fpr)
819 [TS_FPRWIDTH * (index - PT_FPR0)];
821 ret = put_user(tmp,(unsigned long __user *) data);
825 /* write the word at location addr in the USER area */
826 case PTRACE_POKEUSR: {
830 /* convert to index and check */
832 index = (unsigned long) addr >> 2;
833 if ((addr & 3) || (index > PT_FPSCR)
834 || (child->thread.regs == NULL))
836 index = (unsigned long) addr >> 3;
837 if ((addr & 7) || (index > PT_FPSCR))
841 CHECK_FULL_REGS(child->thread.regs);
842 if (index < PT_FPR0) {
843 ret = ptrace_put_reg(child, index, data);
845 flush_fp_to_thread(child);
846 ((unsigned long *)child->thread.fpr)
847 [TS_FPRWIDTH * (index - PT_FPR0)] = data;
853 case PTRACE_GET_DEBUGREG: {
855 /* We only support one DABR and no IABRS at the moment */
858 ret = put_user(child->thread.dabr,
859 (unsigned long __user *)data);
863 case PTRACE_SET_DEBUGREG:
864 ret = ptrace_set_debugreg(child, addr, data);
868 case PTRACE_GETREGS64:
870 case PTRACE_GETREGS: /* Get all pt_regs from the child. */
871 return copy_regset_to_user(child, &user_ppc_native_view,
873 0, sizeof(struct pt_regs),
874 (void __user *) data);
877 case PTRACE_SETREGS64:
879 case PTRACE_SETREGS: /* Set all gp regs in the child. */
880 return copy_regset_from_user(child, &user_ppc_native_view,
882 0, sizeof(struct pt_regs),
883 (const void __user *) data);
885 case PTRACE_GETFPREGS: /* Get the child FPU state (FPR0...31 + FPSCR) */
886 return copy_regset_to_user(child, &user_ppc_native_view,
888 0, sizeof(elf_fpregset_t),
889 (void __user *) data);
891 case PTRACE_SETFPREGS: /* Set the child FPU state (FPR0...31 + FPSCR) */
892 return copy_regset_from_user(child, &user_ppc_native_view,
894 0, sizeof(elf_fpregset_t),
895 (const void __user *) data);
897 #ifdef CONFIG_ALTIVEC
898 case PTRACE_GETVRREGS:
899 return copy_regset_to_user(child, &user_ppc_native_view,
901 0, (33 * sizeof(vector128) +
903 (void __user *) data);
905 case PTRACE_SETVRREGS:
906 return copy_regset_from_user(child, &user_ppc_native_view,
908 0, (33 * sizeof(vector128) +
910 (const void __user *) data);
913 case PTRACE_GETVSRREGS:
914 return copy_regset_to_user(child, &user_ppc_native_view,
916 0, (32 * sizeof(vector128) +
918 (void __user *) data);
920 case PTRACE_SETVSRREGS:
921 return copy_regset_from_user(child, &user_ppc_native_view,
923 0, (32 * sizeof(vector128) +
925 (const void __user *) data);
928 case PTRACE_GETEVRREGS:
929 /* Get the child spe register state. */
930 return copy_regset_to_user(child, &user_ppc_native_view,
931 REGSET_SPE, 0, 35 * sizeof(u32),
932 (void __user *) data);
934 case PTRACE_SETEVRREGS:
935 /* Set the child spe register state. */
936 return copy_regset_from_user(child, &user_ppc_native_view,
937 REGSET_SPE, 0, 35 * sizeof(u32),
938 (const void __user *) data);
941 /* Old reverse args ptrace callss */
942 case PPC_PTRACE_GETREGS: /* Get GPRs 0 - 31. */
943 case PPC_PTRACE_SETREGS: /* Set GPRs 0 - 31. */
944 case PPC_PTRACE_GETFPREGS: /* Get FPRs 0 - 31. */
945 case PPC_PTRACE_SETFPREGS: /* Get FPRs 0 - 31. */
946 ret = arch_ptrace_old(child, request, addr, data);
950 ret = ptrace_request(child, request, addr, data);
956 static void do_syscall_trace(void)
958 /* the 0x80 provides a way for the tracing parent to distinguish
959 between a syscall stop and SIGTRAP delivery */
960 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
964 * this isn't the same as continuing with a signal, but it will do
965 * for normal use. strace only continues with a signal if the
966 * stopping signal is not SIGTRAP. -brl
968 if (current->exit_code) {
969 send_sig(current->exit_code, current, 1);
970 current->exit_code = 0;
974 void do_syscall_trace_enter(struct pt_regs *regs)
976 secure_computing(regs->gpr[0]);
978 if (test_thread_flag(TIF_SYSCALL_TRACE)
979 && (current->ptrace & PT_PTRACED))
982 if (unlikely(current->audit_context)) {
984 if (!test_thread_flag(TIF_32BIT))
985 audit_syscall_entry(AUDIT_ARCH_PPC64,
987 regs->gpr[3], regs->gpr[4],
988 regs->gpr[5], regs->gpr[6]);
991 audit_syscall_entry(AUDIT_ARCH_PPC,
993 regs->gpr[3] & 0xffffffff,
994 regs->gpr[4] & 0xffffffff,
995 regs->gpr[5] & 0xffffffff,
996 regs->gpr[6] & 0xffffffff);
1000 void do_syscall_trace_leave(struct pt_regs *regs)
1002 if (unlikely(current->audit_context))
1003 audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
1006 if ((test_thread_flag(TIF_SYSCALL_TRACE)
1007 || test_thread_flag(TIF_SINGLESTEP))
1008 && (current->ptrace & PT_PTRACED))