From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mh1O8-0007V3-IY for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:21:08 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mh1O3-0007Kk-F6 for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:21:07 -0400 Received: from [199.232.76.173] (port=36205 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mh1O3-0007KR-7r for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:21:03 -0400 Received: from mail.gmx.net ([213.165.64.20]:51018) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Mh1O2-0001WF-Hm for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:21:03 -0400 From: "Jan-Simon =?utf-8?q?M=C3=B6ller?=" Subject: Re: [Qemu-devel] [Patch] linux-user/syscall.c - don't add GUEST_BASE to NULL pointer Date: Fri, 28 Aug 2009 15:20:59 +0200 References: <200908260002.03066.dl9pf@gmx.de> <200908260137.48781.dl9pf@gmx.de> <20090826134043.GB7862@kos.to> In-Reply-To: <20090826134043.GB7862@kos.to> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200908281520.59454.dl9pf@gmx.de> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Am Mittwoch 26 August 2009 15:40:43 schrieb Riku Voipio: > 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 > > always return NULL on x =3D NULL ? > > I agree this seems like a a better idea than modifying the users of g2h. > > > Something like: > > > > Signed-off-by: Jan-Simon M=C3=B6ller > > > > 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 > > > > /* All direct uses of g2h and h2g need to go away for usermode softmmu= =2E=20 > > */ -#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 */ \ > > > > Take the first patch for syscall.c / mount . Unfortunately, the above one has side-effects where functions rely on a=20 shifted NULL pointer ...=20 Best, Jan-Simon