qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-1.4] linux-user: Restore cast to target type


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH for-1.4] linux-user: Restore cast to target type in get_user()
Date: Thu, 31 Jan 2013 16:29:36 +0000

On 31 January 2013 16:22, Richard Henderson <address@hidden> wrote:
> On 01/31/2013 04:50 AM, Peter Maydell wrote:
>> Commit 658f2dc97 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.

> I now recall that I'd intended to go audit the uses of ld[us][bw]_p
> and change the return type to be the "natural" one, which would not
> have had this surprise.  But then failed to actually do so.

That audit would not have caught the actual problem case, which
doesn't involve byte or word loads at all, but 'long' [ie 32 bit]
ones. The byte and word cases in __get_user() work OK because
the ld[us][bw]_p implementations return an appropriately sign
or zero extended value; but there is no signed/unsigned distinction
for ldl_p and so the caller (ie __get_user) must use or cast
via the right type to get the sign/zero extension right.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]