Skip to content

Commit c213630

Browse files
committed
Merge branch 'x86-uaccess-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 uaccess changes from Ingo Molnar: "A single change that micro-optimizes __copy_*_user_inatomic(), used by the futex code" * 'x86-uaccess-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86: Add 1/2/4/8 byte optimization to 64bit __copy_{from,to}_user_inatomic
2 parents 986189f + ff47ab4 commit c213630

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

arch/x86/include/asm/uaccess_64.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ __must_check unsigned long
4949
copy_in_user(void __user *to, const void __user *from, unsigned len);
5050

5151
static __always_inline __must_check
52-
int __copy_from_user(void *dst, const void __user *src, unsigned size)
52+
int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size)
5353
{
5454
int ret = 0;
5555

56-
might_fault();
5756
if (!__builtin_constant_p(size))
5857
return copy_user_generic(dst, (__force void *)src, size);
5958
switch (size) {
@@ -93,11 +92,17 @@ int __copy_from_user(void *dst, const void __user *src, unsigned size)
9392
}
9493

9594
static __always_inline __must_check
96-
int __copy_to_user(void __user *dst, const void *src, unsigned size)
95+
int __copy_from_user(void *dst, const void __user *src, unsigned size)
96+
{
97+
might_fault();
98+
return __copy_from_user_nocheck(dst, src, size);
99+
}
100+
101+
static __always_inline __must_check
102+
int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size)
97103
{
98104
int ret = 0;
99105

100-
might_fault();
101106
if (!__builtin_constant_p(size))
102107
return copy_user_generic((__force void *)dst, src, size);
103108
switch (size) {
@@ -136,6 +141,13 @@ int __copy_to_user(void __user *dst, const void *src, unsigned size)
136141
}
137142
}
138143

144+
static __always_inline __must_check
145+
int __copy_to_user(void __user *dst, const void *src, unsigned size)
146+
{
147+
might_fault();
148+
return __copy_to_user_nocheck(dst, src, size);
149+
}
150+
139151
static __always_inline __must_check
140152
int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
141153
{
@@ -192,13 +204,13 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
192204
static __must_check __always_inline int
193205
__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
194206
{
195-
return copy_user_generic(dst, (__force const void *)src, size);
207+
return __copy_from_user_nocheck(dst, (__force const void *)src, size);
196208
}
197209

198210
static __must_check __always_inline int
199211
__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
200212
{
201-
return copy_user_generic((__force void *)dst, src, size);
213+
return __copy_to_user_nocheck((__force void *)dst, src, size);
202214
}
203215

204216
extern long __copy_user_nocache(void *dst, const void __user *src,

0 commit comments

Comments
 (0)