2 * User address space access functions.
4 * For licencing details see kernel-base/COPYING
7 #include <linux/highmem.h>
8 #include <linux/module.h>
10 #include <asm/word-at-a-time.h>
11 #include <linux/sched.h>
14 * best effort, GUP based copy_from_user() that is NMI-safe
17 copy_from_user_nmi(void *to
, const void __user
*from
, unsigned long n
)
19 unsigned long offset
, addr
= (unsigned long)from
;
20 unsigned long size
, len
= 0;
25 if (__range_not_ok(from
, n
, TASK_SIZE
))
29 ret
= __get_user_pages_fast(addr
, 1, 0, &page
);
33 offset
= addr
& (PAGE_SIZE
- 1);
34 size
= min(PAGE_SIZE
- offset
, n
- len
);
36 map
= kmap_atomic(page
);
37 memcpy(to
, map
+offset
, size
);
49 EXPORT_SYMBOL_GPL(copy_from_user_nmi
);