From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KfGLW-0000Gx-7u for qemu-devel@nongnu.org; Mon, 15 Sep 2008 11:50:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KfGLV-0000Fq-8o for qemu-devel@nongnu.org; Mon, 15 Sep 2008 11:50:37 -0400 Received: from [199.232.76.173] (port=59525 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KfGLU-0000Fc-Os for qemu-devel@nongnu.org; Mon, 15 Sep 2008 11:50:36 -0400 Received: from mx2.redhat.com ([66.187.237.31]:52289) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KfGLU-0004vr-M3 for qemu-devel@nongnu.org; Mon, 15 Sep 2008 11:50:36 -0400 Date: Mon, 15 Sep 2008 12:48:43 -0300 From: Eduardo Habkost Subject: Re: [Qemu-devel] Re: [PATCH] Make page_find() return 0 for too-large addresses Message-ID: <20080915154843.GC12539@blackpad> References: <20080912185856.GM3982@blackpad> <48CAC809.5000901@codemonkey.ws> <20080912201406.GA10147@blackpad> <20080912204404.GB10147@blackpad> <48CE7F4A.3060000@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <48CE7F4A.3060000@codemonkey.ws> Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, gcosta@redhat.com On Mon, Sep 15, 2008 at 10:29:14AM -0500, Anthony Liguori wrote: > Eduardo Habkost wrote: >> >> New patch, reusing the range check from page_find_alloc() on >> page_find(). Untested. >> =20 > > Have you tested this patch yet? I like to avoid being the first one to= =20 > test something when it's not my code :-) I've tested it now, both with KVM enabled and with KVM disabled. My machine didn't explode yet, so it seems to be fine. :) > > Regards, > > Anthony Liguori > >> Signed-off-by: Eduardo Habkost >> --- >> Index: qemu/exec.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- qemu/exec.c (revis=E3o 5200) >> +++ qemu/exec.c (c=F3pia de trabalho) >> @@ -279,17 +279,24 @@ static void page_init(void) >> #endif >> } >> -static inline PageDesc *page_find_alloc(target_ulong index) >> +static inline PageDesc **page_l1_map(target_ulong index) >> { >> - PageDesc **lp, *p; >> - >> #if TARGET_LONG_BITS > 32 >> /* Host memory outside guest VM. For 32-bit targets we have alre= ady >> excluded high addresses. */ >> if (index > ((target_ulong)L2_SIZE * L1_SIZE)) >> return NULL; >> #endif >> - lp =3D &l1_map[index >> L2_BITS]; >> + return &l1_map[index >> L2_BITS]; >> +} >> + >> +static inline PageDesc *page_find_alloc(target_ulong index) >> +{ >> + PageDesc **lp, *p; >> + lp =3D page_l1_map(index); >> + if (!lp) >> + return NULL; >> + >> p =3D *lp; >> if (!p) { >> /* allocate if not found */ >> @@ -316,9 +323,12 @@ static inline PageDesc *page_find_alloc( >> static inline PageDesc *page_find(target_ulong index) >> { >> - PageDesc *p; >> + PageDesc **lp, *p; >> + lp =3D page_l1_map(index); >> + if (!lp) >> + return NULL; >> - p =3D l1_map[index >> L2_BITS]; >> + p =3D *lp; >> if (!p) >> return 0; >> return p + (index & (L2_SIZE - 1)); >> >> >> =20 > > --=20 Eduardo