From patchwork Mon Dec 16 17:14: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: 22529 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8221923FC7 for ; Mon, 16 Dec 2013 17:14:26 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id jw12sf10124417veb.11 for ; Mon, 16 Dec 2013 09:14:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:references:in-reply-to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=BWiy0dqh6a4al0zZhlU3IhsNwnNikB+lNZyA6ZG5sAk=; b=XeMf1YzBTe+Cfr440+BwwniEKARLZXPHpYCuI2uZ0ZZzNvbQhqaZ9kruM29syamM4M a7aXkb4jRtV/URUTnjUofCJZup3qgW+apbG6cIbhBXHMnIEIPNNaHY/Z50LoeBBUrvB/ LRKxM9Tl0UD3Ziy8WolZP60xcO61oMlk/dbAo0HO0BbM/pslpLRQbu2cm8MQ10HZkVFF VqpEj/dWs58pNds5vypVtdSEYGkbBAApQQVRSwbdEV1h9xWkOgvHUiM5Z7FoBp+tn1lP r5ZIzqijjvWHn+CIzEKWLVZpWKfE0h8aWAwbMgPN77qdYhdH9jDWU9ECkbug9QwDL+9F xV0A== X-Gm-Message-State: ALoCoQnOQg2xKYYce5x1v+hemC04ZkvU8Gbrgss4WKXa+CSScwIMGbIDRelBeWZluIo/PP8DejCT X-Received: by 10.58.46.36 with SMTP id s4mr5915872vem.18.1387214065849; Mon, 16 Dec 2013 09:14:25 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.196 with SMTP id kw4ls2062308qeb.90.gmail; Mon, 16 Dec 2013 09:14:25 -0800 (PST) X-Received: by 10.58.241.135 with SMTP id wi7mr15990vec.70.1387214065756; Mon, 16 Dec 2013 09:14:25 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id gq10si4133191vdc.69.2013.12.16.09.14.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:14:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so3494146veb.16 for ; Mon, 16 Dec 2013 09:14:25 -0800 (PST) X-Received: by 10.220.74.69 with SMTP id t5mr8901541vcj.18.1387214065632; Mon, 16 Dec 2013 09:14:25 -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 u4csp4432vcz; Mon, 16 Dec 2013 09:14:25 -0800 (PST) X-Received: by 10.180.78.165 with SMTP id c5mr14942587wix.3.1387214064533; Mon, 16 Dec 2013 09:14:24 -0800 (PST) Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com [74.125.82.52]) by mx.google.com with ESMTPS id fv3si5398019wjb.114.2013.12.16.09.14.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:14:24 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.52 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.52; Received: by mail-wg0-f52.google.com with SMTP id x13so4942389wgg.7 for ; Mon, 16 Dec 2013 09:14:24 -0800 (PST) X-Received: by 10.180.211.71 with SMTP id na7mr14692917wic.5.1387214063890; Mon, 16 Dec 2013 09:14:23 -0800 (PST) Received: from [192.168.0.2] (cpc8-cmbg15-2-0-cust169.5-4.cable.virginm.net. [86.30.140.170]) by mx.google.com with ESMTPSA id cx3sm44635850wib.0.2013.12.16.09.14.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:14:23 -0800 (PST) Message-ID: <52AF34ED.6070307@linaro.org> Date: Mon, 16 Dec 2013 17:14:21 +0000 From: Julien Grall User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Ian Campbell CC: Tim Deegan , xen-devel@lists.xenproject.org, patches@linaro.org, stefano.stabellini@citrix.com, Jan Beulich , Keir Fraser Subject: Re: [PATCH v4 08/11] xen/arm: Handle remove foreign mapping References: <1386963461-6520-1-git-send-email-julien.grall@linaro.org> <1386963461-6520-9-git-send-email-julien.grall@linaro.org> <20131216115131.GB35881@deinos.phlegethon.org> <52AF1D6E.7080402@linaro.org> <1387208403.21086.12.camel@kazak.uk.xensource.com> <52AF29C3.1030700@linaro.org> <1387211584.21086.27.camel@kazak.uk.xensource.com> In-Reply-To: <1387211584.21086.27.camel@kazak.uk.xensource.com> 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.171 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: , Here a new version of this patch. If needed I can resend the whole patch series. commit aa505db91a90bf00b216a5368b3721fdda02e437 Author: Julien Grall Date: Fri Dec 13 16:51:03 2013 +0000 xen/arm: Handle remove foreign mapping 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 --- 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 diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 39d8a03..f7bd7e2 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;