sh: convert to ->regset_get()
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 16 Jun 2020 04:54:51 +0000 (00:54 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 27 Jul 2020 18:31:09 +0000 (14:31 -0400)
NB: there's a direct call of fpregs_get() left in dump_fpu().
To be taken out once we convert ELF_FDPIC to use of regset.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/sh/kernel/process_32.c
arch/sh/kernel/ptrace_32.c

index 456cc8d..6ab397b 100644 (file)
@@ -103,9 +103,8 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
 
        fpvalid = !!tsk_used_math(tsk);
        if (fpvalid)
-               fpvalid = !fpregs_get(tsk, NULL, 0,
-                                     sizeof(struct user_fpu_struct),
-                                     fpu, NULL);
+               fpvalid = !fpregs_get(tsk, NULL,
+                                     (struct membuf){fpu, sizeof(*fpu)});
 #endif
 
        return fpvalid;
index 64bfb71..5c93bdb 100644 (file)
@@ -134,26 +134,11 @@ void ptrace_disable(struct task_struct *child)
 
 static int genregs_get(struct task_struct *target,
                       const struct user_regset *regset,
-                      unsigned int pos, unsigned int count,
-                      void *kbuf, void __user *ubuf)
+                      struct membuf to)
 {
        const struct pt_regs *regs = task_pt_regs(target);
-       int ret;
 
-       ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-                                 regs->regs,
-                                 0, 16 * sizeof(unsigned long));
-       if (!ret)
-               /* PC, PR, SR, GBR, MACH, MACL, TRA */
-               ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-                                         &regs->pc,
-                                         offsetof(struct pt_regs, pc),
-                                         sizeof(struct pt_regs));
-       if (!ret)
-               ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
-                                              sizeof(struct pt_regs), -1);
-
-       return ret;
+       return membuf_write(&to, regs, sizeof(struct pt_regs));
 }
 
 static int genregs_set(struct task_struct *target,
@@ -182,8 +167,7 @@ static int genregs_set(struct task_struct *target,
 #ifdef CONFIG_SH_FPU
 int fpregs_get(struct task_struct *target,
               const struct user_regset *regset,
-              unsigned int pos, unsigned int count,
-              void *kbuf, void __user *ubuf)
+              struct membuf to)
 {
        int ret;
 
@@ -191,12 +175,8 @@ int fpregs_get(struct task_struct *target,
        if (ret)
                return ret;
 
-       if ((boot_cpu_data.flags & CPU_HAS_FPU))
-               return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-                                          &target->thread.xstate->hardfpu, 0, -1);
-
-       return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-                                  &target->thread.xstate->softfpu, 0, -1);
+       return membuf_write(&to, target->thread.xstate,
+                           sizeof(struct user_fpu_struct));
 }
 
 static int fpregs_set(struct task_struct *target,
@@ -230,20 +210,12 @@ static int fpregs_active(struct task_struct *target,
 #ifdef CONFIG_SH_DSP
 static int dspregs_get(struct task_struct *target,
                       const struct user_regset *regset,
-                      unsigned int pos, unsigned int count,
-                      void *kbuf, void __user *ubuf)
+                      struct membuf to)
 {
        const struct pt_dspregs *regs =
                (struct pt_dspregs *)&target->thread.dsp_status.dsp_regs;
-       int ret;
 
-       ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, regs,
-                                 0, sizeof(struct pt_dspregs));
-       if (!ret)
-               ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
-                                              sizeof(struct pt_dspregs), -1);
-
-       return ret;
+       return membuf_write(&to, regs, sizeof(struct pt_dspregs));
 }
 
 static int dspregs_set(struct task_struct *target,
@@ -324,7 +296,7 @@ static const struct user_regset sh_regsets[] = {
                .n              = ELF_NGREG,
                .size           = sizeof(long),
                .align          = sizeof(long),
-               .get            = genregs_get,
+               .regset_get             = genregs_get,
                .set            = genregs_set,
        },
 
@@ -334,7 +306,7 @@ static const struct user_regset sh_regsets[] = {
                .n              = sizeof(struct user_fpu_struct) / sizeof(long),
                .size           = sizeof(long),
                .align          = sizeof(long),
-               .get            = fpregs_get,
+               .regset_get             = fpregs_get,
                .set            = fpregs_set,
                .active         = fpregs_active,
        },
@@ -345,7 +317,7 @@ static const struct user_regset sh_regsets[] = {
                .n              = sizeof(struct pt_dspregs) / sizeof(long),
                .size           = sizeof(long),
                .align          = sizeof(long),
-               .get            = dspregs_get,
+               .regset_get             = dspregs_get,
                .set            = dspregs_set,
                .active         = dspregs_active,
        },