2
* User address space access functions.
3
* The non inlined parts of asm-i386/uaccess.h are here.
5
* Copyright 1997 Andi Kleen <ak@muc.de>
6
* Copyright 1997 Linus Torvalds
8
#include <linux/config.h>
9
#include <asm/uaccess.h>
10
//#include <asm/mmx.h>
12
#ifdef CONFIG_X86_USE_3DNOW_AND_WORKS
15
__generic_copy_to_user(void *to, const void *from, unsigned long n)
17
if (access_ok(VERIFY_WRITE, to, n))
20
__copy_user(to,from,n);
22
mmx_copy_user(to,from,n);
28
__generic_copy_from_user(void *to, const void *from, unsigned long n)
30
if (access_ok(VERIFY_READ, from, n))
33
__copy_user_zeroing(to,from,n);
35
mmx_copy_user_zeroing(to, from, n);
45
__generic_copy_to_user(void *to, const void *from, unsigned long n)
48
if (access_ok(VERIFY_WRITE, to, n))
49
__copy_user(to,from,n);
54
__generic_copy_from_user(void *to, const void *from, unsigned long n)
57
if (access_ok(VERIFY_READ, from, n))
58
__copy_user_zeroing(to,from,n);
67
* Copy a null terminated string from userspace.
70
#define __do_strncpy_from_user(dst,src,count,res) \
72
int __d0, __d1, __d2; \
73
__asm__ __volatile__( \
78
" testb %%al,%%al\n" \
84
".section .fixup,\"ax\"\n" \
88
".section __ex_table,\"a\"\n" \
92
: "=d"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1), \
94
: "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
99
__strncpy_from_user(char *dst, const char *src, long count)
102
__do_strncpy_from_user(dst, src, count, res);
107
strncpy_from_user(char *dst, const char *src, long count)
110
if (access_ok(VERIFY_READ, src, 1))
111
__do_strncpy_from_user(dst, src, count, res);
120
#define __do_clear_user(addr,size) \
123
__asm__ __volatile__( \
128
".section .fixup,\"ax\"\n" \
129
"3: lea 0(%2,%0,4),%0\n" \
132
".section __ex_table,\"a\"\n" \
137
: "=&c"(size), "=&D" (__d0) \
138
: "r"(size & 3), "0"(size / 4), "1"(addr), "a"(0)); \
142
clear_user(void *to, unsigned long n)
144
if (access_ok(VERIFY_WRITE, to, n))
145
__do_clear_user(to, n);
150
__clear_user(void *to, unsigned long n)
152
__do_clear_user(to, n);
157
* Return the size of a string (including the ending 0)
159
* Return 0 on exception, a value greater than N if too long
162
long strnlen_user(const char *s, long n)
164
unsigned long mask = -__addr_ok(s);
165
unsigned long res, tmp;
167
__asm__ __volatile__(
176
".section .fixup,\"ax\"\n"
177
"2: xorl %%eax,%%eax\n"
182
".section __ex_table,\"a\"\n"
186
:"=r" (n), "=D" (s), "=a" (res), "=c" (tmp)
187
:"0" (n), "1" (s), "2" (0), "3" (mask)