308
338
return put_user_reg(tsk, off >> 2, val);
312
* Get all user integer registers.
314
static int ptrace_getregs(struct task_struct *tsk, void __user *uregs)
316
struct pt_regs *regs = task_pt_regs(tsk);
318
return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0;
322
* Set all user integer registers.
324
static int ptrace_setregs(struct task_struct *tsk, void __user *uregs)
326
struct pt_regs newregs;
330
if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) {
331
struct pt_regs *regs = task_pt_regs(tsk);
334
if (valid_user_regs(&newregs)) {
344
* Get the child FPU state.
346
static int ptrace_getfpregs(struct task_struct *tsk, void __user *ufp)
348
return copy_to_user(ufp, &task_thread_info(tsk)->fpstate,
349
sizeof(struct user_fp)) ? -EFAULT : 0;
353
* Set the child FPU state.
355
static int ptrace_setfpregs(struct task_struct *tsk, void __user *ufp)
357
struct thread_info *thread = task_thread_info(tsk);
358
thread->used_cp[1] = thread->used_cp[2] = 1;
359
return copy_from_user(&thread->fpstate, ufp,
360
sizeof(struct user_fp)) ? -EFAULT : 0;
363
341
#ifdef CONFIG_IWMMXT
423
* Get the child VFP state.
425
static int ptrace_getvfpregs(struct task_struct *tsk, void __user *data)
427
struct thread_info *thread = task_thread_info(tsk);
428
union vfp_state *vfp = &thread->vfpstate;
429
struct user_vfp __user *ufp = data;
431
vfp_sync_hwstate(thread);
433
/* copy the floating point registers */
434
if (copy_to_user(&ufp->fpregs, &vfp->hard.fpregs,
435
sizeof(vfp->hard.fpregs)))
438
/* copy the status and control register */
439
if (put_user(vfp->hard.fpscr, &ufp->fpscr))
446
* Set the child VFP state.
448
static int ptrace_setvfpregs(struct task_struct *tsk, void __user *data)
450
struct thread_info *thread = task_thread_info(tsk);
451
union vfp_state *vfp = &thread->vfpstate;
452
struct user_vfp __user *ufp = data;
454
vfp_sync_hwstate(thread);
456
/* copy the floating point registers */
457
if (copy_from_user(&vfp->hard.fpregs, &ufp->fpregs,
458
sizeof(vfp->hard.fpregs)))
461
/* copy the status and control register */
462
if (get_user(vfp->hard.fpscr, &ufp->fpscr))
465
vfp_flush_hwstate(thread);
471
399
#ifdef CONFIG_HAVE_HW_BREAKPOINT
473
401
* Convert a virtual register number into an index for a thread_info
625
/* regset get/set implementations */
627
static int gpr_get(struct task_struct *target,
628
const struct user_regset *regset,
629
unsigned int pos, unsigned int count,
630
void *kbuf, void __user *ubuf)
632
struct pt_regs *regs = task_pt_regs(target);
634
return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
639
static int gpr_set(struct task_struct *target,
640
const struct user_regset *regset,
641
unsigned int pos, unsigned int count,
642
const void *kbuf, const void __user *ubuf)
645
struct pt_regs newregs;
647
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
653
if (!valid_user_regs(&newregs))
656
*task_pt_regs(target) = newregs;
660
static int fpa_get(struct task_struct *target,
661
const struct user_regset *regset,
662
unsigned int pos, unsigned int count,
663
void *kbuf, void __user *ubuf)
665
return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
666
&task_thread_info(target)->fpstate,
667
0, sizeof(struct user_fp));
670
static int fpa_set(struct task_struct *target,
671
const struct user_regset *regset,
672
unsigned int pos, unsigned int count,
673
const void *kbuf, const void __user *ubuf)
675
struct thread_info *thread = task_thread_info(target);
677
thread->used_cp[1] = thread->used_cp[2] = 1;
679
return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
681
0, sizeof(struct user_fp));
686
* VFP register get/set implementations.
688
* With respect to the kernel, struct user_fp is divided into three chunks:
689
* 16 or 32 real VFP registers (d0-d15 or d0-31)
690
* These are transferred to/from the real registers in the task's
691
* vfp_hard_struct. The number of registers depends on the kernel
694
* 16 or 0 fake VFP registers (d16-d31 or empty)
695
* i.e., the user_vfp structure has space for 32 registers even if
696
* the kernel doesn't have them all.
698
* vfp_get() reads this chunk as zero where applicable
699
* vfp_set() ignores this chunk
701
* 1 word for the FPSCR
703
* The bounds-checking logic built into user_regset_copyout and friends
704
* means that we can make a simple sequence of calls to map the relevant data
705
* to/from the specified slice of the user regset structure.
707
static int vfp_get(struct task_struct *target,
708
const struct user_regset *regset,
709
unsigned int pos, unsigned int count,
710
void *kbuf, void __user *ubuf)
713
struct thread_info *thread = task_thread_info(target);
714
struct vfp_hard_struct const *vfp = &thread->vfpstate.hard;
715
const size_t user_fpregs_offset = offsetof(struct user_vfp, fpregs);
716
const size_t user_fpscr_offset = offsetof(struct user_vfp, fpscr);
718
vfp_sync_hwstate(thread);
720
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
723
user_fpregs_offset + sizeof(vfp->fpregs));
727
ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
728
user_fpregs_offset + sizeof(vfp->fpregs),
733
return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
736
user_fpscr_offset + sizeof(vfp->fpscr));
740
* For vfp_set() a read-modify-write is done on the VFP registers,
741
* in order to avoid writing back a half-modified set of registers on
744
static int vfp_set(struct task_struct *target,
745
const struct user_regset *regset,
746
unsigned int pos, unsigned int count,
747
const void *kbuf, const void __user *ubuf)
750
struct thread_info *thread = task_thread_info(target);
751
struct vfp_hard_struct new_vfp = thread->vfpstate.hard;
752
const size_t user_fpregs_offset = offsetof(struct user_vfp, fpregs);
753
const size_t user_fpscr_offset = offsetof(struct user_vfp, fpscr);
755
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
758
user_fpregs_offset + sizeof(new_vfp.fpregs));
762
ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
763
user_fpregs_offset + sizeof(new_vfp.fpregs),
768
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
771
user_fpscr_offset + sizeof(new_vfp.fpscr));
775
vfp_sync_hwstate(thread);
776
thread->vfpstate.hard = new_vfp;
777
vfp_flush_hwstate(thread);
781
#endif /* CONFIG_VFP */
791
static const struct user_regset arm_regsets[] = {
793
.core_note_type = NT_PRSTATUS,
796
.align = sizeof(u32),
802
* For the FPA regs in fpstate, the real fields are a mixture
803
* of sizes, so pretend that the registers are word-sized:
805
.core_note_type = NT_PRFPREG,
806
.n = sizeof(struct user_fp) / sizeof(u32),
808
.align = sizeof(u32),
815
* Pretend that the VFP regs are word-sized, since the FPSCR is
816
* a single word dangling at the end of struct user_vfp:
818
.core_note_type = NT_ARM_VFP,
819
.n = ARM_VFPREGS_SIZE / sizeof(u32),
821
.align = sizeof(u32),
825
#endif /* CONFIG_VFP */
828
static const struct user_regset_view user_arm_view = {
829
.name = "arm", .e_machine = ELF_ARCH, .ei_osabi = ELF_OSABI,
830
.regsets = arm_regsets, .n = ARRAY_SIZE(arm_regsets)
833
const struct user_regset_view *task_user_regset_view(struct task_struct *task)
835
return &user_arm_view;
697
838
long arch_ptrace(struct task_struct *child, long request,
698
839
unsigned long addr, unsigned long data)
712
853
case PTRACE_GETREGS:
713
ret = ptrace_getregs(child, datap);
854
ret = copy_regset_to_user(child,
855
&user_arm_view, REGSET_GPR,
856
0, sizeof(struct pt_regs),
716
860
case PTRACE_SETREGS:
717
ret = ptrace_setregs(child, datap);
861
ret = copy_regset_from_user(child,
862
&user_arm_view, REGSET_GPR,
863
0, sizeof(struct pt_regs),
720
867
case PTRACE_GETFPREGS:
721
ret = ptrace_getfpregs(child, datap);
868
ret = copy_regset_to_user(child,
869
&user_arm_view, REGSET_FPR,
870
0, sizeof(union fp_state),
724
874
case PTRACE_SETFPREGS:
725
ret = ptrace_setfpregs(child, datap);
875
ret = copy_regset_from_user(child,
876
&user_arm_view, REGSET_FPR,
877
0, sizeof(union fp_state),
728
881
#ifdef CONFIG_IWMMXT