Go to the documentation of this file.
9 #include <linux/errno.h>
10 #include <linux/compiler.h>
11 #include <linux/string.h>
20 #include <asm/processor.h>
35 #define KERNEL_DS ((mm_segment_t) { ASI_P })
36 #define USER_DS ((mm_segment_t) { ASI_AIUS })
39 #define VERIFY_WRITE 1
41 #define get_fs() ((mm_segment_t) { get_thread_current_ds() })
42 #define get_ds() (KERNEL_DS)
44 #define segment_eq(a,b) ((a).seg == (b).seg)
48 set_thread_current_ds((val).seg); \
49 __asm__ __volatile__ ("wr %%g0, %0, %%asi" : : "r" ((val).seg)); \
91 #define put_user(x,ptr) ({ \
92 unsigned long __pu_addr = (unsigned long)(ptr); \
93 __chk_user_ptr(ptr); \
94 __put_user_nocheck((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); })
96 #define get_user(x,ptr) ({ \
97 unsigned long __gu_addr = (unsigned long)(ptr); \
98 __chk_user_ptr(ptr); \
99 __get_user_nocheck((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); })
101 #define __put_user(x,ptr) put_user(x,ptr)
102 #define __get_user(x,ptr) get_user(x,ptr)
105 #define __m(x) ((struct __large_struct *)(x))
107 #define __put_user_nocheck(data,addr,size) ({ \
108 register int __pu_ret; \
110 case 1: __put_user_asm(data,b,addr,__pu_ret); break; \
111 case 2: __put_user_asm(data,h,addr,__pu_ret); break; \
112 case 4: __put_user_asm(data,w,addr,__pu_ret); break; \
113 case 8: __put_user_asm(data,x,addr,__pu_ret); break; \
114 default: __pu_ret = __put_user_bad(); break; \
117 #define __put_user_asm(x,size,addr,ret) \
118 __asm__ __volatile__( \
120 "1:\t" "st"#size "a %1, [%2] %%asi\n\t" \
123 ".section .fixup,#alloc,#execinstr\n\t" \
126 "sethi %%hi(2b), %0\n\t" \
127 "jmpl %0 + %%lo(2b), %%g0\n\t" \
128 " mov %3, %0\n\n\t" \
130 ".section __ex_table,\"a\"\n\t" \
134 : "=r" (ret) : "r" (x), "r" (__m(addr)), \
139 #define __get_user_nocheck(data,addr,size,type) ({ \
140 register int __gu_ret; \
141 register unsigned long __gu_val; \
143 case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \
144 case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \
145 case 4: __get_user_asm(__gu_val,uw,addr,__gu_ret); break; \
146 case 8: __get_user_asm(__gu_val,x,addr,__gu_ret); break; \
147 default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \
148 } data = (type) __gu_val; __gu_ret; })
150 #define __get_user_nocheck_ret(data,addr,size,type,retval) ({ \
151 register unsigned long __gu_val __asm__ ("l1"); \
153 case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \
154 case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \
155 case 4: __get_user_asm_ret(__gu_val,uw,addr,retval); break; \
156 case 8: __get_user_asm_ret(__gu_val,x,addr,retval); break; \
157 default: if (__get_user_bad()) return retval; \
158 } data = (type) __gu_val; })
160 #define __get_user_asm(x,size,addr,ret) \
161 __asm__ __volatile__( \
163 "1:\t" "ld"#size "a [%2] %%asi, %1\n\t" \
166 ".section .fixup,#alloc,#execinstr\n\t" \
169 "sethi %%hi(2b), %0\n\t" \
171 "jmpl %0 + %%lo(2b), %%g0\n\t" \
172 " mov %3, %0\n\n\t" \
174 ".section __ex_table,\"a\"\n\t" \
176 ".word 1b, 3b\n\n\t" \
178 : "=r" (ret), "=r" (x) : "r" (__m(addr)), \
181 #define __get_user_asm_ret(x,size,addr,retval) \
182 if (__builtin_constant_p(retval) && retval == -EFAULT) \
183 __asm__ __volatile__( \
185 "1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \
186 ".section __ex_table,\"a\"\n\t" \
188 ".word 1b,__ret_efault\n\n\t" \
190 : "=r" (x) : "r" (__m(addr))); \
192 __asm__ __volatile__( \
194 "1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \
195 ".section .fixup,#alloc,#execinstr\n\t" \
199 " restore %%g0, %2, %%o0\n\n\t" \
201 ".section __ex_table,\"a\"\n\t" \
203 ".word 1b, 3b\n\n\t" \
205 : "=r" (x) : "r" (__m(addr)), "i" (retval))
210 const void __user *
from,
224 #define __copy_from_user copy_from_user
232 copy_to_user(
void __user *to,
const void *from,
unsigned long size)
240 #define __copy_to_user copy_to_user
243 const void __user *from,
248 copy_in_user(
void __user *to,
void __user *from,
unsigned long size)
256 #define __copy_in_user copy_in_user
260 #define clear_user __clear_user
265 #define __copy_to_user_inatomic ___copy_to_user
266 #define __copy_from_user_inatomic ___copy_from_user