From: Dan Magenheimer Subject: RE: Re: xen crash in tmem: checking a xen pfn for domain ownership Date: Tue, 21 Sep 2010 11:53:40 -0700 (PDT) Message-ID: <4708fde1-b363-4c09-bc3f-a6eba02603f2@default> References: <12d0043a-2042-4939-9489-8ec8a50ea785@default C8BE20E7.239B6%keir.fraser@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser , Jan Beulich Cc: Xen-devel List-Id: xen-devel@lists.xenproject.org > Rest of the code looks fine. Except for a couple of bugs that took awhile to track down :-( First (stupid one), get_page returns 1 for success and 0 for failure and I was testing for failure by <=3D 0 (the Linux convention, oops). Second, and much more subtle, apparently get_page_and_type must always be bracketed with a put_page_and_type, and get_page must always be bracketed with a put_page, i.e. these can't be mixed. It appears that the "and_type" versions take two references, not one so mixing them results in bad non-obvious BUGs when pages are cycled through the heap. > -----Original Message----- > From: Keir Fraser [mailto:keir.fraser@eu.citrix.com] > Sent: Tuesday, September 21, 2010 1:44 AM > To: Dan Magenheimer; Jan Beulich > Cc: Xen-devel > Subject: Re: [Xen-devel] Re: xen crash in tmem: checking a xen pfn for > domain ownership >=20 > On 21/09/2010 00:03, "Dan Magenheimer" > wrote: >=20 > > if ( is_hvm_domain(current->domain) ) > > { > > xmfn =3D mfn_x(gfn_to_mfn_unshare(current->domain, cmfn, &t, > 2)); > > if (t !=3D p2m_ram_rw || xmfn =3D=3D INVALID_MFN) > > return NULL; > > } > > else > > { > > xmfn =3D cmfn; > > if (!mfn_valid(xmfn)) > > return NULL; > > } >=20 > This is needlessly cumbersome. You can do it without the if(is_hvm): >=20 > xmfn =3D mfn_x(gfn_to_mfn(current->domain, cmfn, &t); > if ((t !=3D p2m_ram_rw) || !mfn_valid(xmfn)) > return NULL; >=20 > (Didn't use hfn_to_mfn_unshare as you have decided against it.) >=20 > Rest of the code looks fine. >=20 > -- Keir >=20 >=20