Skip to content

Commit 47e1285

Browse files
author
Al Viro
committed
powerpc: switch to ->regset_get()
Note: compat variant of REGSET_TM_CGPR is almost certainly wrong; it claims to be 48*64bit, but just as compat REGSET_GPR it stores 44*32bit of (truncated) registers + 4 32bit zeros... followed by 48 more 32bit zeroes. Might be too late to change - it's a userland ABI, after all ;-/ Signed-off-by: Al Viro <[email protected]>
1 parent 0557d64 commit 47e1285

File tree

7 files changed

+148
-304
lines changed

7 files changed

+148
-304
lines changed

arch/powerpc/kernel/ptrace/ptrace-altivec.c

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,25 @@ int vr_active(struct task_struct *target, const struct user_regset *regset)
4141
* };
4242
*/
4343
int vr_get(struct task_struct *target, const struct user_regset *regset,
44-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
44+
struct membuf to)
4545
{
46-
int ret;
46+
union {
47+
elf_vrreg_t reg;
48+
u32 word;
49+
} vrsave;
4750

4851
flush_altivec_to_thread(target);
4952

5053
BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
5154
offsetof(struct thread_vr_state, vr[32]));
5255

53-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
54-
&target->thread.vr_state, 0,
55-
33 * sizeof(vector128));
56-
if (!ret) {
57-
/*
58-
* Copy out only the low-order word of vrsave.
59-
*/
60-
int start, end;
61-
union {
62-
elf_vrreg_t reg;
63-
u32 word;
64-
} vrsave;
65-
memset(&vrsave, 0, sizeof(vrsave));
66-
67-
vrsave.word = target->thread.vrsave;
68-
69-
start = 33 * sizeof(vector128);
70-
end = start + sizeof(vrsave);
71-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &vrsave,
72-
start, end);
73-
}
74-
75-
return ret;
56+
membuf_write(&to, &target->thread.vr_state, 33 * sizeof(vector128));
57+
/*
58+
* Copy out only the low-order word of vrsave.
59+
*/
60+
memset(&vrsave, 0, sizeof(vrsave));
61+
vrsave.word = target->thread.vrsave;
62+
return membuf_write(&to, &vrsave, sizeof(vrsave));
7663
}
7764

7865
/*

arch/powerpc/kernel/ptrace/ptrace-decl.h

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,31 @@ enum powerpc_regset {
6363

6464
/* ptrace-(no)vsx */
6565

