H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_UACCESS_64_H |
| 2 | #define _ASM_X86_UACCESS_64_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
| 4 | /* |
| 5 | * User space memory access functions |
| 6 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/compiler.h> |
| 8 | #include <linux/errno.h> |
Nick Piggin | 16dbc6c | 2008-10-02 14:50:12 -0700 | [diff] [blame] | 9 | #include <linux/lockdep.h> |
Jan Beulich | 1b1d925 | 2009-12-18 16:12:56 +0000 | [diff] [blame] | 10 | #include <asm/alternative.h> |
Borislav Petkov | cd4d09e | 2016-01-26 22:12:04 +0100 | [diff] [blame] | 11 | #include <asm/cpufeatures.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/page.h> |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | /* |
| 15 | * Copy To/From Userspace |
| 16 | */ |
| 17 | |
| 18 | /* Handles exceptions in both to and from, but doesn't do access_ok */ |
Andi Kleen | 9591200 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 19 | __must_check unsigned long |
Fenghua Yu | 954e482 | 2012-05-24 18:19:45 -0700 | [diff] [blame] | 20 | copy_user_enhanced_fast_string(void *to, const void *from, unsigned len); |
| 21 | __must_check unsigned long |
Jan Beulich | 1b1d925 | 2009-12-18 16:12:56 +0000 | [diff] [blame] | 22 | copy_user_generic_string(void *to, const void *from, unsigned len); |
| 23 | __must_check unsigned long |
| 24 | copy_user_generic_unrolled(void *to, const void *from, unsigned len); |
| 25 | |
| 26 | static __always_inline __must_check unsigned long |
| 27 | copy_user_generic(void *to, const void *from, unsigned len) |
| 28 | { |
| 29 | unsigned ret; |
| 30 | |
Fenghua Yu | 954e482 | 2012-05-24 18:19:45 -0700 | [diff] [blame] | 31 | /* |
| 32 | * If CPU has ERMS feature, use copy_user_enhanced_fast_string. |
| 33 | * Otherwise, if CPU has rep_good feature, use copy_user_generic_string. |
| 34 | * Otherwise, use copy_user_generic_unrolled. |
| 35 | */ |
| 36 | alternative_call_2(copy_user_generic_unrolled, |
Jan Beulich | 1b1d925 | 2009-12-18 16:12:56 +0000 | [diff] [blame] | 37 | copy_user_generic_string, |
| 38 | X86_FEATURE_REP_GOOD, |
Fenghua Yu | 954e482 | 2012-05-24 18:19:45 -0700 | [diff] [blame] | 39 | copy_user_enhanced_fast_string, |
| 40 | X86_FEATURE_ERMS, |
Jan Beulich | 1b1d925 | 2009-12-18 16:12:56 +0000 | [diff] [blame] | 41 | ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from), |
| 42 | "=d" (len)), |
| 43 | "1" (to), "2" (from), "3" (len) |
| 44 | : "memory", "rcx", "r8", "r9", "r10", "r11"); |
| 45 | return ret; |
| 46 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Andi Kleen | 9591200 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 48 | __must_check unsigned long |
Andi Kleen | 9591200 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 49 | copy_in_user(void __user *to, const void __user *from, unsigned len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Frederic Weisbecker | 3c93ca0 | 2009-11-16 15:42:18 +0100 | [diff] [blame] | 51 | static __always_inline __must_check |
Andi Kleen | ff47ab4f | 2013-08-16 14:17:19 -0700 | [diff] [blame] | 52 | int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 53 | { |
Andi Kleen | 383d079 | 2006-09-26 10:52:40 +0200 | [diff] [blame] | 54 | int ret = 0; |
Ingo Molnar | d1a7618 | 2008-10-28 16:54:49 +0100 | [diff] [blame] | 55 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | if (!__builtin_constant_p(size)) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 57 | return copy_user_generic(dst, (__force void *)src, size); |
| 58 | switch (size) { |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 59 | case 1: |
| 60 | __uaccess_begin(); |
| 61 | __get_user_asm(*(u8 *)dst, (u8 __user *)src, |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 62 | ret, "b", "b", "=q", 1); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 63 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | return ret; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 65 | case 2: |
| 66 | __uaccess_begin(); |
| 67 | __get_user_asm(*(u16 *)dst, (u16 __user *)src, |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 68 | ret, "w", "w", "=r", 2); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 69 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | return ret; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 71 | case 4: |
| 72 | __uaccess_begin(); |
| 73 | __get_user_asm(*(u32 *)dst, (u32 __user *)src, |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 74 | ret, "l", "k", "=r", 4); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 75 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | return ret; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 77 | case 8: |
| 78 | __uaccess_begin(); |
| 79 | __get_user_asm(*(u64 *)dst, (u64 __user *)src, |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 80 | ret, "q", "", "=r", 8); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 81 | __uaccess_end(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 82 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | case 10: |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 84 | __uaccess_begin(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 85 | __get_user_asm(*(u64 *)dst, (u64 __user *)src, |
Hiroshi Shimamoto | 20a4a23 | 2008-11-13 18:06:04 -0800 | [diff] [blame] | 86 | ret, "q", "", "=r", 10); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 87 | if (likely(!ret)) |
| 88 | __get_user_asm(*(u16 *)(8 + (char *)dst), |
| 89 | (u16 __user *)(8 + (char __user *)src), |
| 90 | ret, "w", "w", "=r", 2); |
| 91 | __uaccess_end(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 92 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | case 16: |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 94 | __uaccess_begin(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 95 | __get_user_asm(*(u64 *)dst, (u64 __user *)src, |
| 96 | ret, "q", "", "=r", 16); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 97 | if (likely(!ret)) |
| 98 | __get_user_asm(*(u64 *)(8 + (char *)dst), |
| 99 | (u64 __user *)(8 + (char __user *)src), |
| 100 | ret, "q", "", "=r", 8); |
| 101 | __uaccess_end(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 102 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | default: |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 104 | return copy_user_generic(dst, (__force void *)src, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | } |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 106 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
Andi Kleen | 9591200 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 108 | static __always_inline __must_check |
Andi Kleen | ff47ab4f | 2013-08-16 14:17:19 -0700 | [diff] [blame] | 109 | int __copy_from_user(void *dst, const void __user *src, unsigned size) |
| 110 | { |
| 111 | might_fault(); |
| 112 | return __copy_from_user_nocheck(dst, src, size); |
| 113 | } |
| 114 | |
| 115 | static __always_inline __must_check |
| 116 | int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 117 | { |
Andi Kleen | 383d079 | 2006-09-26 10:52:40 +0200 | [diff] [blame] | 118 | int ret = 0; |
Ingo Molnar | d1a7618 | 2008-10-28 16:54:49 +0100 | [diff] [blame] | 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | if (!__builtin_constant_p(size)) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 121 | return copy_user_generic((__force void *)dst, src, size); |
| 122 | switch (size) { |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 123 | case 1: |
| 124 | __uaccess_begin(); |
| 125 | __put_user_asm(*(u8 *)src, (u8 __user *)dst, |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 126 | ret, "b", "b", "iq", 1); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 127 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | return ret; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 129 | case 2: |
| 130 | __uaccess_begin(); |
| 131 | __put_user_asm(*(u16 *)src, (u16 __user *)dst, |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 132 | ret, "w", "w", "ir", 2); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 133 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | return ret; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 135 | case 4: |
| 136 | __uaccess_begin(); |
| 137 | __put_user_asm(*(u32 *)src, (u32 __user *)dst, |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 138 | ret, "l", "k", "ir", 4); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 139 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | return ret; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 141 | case 8: |
| 142 | __uaccess_begin(); |
| 143 | __put_user_asm(*(u64 *)src, (u64 __user *)dst, |
Uros Bizjak | 155b735 | 2009-07-19 18:06:35 +0200 | [diff] [blame] | 144 | ret, "q", "", "er", 8); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 145 | __uaccess_end(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 146 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | case 10: |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 148 | __uaccess_begin(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 149 | __put_user_asm(*(u64 *)src, (u64 __user *)dst, |
Uros Bizjak | 155b735 | 2009-07-19 18:06:35 +0200 | [diff] [blame] | 150 | ret, "q", "", "er", 10); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 151 | if (likely(!ret)) { |
| 152 | asm("":::"memory"); |
| 153 | __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst, |
| 154 | ret, "w", "w", "ir", 2); |
| 155 | } |
| 156 | __uaccess_end(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 157 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | case 16: |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 159 | __uaccess_begin(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 160 | __put_user_asm(*(u64 *)src, (u64 __user *)dst, |
Uros Bizjak | 155b735 | 2009-07-19 18:06:35 +0200 | [diff] [blame] | 161 | ret, "q", "", "er", 16); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 162 | if (likely(!ret)) { |
| 163 | asm("":::"memory"); |
| 164 | __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst, |
| 165 | ret, "q", "", "er", 8); |
| 166 | } |
| 167 | __uaccess_end(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 168 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | default: |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 170 | return copy_user_generic((__force void *)dst, src, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | } |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 172 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
Andi Kleen | 9591200 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 174 | static __always_inline __must_check |
Andi Kleen | ff47ab4f | 2013-08-16 14:17:19 -0700 | [diff] [blame] | 175 | int __copy_to_user(void __user *dst, const void *src, unsigned size) |
| 176 | { |
| 177 | might_fault(); |
| 178 | return __copy_to_user_nocheck(dst, src, size); |
| 179 | } |
| 180 | |
| 181 | static __always_inline __must_check |
Andi Kleen | 9591200 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 182 | int __copy_in_user(void __user *dst, const void __user *src, unsigned size) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 183 | { |
Andi Kleen | 383d079 | 2006-09-26 10:52:40 +0200 | [diff] [blame] | 184 | int ret = 0; |
Ingo Molnar | d1a7618 | 2008-10-28 16:54:49 +0100 | [diff] [blame] | 185 | |
| 186 | might_fault(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | if (!__builtin_constant_p(size)) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 188 | return copy_user_generic((__force void *)dst, |
| 189 | (__force void *)src, size); |
| 190 | switch (size) { |
| 191 | case 1: { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | u8 tmp; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 193 | __uaccess_begin(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 194 | __get_user_asm(tmp, (u8 __user *)src, |
| 195 | ret, "b", "b", "=q", 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | if (likely(!ret)) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 197 | __put_user_asm(tmp, (u8 __user *)dst, |
| 198 | ret, "b", "b", "iq", 1); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 199 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | return ret; |
| 201 | } |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 202 | case 2: { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | u16 tmp; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 204 | __uaccess_begin(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 205 | __get_user_asm(tmp, (u16 __user *)src, |
| 206 | ret, "w", "w", "=r", 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | if (likely(!ret)) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 208 | __put_user_asm(tmp, (u16 __user *)dst, |
| 209 | ret, "w", "w", "ir", 2); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 210 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | return ret; |
| 212 | } |
| 213 | |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 214 | case 4: { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | u32 tmp; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 216 | __uaccess_begin(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 217 | __get_user_asm(tmp, (u32 __user *)src, |
| 218 | ret, "l", "k", "=r", 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | if (likely(!ret)) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 220 | __put_user_asm(tmp, (u32 __user *)dst, |
| 221 | ret, "l", "k", "ir", 4); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 222 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | return ret; |
| 224 | } |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 225 | case 8: { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | u64 tmp; |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 227 | __uaccess_begin(); |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 228 | __get_user_asm(tmp, (u64 __user *)src, |
| 229 | ret, "q", "", "=r", 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | if (likely(!ret)) |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 231 | __put_user_asm(tmp, (u64 __user *)dst, |
Uros Bizjak | 155b735 | 2009-07-19 18:06:35 +0200 | [diff] [blame] | 232 | ret, "q", "", "er", 8); |
Linus Torvalds | 11f1a4b | 2015-12-17 09:45:09 -0800 | [diff] [blame] | 233 | __uaccess_end(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | return ret; |
| 235 | } |
| 236 | default: |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 237 | return copy_user_generic((__force void *)dst, |
| 238 | (__force void *)src, size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | } |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 240 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | |
Jan Beulich | 1472248 | 2009-11-13 11:56:24 +0000 | [diff] [blame] | 242 | static __must_check __always_inline int |
| 243 | __copy_from_user_inatomic(void *dst, const void __user *src, unsigned size) |
| 244 | { |
Steven Rostedt | df90ca9 | 2014-01-03 16:45:00 -0500 | [diff] [blame] | 245 | return __copy_from_user_nocheck(dst, src, size); |
Jan Beulich | 1472248 | 2009-11-13 11:56:24 +0000 | [diff] [blame] | 246 | } |
Andi Kleen | b885808 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 247 | |
| 248 | static __must_check __always_inline int |
| 249 | __copy_to_user_inatomic(void __user *dst, const void *src, unsigned size) |
| 250 | { |
Steven Rostedt | df90ca9 | 2014-01-03 16:45:00 -0500 | [diff] [blame] | 251 | return __copy_to_user_nocheck(dst, src, size); |
Andi Kleen | b885808 | 2006-09-30 01:47:55 +0200 | [diff] [blame] | 252 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
Joe Perches | b896313 | 2008-03-23 01:03:49 -0700 | [diff] [blame] | 254 | extern long __copy_user_nocache(void *dst, const void __user *src, |
| 255 | unsigned size, int zerorest); |
Andi Kleen | 0812a57 | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 256 | |
Ingo Molnar | f180053 | 2009-03-02 11:00:57 +0100 | [diff] [blame] | 257 | static inline int |
| 258 | __copy_from_user_nocache(void *dst, const void __user *src, unsigned size) |
Andi Kleen | 0812a57 | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 259 | { |
Michael S. Tsirkin | 016be2e | 2013-05-26 17:31:55 +0300 | [diff] [blame] | 260 | might_fault(); |
Ingo Molnar | f180053 | 2009-03-02 11:00:57 +0100 | [diff] [blame] | 261 | return __copy_user_nocache(dst, src, size, 1); |
Andi Kleen | 0812a57 | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 262 | } |
| 263 | |
Ingo Molnar | f180053 | 2009-03-02 11:00:57 +0100 | [diff] [blame] | 264 | static inline int |
| 265 | __copy_from_user_inatomic_nocache(void *dst, const void __user *src, |
| 266 | unsigned size) |
Andi Kleen | 0812a57 | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 267 | { |
Ingo Molnar | f180053 | 2009-03-02 11:00:57 +0100 | [diff] [blame] | 268 | return __copy_user_nocache(dst, src, size, 0); |
Andi Kleen | 0812a57 | 2007-02-13 13:26:19 +0100 | [diff] [blame] | 269 | } |
| 270 | |
Vitaly Mayatskikh | 1129585 | 2008-07-02 15:48:21 +0200 | [diff] [blame] | 271 | unsigned long |
Linus Torvalds | cae2a17 | 2015-04-06 10:26:17 -0700 | [diff] [blame] | 272 | copy_user_handle_tail(char *to, char *from, unsigned len); |
Vitaly Mayatskikh | 1129585 | 2008-07-02 15:48:21 +0200 | [diff] [blame] | 273 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 274 | #endif /* _ASM_X86_UACCESS_64_H */ |