[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 6/8] linux-user: Rewrite __get_user/__put_user w
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 6/8] linux-user: Rewrite __get_user/__put_user with __builtin_choose_expr |
Date: |
Thu, 31 Jan 2013 11:15:51 +0000 |
On 23 January 2013 18:31, Laurent Desnogues <address@hidden> wrote:
> On Sat, Jan 5, 2013 at 1:39 AM, Richard Henderson <address@hidden> wrote:
>> +#define __get_user_e(x, hptr, e) \
>> + ((x) = \
>> + __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)
>
> For 8- and 16-bit quantities the load is explicitly unsigned
> through the use of ldub and lduw. But for 32-bit, ldl_[bl]e_p
> return an int, so if x is a 64-bit variable sign-extension will
> happen. I'm not sure this is desirable, for instance when
> using get_user_u32 which makes one think the result is an
> unsigned 32-bit value. Shouldn't ldul*_p functions be added
> and used in __get_user_e?
>
> Note I found this in private code, but wonder if some public
> code isn't affected by this.
I just did an audit of all the uses of get_user_u32 in the codebase
and I think the only one that runs into this (ie does get_user_u32
into a variable which is 64 bits wide) is the PPC do_store_exclusive()
in linux-user/main.c. So probably this patch broke PPC64 linux-user
32 bit exclusive stores.
-- PMM
- [Qemu-devel] [PATCH v2 0/8] linux-user fixes, Richard Henderson, 2013/01/04
- [Qemu-devel] [PATCH 1/8] fdt: Use bswapN instead of bswap_N, Richard Henderson, 2013/01/04
- [Qemu-devel] [PATCH 4/8] bswap: Rewrite all ld<type>_<endian>_p functions, Richard Henderson, 2013/01/04
- [Qemu-devel] [PATCH 2/8] bswap: Tidy base definitions of bswapN, Richard Henderson, 2013/01/04
- [Qemu-devel] [PATCH 5/8] bswap: Rewrite cpu_to_<endian><type>u with {ld, st}<type>_<endian>_p, Richard Henderson, 2013/01/04
- [Qemu-devel] [PATCH 3/8] bswap: Add host endian unaligned access functions, Richard Henderson, 2013/01/04
- [Qemu-devel] [PATCH 8/8] user: Consider symbolic links as possible directories, Richard Henderson, 2013/01/04
- [Qemu-devel] [PATCH 6/8] linux-user: Rewrite __get_user/__put_user with __builtin_choose_expr, Richard Henderson, 2013/01/04
- [Qemu-devel] [PATCH 7/8] alpha-linux-user: Fix sigaction, Richard Henderson, 2013/01/04
- Re: [Qemu-devel] [PATCH v2 0/8] linux-user fixes, Blue Swirl, 2013/01/12