diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-22 17:19:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-22 17:19:37 -0400 |
commit | 5b09c3edecd37ec1a52fbd5ae97a19734edc7a77 (patch) | |
tree | 899fbf0a4255f76ae18d280b216b8ddede02512b | |
parent | f6c658df63856db3bf8f467024b1dbee37b5399c (diff) |
x86: remove pointless uaccess_32.h complexity
I'm looking at trying to possibly merge the 32-bit and 64-bit versions
of the x86 uaccess.h implementation, but first this needs to be cleaned
up.
For example, the 32-bit version of "__copy_to_user_inatomic()" is mostly
the special cases for the constant size, and it's actually never
relevant. Every user except for one aren't actually using a constant
size anyway, and the one user that uses it is better off just using
__put_user() instead.
So get rid of the unnecessary complexity.
[ The same cleanup should likely happen to __copy_from_user_inatomic()
as well, but that one has a lot more users that I need to take a look
at first ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/x86/include/asm/uaccess_32.h | 36 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_execbuffer.c | 4 |
2 files changed, 1 insertions, 39 deletions
diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h index 3fe0eac59462..537cc883ea29 100644 --- a/arch/x86/include/asm/uaccess_32.h +++ b/arch/x86/include/asm/uaccess_32.h | |||
@@ -33,46 +33,10 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero | |||
33 | * the specified block with access_ok() before calling this function. | 33 | * the specified block with access_ok() before calling this function. |
34 | * The caller should also make sure he pins the user space address | 34 | * The caller should also make sure he pins the user space address |
35 | * so that we don't result in page fault and sleep. | 35 | * so that we don't result in page fault and sleep. |
36 | * | ||
37 | * Here we special-case 1, 2 and 4-byte copy_*_user invocations. On a fault | ||
38 | * we return the initial request size (1, 2 or 4), as copy_*_user should do. | ||
39 | * If a store crosses a page boundary and gets a fault, the x86 will not write | ||
40 | * anything, so this is accurate. | ||
41 | */ | 36 | */ |
42 | |||
43 | static __always_inline unsigned long __must_check | 37 | static __always_inline unsigned long __must_check |
44 | __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n) | 38 | __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n) |
45 | { | 39 | { |
46 | if (__builtin_constant_p(n)) { | ||
47 | unsigned long ret; | ||
48 | |||
49 | switch (n) { | ||
50 | case 1: | ||
51 | __uaccess_begin(); | ||
52 | __put_user_size(*(u8 *)from, (u8 __user *)to, | ||
53 | 1, ret, 1); | ||
54 | __uaccess_end(); | ||
55 | return ret; | ||
56 | case 2: | ||
57 | __uaccess_begin(); | ||
58 | __put_user_size(*(u16 *)from, (u16 __user *)to, | ||
59 | 2, ret, 2); | ||
60 | __uaccess_end(); | ||
61 | return ret; | ||
62 | case 4: | ||
63 | __uaccess_begin(); | ||
64 | __put_user_size(*(u32 *)from, (u32 __user *)to, | ||
65 | 4, ret, 4); | ||
66 | __uaccess_end(); | ||
67 | return ret; | ||
68 | case 8: | ||
69 | __uaccess_begin(); | ||
70 | __put_user_size(*(u64 *)from, (u64 __user *)to, | ||
71 | 8, ret, 8); | ||
72 | __uaccess_end(); | ||
73 | return ret; | ||
74 | } | ||
75 | } | ||
76 | return __copy_to_user_ll(to, from, n); | 40 | return __copy_to_user_ll(to, from, n); |
77 | } | 41 | } |
78 | 42 | ||
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index a676eedb441b..d4d7c88ab595 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c | |||
@@ -535,9 +535,7 @@ i915_gem_execbuffer_relocate_vma(struct i915_vma *vma, | |||
535 | return ret; | 535 | return ret; |
536 | 536 | ||
537 | if (r->presumed_offset != offset && | 537 | if (r->presumed_offset != offset && |
538 | __copy_to_user_inatomic(&user_relocs->presumed_offset, | 538 | __put_user(r->presumed_offset, &user_relocs->presumed_offset)) { |
539 | &r->presumed_offset, | ||
540 | sizeof(r->presumed_offset))) { | ||
541 | return -EFAULT; | 539 | return -EFAULT; |
542 | } | 540 | } |
543 | 541 | ||