@@ -18,88 +18,61 @@ static struct callee_regs *task_callee_regs(struct task_struct *tsk)
18
18
19
19
static int genregs_get (struct task_struct * target ,
20
20
const struct user_regset * regset ,
21
- unsigned int pos , unsigned int count ,
22
- void * kbuf , void __user * ubuf )
21
+ struct membuf to )
23
22
{
24
23
const struct pt_regs * ptregs = task_pt_regs (target );
25
24
const struct callee_regs * cregs = task_callee_regs (target );
26
- int ret = 0 ;
27
25
unsigned int stop_pc_val ;
28
26
29
- #define REG_O_CHUNK (START , END , PTR ) \
30
- if (!ret) \
31
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, PTR, \
32
- offsetof(struct user_regs_struct, START), \
33
- offsetof(struct user_regs_struct, END));
34
-
35
- #define REG_O_ONE (LOC , PTR ) \
36
- if (!ret) \
37
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, PTR, \
38
- offsetof(struct user_regs_struct, LOC), \
39
- offsetof(struct user_regs_struct, LOC) + 4);
40
-
41
- #define REG_O_ZERO (LOC ) \
42
- if (!ret) \
43
- ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, \
44
- offsetof(struct user_regs_struct, LOC), \
45
- offsetof(struct user_regs_struct, LOC) + 4);
46
-
47
- REG_O_ZERO (pad );
48
- REG_O_ONE (scratch .bta , & ptregs -> bta );
49
- REG_O_ONE (scratch .lp_start , & ptregs -> lp_start );
50
- REG_O_ONE (scratch .lp_end , & ptregs -> lp_end );
51
- REG_O_ONE (scratch .lp_count , & ptregs -> lp_count );
52
- REG_O_ONE (scratch .status32 , & ptregs -> status32 );
53
- REG_O_ONE (scratch .ret , & ptregs -> ret );
54
- REG_O_ONE (scratch .blink , & ptregs -> blink );
55
- REG_O_ONE (scratch .fp , & ptregs -> fp );
56
- REG_O_ONE (scratch .gp , & ptregs -> r26 );
57
- REG_O_ONE (scratch .r12 , & ptregs -> r12 );
58
- REG_O_ONE (scratch .r11 , & ptregs -> r11 );
59
- REG_O_ONE (scratch .r10 , & ptregs -> r10 );
60
- REG_O_ONE (scratch .r9 , & ptregs -> r9 );
61
- REG_O_ONE (scratch .r8 , & ptregs -> r8 );
62
- REG_O_ONE (scratch .r7 , & ptregs -> r7 );
63
- REG_O_ONE (scratch .r6 , & ptregs -> r6 );
64
- REG_O_ONE (scratch .r5 , & ptregs -> r5 );
65
- REG_O_ONE (scratch .r4 , & ptregs -> r4 );
66
- REG_O_ONE (scratch .r3 , & ptregs -> r3 );
67
- REG_O_ONE (scratch .r2 , & ptregs -> r2 );
68
- REG_O_ONE (scratch .r1 , & ptregs -> r1 );
69
- REG_O_ONE (scratch .r0 , & ptregs -> r0 );
70
- REG_O_ONE (scratch .sp , & ptregs -> sp );
71
-
72
- REG_O_ZERO (pad2 );
73
-
74
- REG_O_ONE (callee .r25 , & cregs -> r25 );
75
- REG_O_ONE (callee .r24 , & cregs -> r24 );
76
- REG_O_ONE (callee .r23 , & cregs -> r23 );
77
- REG_O_ONE (callee .r22 , & cregs -> r22 );
78
- REG_O_ONE (callee .r21 , & cregs -> r21 );
79
- REG_O_ONE (callee .r20 , & cregs -> r20 );
80
- REG_O_ONE (callee .r19 , & cregs -> r19 );
81
- REG_O_ONE (callee .r18 , & cregs -> r18 );
82
- REG_O_ONE (callee .r17 , & cregs -> r17 );
83
- REG_O_ONE (callee .r16 , & cregs -> r16 );
84
- REG_O_ONE (callee .r15 , & cregs -> r15 );
85
- REG_O_ONE (callee .r14 , & cregs -> r14 );
86
- REG_O_ONE (callee .r13 , & cregs -> r13 );
87
-
88
- REG_O_ONE (efa , & target -> thread .fault_address );
89
-
90
- if (!ret ) {
91
- if (in_brkpt_trap (ptregs )) {
92
- stop_pc_val = target -> thread .fault_address ;
93
- pr_debug ("\t\tstop_pc (brk-pt)\n" );
94
- } else {
95
- stop_pc_val = ptregs -> ret ;
96
- pr_debug ("\t\tstop_pc (others)\n" );
97
- }
98
-
99
- REG_O_ONE (stop_pc , & stop_pc_val );
27
+ membuf_zero (& to , 4 ); // pad
28
+ membuf_store (& to , ptregs -> bta );
29
+ membuf_store (& to , ptregs -> lp_start );
30
+ membuf_store (& to , ptregs -> lp_end );
31
+ membuf_store (& to , ptregs -> lp_count );
32
+ membuf_store (& to , ptregs -> status32 );
33
+ membuf_store (& to , ptregs -> ret );
34
+ membuf_store (& to , ptregs -> blink );
35
+ membuf_store (& to , ptregs -> fp );
36
+ membuf_store (& to , ptregs -> r26 ); // gp
37
+ membuf_store (& to , ptregs -> r12 );
38
+ membuf_store (& to , ptregs -> r11 );
39
+ membuf_store (& to , ptregs -> r10 );
40
+ membuf_store (& to , ptregs -> r9 );
41
+ membuf_store (& to , ptregs -> r8 );
42
+ membuf_store (& to , ptregs -> r7 );
43
+ membuf_store (& to , ptregs -> r6 );
44
+ membuf_store (& to , ptregs -> r5 );
45
+ membuf_store (& to , ptregs -> r4 );
46
+ membuf_store (& to , ptregs -> r3 );
47
+ membuf_store (& to , ptregs -> r2 );
48
+ membuf_store (& to , ptregs -> r1 );
49
+ membuf_store (& to , ptregs -> r0 );
50
+ membuf_store (& to , ptregs -> sp );
51
+ membuf_zero (& to , 4 ); // pad2
52
+ membuf_store (& to , cregs -> r25 );
53
+ membuf_store (& to , cregs -> r24 );
54
+ membuf_store (& to , cregs -> r23 );
55
+ membuf_store (& to , cregs -> r22 );
56
+ membuf_store (& to , cregs -> r21 );
57
+ membuf_store (& to , cregs -> r20 );
58
+ membuf_store (& to , cregs -> r19 );
59
+ membuf_store (& to , cregs -> r18 );
60
+ membuf_store (& to , cregs -> r17 );
61
+ membuf_store (& to , cregs -> r16 );
62
+ membuf_store (& to , cregs -> r15 );
63
+ membuf_store (& to , cregs -> r14 );
64
+ membuf_store (& to , cregs -> r13 );
65
+ membuf_store (& to , target -> thread .fault_address ); // efa
66
+
67
+ if (in_brkpt_trap (ptregs )) {
68
+ stop_pc_val = target -> thread .fault_address ;
69
+ pr_debug ("\t\tstop_pc (brk-pt)\n" );
70
+ } else {
71
+ stop_pc_val = ptregs -> ret ;
72
+ pr_debug ("\t\tstop_pc (others)\n" );
100
73
}
101
74
102
- return ret ;
75
+ return membuf_store ( & to , stop_pc_val ); // stop_pc
103
76
}
104
77
105
78
static int genregs_set (struct task_struct * target ,
@@ -184,25 +157,20 @@ static int genregs_set(struct task_struct *target,
184
157
#ifdef CONFIG_ISA_ARCV2
185
158
static int arcv2regs_get (struct task_struct * target ,
186
159
const struct user_regset * regset ,
187
- unsigned int pos , unsigned int count ,
188
- void * kbuf , void __user * ubuf )
160
+ struct membuf to )
189
161
{
190
162
const struct pt_regs * regs = task_pt_regs (target );
191
- int ret , copy_sz ;
192
163
193
164
if (IS_ENABLED (CONFIG_ARC_HAS_ACCL_REGS ))
194
- copy_sz = sizeof (struct user_regs_arcv2 );
195
- else
196
- copy_sz = 4 ; /* r30 only */
165
+ /*
166
+ * itemized copy not needed like above as layout of regs (r30,r58,r59)
167
+ * is exactly same in kernel (pt_regs) and userspace (user_regs_arcv2)
168
+ */
169
+ return membuf_write (& to , & regs -> r30 , sizeof (struct user_regs_arcv2 ));
197
170
198
- /*
199
- * itemized copy not needed like above as layout of regs (r30,r58,r59)
200
- * is exactly same in kernel (pt_regs) and userspace (user_regs_arcv2)
201
- */
202
- ret = user_regset_copyout (& pos , & count , & kbuf , & ubuf , & regs -> r30 ,
203
- 0 , copy_sz );
204
171
205
- return ret ;
172
+ membuf_write (& to , & regs -> r30 , 4 ); /* r30 only */
173
+ return membuf_zero (& to , sizeof (struct user_regs_arcv2 ) - 4 );
206
174
}
207
175
208
176
static int arcv2regs_set (struct task_struct * target ,
@@ -237,7 +205,7 @@ static const struct user_regset arc_regsets[] = {
237
205
.n = ELF_NGREG ,
238
206
.size = sizeof (unsigned long ),
239
207
.align = sizeof (unsigned long ),
240
- .get = genregs_get ,
208
+ .regset_get = genregs_get ,
241
209
.set = genregs_set ,
242
210
},
243
211
#ifdef CONFIG_ISA_ARCV2
@@ -246,7 +214,7 @@ static const struct user_regset arc_regsets[] = {
246
214
.n = ELF_ARCV2REG ,
247
215
.size = sizeof (unsigned long ),
248
216
.align = sizeof (unsigned long ),
249
- .get = arcv2regs_get ,
217
+ .regset_get = arcv2regs_get ,
250
218
.set = arcv2regs_set ,
251
219
},
252
220
#endif
0 commit comments