2008-10-23 12:26:29 +07:00
|
|
|
#ifndef _ASM_X86_UACCESS_32_H
|
|
|
|
#define _ASM_X86_UACCESS_32_H
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* User space memory access functions
|
|
|
|
*/
|
|
|
|
#include <linux/string.h>
|
2008-02-04 22:47:59 +07:00
|
|
|
#include <asm/asm.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/page.h>
|
|
|
|
|
2017-03-26 06:33:21 +07:00
|
|
|
unsigned long __must_check __copy_user_ll
|
|
|
|
(void *to, const void *from, unsigned long n);
|
2008-03-23 15:03:48 +07:00
|
|
|
unsigned long __must_check __copy_from_user_ll_nocache_nozero
|
|
|
|
(void *to, const void __user *from, unsigned long n);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-01-15 04:21:30 +07:00
|
|
|
static __always_inline unsigned long __must_check
|
2017-03-26 06:33:21 +07:00
|
|
|
raw_copy_to_user(void __user *to, const void *from, unsigned long n)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-03-26 06:33:21 +07:00
|
|
|
return __copy_user_ll((__force void *)to, from, n);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2006-06-25 19:48:02 +07:00
|
|
|
static __always_inline unsigned long
|
2017-03-26 06:33:21 +07:00
|
|
|
raw_copy_from_user(void *to, const void __user *from, unsigned long n)
|
2006-06-25 19:48:02 +07:00
|
|
|
{
|
2005-04-17 05:20:36 +07:00
|
|
|
if (__builtin_constant_p(n)) {
|
|
|
|
unsigned long ret;
|
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
case 1:
|
2017-03-26 06:33:21 +07:00
|
|
|
ret = 0;
|
2016-02-24 05:58:52 +07:00
|
|
|
__uaccess_begin();
|
2017-03-26 06:33:21 +07:00
|
|
|
__get_user_asm_nozero(*(u8 *)to, from, ret,
|
|
|
|
"b", "b", "=q", 1);
|
2016-02-24 05:58:52 +07:00
|
|
|
__uaccess_end();
|
2005-04-17 05:20:36 +07:00
|
|
|
return ret;
|
|
|
|
case 2:
|
2017-03-26 06:33:21 +07:00
|
|
|
ret = 0;
|
2016-02-24 05:58:52 +07:00
|
|
|
__uaccess_begin();
|
2017-03-26 06:33:21 +07:00
|
|
|
__get_user_asm_nozero(*(u16 *)to, from, ret,
|
|
|
|
"w", "w", "=r", 2);
|
2016-02-24 05:58:52 +07:00
|
|
|
__uaccess_end();
|
2005-04-17 05:20:36 +07:00
|
|
|
return ret;
|
|
|
|
case 4:
|
2017-03-26 06:33:21 +07:00
|
|
|
ret = 0;
|
2016-02-24 05:58:52 +07:00
|
|
|
__uaccess_begin();
|
2017-03-26 06:33:21 +07:00
|
|
|
__get_user_asm_nozero(*(u32 *)to, from, ret,
|
|
|
|
"l", "k", "=r", 4);
|
2016-02-24 05:58:52 +07:00
|
|
|
__uaccess_end();
|
2005-04-17 05:20:36 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
2017-03-26 06:33:21 +07:00
|
|
|
return __copy_user_ll(to, (__force const void *)from, n);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2006-01-15 04:21:30 +07:00
|
|
|
static __always_inline unsigned long
|
2008-03-23 15:03:48 +07:00
|
|
|
__copy_from_user_inatomic_nocache(void *to, const void __user *from,
|
|
|
|
unsigned long n)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2006-06-25 19:48:02 +07:00
|
|
|
return __copy_from_user_ll_nocache_nozero(to, from, n);
|
2006-06-23 16:04:16 +07:00
|
|
|
}
|
|
|
|
|
2008-10-23 12:26:29 +07:00
|
|
|
#endif /* _ASM_X86_UACCESS_32_H */
|