66-
int fpr_get(struct task_struct *target, const struct user_regset *regset,
67-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
66+
user_regset_get2_fn fpr_get;
6867
int fpr_set(struct task_struct *target, const struct user_regset *regset,
6968
unsigned int pos, unsigned int count,
7069
const void *kbuf, const void __user *ubuf);
7170

7271
/* ptrace-vsx */
7372

7473
int vsr_active(struct task_struct *target, const struct user_regset *regset);
75-
int vsr_get(struct task_struct *target, const struct user_regset *regset,
76-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
74+
user_regset_get2_fn vsr_get;
7775
int vsr_set(struct task_struct *target, const struct user_regset *regset,
7876
unsigned int pos, unsigned int count,
7977
const void *kbuf, const void __user *ubuf);
8078

8179
/* ptrace-altivec */
8280

8381
int vr_active(struct task_struct *target, const struct user_regset *regset);
84-
int vr_get(struct task_struct *target, const struct user_regset *regset,
85-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
82+
user_regset_get2_fn vr_get;
8683
int vr_set(struct task_struct *target, const struct user_regset *regset,
8784
unsigned int pos, unsigned int count,
8885
const void *kbuf, const void __user *ubuf);
8986

9087
/* ptrace-spe */
9188

9289
int evr_active(struct task_struct *target, const struct user_regset *regset);
93-
int evr_get(struct task_struct *target, const struct user_regset *regset,
94-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
90+
user_regset_get2_fn evr_get;
9591
int evr_set(struct task_struct *target, const struct user_regset *regset,
9692
unsigned int pos, unsigned int count,
9793
const void *kbuf, const void __user *ubuf);
@@ -100,9 +96,8 @@ int evr_set(struct task_struct *target, const struct user_regset *regset,
10096

10197
int gpr32_get_common(struct task_struct *target,
10298
const struct user_regset *regset,
103-
unsigned int pos, unsigned int count,
104-
void *kbuf, void __user *ubuf,
105-
unsigned long *regs);
99+
struct membuf to,
100+
unsigned long *regs);
106101
int gpr32_set_common(struct task_struct *target,
107102
const struct user_regset *regset,
108103
unsigned int pos, unsigned int count,
@@ -118,55 +113,46 @@ static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
118113
#endif
119114

120115
int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset);
121-
int tm_cgpr_get(struct task_struct *target, const struct user_regset *regset,
122-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
116+
user_regset_get2_fn tm_cgpr_get;
123117
int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset,
124118
unsigned int pos, unsigned int count,
125119
const void *kbuf, const void __user *ubuf);
126120
int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset);
127-
int tm_cfpr_get(struct task_struct *target, const struct user_regset *regset,
128-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
121+
user_regset_get2_fn tm_cfpr_get;
129122
int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset,
130123
unsigned int pos, unsigned int count,
131124
const void *kbuf, const void __user *ubuf);
132125
int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset);
133-
int tm_cvmx_get(struct task_struct *target, const struct user_regset *regset,
134-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
126+
user_regset_get2_fn tm_cvmx_get;
135127
int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset,
136128
unsigned int pos, unsigned int count,
137129
const void *kbuf, const void __user *ubuf);
138130
int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset);
139-
int tm_cvsx_get(struct task_struct *target, const struct user_regset *regset,
140-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
131+
user_regset_get2_fn tm_cvsx_get;
141132
int tm_cvsx_set(struct task_struct *target, const struct user_regset *regset,
142133
unsigned int pos, unsigned int count,
143134
const void *kbuf, const void __user *ubuf);
144135
int tm_spr_active(struct task_struct *target, const struct user_regset *regset);
145-
int tm_spr_get(struct task_struct *target, const struct user_regset *regset,
146-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
136+
user_regset_get2_fn tm_spr_get;
147137
int tm_spr_set(struct task_struct *target, const struct user_regset *regset,
148138
unsigned int pos, unsigned int count,
149139
const void *kbuf, const void __user *ubuf);
150140
int tm_tar_active(struct task_struct *target, const struct user_regset *regset);
151-
int tm_tar_get(struct task_struct *target, const struct user_regset *regset,
152-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
141+
user_regset_get2_fn tm_tar_get;
153142
int tm_tar_set(struct task_struct *target, const struct user_regset *regset,
154143
unsigned int pos, unsigned int count,
155144
const void *kbuf, const void __user *ubuf);
156145
int tm_ppr_active(struct task_struct *target, const struct user_regset *regset);
157-
int tm_ppr_get(struct task_struct *target, const struct user_regset *regset,
158-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
146+
user_regset_get2_fn tm_ppr_get;
159147
int tm_ppr_set(struct task_struct *target, const struct user_regset *regset,
160148
unsigned int pos, unsigned int count,
161149
const void *kbuf, const void __user *ubuf);
162150
int tm_dscr_active(struct task_struct *target, const struct user_regset *regset);
163-
int tm_dscr_get(struct task_struct *target, const struct user_regset *regset,
164-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
151+
user_regset_get2_fn tm_dscr_get;
165152
int tm_dscr_set(struct task_struct *target, const struct user_regset *regset,
166153
unsigned int pos, unsigned int count,
167154
const void *kbuf, const void __user *ubuf);
168-
int tm_cgpr32_get(struct task_struct *target, const struct user_regset *regset,
169-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
155+
user_regset_get2_fn tm_cgpr32_get;
170156
int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset,
171157
unsigned int pos, unsigned int count,
172158
const void *kbuf, const void __user *ubuf);

arch/powerpc/kernel/ptrace/ptrace-novsx.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
* };
2020
*/
2121
int fpr_get(struct task_struct *target, const struct user_regset *regset,
22-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
22+
struct membuf to)
2323
{
2424
BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
2525
offsetof(struct thread_fp_state, fpr[32]));
2626

2727
flush_fp_to_thread(target);
2828

29-
return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
30-
&target->thread.fp_state, 0, -1);
29+
return membuf_write(&to, &target->thread.fp_state, 33 * sizeof(u64));
3130
}
3231

3332
/*

arch/powerpc/kernel/ptrace/ptrace-spe.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,17 @@ int evr_active(struct task_struct *target, const struct user_regset *regset)
2323
}
2424

2525
int evr_get(struct task_struct *target, const struct user_regset *regset,
26-
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
26+
struct membuf to)
2727
{
28-
int ret;
29-
3028
flush_spe_to_thread(target);
3129

32-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
33-
&target->thread.evr,
34-
0, sizeof(target->thread.evr));
30+
membuf_write(&to, &target->thread.evr, sizeof(target->thread.evr));
3531

3632
BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
3733
offsetof(struct thread_struct, spefscr));
3834

39-
if (!ret)
40-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
41-
&target->thread.acc,
42-
sizeof(target->thread.evr), -1);
43-
44-
return ret;
35+
return membuf_write(&to, &target->thread.acc,
36+
sizeof(u64) + sizeof(u32));
4537
}
4638

4739
int evr_set(struct task_struct *target, const struct user_regset *regset,

0 commit comments

Comments
 (0)