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 206 #define access_ok(type,addr,size) \
207 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 213 switch(size) {\
214 214 case 1:\
215   - *(uint8_t *)(ptr) = (typeof(*ptr))(x);\
  215 + *(uint8_t *)(hptr) = (typeof(*hptr))(x);\
216 216 break;\
217 217 case 2:\
218   - *(uint16_t *)(ptr) = tswap16((typeof(*ptr))(x));\
  218 + *(uint16_t *)(hptr) = tswap16((typeof(*hptr))(x));\
219 219 break;\
220 220 case 4:\
221   - *(uint32_t *)(ptr) = tswap32((typeof(*ptr))(x));\
  221 + *(uint32_t *)(hptr) = tswap32((typeof(*hptr))(x));\
222 222 break;\
223 223 case 8:\
224   - *(uint64_t *)(ptr) = tswap64((typeof(*ptr))(x));\
  224 + *(uint64_t *)(hptr) = tswap64((typeof(*hptr))(x));\
225 225 break;\
226 226 default:\
227 227 abort();\
... ... @@ -229,21 +229,21 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);
229 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 235 switch(size) {\
236 236 case 1:\
237   - x = (typeof(*ptr))*(uint8_t *)(ptr);\
  237 + x = (typeof(*hptr))*(uint8_t *)(hptr);\
238 238 break;\
239 239 case 2:\
240   - x = (typeof(*ptr))tswap16(*(uint16_t *)(ptr));\
  240 + x = (typeof(*hptr))tswap16(*(uint16_t *)(hptr));\
241 241 break;\
242 242 case 4:\
243   - x = (typeof(*ptr))tswap32(*(uint32_t *)(ptr));\
  243 + x = (typeof(*hptr))tswap32(*(uint32_t *)(hptr));\
244 244 break;\
245 245 case 8:\
246   - x = (typeof(*ptr))tswap64(*(uint64_t *)(ptr));\
  246 + x = (typeof(*hptr))tswap64(*(uint64_t *)(hptr));\
247 247 break;\
248 248 default:\
249 249 abort();\
... ...