From patchwork Mon Dec 9 03:34:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22156 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 78CF123FD2 for ; Mon, 9 Dec 2013 03:34:27 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id g10sf15293178pdj.5 for ; Sun, 08 Dec 2013 19:34:26 -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=X7EjLoLYo8AKM6353/OlT7dAl+itTWeHkZcwS37zLok=; b=KA0e3L2X6nyRWv2SHiMk0NPrsbYoD4IGLWeS1QeidMJ43ZM6rWt7uG9v0ISfhUEwh9 NHA+eBYSNmxDe+3utDW918ABddeXxFzmfw8bifZV9FE4zk0Cy0WKjcWBPWqr9S9WkJQY zr+uQJ577uVo6BbBvCuFkKyPa1K2UuiHFSp39nl2ltnAct6uvFpMDPWOWUQM73CUoolu V9uf9RVTWFBWMV/qKxfoNgop+GdNRmk0sxRExETl9OzFw+4Fg87Wj1KYaLiig+GaNgxx 04+5SUG6XixtkhN+zYXw3Efmml03DLku+HI4YLOV+RzQXs3GzK1fIfz/HGpU7iDrbiOt 77SA== X-Gm-Message-State: ALoCoQk/BgNFgWroxiDCldc89cWENMFH7lbldh2WznKJITZlEw4an8nUiM1YfeRkaGPB8vbzsrB0 X-Received: by 10.66.220.4 with SMTP id ps4mr8898658pac.18.1386560066761; Sun, 08 Dec 2013 19:34:26 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.70.170 with SMTP id n10ls1980688qeu.82.gmail; Sun, 08 Dec 2013 19:34:26 -0800 (PST) X-Received: by 10.220.97.145 with SMTP id l17mr719321vcn.35.1386560066605; Sun, 08 Dec 2013 19:34:26 -0800 (PST) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id tl2si3179346vdc.25.2013.12.08.19.34.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Dec 2013 19:34:26 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.180 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.180; Received: by mail-ve0-f180.google.com with SMTP id jz11so3049421veb.25 for ; Sun, 08 Dec 2013 19:34:26 -0800 (PST) X-Received: by 10.221.40.10 with SMTP id to10mr779758vcb.22.1386560066533; Sun, 08 Dec 2013 19:34:26 -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 u4csp75734vcz; Sun, 8 Dec 2013 19:34:26 -0800 (PST) X-Received: by 10.14.218.69 with SMTP id j45mr11058657eep.22.1386560065584; Sun, 08 Dec 2013 19:34:25 -0800 (PST) Received: from mail-ea0-f172.google.com (mail-ea0-f172.google.com [209.85.215.172]) by mx.google.com with ESMTPS id e2si7740741eeg.30.2013.12.08.19.34.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Dec 2013 19:34:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.172 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.172; Received: by mail-ea0-f172.google.com with SMTP id q10so1288115ead.17 for ; Sun, 08 Dec 2013 19:34:25 -0800 (PST) X-Received: by 10.15.26.6 with SMTP id m6mr5448334eeu.80.1386560065179; Sun, 08 Dec 2013 19:34:25 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id g7sm23681234eet.12.2013.12.08.19.34.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2013 19:34:24 -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 v2 09/10] xen/arm: Set foreign page type to p2m_map_foreign Date: Mon, 9 Dec 2013 03:34:06 +0000 Message-Id: <1386560047-17500-10-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386560047-17500-1-git-send-email-julien.grall@linaro.org> References: <1386560047-17500-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.180 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 --- 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 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index ba51f6e..b08ffa0 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -993,6 +993,7 @@ static int xenmem_add_to_physmap_one( { unsigned long mfn = 0; int rc; + p2m_type_t t; switch ( space ) { @@ -1025,18 +1026,22 @@ 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; @@ -1048,15 +1053,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; @@ -1067,7 +1075,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; }