]>
Commit | Line | Data |
---|---|---|
1ac2e6ca RR |
1 | /* |
2 | * User address space access functions. | |
3 | * | |
4 | * For licencing details see kernel-base/COPYING | |
5 | */ | |
6 | ||
beba3a20 | 7 | #include <linux/uaccess.h> |
e683014c | 8 | #include <linux/export.h> |
1ac2e6ca | 9 | |
4012e77a AL |
10 | #include <asm/tlbflush.h> |
11 | ||
1ac2e6ca | 12 | /* |
e00b12e6 PZ |
13 | * We rely on the nested NMI work to allow atomic faults from the NMI path; the |
14 | * nested NMI paths are careful to preserve CR2. | |
1ac2e6ca RR |
15 | */ |
16 | unsigned long | |
17 | copy_from_user_nmi(void *to, const void __user *from, unsigned long n) | |
18 | { | |
e00b12e6 | 19 | unsigned long ret; |
1ac2e6ca | 20 | |
25f42985 | 21 | if (__range_not_ok(from, n, TASK_SIZE)) |
ebf2d268 | 22 | return n; |
e00b12e6 | 23 | |
4012e77a AL |
24 | if (!nmi_uaccess_okay()) |
25 | return n; | |
26 | ||
e00b12e6 PZ |
27 | /* |
28 | * Even though this function is typically called from NMI/IRQ context | |
29 | * disable pagefaults so that its behaviour is consistent even when | |
30 | * called form other contexts. | |
31 | */ | |
32 | pagefault_disable(); | |
33 | ret = __copy_from_user_inatomic(to, from, n); | |
34 | pagefault_enable(); | |
35 | ||
0a196848 | 36 | return ret; |
1ac2e6ca RR |
37 | } |
38 | EXPORT_SYMBOL_GPL(copy_from_user_nmi); |