From: "Jan Beulich" Subject: Re: [PATCH v2] xen/arm: Allow balooning working with 1:1 memory mapping Date: Mon, 16 Dec 2013 09:08:44 +0000 Message-ID: <52AED12C020000780010D832@nat28.tlf.novell.com> References: <1386965881-12151-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.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VsUAU-0005J1-SQ for xen-devel@lists.xenproject.org; Mon, 16 Dec 2013 09:08:51 +0000 In-Reply-To: <1386965881-12151-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, tim@xen.org, stefano.stabellini@citrix.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 13.12.13 at 21:18, Julien Grall wrote: > --- a/xen/common/memory.c > +++ b/xen/common/memory.c > @@ -90,7 +90,7 @@ static void increase_reservation(struct memop_args *a) > > static void populate_physmap(struct memop_args *a) > { > - struct page_info *page; > + struct page_info *page = NULL; Why? > @@ -122,7 +122,29 @@ static void populate_physmap(struct memop_args *a) > } > else > { > - page = alloc_domheap_pages(d, a->extent_order, a->memflags); > + if ( d == dom0 && is_dom0_mapped_11() ) > + { > + mfn = gpfn; > + if (!mfn_valid(mfn)) Coding style. > + { > + gdprintk(XENLOG_INFO, "Invalid mfn 0x%"PRI_xen_pfn"\n", > + mfn); > + goto out; > + } > + > + page = mfn_to_page(mfn); > + if ( !get_page(page, d) ) > + { > + gdprintk(XENLOG_INFO, > + "mfn 0x%"PRI_xen_pfn" doesn't belong to dom0\n", > + mfn); > + goto out; > + } > + put_page(page); > + } I think this hack doesn't belong into a common file. Rather than having the (anyway oddly named) is_dom0_mapped_11(), it would seem more clean to have this implemented by an inline function for ARM, returning the struct page_info * (and getting #define-d to NULL for all other cases, perhaps not even in an x86 header, but right in the source file). And even if we were to stay with the implementation here, for being at least half way sane the checking macro should take a domain argument rather than requiring the extra "d == dom0" check up front. Plus the "11" there is bogus - I first read this as "eleven" rather than "1:1", wondering what eleven here was about. I'd suggest something like is_domain_direct_mapped() or is_domain_identity_mapped(). Jan