From patchwork Thu Dec 5 15:42:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22077 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D3BE3202E0 for ; Thu, 5 Dec 2013 15:42:37 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id oy12sf40663714veb.1 for ; Thu, 05 Dec 2013 07:42:37 -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:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=5YX4+4gtxD+aOg6FRh3wR1jLbKS2LwMwWXTLudr01lE=; b=ZQr9fux0CMUy3fkNQkhTITG4nIt9JTN2T30JcNZd70IovzcIjXTUeb7UroyjvD+qRM 3Ey/tkjfphvpMv7T17ImYvmfgUaozEb0vUIJ+AwRbd2FSh8XRFNKq/rf8GfP1uSkiaAE VzCZ/oJag3opGtYbO8ay5wL0qRRELn9TJ1m+J/97FENISdgLAVzLvKe03KpAvaZZrV44 trXeig9+Ne9DiI1qXWt1W9Tp2nQnfiyxhMMCP1sLM2Ht1ydSWeW06OtSo2195pnHfyjv kH4TXoo4CsY7CgPrHftiuSf67X4IdeKMaba55HH2fpXWEuS+RPFaCA9pVdNqqRuUhmMH T+MA== X-Gm-Message-State: ALoCoQlTRG9vL+cvhcJPh2Lh1LPoGrOd0J2ZtQKQ3InCyFLlXLeNBHu4NMhQTshQIlnk571utmIv X-Received: by 10.224.131.6 with SMTP id v6mr40009558qas.1.1386258157663; Thu, 05 Dec 2013 07:42:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.145 with SMTP id u17ls857028qef.42.gmail; Thu, 05 Dec 2013 07:42:37 -0800 (PST) X-Received: by 10.220.194.133 with SMTP id dy5mr64440270vcb.3.1386258157550; Thu, 05 Dec 2013 07:42:37 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id ph5si34880502veb.14.2013.12.05.07.42.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 07:42:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 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.170; Received: by mail-ve0-f170.google.com with SMTP id oy12so14031361veb.15 for ; Thu, 05 Dec 2013 07:42:37 -0800 (PST) X-Received: by 10.220.74.69 with SMTP id t5mr49587196vcj.18.1386258157354; Thu, 05 Dec 2013 07:42:37 -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 u4csp24848vcz; Thu, 5 Dec 2013 07:42:37 -0800 (PST) X-Received: by 10.180.90.37 with SMTP id bt5mr12628877wib.43.1386258156611; Thu, 05 Dec 2013 07:42:36 -0800 (PST) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by mx.google.com with ESMTPS id q6si12893503wjf.14.2013.12.05.07.42.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 07:42:36 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.176 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.212.176; Received: by mail-wi0-f176.google.com with SMTP id hq4so10089010wib.9 for ; Thu, 05 Dec 2013 07:42:36 -0800 (PST) X-Received: by 10.194.20.202 with SMTP id p10mr25561545wje.39.1386258155984; Thu, 05 Dec 2013 07:42:35 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id w20sm7350575wia.5.2013.12.05.07.42.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2013 07:42:35 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, time@xen.org, stefano.stabellini@citrix.com, 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> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386258131-755-1-git-send-email-julien.grall@linaro.org> References: <1386258131-755-1-git-send-email-julien.grall@linaro.org> 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.170 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: , 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; }