From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH 7/8] xen/arm: Set foreign page type to p2m_map_foreign Date: Thu, 5 Dec 2013 15:42:10 +0000 Message-ID: <1386258131-755-8-git-send-email-julien.grall@linaro.org> References: <1386258131-755-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.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vob4X-0001w8-Nj for xen-devel@lists.xenproject.org; Thu, 05 Dec 2013 15:42:37 +0000 Received: by mail-wi0-f177.google.com with SMTP id cc10so10001257wib.16 for ; Thu, 05 Dec 2013 07:42:36 -0800 (PST) In-Reply-To: <1386258131-755-1-git-send-email-julien.grall@linaro.org> 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: Julien Grall , stefano.stabellini@citrix.com, ian.campbell@citrix.com, time@xen.org, patches@linaro.org List-Id: xen-devel@lists.xenproject.org Xen needs to know that the current page belongs to another domain. Also take the refcount to this page. Signed-off-by: Julien Grall --- xen/arch/arm/mm.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 960c872..bf383a7 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -977,6 +977,7 @@ static int xenmem_add_to_physmap_one( { unsigned long mfn = 0; int rc; + p2m_type_t t = p2m_ram_rw; switch ( space ) { @@ -1019,8 +1020,8 @@ static int xenmem_add_to_physmap_one( break; case XENMAPSPACE_gmfn_foreign: { - paddr_t maddr; struct domain *od; + struct page_info *page; od = rcu_lock_domain_by_any_id(foreign_domid); if ( od == NULL ) return -ESRCH; @@ -1032,15 +1033,18 @@ static int xenmem_add_to_physmap_one( return rc; } - maddr = p2m_lookup(od, pfn_to_paddr(idx)); - if ( maddr == INVALID_PADDR ) + /* Take refcount to the foreign domain page. + * Refcount will be release in XENMEM_remove_from_physmap */ + page = get_page_from_gfn(od, idx, NULL, P2M_ALLOC); + if ( !page ) { dump_p2m_lookup(od, pfn_to_paddr(idx)); rcu_unlock_domain(od); return -EINVAL; } - mfn = maddr >> PAGE_SHIFT; + mfn = page_to_mfn(page); + t = p2m_map_foreign; rcu_unlock_domain(od); break; @@ -1051,7 +1055,7 @@ static int xenmem_add_to_physmap_one( } /* Map at new location. */ - rc = guest_physmap_add_page(d, gpfn, mfn, 0); + rc = guest_physmap_add_entry(d, gpfn, mfn, 0, t); return rc; } -- 1.7.10.4