]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1965aae3 PA |
2 | #ifndef _ASM_X86_UACCESS_32_H |
3 | #define _ASM_X86_UACCESS_32_H | |
1da177e4 LT |
4 | |
5 | /* | |
6 | * User space memory access functions | |
7 | */ | |
1da177e4 | 8 | #include <linux/string.h> |
14e6d17d | 9 | #include <asm/asm.h> |
1da177e4 LT |
10 | #include <asm/page.h> |
11 | ||
beba3a20 AV |
12 | unsigned long __must_check __copy_user_ll |
13 | (void *to, const void *from, unsigned long n); | |
b1fcec7f JP |
14 | unsigned long __must_check __copy_from_user_ll_nocache_nozero |
15 | (void *to, const void __user *from, unsigned long n); | |
1da177e4 | 16 | |
652050ae | 17 | static __always_inline unsigned long __must_check |
beba3a20 | 18 | raw_copy_to_user(void __user *to, const void *from, unsigned long n) |
1da177e4 | 19 | { |
beba3a20 | 20 | return __copy_user_ll((__force void *)to, from, n); |
1da177e4 LT |
21 | } |
22 | ||
7c12d811 | 23 | static __always_inline unsigned long |
beba3a20 | 24 | raw_copy_from_user(void *to, const void __user *from, unsigned long n) |
7c12d811 | 25 | { |
1da177e4 LT |
26 | if (__builtin_constant_p(n)) { |
27 | unsigned long ret; | |
28 | ||
29 | switch (n) { | |
30 | case 1: | |
beba3a20 | 31 | ret = 0; |
de9e478b | 32 | __uaccess_begin(); |
beba3a20 AV |
33 | __get_user_asm_nozero(*(u8 *)to, from, ret, |
34 | "b", "b", "=q", 1); | |
de9e478b | 35 | __uaccess_end(); |
1da177e4 LT |
36 | return ret; |
37 | case 2: | |
beba3a20 | 38 | ret = 0; |
de9e478b | 39 | __uaccess_begin(); |
beba3a20 AV |
40 | __get_user_asm_nozero(*(u16 *)to, from, ret, |
41 | "w", "w", "=r", 2); | |
de9e478b | 42 | __uaccess_end(); |
1da177e4 LT |
43 | return ret; |
44 | case 4: | |
beba3a20 | 45 | ret = 0; |
de9e478b | 46 | __uaccess_begin(); |
beba3a20 AV |
47 | __get_user_asm_nozero(*(u32 *)to, from, ret, |
48 | "l", "k", "=r", 4); | |
de9e478b | 49 | __uaccess_end(); |
1da177e4 LT |
50 | return ret; |
51 | } | |
52 | } | |
beba3a20 | 53 | return __copy_user_ll(to, (__force const void *)from, n); |
1da177e4 LT |
54 | } |
55 | ||
652050ae | 56 | static __always_inline unsigned long |
b1fcec7f JP |
57 | __copy_from_user_inatomic_nocache(void *to, const void __user *from, |
58 | unsigned long n) | |
1da177e4 | 59 | { |
7c12d811 | 60 | return __copy_from_user_ll_nocache_nozero(to, from, n); |
c22ce143 HY |
61 | } |
62 | ||
1965aae3 | 63 | #endif /* _ASM_X86_UACCESS_32_H */ |