Skip to content

Commit 2cb6cd4

Browse files
author
Al Viro
committed
riscv: switch to ->regset_get()
Note: riscv_fpr_get() used to forget to zero-pad at the end. Not worth -stable... Signed-off-by: Al Viro <[email protected]>
1 parent c7a0faa commit 2cb6cd4

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

arch/riscv/kernel/ptrace.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,10 @@ enum riscv_regset {
3030

3131
static int riscv_gpr_get(struct task_struct *target,
3232
const struct user_regset *regset,
33-
unsigned int pos, unsigned int count,
34-
void *kbuf, void __user *ubuf)
33+
struct membuf to)
3534
{
36-
struct pt_regs *regs;
37-
38-
regs = task_pt_regs(target);
39-
return user_regset_copyout(&pos, &count, &kbuf, &ubuf, regs, 0, -1);
35+
return membuf_write(&to, task_pt_regs(target),
36+
sizeof(struct user_regs_struct));
4037
}
4138

4239
static int riscv_gpr_set(struct task_struct *target,
@@ -55,21 +52,13 @@ static int riscv_gpr_set(struct task_struct *target,
5552
#ifdef CONFIG_FPU
5653
static int riscv_fpr_get(struct task_struct *target,
5754
const struct user_regset *regset,
58-
unsigned int pos, unsigned int count,
59-
void *kbuf, void __user *ubuf)
55+
struct membuf to)
6056
{
61-
int ret;
6257
struct __riscv_d_ext_state *fstate = &target->thread.fstate;
6358

64-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, fstate, 0,
65-
offsetof(struct __riscv_d_ext_state, fcsr));
66-
if (!ret) {
67-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, fstate, 0,
68-
offsetof(struct __riscv_d_ext_state, fcsr) +
69-
sizeof(fstate->fcsr));
70-
}
71-
72-
return ret;
59+
membuf_write(&to, fstate, offsetof(struct __riscv_d_ext_state, fcsr));
60+
membuf_store(&to, fstate->fcsr);
61+
return membuf_zero(&to, 4); // explicitly pad
7362
}
7463

7564
static int riscv_fpr_set(struct task_struct *target,
@@ -98,17 +87,17 @@ static const struct user_regset riscv_user_regset[] = {
9887
.n = ELF_NGREG,
9988
.size = sizeof(elf_greg_t),
10089
.align = sizeof(elf_greg_t),
101-
.get = &riscv_gpr_get,
102-
.set = &riscv_gpr_set,
90+
.regset_get = riscv_gpr_get,
91+
.set = riscv_gpr_set,
10392
},
10493
#ifdef CONFIG_FPU
10594
[REGSET_F] = {
10695
.core_note_type = NT_PRFPREG,
10796
.n = ELF_NFPREG,
10897
.size = sizeof(elf_fpreg_t),
10998
.align = sizeof(elf_fpreg_t),
110-
.get = &riscv_fpr_get,
111-
.set = &riscv_fpr_set,
99+
.regset_get = riscv_fpr_get,
100+
.set = riscv_fpr_set,
112101
},
113102
#endif
114103
};

0 commit comments

Comments
 (0)