From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUsp0-0006fV-4i for qemu-devel@nongnu.org; Wed, 03 Aug 2016 05:50:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUsov-00012V-OD for qemu-devel@nongnu.org; Wed, 03 Aug 2016 05:50:40 -0400 Received: from gate.crashing.org ([63.228.1.57]:41720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUsov-00012H-DK for qemu-devel@nongnu.org; Wed, 03 Aug 2016 05:50:37 -0400 Message-ID: <1470217830.12584.70.camel@kernel.crashing.org> From: Benjamin Herrenschmidt Date: Wed, 03 Aug 2016 19:50:30 +1000 In-Reply-To: References: <1470194119.12584.43.camel@kernel.crashing.org> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/2] Fix g2h() for 32-bit targets on 64-bit hosts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers On Wed, 2016-08-03 at 09:40 +0100, Peter Maydell wrote: > > index 6eb5fe8..0164535 100644 > > --- a/include/exec/cpu_ldst.h > > +++ b/include/exec/cpu_ldst.h > > @@ -49,7 +49,7 @@ > > > >=C2=A0 #if defined(CONFIG_USER_ONLY) > >=C2=A0 /* All direct uses of g2h and h2g need to go away for usermode = softmmu.=C2=A0 */ > > -#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + guest_ba= se)) > > +#define g2h(x) ((void *)(guest_base + (unsigned long)(target_ulong)(= x))) >=20 > I'm confused. Is this just swapping the order of the operands to '+'? > I wouldn't expect that to make any difference because typecast has > higher precedence than '+'... The typecast to target_ulong which is 32-bits :-) > > I run 32-bit (ARM) programs on x86-64 a lot so I would be surprised > if g2h() was broken like this. I had a pretty clear breakage case, and this along with patch 1 fixed it. Cheers, Ben.