Skip to content

Commit 1af1717

Browse files
mstsirkinIngo Molnar
authored andcommitted
powerpc: uaccess s/might_sleep/might_fault/
The only reason uaccess routines might sleep is if they fault. Make this explicit. Arnd Bergmann suggested that the following code if (!is_kernel_addr((unsigned long)__pu_addr)) might_fault(); can be further simplified by adding a version of might_fault that includes the kernel addr check. Will be considered as a further optimization in future. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1369577426-26721-7-git-send-email-mst@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 3837a3c commit 1af1717

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

arch/powerpc/include/asm/uaccess.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ do { \
178178
long __pu_err; \
179179
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \
180180
if (!is_kernel_addr((unsigned long)__pu_addr)) \
181-
might_sleep(); \
181+
might_fault(); \
182182
__chk_user_ptr(ptr); \
183183
__put_user_size((x), __pu_addr, (size), __pu_err); \
184184
__pu_err; \
@@ -188,7 +188,7 @@ do { \
188188
({ \
189189
long __pu_err = -EFAULT; \
190190
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \
191-
might_sleep(); \
191+
might_fault(); \
192192
if (access_ok(VERIFY_WRITE, __pu_addr, size)) \
193193
__put_user_size((x), __pu_addr, (size), __pu_err); \
194194
__pu_err; \
@@ -268,7 +268,7 @@ do { \
268268
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
269269
__chk_user_ptr(ptr); \
270270
if (!is_kernel_addr((unsigned long)__gu_addr)) \
271-
might_sleep(); \
271+
might_fault(); \
272272
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
273273
(x) = (__typeof__(*(ptr)))__gu_val; \
274274
__gu_err; \
@@ -282,7 +282,7 @@ do { \
282282
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
283283
__chk_user_ptr(ptr); \
284284
if (!is_kernel_addr((unsigned long)__gu_addr)) \
285-
might_sleep(); \
285+
might_fault(); \
286286
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
287287
(x) = (__typeof__(*(ptr)))__gu_val; \
288288
__gu_err; \
@@ -294,7 +294,7 @@ do { \
294294
long __gu_err = -EFAULT; \
295295
unsigned long __gu_val = 0; \
296296
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
297-
might_sleep(); \
297+
might_fault(); \
298298
if (access_ok(VERIFY_READ, __gu_addr, (size))) \
299299
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
300300
(x) = (__typeof__(*(ptr)))__gu_val; \
@@ -419,22 +419,22 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
419419
static inline unsigned long __copy_from_user(void *to,
420420
const void __user *from, unsigned long size)
421421
{
422-
might_sleep();
422+
might_fault();
423423
return __copy_from_user_inatomic(to, from, size);
424424
}
425425

426426
static inline unsigned long __copy_to_user(void __user *to,
427427
const void *from, unsigned long size)
428428
{
429-
might_sleep();
429+
might_fault();
430430
return __copy_to_user_inatomic(to, from, size);
431431
}
432432

433433
extern unsigned long __clear_user(void __user *addr, unsigned long size);
434434

435435
static inline unsigned long clear_user(void __user *addr, unsigned long size)
436436
{
437-
might_sleep();
437+
might_fault();
438438
if (likely(access_ok(VERIFY_WRITE, addr, size)))
439439
return __clear_user(addr, size);
440440
if ((unsigned long)addr < TASK_SIZE) {

0 commit comments

Comments
 (0)