From patchwork Tue Dec 10 14:18:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22219 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1AA2723908 for ; Tue, 10 Dec 2013 14:18:52 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id ht17sf10068654vcb.10 for ; Tue, 10 Dec 2013 06:18:51 -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=ZU13QWWFq6cAK7HPOv/sHe5mhQspMUudAisY85ooxDk=; b=Y+NN5n1seClhUbp3INFxPM4/qvgpazx48VsVdsCgj8sWqbRl92TrhFw23vaHEjuh3X KQUSQUgy6+lypZK6IDUiENZ7l8XobQhMeiEh5kecpuFyufJ1fM7YmPjducBJLM1RYI+N xlpIdBrFJo5SL7kREMNY5YbGUrB4d80pR9PlEmpVKpvmjXUS/tC48r8o60nSC8oSuIA4 GgkOSGfJTkH7uHWYuV8CukWQH2qPbA4quCx/tv28neJI0TmozitwEdxlhJc5Kj0RNRWO dmDDPy5SWTOAo8y4/TnD0oXEaLbPgkqFjFIEr78cIABrXsGpn/05FoK4/MbZ2X8b2q/P LLxQ== X-Gm-Message-State: ALoCoQkxjA0cUCh4YGTfrQn6gdEuM4CeAjIEyPFNKGKBN2mc2k1o0pJIQoU4lGaZgW3odNwETNsn X-Received: by 10.52.184.228 with SMTP id ex4mr4023630vdc.1.1386685131837; Tue, 10 Dec 2013 06:18:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.37.195 with SMTP id a3ls2386945qek.88.gmail; Tue, 10 Dec 2013 06:18:51 -0800 (PST) X-Received: by 10.58.29.37 with SMTP id g5mr29059veh.38.1386685131628; Tue, 10 Dec 2013 06:18:51 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id mh9si5171427vec.140.2013.12.10.06.18.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Dec 2013 06:18:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 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.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so4955334veb.27 for ; Tue, 10 Dec 2013 06:18:51 -0800 (PST) X-Received: by 10.221.49.135 with SMTP id va7mr21810vcb.50.1386685131548; Tue, 10 Dec 2013 06:18:51 -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 u4csp191440vcz; Tue, 10 Dec 2013 06:18:51 -0800 (PST) X-Received: by 10.194.243.170 with SMTP id wz10mr2287661wjc.74.1386685130196; Tue, 10 Dec 2013 06:18:50 -0800 (PST) Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by mx.google.com with ESMTPS id fw4si6808329wjb.97.2013.12.10.06.18.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Dec 2013 06:18:50 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.47 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.47; Received: by mail-wg0-f47.google.com with SMTP id n12so5012547wgh.14 for ; Tue, 10 Dec 2013 06:18:49 -0800 (PST) X-Received: by 10.194.80.137 with SMTP id r9mr585589wjx.88.1386685129652; Tue, 10 Dec 2013 06:18:49 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id nb16sm5556779wic.0.2013.12.10.06.18.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2013 06:18:48 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, tim@xen.org, stefano.stabellini@citrix.com, Julien Grall Subject: [PATCH v3 09/10] xen/arm: Set foreign page type to p2m_map_foreign Date: Tue, 10 Dec 2013 14:18:21 +0000 Message-Id: <1386685102-563-10-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386685102-563-1-git-send-email-julien.grall@linaro.org> References: <1386685102-563-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.182 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 a reference to this page. Signed-off-by: Julien Grall --- Changes in v3: - Typoes - Check if the foreign domain is different from the current domain Changes in v2: - Even if gcc is buggy (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18501) define p2m type per mapspace to let the compiler warns about unitialized values. --- xen/arch/arm/mm.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 619aec9..2a2c769 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; switch ( space ) { @@ -1009,22 +1010,29 @@ static int xenmem_add_to_physmap_one( d->arch.grant_table_gpfn[idx] = gpfn; + t = p2m_ram_rw; + spin_unlock(&d->grant_table->lock); break; case XENMAPSPACE_shared_info: - if ( idx == 0 ) - mfn = virt_to_mfn(d->shared_info); - else + if ( idx != 0 ) return -EINVAL; + + mfn = virt_to_mfn(d->shared_info); + t = p2m_ram_rw; + 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; + if ( od == d ) + return -EINVAL; + rc = xsm_map_gmfn_foreign(XSM_TARGET, d, od); if ( rc ) { @@ -1032,15 +1040,18 @@ static int xenmem_add_to_physmap_one( return rc; } - maddr = p2m_lookup(od, pfn_to_paddr(idx), NULL); - if ( maddr == INVALID_PADDR ) + /* Take reference to the foreign domain page. + * Reference 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 +1062,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; }