提交 1af1717d 编写于 作者: M Michael S. Tsirkin 提交者: Ingo Molnar

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: NMichael S. Tsirkin <mst@redhat.com>
Acked-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: NPeter 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.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 3837a3cf
...@@ -178,7 +178,7 @@ do { \ ...@@ -178,7 +178,7 @@ do { \
long __pu_err; \ long __pu_err; \
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \ __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
if (!is_kernel_addr((unsigned long)__pu_addr)) \ if (!is_kernel_addr((unsigned long)__pu_addr)) \
might_sleep(); \ might_fault(); \
__chk_user_ptr(ptr); \ __chk_user_ptr(ptr); \
__put_user_size((x), __pu_addr, (size), __pu_err); \ __put_user_size((x), __pu_addr, (size), __pu_err); \
__pu_err; \ __pu_err; \
...@@ -188,7 +188,7 @@ do { \ ...@@ -188,7 +188,7 @@ do { \
({ \ ({ \
long __pu_err = -EFAULT; \ long __pu_err = -EFAULT; \
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \ __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
might_sleep(); \ might_fault(); \
if (access_ok(VERIFY_WRITE, __pu_addr, size)) \ if (access_ok(VERIFY_WRITE, __pu_addr, size)) \
__put_user_size((x), __pu_addr, (size), __pu_err); \ __put_user_size((x), __pu_addr, (size), __pu_err); \
__pu_err; \ __pu_err; \
...@@ -268,7 +268,7 @@ do { \ ...@@ -268,7 +268,7 @@ do { \
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
__chk_user_ptr(ptr); \ __chk_user_ptr(ptr); \
if (!is_kernel_addr((unsigned long)__gu_addr)) \ if (!is_kernel_addr((unsigned long)__gu_addr)) \
might_sleep(); \ might_fault(); \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \ (x) = (__typeof__(*(ptr)))__gu_val; \
__gu_err; \ __gu_err; \
...@@ -282,7 +282,7 @@ do { \ ...@@ -282,7 +282,7 @@ do { \
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
__chk_user_ptr(ptr); \ __chk_user_ptr(ptr); \
if (!is_kernel_addr((unsigned long)__gu_addr)) \ if (!is_kernel_addr((unsigned long)__gu_addr)) \
might_sleep(); \ might_fault(); \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \ (x) = (__typeof__(*(ptr)))__gu_val; \
__gu_err; \ __gu_err; \
...@@ -294,7 +294,7 @@ do { \ ...@@ -294,7 +294,7 @@ do { \
long __gu_err = -EFAULT; \ long __gu_err = -EFAULT; \
unsigned long __gu_val = 0; \ unsigned long __gu_val = 0; \
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
might_sleep(); \ might_fault(); \
if (access_ok(VERIFY_READ, __gu_addr, (size))) \ if (access_ok(VERIFY_READ, __gu_addr, (size))) \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \ (x) = (__typeof__(*(ptr)))__gu_val; \
...@@ -419,14 +419,14 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to, ...@@ -419,14 +419,14 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
static inline unsigned long __copy_from_user(void *to, static inline unsigned long __copy_from_user(void *to,
const void __user *from, unsigned long size) const void __user *from, unsigned long size)
{ {
might_sleep(); might_fault();
return __copy_from_user_inatomic(to, from, size); return __copy_from_user_inatomic(to, from, size);
} }
static inline unsigned long __copy_to_user(void __user *to, static inline unsigned long __copy_to_user(void __user *to,
const void *from, unsigned long size) const void *from, unsigned long size)
{ {
might_sleep(); might_fault();
return __copy_to_user_inatomic(to, from, size); return __copy_to_user_inatomic(to, from, size);
} }
...@@ -434,7 +434,7 @@ extern unsigned long __clear_user(void __user *addr, unsigned long size); ...@@ -434,7 +434,7 @@ extern unsigned long __clear_user(void __user *addr, unsigned long size);
static inline unsigned long clear_user(void __user *addr, unsigned long size) static inline unsigned long clear_user(void __user *addr, unsigned long size)
{ {
might_sleep(); might_fault();
if (likely(access_ok(VERIFY_WRITE, addr, size))) if (likely(access_ok(VERIFY_WRITE, addr, size)))
return __clear_user(addr, size); return __clear_user(addr, size);
if ((unsigned long)addr < TASK_SIZE) { if ((unsigned long)addr < TASK_SIZE) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册