From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH] xen: privcmd: do not return pages which we have failed to unmap Date: Fri, 6 Dec 2013 15:08:36 -0500 Message-ID: <20131206200836.GB10345@pegasus.dumpdata.com> References: <1386172341-12110-1-git-send-email-ian.campbell@citrix.com> <529F5112.3020206@citrix.com> <1386173033.17466.99.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vp1ih-0004kt-2B for xen-devel@lists.xenproject.org; Fri, 06 Dec 2013 20:09:51 +0000 Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: xen-devel@lists.xenproject.org, Boris Ostrovsky , xen-devel@lists.xen.org, Ian Campbell , David Vrabel List-Id: xen-devel@lists.xenproject.org On Fri, Dec 06, 2013 at 05:58:25PM +0000, Stefano Stabellini wrote: > On Wed, 4 Dec 2013, Ian Campbell wrote: > > >From 900f1e903bacf376800b078aef03e8d5ff524562 Mon Sep 17 00:00:00 2001 > > From: Ian Campbell > > Date: Wed, 4 Dec 2013 14:19:52 +0000 > > Subject: [PATCH] xen: privcmd: do not return pages which we have failed to > > unmap > > > > This failure represents a hypervisor issue, but if it does occur then nothing > > good can come of returning pages which still refer to a foreign owned page > > into the general allocation pool. > > > > Instead we are forced to leak them. Log that we have done so. > > > > The potential for failure only exists for autotranslated guest (e.g. ARM and > > x86 PVH). > > > > Signed-off-by: Ian Campbell > > Cc: Konrad Rzeszutek Wilk > > Cc: Boris Ostrovsky > > Cc: David Vrabel > > Cc: Stefano Stabellini > > Cc: xen-devel@lists.xenproject.org > > --- > > v2: Don't leak the actual pages array as well > > Log rc > > > Acked-by: Stefano Stabellini > > Konrad, you can go ahead and add it to xentip, unless you would rather > have me do it. Why don't you do it. Thanks! > > > > drivers/xen/privcmd.c | 9 +++++++-- > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c > > index 8e74590..569a13b 100644 > > --- a/drivers/xen/privcmd.c > > +++ b/drivers/xen/privcmd.c > > @@ -533,12 +533,17 @@ static void privcmd_close(struct vm_area_struct *vma) > > { > > struct page **pages = vma->vm_private_data; > > int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; > > + int rc; > > > > if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages) > > return; > > > > - xen_unmap_domain_mfn_range(vma, numpgs, pages); > > - free_xenballooned_pages(numpgs, pages); > > + rc = xen_unmap_domain_mfn_range(vma, numpgs, pages); > > + if (rc == 0) > > + free_xenballooned_pages(numpgs, pages); > > + else > > + pr_crit("unable to unmap MFN range: leaking %d pages. rc=%d\n", > > + numpgs, rc); > > kfree(pages); > > } > > > > -- > > 1.7.10.4 > > > > > >