From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH] xen/arm: Allow balooning working with 1:1 memory mapping Date: Thu, 14 Nov 2013 15:15:48 +0000 Message-ID: <1384442148-12014-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.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VgyeC-0007Mf-RS for xen-devel@lists.xenproject.org; Thu, 14 Nov 2013 15:15:57 +0000 Received: by mail-wg0-f53.google.com with SMTP id b13so2106721wgh.8 for ; Thu, 14 Nov 2013 07:15:55 -0800 (PST) List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Keir Fraser , ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, Julien Grall , tim@xen.org, Jan Beulich , patches@linaro.org List-Id: xen-devel@lists.xenproject.org With the lake of iommu, dom0 must have a 1:1 memory mapping for all these guest physical address. When the ballon decides to give back a page to the kernel, this page must have the same address as previously. Otherwise, we will loose the 1:1 mapping and will break DMA-capable device. Signed-off-by: Julien Grall CC: Keir Fraser CC: Jan Beulich --- xen/common/memory.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index 50b740f..df36d43 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -28,6 +28,9 @@ #include #include #include +#ifdef CONFIG_ARM +#include +#endif struct memop_args { /* INPUT */ @@ -90,7 +93,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; unsigned long i, j; xen_pfn_t gpfn, mfn; struct domain *d = a->domain; @@ -122,7 +125,33 @@ static void populate_physmap(struct memop_args *a) } else { - page = alloc_domheap_pages(d, a->extent_order, a->memflags); +#ifdef CONFIG_ARM + if ( d == dom0 && platform_has_quirk(PLATFORM_QUIRK_DOM0_MAPPING_11) ) + { + mfn = gpfn; + if (!mfn_valid(mfn)) + { + 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); + } + else +#endif + { + page = alloc_domheap_pages(d, a->extent_order, a->memflags); + } + if ( unlikely(page == NULL) ) { if ( !opt_tmem || (a->extent_order != 0) ) @@ -270,6 +299,15 @@ static void decrease_reservation(struct memop_args *a) && p2m_pod_decrease_reservation(a->domain, gmfn, a->extent_order) ) continue; +#ifdef CONFIG_ARM + /* With the lake for iommu, dom0 must retrieve the same pfn when + * the hypercall populate_physmap is called. + */ + if ( a->domain == dom0 && + platform_has_quirk(PLATFORM_QUIRK_DOM0_MAPPING_11) ) + continue; +#endif + for ( j = 0; j < (1 << a->extent_order); j++ ) if ( !guest_remove_page(a->domain, gmfn + j) ) goto out; -- 1.8.3.1