From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgIk5-0000Fr-6o for qemu-devel@nongnu.org; Wed, 26 Aug 2009 09:40:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgIk2-0000F7-MS for qemu-devel@nongnu.org; Wed, 26 Aug 2009 09:40:48 -0400 Received: from [199.232.76.173] (port=42896 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgIk1-0000Et-To for qemu-devel@nongnu.org; Wed, 26 Aug 2009 09:40:46 -0400 Received: from [84.20.150.76] (port=57490 helo=naru.obs2.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MgIk1-0000DW-FZ for qemu-devel@nongnu.org; Wed, 26 Aug 2009 09:40:45 -0400 Date: Wed, 26 Aug 2009 16:40:43 +0300 From: Riku Voipio Subject: Re: [Qemu-devel] [Patch] linux-user/syscall.c - don't add GUEST_BASE to NULL pointer Message-ID: <20090826134043.GB7862@kos.to> References: <200908260002.03066.dl9pf@gmx.de> <200908260137.48781.dl9pf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <200908260137.48781.dl9pf@gmx.de> Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan-Simon =?utf-8?Q?M=C3=B6ller?= Cc: qemu-devel@nongnu.org On Wed, Aug 26, 2009 at 01:37:48AM +0200, Jan-Simon M=C3=B6ller wrote: > Thinking a bit more about this, I wonder if g2h(x) shouldn't itself alw= ays=20 > return NULL on x =3D NULL ?=20 I agree this seems like a a better idea than modifying the users of g2h. > Something like: >=20 > Signed-off-by: Jan-Simon M=C3=B6ller >=20 > diff --git a/cpu-all.h b/cpu-all.h > index 1a6a812..631f678 100644 > --- a/cpu-all.h > +++ b/cpu-all.h > @@ -633,7 +633,7 @@ extern int have_guest_base; > #endif >=20 > /* All direct uses of g2h and h2g need to go away for usermode softmmu= . */ > -#define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE)) > +#define g2h(x) ( !x ? NULL:((void *)((unsigned long)(x) + GUEST_BASE))= ) > #define h2g(x) ({ \ > unsigned long __ret =3D (unsigned long)(x) - GUEST_BASE; \ > /* Check if given address fits target address space */ \ >=20 >=20 > I read the comment above, but before replacing it in user-mode (if poss= ible),=20 > we should fix it ;) . >=20 >=20 > Best, > Jan-Simon >=20 >=20 >=20