Skip to content

Commit 30e3024

Browse files
torvaldsAlex Shi
authored andcommitted
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> (cherry picked from commit 5b09c3edecd37ec1a52fbd5ae97a19734edc7a77) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 9a6d5a0 commit 30e3024

2 files changed

Lines changed: 1 addition & 39 deletions

File tree

arch/x86/include/asm/uaccess_32.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,10 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
3333
* the specified block with access_ok() before calling this function.
3434
* The caller should also make sure he pins the user space address
3535
* 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.
4136
*/
42-
4337
static __always_inline unsigned long __must_check
4438
__copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
4539
{
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-
}
7640
return __copy_to_user_ll(to, from, n);
7741
}
7842

drivers/gpu/drm/i915/i915_gem_execbuffer.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,7 @@ i915_gem_execbuffer_relocate_vma(struct i915_vma *vma,
513513
return ret;
514514

515515
if (r->presumed_offset != offset &&
516-
__copy_to_user_inatomic(&user_relocs->presumed_offset,
517-
&r->presumed_offset,
518-
sizeof(r->presumed_offset))) {
516+
__put_user(r->presumed_offset, &user_relocs->presumed_offset)) {
519517
return -EFAULT;
520518
}
521519

0 commit comments

Comments
 (0)