Skip to content

Commit

Permalink
linux-user: Restore cast to target type in get_user()
Browse files Browse the repository at this point in the history
Commit 658f2dc accidentally dropped the cast to the target type of
the value loaded by get_user().  The most visible effect of this would
be that the sequence "uint64_t v; get_user_u32(v, addr)" would sign
extend the 32 bit loaded value into v rather than zero extending as
would be expected for a _u32 accessor.  Put the cast back again to
restore the old behaviour.

Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
pm215 authored and Anthony Liguori committed Feb 6, 2013
1 parent f565235 commit 0bc8ce9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions linux-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
((hptr), (x)), 0)

#define __get_user_e(x, hptr, e) \
((x) = \
((x) = (typeof(*hptr))( \
__builtin_choose_expr(sizeof(*(hptr)) == 1, ldub_p, \
__builtin_choose_expr(sizeof(*(hptr)) == 2, lduw_##e##_p, \
__builtin_choose_expr(sizeof(*(hptr)) == 4, ldl_##e##_p, \
__builtin_choose_expr(sizeof(*(hptr)) == 8, ldq_##e##_p, abort)))) \
(hptr), 0)
(hptr)), 0)

#ifdef TARGET_WORDS_BIGENDIAN
# define __put_user(x, hptr) __put_user_e(x, hptr, be)
Expand Down

0 comments on commit 0bc8ce9

Please sign in to comment.