2 * Based on arch/arm/kernel/ptrace.c
5 * edited by Linus Torvalds
6 * ARM modifications Copyright (C) 2000 Russell King
7 * Copyright (C) 2012 ARM Ltd.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <linux/kernel.h>
23 #include <linux/sched.h>
25 #include <linux/smp.h>
26 #include <linux/ptrace.h>
27 #include <linux/user.h>
28 #include <linux/security.h>
29 #include <linux/init.h>
30 #include <linux/signal.h>
31 #include <linux/uaccess.h>
32 #include <linux/perf_event.h>
33 #include <linux/hw_breakpoint.h>
34 #include <linux/regset.h>
35 #include <linux/tracehook.h>
36 #include <linux/elf.h>
38 #include <asm/compat.h>
39 #include <asm/debug-monitors.h>
40 #include <asm/pgtable.h>
41 #include <asm/traps.h>
42 #include <asm/system_misc.h>
45 * TODO: does not yet catch signals sent when the child dies.
46 * in exit.c or in signal.c.
50 * Called by kernel/ptrace.c when detaching..
52 void ptrace_disable(struct task_struct *child)
56 #ifdef CONFIG_HAVE_HW_BREAKPOINT
58 * Handle hitting a HW-breakpoint.
60 static void ptrace_hbptriggered(struct perf_event *bp,
61 struct perf_sample_data *data,
64 struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp);
68 .si_code = TRAP_HWBKPT,
69 .si_addr = (void __user *)(bkpt->trigger),
75 if (!is_compat_task())
78 for (i = 0; i < ARM_MAX_BRP; ++i) {
79 if (current->thread.debug.hbp_break[i] == bp) {
80 info.si_errno = (i << 1) + 1;
85 for (i = 0; i < ARM_MAX_WRP; ++i) {
86 if (current->thread.debug.hbp_watch[i] == bp) {
87 info.si_errno = -((i << 1) + 1);
94 force_sig_info(SIGTRAP, &info, current);
98 * Unregister breakpoints from this task and reset the pointers in
101 void flush_ptrace_hw_breakpoint(struct task_struct *tsk)
104 struct thread_struct *t = &tsk->thread;
106 for (i = 0; i < ARM_MAX_BRP; i++) {
107 if (t->debug.hbp_break[i]) {
108 unregister_hw_breakpoint(t->debug.hbp_break[i]);
109 t->debug.hbp_break[i] = NULL;
113 for (i = 0; i < ARM_MAX_WRP; i++) {
114 if (t->debug.hbp_watch[i]) {
115 unregister_hw_breakpoint(t->debug.hbp_watch[i]);
116 t->debug.hbp_watch[i] = NULL;
121 void ptrace_hw_copy_thread(struct task_struct *tsk)
123 memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
126 static struct perf_event *ptrace_hbp_get_event(unsigned int note_type,
127 struct task_struct *tsk,
130 struct perf_event *bp = ERR_PTR(-EINVAL);
133 case NT_ARM_HW_BREAK:
134 if (idx < ARM_MAX_BRP)
135 bp = tsk->thread.debug.hbp_break[idx];
137 case NT_ARM_HW_WATCH:
138 if (idx < ARM_MAX_WRP)
139 bp = tsk->thread.debug.hbp_watch[idx];
146 static int ptrace_hbp_set_event(unsigned int note_type,
147 struct task_struct *tsk,
149 struct perf_event *bp)
154 case NT_ARM_HW_BREAK:
155 if (idx < ARM_MAX_BRP) {
156 tsk->thread.debug.hbp_break[idx] = bp;
160 case NT_ARM_HW_WATCH:
161 if (idx < ARM_MAX_WRP) {
162 tsk->thread.debug.hbp_watch[idx] = bp;
171 static struct perf_event *ptrace_hbp_create(unsigned int note_type,
172 struct task_struct *tsk,
175 struct perf_event *bp;
176 struct perf_event_attr attr;
180 case NT_ARM_HW_BREAK:
181 type = HW_BREAKPOINT_X;
183 case NT_ARM_HW_WATCH:
184 type = HW_BREAKPOINT_RW;
187 return ERR_PTR(-EINVAL);
190 ptrace_breakpoint_init(&attr);
193 * Initialise fields to sane defaults
194 * (i.e. values that will pass validation).
197 attr.bp_len = HW_BREAKPOINT_LEN_4;
201 bp = register_user_hw_breakpoint(&attr, ptrace_hbptriggered, NULL, tsk);
205 err = ptrace_hbp_set_event(note_type, tsk, idx, bp);
212 static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
213 struct arch_hw_breakpoint_ctrl ctrl,
214 struct perf_event_attr *attr)
216 int err, len, type, disabled = !ctrl.enabled;
218 attr->disabled = disabled;
222 err = arch_bp_generic_fields(ctrl, &len, &type);
227 case NT_ARM_HW_BREAK:
228 if ((type & HW_BREAKPOINT_X) != type)
231 case NT_ARM_HW_WATCH:
232 if ((type & HW_BREAKPOINT_RW) != type)
240 attr->bp_type = type;
245 static int ptrace_hbp_get_resource_info(unsigned int note_type, u32 *info)
251 case NT_ARM_HW_BREAK:
252 num = hw_breakpoint_slots(TYPE_INST);
254 case NT_ARM_HW_WATCH:
255 num = hw_breakpoint_slots(TYPE_DATA);
261 reg |= debug_monitors_arch();
269 static int ptrace_hbp_get_ctrl(unsigned int note_type,
270 struct task_struct *tsk,
274 struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx);
279 *ctrl = bp ? encode_ctrl_reg(counter_arch_bp(bp)->ctrl) : 0;
283 static int ptrace_hbp_get_addr(unsigned int note_type,
284 struct task_struct *tsk,
288 struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx);
293 *addr = bp ? bp->attr.bp_addr : 0;
297 static struct perf_event *ptrace_hbp_get_initialised_bp(unsigned int note_type,
298 struct task_struct *tsk,
301 struct perf_event *bp = ptrace_hbp_get_event(note_type, tsk, idx);
304 bp = ptrace_hbp_create(note_type, tsk, idx);
309 static int ptrace_hbp_set_ctrl(unsigned int note_type,
310 struct task_struct *tsk,
315 struct perf_event *bp;
316 struct perf_event_attr attr;
317 struct arch_hw_breakpoint_ctrl ctrl;
319 bp = ptrace_hbp_get_initialised_bp(note_type, tsk, idx);
326 decode_ctrl_reg(uctrl, &ctrl);
327 err = ptrace_hbp_fill_attr_ctrl(note_type, ctrl, &attr);
331 return modify_user_hw_breakpoint(bp, &attr);
334 static int ptrace_hbp_set_addr(unsigned int note_type,
335 struct task_struct *tsk,
340 struct perf_event *bp;
341 struct perf_event_attr attr;
343 bp = ptrace_hbp_get_initialised_bp(note_type, tsk, idx);
351 err = modify_user_hw_breakpoint(bp, &attr);
355 #define PTRACE_HBP_ADDR_SZ sizeof(u64)
356 #define PTRACE_HBP_CTRL_SZ sizeof(u32)
357 #define PTRACE_HBP_PAD_SZ sizeof(u32)
359 static int hw_break_get(struct task_struct *target,
360 const struct user_regset *regset,
361 unsigned int pos, unsigned int count,
362 void *kbuf, void __user *ubuf)
364 unsigned int note_type = regset->core_note_type;
365 int ret, idx = 0, offset, limit;
370 ret = ptrace_hbp_get_resource_info(note_type, &info);
374 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &info, 0,
380 offset = offsetof(struct user_hwdebug_state, pad);
381 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, offset,
382 offset + PTRACE_HBP_PAD_SZ);
386 /* (address, ctrl) registers */
387 offset = offsetof(struct user_hwdebug_state, dbg_regs);
388 limit = regset->n * regset->size;
389 while (count && offset < limit) {
390 ret = ptrace_hbp_get_addr(note_type, target, idx, &addr);
393 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &addr,
394 offset, offset + PTRACE_HBP_ADDR_SZ);
397 offset += PTRACE_HBP_ADDR_SZ;
399 ret = ptrace_hbp_get_ctrl(note_type, target, idx, &ctrl);
402 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &ctrl,
403 offset, offset + PTRACE_HBP_CTRL_SZ);
406 offset += PTRACE_HBP_CTRL_SZ;
408 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
410 offset + PTRACE_HBP_PAD_SZ);
413 offset += PTRACE_HBP_PAD_SZ;
420 static int hw_break_set(struct task_struct *target,
421 const struct user_regset *regset,
422 unsigned int pos, unsigned int count,
423 const void *kbuf, const void __user *ubuf)
425 unsigned int note_type = regset->core_note_type;
426 int ret, idx = 0, offset, limit;
430 /* Resource info and pad */
431 offset = offsetof(struct user_hwdebug_state, dbg_regs);
432 ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, offset);
436 /* (address, ctrl) registers */
437 limit = regset->n * regset->size;
438 while (count && offset < limit) {
439 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &addr,
440 offset, offset + PTRACE_HBP_ADDR_SZ);
443 ret = ptrace_hbp_set_addr(note_type, target, idx, addr);
446 offset += PTRACE_HBP_ADDR_SZ;
448 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl,
449 offset, offset + PTRACE_HBP_CTRL_SZ);
452 ret = ptrace_hbp_set_ctrl(note_type, target, idx, ctrl);
455 offset += PTRACE_HBP_CTRL_SZ;
457 ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
459 offset + PTRACE_HBP_PAD_SZ);
462 offset += PTRACE_HBP_PAD_SZ;
468 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
470 static int gpr_get(struct task_struct *target,
471 const struct user_regset *regset,
472 unsigned int pos, unsigned int count,
473 void *kbuf, void __user *ubuf)
475 struct user_pt_regs *uregs = &task_pt_regs(target)->user_regs;
476 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, -1);
479 static int gpr_set(struct task_struct *target, const struct user_regset *regset,
480 unsigned int pos, unsigned int count,
481 const void *kbuf, const void __user *ubuf)
484 struct user_pt_regs newregs;
486 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newregs, 0, -1);
490 if (!valid_user_regs(&newregs))
493 task_pt_regs(target)->user_regs = newregs;
498 * TODO: update fp accessors for lazy context switching (sync/flush hwstate)
500 static int fpr_get(struct task_struct *target, const struct user_regset *regset,
501 unsigned int pos, unsigned int count,
502 void *kbuf, void __user *ubuf)
504 struct user_fpsimd_state *uregs;
505 uregs = &target->thread.fpsimd_state.user_fpsimd;
506 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0, -1);
509 static int fpr_set(struct task_struct *target, const struct user_regset *regset,
510 unsigned int pos, unsigned int count,
511 const void *kbuf, const void __user *ubuf)
514 struct user_fpsimd_state newstate;
516 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newstate, 0, -1);
520 target->thread.fpsimd_state.user_fpsimd = newstate;
524 static int tls_get(struct task_struct *target, const struct user_regset *regset,
525 unsigned int pos, unsigned int count,
526 void *kbuf, void __user *ubuf)
528 unsigned long *tls = &target->thread.tp_value;
529 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, tls, 0, -1);
532 static int tls_set(struct task_struct *target, const struct user_regset *regset,
533 unsigned int pos, unsigned int count,
534 const void *kbuf, const void __user *ubuf)
539 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &tls, 0, -1);
543 target->thread.tp_value = tls;
547 enum aarch64_regset {
551 #ifdef CONFIG_HAVE_HW_BREAKPOINT
557 static const struct user_regset aarch64_regsets[] = {
559 .core_note_type = NT_PRSTATUS,
560 .n = sizeof(struct user_pt_regs) / sizeof(u64),
562 .align = sizeof(u64),
567 .core_note_type = NT_PRFPREG,
568 .n = sizeof(struct user_fpsimd_state) / sizeof(u32),
570 * We pretend we have 32-bit registers because the fpsr and
571 * fpcr are 32-bits wide.
574 .align = sizeof(u32),
579 .core_note_type = NT_ARM_TLS,
581 .size = sizeof(void *),
582 .align = sizeof(void *),
586 #ifdef CONFIG_HAVE_HW_BREAKPOINT
587 [REGSET_HW_BREAK] = {
588 .core_note_type = NT_ARM_HW_BREAK,
589 .n = sizeof(struct user_hwdebug_state) / sizeof(u32),
591 .align = sizeof(u32),
595 [REGSET_HW_WATCH] = {
596 .core_note_type = NT_ARM_HW_WATCH,
597 .n = sizeof(struct user_hwdebug_state) / sizeof(u32),
599 .align = sizeof(u32),
606 static const struct user_regset_view user_aarch64_view = {
607 .name = "aarch64", .e_machine = EM_AARCH64,
608 .regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets)
612 #include <linux/compat.h>
619 static int compat_gpr_get(struct task_struct *target,
620 const struct user_regset *regset,
621 unsigned int pos, unsigned int count,
622 void *kbuf, void __user *ubuf)
625 unsigned int i, start, num_regs;
627 /* Calculate the number of AArch32 registers contained in count */
628 num_regs = count / regset->size;
630 /* Convert pos into an register number */
631 start = pos / regset->size;
633 if (start + num_regs > regset->n)
636 for (i = 0; i < num_regs; ++i) {
637 unsigned int idx = start + i;
642 reg = (void *)&task_pt_regs(target)->pc;
645 reg = (void *)&task_pt_regs(target)->pstate;
648 reg = (void *)&task_pt_regs(target)->orig_x0;
651 reg = (void *)&task_pt_regs(target)->regs[idx];
655 memcpy(kbuf, ®, sizeof(reg));
658 ret = copy_to_user(ubuf, ®, sizeof(reg));
671 static int compat_gpr_set(struct task_struct *target,
672 const struct user_regset *regset,
673 unsigned int pos, unsigned int count,
674 const void *kbuf, const void __user *ubuf)
676 struct pt_regs newregs;
678 unsigned int i, start, num_regs;
680 /* Calculate the number of AArch32 registers contained in count */
681 num_regs = count / regset->size;
683 /* Convert pos into an register number */
684 start = pos / regset->size;
686 if (start + num_regs > regset->n)
689 newregs = *task_pt_regs(target);
691 for (i = 0; i < num_regs; ++i) {
692 unsigned int idx = start + i;
696 memcpy(®, kbuf, sizeof(reg));
699 ret = copy_from_user(®, ubuf, sizeof(reg));
710 reg = (void *)&newregs.pc;
713 reg = (void *)&newregs.pstate;
716 reg = (void *)&newregs.orig_x0;
719 reg = (void *)&newregs.regs[idx];
722 ret = copy_from_user(reg, ubuf, sizeof(compat_ulong_t));
727 ubuf += sizeof(compat_ulong_t);
730 if (valid_user_regs(&newregs.user_regs))
731 *task_pt_regs(target) = newregs;
739 static int compat_vfp_get(struct task_struct *target,
740 const struct user_regset *regset,
741 unsigned int pos, unsigned int count,
742 void *kbuf, void __user *ubuf)
744 struct user_fpsimd_state *uregs;
745 compat_ulong_t fpscr;
748 uregs = &target->thread.fpsimd_state.user_fpsimd;
751 * The VFP registers are packed into the fpsimd_state, so they all sit
752 * nicely together for us. We just need to create the fpscr separately.
754 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, uregs, 0,
755 VFP_STATE_SIZE - sizeof(compat_ulong_t));
758 fpscr = (uregs->fpsr & VFP_FPSCR_STAT_MASK) |
759 (uregs->fpcr & VFP_FPSCR_CTRL_MASK);
760 ret = put_user(fpscr, (compat_ulong_t *)ubuf);
766 static int compat_vfp_set(struct task_struct *target,
767 const struct user_regset *regset,
768 unsigned int pos, unsigned int count,
769 const void *kbuf, const void __user *ubuf)
771 struct user_fpsimd_state *uregs;
772 compat_ulong_t fpscr;
775 if (pos + count > VFP_STATE_SIZE)
778 uregs = &target->thread.fpsimd_state.user_fpsimd;
780 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, uregs, 0,
781 VFP_STATE_SIZE - sizeof(compat_ulong_t));
784 ret = get_user(fpscr, (compat_ulong_t *)ubuf);
785 uregs->fpsr = fpscr & VFP_FPSCR_STAT_MASK;
786 uregs->fpcr = fpscr & VFP_FPSCR_CTRL_MASK;
792 static const struct user_regset aarch32_regsets[] = {
793 [REGSET_COMPAT_GPR] = {
794 .core_note_type = NT_PRSTATUS,
795 .n = COMPAT_ELF_NGREG,
796 .size = sizeof(compat_elf_greg_t),
797 .align = sizeof(compat_elf_greg_t),
798 .get = compat_gpr_get,
799 .set = compat_gpr_set
801 [REGSET_COMPAT_VFP] = {
802 .core_note_type = NT_ARM_VFP,
803 .n = VFP_STATE_SIZE / sizeof(compat_ulong_t),
804 .size = sizeof(compat_ulong_t),
805 .align = sizeof(compat_ulong_t),
806 .get = compat_vfp_get,
807 .set = compat_vfp_set
811 static const struct user_regset_view user_aarch32_view = {
812 .name = "aarch32", .e_machine = EM_ARM,
813 .regsets = aarch32_regsets, .n = ARRAY_SIZE(aarch32_regsets)
816 static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off,
817 compat_ulong_t __user *ret)
824 if (off == COMPAT_PT_TEXT_ADDR)
825 tmp = tsk->mm->start_code;
826 else if (off == COMPAT_PT_DATA_ADDR)
827 tmp = tsk->mm->start_data;
828 else if (off == COMPAT_PT_TEXT_END_ADDR)
829 tmp = tsk->mm->end_code;
830 else if (off < sizeof(compat_elf_gregset_t))
831 return copy_regset_to_user(tsk, &user_aarch32_view,
832 REGSET_COMPAT_GPR, off,
833 sizeof(compat_ulong_t), ret);
834 else if (off >= COMPAT_USER_SZ)
839 return put_user(tmp, ret);
842 static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
846 mm_segment_t old_fs = get_fs();
848 if (off & 3 || off >= COMPAT_USER_SZ)
851 if (off >= sizeof(compat_elf_gregset_t))
855 ret = copy_regset_from_user(tsk, &user_aarch32_view,
856 REGSET_COMPAT_GPR, off,
857 sizeof(compat_ulong_t),
864 #ifdef CONFIG_HAVE_HW_BREAKPOINT
867 * Convert a virtual register number into an index for a thread_info
868 * breakpoint array. Breakpoints are identified using positive numbers
869 * whilst watchpoints are negative. The registers are laid out as pairs
870 * of (address, control), each pair mapping to a unique hw_breakpoint struct.
871 * Register 0 is reserved for describing resource information.
873 static int compat_ptrace_hbp_num_to_idx(compat_long_t num)
875 return (abs(num) - 1) >> 1;
878 static int compat_ptrace_hbp_get_resource_info(u32 *kdata)
880 u8 num_brps, num_wrps, debug_arch, wp_len;
883 num_brps = hw_breakpoint_slots(TYPE_INST);
884 num_wrps = hw_breakpoint_slots(TYPE_DATA);
886 debug_arch = debug_monitors_arch();
900 static int compat_ptrace_hbp_get(unsigned int note_type,
901 struct task_struct *tsk,
908 int err, idx = compat_ptrace_hbp_num_to_idx(num);;
911 err = ptrace_hbp_get_addr(note_type, tsk, idx, &addr);
914 err = ptrace_hbp_get_ctrl(note_type, tsk, idx, &ctrl);
921 static int compat_ptrace_hbp_set(unsigned int note_type,
922 struct task_struct *tsk,
929 int err, idx = compat_ptrace_hbp_num_to_idx(num);
933 err = ptrace_hbp_set_addr(note_type, tsk, idx, addr);
936 err = ptrace_hbp_set_ctrl(note_type, tsk, idx, ctrl);
942 static int compat_ptrace_gethbpregs(struct task_struct *tsk, compat_long_t num,
943 compat_ulong_t __user *data)
947 mm_segment_t old_fs = get_fs();
952 ret = compat_ptrace_hbp_get(NT_ARM_HW_WATCH, tsk, num, &kdata);
954 } else if (num == 0) {
955 ret = compat_ptrace_hbp_get_resource_info(&kdata);
958 ret = compat_ptrace_hbp_get(NT_ARM_HW_BREAK, tsk, num, &kdata);
963 ret = put_user(kdata, data);
968 static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num,
969 compat_ulong_t __user *data)
973 mm_segment_t old_fs = get_fs();
978 ret = get_user(kdata, data);
984 ret = compat_ptrace_hbp_set(NT_ARM_HW_WATCH, tsk, num, &kdata);
986 ret = compat_ptrace_hbp_set(NT_ARM_HW_BREAK, tsk, num, &kdata);
991 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
993 long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
994 compat_ulong_t caddr, compat_ulong_t cdata)
996 unsigned long addr = caddr;
997 unsigned long data = cdata;
998 void __user *datap = compat_ptr(data);
1002 case PTRACE_PEEKUSR:
1003 ret = compat_ptrace_read_user(child, addr, datap);
1006 case PTRACE_POKEUSR:
1007 ret = compat_ptrace_write_user(child, addr, data);
1010 case COMPAT_PTRACE_GETREGS:
1011 ret = copy_regset_to_user(child,
1014 0, sizeof(compat_elf_gregset_t),
1018 case COMPAT_PTRACE_SETREGS:
1019 ret = copy_regset_from_user(child,
1022 0, sizeof(compat_elf_gregset_t),
1026 case COMPAT_PTRACE_GET_THREAD_AREA:
1027 ret = put_user((compat_ulong_t)child->thread.tp_value,
1028 (compat_ulong_t __user *)datap);
1031 case COMPAT_PTRACE_SET_SYSCALL:
1032 task_pt_regs(child)->syscallno = data;
1036 case COMPAT_PTRACE_GETVFPREGS:
1037 ret = copy_regset_to_user(child,
1044 case COMPAT_PTRACE_SETVFPREGS:
1045 ret = copy_regset_from_user(child,
1052 #ifdef CONFIG_HAVE_HW_BREAKPOINT
1053 case COMPAT_PTRACE_GETHBPREGS:
1054 ret = compat_ptrace_gethbpregs(child, addr, datap);
1057 case COMPAT_PTRACE_SETHBPREGS:
1058 ret = compat_ptrace_sethbpregs(child, addr, datap);
1063 ret = compat_ptrace_request(child, request, addr,
1070 #endif /* CONFIG_COMPAT */
1072 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
1074 #ifdef CONFIG_COMPAT
1075 if (is_compat_thread(task_thread_info(task)))
1076 return &user_aarch32_view;
1078 return &user_aarch64_view;
1081 long arch_ptrace(struct task_struct *child, long request,
1082 unsigned long addr, unsigned long data)
1084 return ptrace_request(child, request, addr, data);
1087 asmlinkage int syscall_trace(int dir, struct pt_regs *regs)
1089 unsigned long saved_reg;
1091 if (!test_thread_flag(TIF_SYSCALL_TRACE))
1092 return regs->syscallno;
1094 if (is_compat_task()) {
1095 /* AArch32 uses ip (r12) for scratch */
1096 saved_reg = regs->regs[12];
1097 regs->regs[12] = dir;
1100 * Save X7. X7 is used to denote syscall entry/exit:
1101 * X7 = 0 -> entry, = 1 -> exit
1103 saved_reg = regs->regs[7];
1104 regs->regs[7] = dir;
1108 tracehook_report_syscall_exit(regs, 0);
1109 else if (tracehook_report_syscall_entry(regs))
1110 regs->syscallno = ~0UL;
1112 if (is_compat_task())
1113 regs->regs[12] = saved_reg;
1115 regs->regs[7] = saved_reg;
1117 return regs->syscallno;