@@ -154,10 +154,6 @@ static int can_copy_perf_config_registers_or_number(u32 user_n_regs,
154
154
if (user_n_regs < kernel_n_regs )
155
155
return - EINVAL ;
156
156
157
- if (!access_ok (u64_to_user_ptr (user_regs_ptr ),
158
- 2 * sizeof (u32 ) * kernel_n_regs ))
159
- return - EFAULT ;
160
-
161
157
return 0 ;
162
158
}
163
159
@@ -166,6 +162,7 @@ static int copy_perf_config_registers_or_number(const struct i915_oa_reg *kernel
166
162
u64 user_regs_ptr ,
167
163
u32 * user_n_regs )
168
164
{
165
+ u32 __user * p = u64_to_user_ptr (user_regs_ptr );
169
166
u32 r ;
170
167
171
168
if (* user_n_regs == 0 ) {
@@ -175,25 +172,19 @@ static int copy_perf_config_registers_or_number(const struct i915_oa_reg *kernel
175
172
176
173
* user_n_regs = kernel_n_regs ;
177
174
178
- for (r = 0 ; r < kernel_n_regs ; r ++ ) {
179
- u32 __user * user_reg_ptr =
180
- u64_to_user_ptr (user_regs_ptr + sizeof (u32 ) * r * 2 );
181
- u32 __user * user_val_ptr =
182
- u64_to_user_ptr (user_regs_ptr + sizeof (u32 ) * r * 2 +
183
- sizeof (u32 ));
184
- int ret ;
185
-
186
- ret = __put_user (i915_mmio_reg_offset (kernel_regs [r ].addr ),
187
- user_reg_ptr );
188
- if (ret )
189
- return - EFAULT ;
175
+ if (!user_write_access_begin (p , 2 * sizeof (u32 ) * kernel_n_regs ))
176
+ return - EFAULT ;
190
177
191
- ret = __put_user (kernel_regs [r ].value , user_val_ptr );
192
- if (ret )
193
- return - EFAULT ;
178
+ for (r = 0 ; r < kernel_n_regs ; r ++ , p += 2 ) {
179
+ unsafe_put_user (i915_mmio_reg_offset (kernel_regs [r ].addr ),
180
+ p , Efault );
181
+ unsafe_put_user (kernel_regs [r ].value , p + 1 , Efault );
194
182
}
195
-
183
+ user_write_access_end ();
196
184
return 0 ;
185
+ Efault :
186
+ user_write_access_end ();
187
+ return - EFAULT ;
197
188
}
198
189
199
190
static int query_perf_config_data (struct drm_i915_private * i915 ,
@@ -229,10 +220,7 @@ static int query_perf_config_data(struct drm_i915_private *i915,
229
220
return - EINVAL ;
230
221
}
231
222
232
- if (!access_ok (user_query_config_ptr , total_size ))
233
- return - EFAULT ;
234
-
235
- if (__get_user (flags , & user_query_config_ptr -> flags ))
223
+ if (get_user (flags , & user_query_config_ptr -> flags ))
236
224
return - EFAULT ;
237
225
238
226
if (flags != 0 )
@@ -245,7 +233,7 @@ static int query_perf_config_data(struct drm_i915_private *i915,
245
233
BUILD_BUG_ON (sizeof (user_query_config_ptr -> uuid ) >= sizeof (uuid ));
246
234
247
235
memset (& uuid , 0 , sizeof (uuid ));
248
- if (__copy_from_user (uuid , user_query_config_ptr -> uuid ,
236
+ if (copy_from_user (uuid , user_query_config_ptr -> uuid ,
249
237
sizeof (user_query_config_ptr -> uuid )))
250
238
return - EFAULT ;
251
239
@@ -259,16 +247,15 @@ static int query_perf_config_data(struct drm_i915_private *i915,
259
247
}
260
248
rcu_read_unlock ();
261
249
} else {
262
- if (__get_user (config_id , & user_query_config_ptr -> config ))
250
+ if (get_user (config_id , & user_query_config_ptr -> config ))
263
251
return - EFAULT ;
264
252
265
253
oa_config = i915_perf_get_oa_config (perf , config_id );
266
254
}
267
255
if (!oa_config )
268
256
return - ENOENT ;
269
257
270
- if (__copy_from_user (& user_config , user_config_ptr ,
271
- sizeof (user_config ))) {
258
+ if (copy_from_user (& user_config , user_config_ptr , sizeof (user_config ))) {
272
259
ret = - EFAULT ;
273
260
goto out ;
274
261
}
@@ -314,8 +301,7 @@ static int query_perf_config_data(struct drm_i915_private *i915,
314
301
315
302
memcpy (user_config .uuid , oa_config -> uuid , sizeof (user_config .uuid ));
316
303
317
- if (__copy_to_user (user_config_ptr , & user_config ,
318
- sizeof (user_config ))) {
304
+ if (copy_to_user (user_config_ptr , & user_config , sizeof (user_config ))) {
319
305
ret = - EFAULT ;
320
306
goto out ;
321
307
}
0 commit comments