提交 89343ecd 编写于 作者: T ths

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
上级 80210bcd
......@@ -206,22 +206,22 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);
#define access_ok(type,addr,size) \
(page_check_range((target_ulong)addr,size,(type==VERIFY_READ)?PAGE_READ:PAGE_WRITE)==0)
/* NOTE get_user and put_user use host addresses. */
#define __put_user(x,ptr)\
/* NOTE __get_user and __put_user use host pointers and don't check access. */
#define __put_user(x, hptr)\
({\
int size = sizeof(*ptr);\
int size = sizeof(*hptr);\
switch(size) {\
case 1:\
*(uint8_t *)(ptr) = (typeof(*ptr))(x);\
*(uint8_t *)(hptr) = (typeof(*hptr))(x);\
break;\
case 2:\
*(uint16_t *)(ptr) = tswap16((typeof(*ptr))(x));\
*(uint16_t *)(hptr) = tswap16((typeof(*hptr))(x));\
break;\
case 4:\
*(uint32_t *)(ptr) = tswap32((typeof(*ptr))(x));\
*(uint32_t *)(hptr) = tswap32((typeof(*hptr))(x));\
break;\
case 8:\
*(uint64_t *)(ptr) = tswap64((typeof(*ptr))(x));\
*(uint64_t *)(hptr) = tswap64((typeof(*hptr))(x));\
break;\
default:\
abort();\
......@@ -229,21 +229,21 @@ int target_msync(abi_ulong start, abi_ulong len, int flags);
0;\
})
#define __get_user(x, ptr) \
#define __get_user(x, hptr) \
({\
int size = sizeof(*ptr);\
int size = sizeof(*hptr);\
switch(size) {\
case 1:\
x = (typeof(*ptr))*(uint8_t *)(ptr);\
x = (typeof(*hptr))*(uint8_t *)(hptr);\
break;\
case 2:\
x = (typeof(*ptr))tswap16(*(uint16_t *)(ptr));\
x = (typeof(*hptr))tswap16(*(uint16_t *)(hptr));\
break;\
case 4:\
x = (typeof(*ptr))tswap32(*(uint32_t *)(ptr));\
x = (typeof(*hptr))tswap32(*(uint32_t *)(hptr));\
break;\
case 8:\
x = (typeof(*ptr))tswap64(*(uint64_t *)(ptr));\
x = (typeof(*hptr))tswap64(*(uint64_t *)(hptr));\
break;\
default:\
abort();\
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册