diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-18 04:42:16 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-11 09:30:32 -0500 |
commit | 05d88a493746819821733e07bed918a6e09f735b (patch) | |
tree | 59f1a8d8e291e62507b3b221240ee9b926e14ce7 /include | |
parent | 43697cb0973da144156e7d11ddd035aee226ee30 (diff) |
asm-generic: uaccess: Allow arches to over-ride __{get,put}_user_fn()
As of now these default to calling the arch provided __copy_{to,from}_user()
routines which being general purpose (w.r.t buffer alignment and lengths)
would lead to alignment checks in generated code (for arches which don't
support unaligned load/stores).
Given that in this case we already know that data involved is "unit"
sized and aligned, using the vanilla copy backend is a bit wasteful.
This change thus allows arches to over-ride the aforementioned routines.
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/uaccess.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index 5f6ee6138f9a..c184aa8ec8cd 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h | |||
@@ -169,12 +169,18 @@ static inline __must_check long __copy_to_user(void __user *to, | |||
169 | -EFAULT; \ | 169 | -EFAULT; \ |
170 | }) | 170 | }) |
171 | 171 | ||
172 | #ifndef __put_user_fn | ||
173 | |||
172 | static inline int __put_user_fn(size_t size, void __user *ptr, void *x) | 174 | static inline int __put_user_fn(size_t size, void __user *ptr, void *x) |
173 | { | 175 | { |
174 | size = __copy_to_user(ptr, x, size); | 176 | size = __copy_to_user(ptr, x, size); |
175 | return size ? -EFAULT : size; | 177 | return size ? -EFAULT : size; |
176 | } | 178 | } |
177 | 179 | ||
180 | #define __put_user_fn(sz, u, k) __put_user_fn(sz, u, k) | ||
181 | |||
182 | #endif | ||
183 | |||
178 | extern int __put_user_bad(void) __attribute__((noreturn)); | 184 | extern int __put_user_bad(void) __attribute__((noreturn)); |
179 | 185 | ||
180 | #define __get_user(x, ptr) \ | 186 | #define __get_user(x, ptr) \ |
@@ -225,12 +231,17 @@ extern int __put_user_bad(void) __attribute__((noreturn)); | |||
225 | -EFAULT; \ | 231 | -EFAULT; \ |
226 | }) | 232 | }) |
227 | 233 | ||
234 | #ifndef __get_user_fn | ||
228 | static inline int __get_user_fn(size_t size, const void __user *ptr, void *x) | 235 | static inline int __get_user_fn(size_t size, const void __user *ptr, void *x) |
229 | { | 236 | { |
230 | size = __copy_from_user(x, ptr, size); | 237 | size = __copy_from_user(x, ptr, size); |
231 | return size ? -EFAULT : size; | 238 | return size ? -EFAULT : size; |
232 | } | 239 | } |
233 | 240 | ||
241 | #define __get_user_fn(sz, u, k) __get_user_fn(sz, u, k) | ||
242 | |||
243 | #endif | ||
244 | |||
234 | extern int __get_user_bad(void) __attribute__((noreturn)); | 245 | extern int __get_user_bad(void) __attribute__((noreturn)); |
235 | 246 | ||
236 | #ifndef __copy_from_user_inatomic | 247 | #ifndef __copy_from_user_inatomic |