From patchwork Thu Nov 14 15:15:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 21508 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B3A6923FDD for ; Thu, 14 Nov 2013 15:15:57 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id b4sf3966064qen.7 for ; Thu, 14 Nov 2013 07:15:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=Vn+iRS2KdP7ShL2uyocJv/MncptTnN7jLplaWIcxiBI=; b=cXM9htVzwEcNYk4KzIsFA4YsHNSyH2N6KEmF6Hs5/MSj1Ja/wsqNgR5hbXX/+MS8zx Pray3ANWSOq5Yq80KKidSzR4FXXSysnoogMudCyrKfdY6lXgpZOK2Sv1OKqswIj/fGa9 Pmc6JsbiA6mhRg3ELIHPxkJmwUtvhtQgsqtPAVGlUJx7b08Rh0SyRZSK0WOZecxBwBVx I4kXAxHQ6NxY0dWFfkhaOvFNLrIZiVsVBofVS7HqITGwDg11ES4Ypz73ULR9baWcmrGn n37FaTfl307jtFEGfvNL9To4UCJtP6eOK5Xn1X4jIOJ9k19PYQaymymQB/WcZkFSaSuD tJVQ== X-Gm-Message-State: ALoCoQlrI8LT6eUBiXQhi8w7Jw9zvNyECbVzHVJdrFfUzhG0sEfEph0hhpz8QtODqdWTfaO1FuvY X-Received: by 10.236.135.79 with SMTP id t55mr937371yhi.39.1384442157103; Thu, 14 Nov 2013 07:15:57 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.29.229 with SMTP id n5ls1001663qeh.73.gmail; Thu, 14 Nov 2013 07:15:56 -0800 (PST) X-Received: by 10.58.50.194 with SMTP id e2mr3717veo.54.1384442156867; Thu, 14 Nov 2013 07:15:56 -0800 (PST) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id us10si17272392vcb.134.2013.11.14.07.15.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 07:15:56 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id oz11so1955900veb.31 for ; Thu, 14 Nov 2013 07:15:56 -0800 (PST) X-Received: by 10.220.196.66 with SMTP id ef2mr1159859vcb.7.1384442156740; Thu, 14 Nov 2013 07:15:56 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp323526vcz; Thu, 14 Nov 2013 07:15:56 -0800 (PST) X-Received: by 10.180.97.5 with SMTP id dw5mr3260692wib.42.1384442155500; Thu, 14 Nov 2013 07:15:55 -0800 (PST) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by mx.google.com with ESMTPS id c9si16393620wjy.47.2013.11.14.07.15.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 07:15:55 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.51 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.51; Received: by mail-wg0-f51.google.com with SMTP id m15so2133854wgh.30 for ; Thu, 14 Nov 2013 07:15:55 -0800 (PST) X-Received: by 10.180.185.101 with SMTP id fb5mr3275338wic.11.1384442154919; Thu, 14 Nov 2013 07:15:54 -0800 (PST) Received: from localhost.localdomain (cpc8-cmbg15-2-0-cust169.5-4.cable.virginm.net. [86.30.140.170]) by mx.google.com with ESMTPSA id b7sm7661420wiz.8.2013.11.14.07.15.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2013 07:15:54 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: ian.campbell@citrix.com, tim@xen.org, patches@linaro.org, stefano.stabellini@eu.citrix.com, Julien Grall , Keir Fraser , Jan Beulich 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> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;