From patchwork Tue Dec 17 16:27:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22604 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AB37223FC6 for ; Tue, 17 Dec 2013 16:28:45 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wm4sf22740062obc.7 for ; Tue, 17 Dec 2013 08:28:45 -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=LwW+gIJtRMS4233nWNN+sxlOqtROelwR8jVoxYwNZ6I=; b=lwZH1fpSsAet+Or1cgpqcN6hTiAstjaxZur84Q/1DLa6nPo/serOlOdskrqp2rssc3 f4xIAwdCXP7j7uv8pSkjuN+Fk4Z+McR5cwJEj6YVvsqeVIIrJR6fSVf58tqqc8WGQELA JHUYo4KQRHnJGL1nQbcvKtFTcmsFp3oIMoJNv6kZfRTnaj0bzvs/Z4Qya5nItr+t1vUw 9R2lbCAr7ZpScz7K9PWDLsFzbfvdr1xQZY7NDwDJutK7wFOyWUsVnI+e+i1NdELCG974 CJgcukBlh/e9UX6zSZEQMucFXmIbYHNhwvvN2Ptt9G8WTj5q/OzCr4bcmTdQ89gah3UZ b4Dg== X-Gm-Message-State: ALoCoQlDOkxUsFs9hz2y2CtFKFou7CCwsomM3tdFOqzn0nYMGSOkdbwpTRCj9fPn7z0jGlAOqG6t X-Received: by 10.43.78.135 with SMTP id zm7mr2893172icb.27.1387297725260; Tue, 17 Dec 2013 08:28:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.59.49 with SMTP id w17ls2598579qeq.68.gmail; Tue, 17 Dec 2013 08:28:45 -0800 (PST) X-Received: by 10.58.233.98 with SMTP id tv2mr11037848vec.11.1387297725151; Tue, 17 Dec 2013 08:28:45 -0800 (PST) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id a6si5038336vdp.26.2013.12.17.08.28.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 08:28:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.179 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.179; Received: by mail-ve0-f179.google.com with SMTP id jw12so4418493veb.24 for ; Tue, 17 Dec 2013 08:28:45 -0800 (PST) X-Received: by 10.58.154.6 with SMTP id vk6mr999666veb.61.1387297725053; Tue, 17 Dec 2013 08:28:45 -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 u4csp79588vcz; Tue, 17 Dec 2013 08:28:42 -0800 (PST) X-Received: by 10.14.172.130 with SMTP id t2mr23667709eel.68.1387297721635; Tue, 17 Dec 2013 08:28:41 -0800 (PST) Received: from mail-ea0-f171.google.com (mail-ea0-f171.google.com [209.85.215.171]) by mx.google.com with ESMTPS id f8si5272299eep.36.2013.12.17.08.28.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 08:28:41 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.171 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.171; Received: by mail-ea0-f171.google.com with SMTP id h10so2988928eak.16 for ; Tue, 17 Dec 2013 08:28:41 -0800 (PST) X-Received: by 10.14.3.130 with SMTP id 2mr23763884eeh.36.1387297721137; Tue, 17 Dec 2013 08:28:41 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id e3sm54411471eeg.11.2013.12.17.08.28.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2013 08:28:39 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, ian.jackson@eu.citrix.com, Julien Grall Subject: [PATCH v6 07/10] xen/arm: Handle remove foreign mapping Date: Tue, 17 Dec 2013 16:27:55 +0000 Message-Id: <1387297678-17762-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387297678-17762-1-git-send-email-julien.grall@linaro.org> References: <1387297678-17762-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.179 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 v6: - Use pte.p2m.base instead of arithmetics - We don't need to clean pte where valid == 0 (save time) 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 bc32935..410acb6 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -328,10 +328,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 = pte.p2m.base; + + if ( !pte.p2m.valid ) + break; + + /* TODO: Handle other p2m type */ + if ( 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;