Commit 89343ecde51e7c287e8647a13f9e18f68a37c87c

Authored by ths
1 parent 80210bcd

EFAULT - update __get_user() __put_user(), by Thayne Harbaugh.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3508 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 13 additions and 13 deletions
linux-user/qemu.h
@@ -206,22 +206,22 @@ int target_msync(abi_ulong start, abi_ulong len, int flags); @@ -206,22 +206,22 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);
206 #define access_ok(type,addr,size) \ 206 #define access_ok(type,addr,size) \
207 (page_check_range((target_ulong)addr,size,(type==VERIFY_READ)?PAGE_READ:PAGE_WRITE)==0) 207 (page_check_range((target_ulong)addr,size,(type==VERIFY_READ)?PAGE_READ:PAGE_WRITE)==0)
208 208
209 -/* NOTE get_user and put_user use host addresses. */  
210 -#define __put_user(x,ptr)\ 209 +/* NOTE __get_user and __put_user use host pointers and don't check access. */
  210 +#define __put_user(x, hptr)\
211 ({\ 211 ({\
212 - int size = sizeof(*ptr);\ 212 + int size = sizeof(*hptr);\
213 switch(size) {\ 213 switch(size) {\
214 case 1:\ 214 case 1:\
215 - *(uint8_t *)(ptr) = (typeof(*ptr))(x);\ 215 + *(uint8_t *)(hptr) = (typeof(*hptr))(x);\
216 break;\ 216 break;\
217 case 2:\ 217 case 2:\
218 - *(uint16_t *)(ptr) = tswap16((typeof(*ptr))(x));\ 218 + *(uint16_t *)(hptr) = tswap16((typeof(*hptr))(x));\
219 break;\ 219 break;\
220 case 4:\ 220 case 4:\
221 - *(uint32_t *)(ptr) = tswap32((typeof(*ptr))(x));\ 221 + *(uint32_t *)(hptr) = tswap32((typeof(*hptr))(x));\
222 break;\ 222 break;\
223 case 8:\ 223 case 8:\
224 - *(uint64_t *)(ptr) = tswap64((typeof(*ptr))(x));\ 224 + *(uint64_t *)(hptr) = tswap64((typeof(*hptr))(x));\
225 break;\ 225 break;\
226 default:\ 226 default:\
227 abort();\ 227 abort();\
@@ -229,21 +229,21 @@ int target_msync(abi_ulong start, abi_ulong len, int flags); @@ -229,21 +229,21 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);
229 0;\ 229 0;\
230 }) 230 })
231 231
232 -#define __get_user(x, ptr) \ 232 +#define __get_user(x, hptr) \
233 ({\ 233 ({\
234 - int size = sizeof(*ptr);\ 234 + int size = sizeof(*hptr);\
235 switch(size) {\ 235 switch(size) {\
236 case 1:\ 236 case 1:\
237 - x = (typeof(*ptr))*(uint8_t *)(ptr);\ 237 + x = (typeof(*hptr))*(uint8_t *)(hptr);\
238 break;\ 238 break;\
239 case 2:\ 239 case 2:\
240 - x = (typeof(*ptr))tswap16(*(uint16_t *)(ptr));\ 240 + x = (typeof(*hptr))tswap16(*(uint16_t *)(hptr));\
241 break;\ 241 break;\
242 case 4:\ 242 case 4:\
243 - x = (typeof(*ptr))tswap32(*(uint32_t *)(ptr));\ 243 + x = (typeof(*hptr))tswap32(*(uint32_t *)(hptr));\
244 break;\ 244 break;\
245 case 8:\ 245 case 8:\
246 - x = (typeof(*ptr))tswap64(*(uint64_t *)(ptr));\ 246 + x = (typeof(*hptr))tswap64(*(uint64_t *)(hptr));\
247 break;\ 247 break;\
248 default:\ 248 default:\
249 abort();\ 249 abort();\