From patchwork Mon Dec 16 17:37:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22536 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4D16023FC6 for ; Mon, 16 Dec 2013 17:37:51 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wo20sf18543809obc.9 for ; Mon, 16 Dec 2013 09:37:50 -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=cEH+glvLrzoljnIt9CviLtpBDT728Ne0nZ7jD6Dnqjg=; b=ZThHOKunKcgo0jPihStMogeoBhesjadnBX90o+FEl6XrNmWQ2hXC52Kv/RUYKsIvPT zJ2zEVMkpxH6vHKuK7avFVdJFxZnEkWks6ZU7RW1s3xbg6175mTkeGH+Cf282D+KINe0 ntT2tRZWFTokvZ3efoZmbMVsfAyUOUbRMOAE2G8WxZIvTzPZPcVDrX7oyGrjnIbjpBR4 Az2RKsR1tg/7PQ4KlEfoD8vt/dMLTkW9tHKIEcMEm7miA9as983XLI8FGctIQi4Iuw5l spMyMfUlhxCIkG6SOM5045FZ27ztjQqy5vdsC8g8ymR+vvPognYO9vzMeANVGTuvUmEI Krcw== X-Gm-Message-State: ALoCoQn130Y4bByHi9Tho3al7q9KJYGIVcdgPD/J1/87sDe6vyJuuR0jl/ewsDwAIaClLpIybn0i X-Received: by 10.182.108.136 with SMTP id hk8mr6515313obb.11.1387215470823; Mon, 16 Dec 2013 09:37:50 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.83.2 with SMTP id m2ls2235916qey.37.gmail; Mon, 16 Dec 2013 09:37:50 -0800 (PST) X-Received: by 10.58.118.84 with SMTP id kk20mr4455819veb.26.1387215470686; Mon, 16 Dec 2013 09:37:50 -0800 (PST) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id dp7si4163050ved.35.2013.12.16.09.37.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:37:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id hu19so3465419vcb.28 for ; Mon, 16 Dec 2013 09:37:50 -0800 (PST) X-Received: by 10.52.160.130 with SMTP id xk2mr7454589vdb.24.1387215470601; Mon, 16 Dec 2013 09:37:50 -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 u4csp6126vcz; Mon, 16 Dec 2013 09:37:50 -0800 (PST) X-Received: by 10.15.74.200 with SMTP id j48mr10025894eey.102.1387215469559; Mon, 16 Dec 2013 09:37:49 -0800 (PST) Received: from mail-ee0-f45.google.com (mail-ee0-f45.google.com [74.125.83.45]) by mx.google.com with ESMTPS id h45si1623477eeo.109.2013.12.16.09.37.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:37:49 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.45 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.45; Received: by mail-ee0-f45.google.com with SMTP id d49so2379270eek.32 for ; Mon, 16 Dec 2013 09:37:49 -0800 (PST) X-Received: by 10.14.182.199 with SMTP id o47mr18083023eem.7.1387215468947; Mon, 16 Dec 2013 09:37:48 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id e3sm44674680eeg.11.2013.12.16.09.37.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2013 09:37:47 -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 v5 07/10] xen/arm: Handle remove foreign mapping Date: Mon, 16 Dec 2013 17:37:29 +0000 Message-Id: <1387215452-10951-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387215452-10951-1-git-send-email-julien.grall@linaro.org> References: <1387215452-10951-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.220.169 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: , Modify get_page_from_gfn to take reference on foreign mapping. This will avoid specific handling in the common code. Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v4.2: - get_page_from_gfn: move foreign checking before get_page - add assert fdom != dom Changes in v4.1: - Remove specific p2m handling in common code - Handle foreign mapping in get_page_from_gfn Changes in v4: - Split patch #6 from dom0 pvh series v6.2 to retrieve only common code. - Rework commit title - Rename xen_rem_foreign_from_p2m in p2m_remove_foreign - Get the mfn from the pte. We are not sure that maddr given in parameters is valid Changes in v3: - Move put_page in create_p2m_entries - Move xenmem_rem_foreign_from_p2m in arch/arm/p2m.c Changes in v2: - Introduce the patch --- xen/arch/arm/p2m.c | 15 +++++++++++++-- xen/include/asm-arm/p2m.h | 12 ++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 9bdcacd..d05fdff 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -317,10 +317,21 @@ static int create_p2m_entries(struct domain *d, break; case REMOVE: { - lpae_t pte; + lpae_t pte = third[third_table_offset(addr)]; + unsigned long mfn; + + maddr = (pte.bits & PADDR_MASK & PAGE_MASK); + mfn = paddr_to_pfn(maddr); + + /* TODO: Handle other p2m type */ + if ( pte.p2m.valid && p2m_is_foreign(pte.p2m.type) ) + { + ASSERT(mfn_valid(mfn)); + put_page(mfn_to_page(mfn)); + } + memset(&pte, 0x00, sizeof(pte)); write_pte(&third[third_table_offset(addr)], pte); - maddr += PAGE_SIZE; } break; } diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 0eb07a8..5ccfa7f 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -122,6 +122,18 @@ static inline struct page_info *get_page_from_gfn( if ( !mfn_valid(mfn) ) return NULL; page = mfn_to_page(mfn); + + /* get_page won't work on foreign mapping because the page doesn't + * belong to the current domain. + */ + if ( p2mt == p2m_map_foreign ) + { + struct domain *fdom = page_get_owner_and_reference(page); + ASSERT(fdom != NULL); + ASSERT(fdom != d); + return page; + } + if ( !get_page(page, d) ) return NULL; return page;