From: "Jan Beulich" Subject: Re: [PATCH V2] xen: Check if the range is valid in init_domheap_pages Date: Wed, 13 Nov 2013 13:26:04 +0000 Message-ID: <52838BFC0200007800102DBE@nat28.tlf.novell.com> References: <1384348525-3230-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VgaSQ-0007IB-Ez for xen-devel@lists.xenproject.org; Wed, 13 Nov 2013 13:26:10 +0000 In-Reply-To: <1384348525-3230-1-git-send-email-julien.grall@linaro.org> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: Keir Fraser , ian.campbell@citrix.com, patches@linaro.org, stefano.stabellini@eu.citrix.com, tim@xen.org, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 13.11.13 at 14:15, Julien Grall wrote: > On ARM, when an initrd is given to xen by U-boot, it will reserve the memory > in the device tree. > In this case, when xen decides to free unused memory, dt_unreserved_regions > will call init_domheap_pages with the start and the end of range equals. But > the latter assumes that (start > end), if not Xen will hang because the > number of pages is equals to (unsigned)-1. The change is simple enough, so I don't really mind it going in, but I wonder ... > Signed-off-by: Julien Grall > CC: Keir Fraser > CC: Jan Beulich > > --- > Changes in v2: > - Change commit title > - Move the check in init_domheap_pages ... who and why suggested to move it here. After all, I'm considering it an error to call the function with non-page-aligned addresses and/ or end < start (I take it that page-aligned, but start == end is not a problem without your change). Jan > --- a/xen/common/page_alloc.c > +++ b/xen/common/page_alloc.c > @@ -1429,6 +1429,9 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) > smfn = round_pgup(ps) >> PAGE_SHIFT; > emfn = round_pgdown(pe) >> PAGE_SHIFT; > > + if ( smfn <= emfn ) > + return; > + > init_heap_pages(mfn_to_page(smfn), emfn - smfn); > } > > -- > 1.8.3.1 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel