From patchwork Thu Sep 26 09:46:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xia, Hongyan" X-Patchwork-Id: 11162219 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54A9C13BD for ; Thu, 26 Sep 2019 09:52:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3019A2053B for ; Thu, 26 Sep 2019 09:52:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="vAcER24b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3019A2053B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQRY-0003NE-0i; Thu, 26 Sep 2019 09:52:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iDQRW-0003LS-Ic for xen-devel@lists.xenproject.org; Thu, 26 Sep 2019 09:52:10 +0000 X-Inumbo-ID: 4dbf6b6e-e043-11e9-964d-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by localhost (Halon) with ESMTPS id 4dbf6b6e-e043-11e9-964d-12813bfff9fa; Thu, 26 Sep 2019 09:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1569491529; x=1601027529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=M4xZGI3sG3gLLgUNWWpn0VT0zlxORA27r6JiOSmnYMw=; b=vAcER24bNxWGPjW5stUr3nOfyK9GZNiyW/cGbJLopdCe4UUVanHWawcB /sD7/w38horWqfMuIzsIIHGAbNP5O3/4SpOzHIe8Yr0qidHvKg6sjhlct AGYp79+Ng4ytndq63X8G2mkti0MnFSDjyP1bPa8H6zEpq1smwLinTzGG0 0=; X-IronPort-AV: E=Sophos;i="5.64,551,1559520000"; d="scan'208";a="836989235" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1a-807d4a99.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 26 Sep 2019 09:50:09 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1a-807d4a99.us-east-1.amazon.com (Postfix) with ESMTPS id E64E4A02B6; Thu, 26 Sep 2019 09:49:55 +0000 (UTC) Received: from EX13D28EUC002.ant.amazon.com (10.43.164.254) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:39 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D28EUC002.ant.amazon.com (10.43.164.254) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 09:49:38 +0000 Received: from u9d785c4ba99158.ant.amazon.com (10.125.106.58) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 09:49:34 +0000 From: To: Date: Thu, 26 Sep 2019 10:46:36 +0100 Message-ID: <8f017ae92757547e7b3492357d305045cffb5650.1569489002.git.hongyax@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [RFC PATCH 73/84] x86/mm: Move vmap_to_mfn() to mm.c and rename to virt_to_mfn_walk(). X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Hongyan Xia , George Dunlap , Andrew Cooper , Konrad Rzeszutek Wilk , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Hongyan Xia Obviously, vmap_to_mfn is a generic mechanism to walk the page table to find the mfn, not vmap specific. Also the difference from virt_to_mfn() is that it actually walks the page table instead of relying on a direct map. Signed-off-by: Hongyan Xia --- xen/arch/x86/mm.c | 13 +++++++++++++ xen/common/vmap.c | 15 +-------------- xen/include/asm-x86/mm.h | 2 ++ xen/include/xen/vmap.h | 3 --- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index f30b5b3951..ab760ecc1f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -5056,6 +5056,19 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v) return pl1e; } +unsigned long virt_to_mfn_walk(void *va) +{ + l1_pgentry_t *pl1e = virt_to_xen_l1e((unsigned long)(va)); + unsigned long ret = l1e_get_pfn(*pl1e); + unmap_xen_pagetable(pl1e); + return ret; +} + +struct page_info *virt_to_page_walk(void *va) +{ + return mfn_to_page(_mfn(virt_to_mfn_walk(va))); +} + /* Convert to from superpage-mapping flags for map_pages_to_xen(). */ #define l1f_to_lNf(f) (((f) & _PAGE_PRESENT) ? ((f) | _PAGE_PSE) : (f)) #define lNf_to_l1f(f) (((f) & _PAGE_PRESENT) ? ((f) & ~_PAGE_PSE) : (f)) diff --git a/xen/common/vmap.c b/xen/common/vmap.c index fcdb8495c8..4323c6811f 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -19,19 +19,6 @@ static unsigned int __read_mostly vm_end[VMAP_REGION_NR]; /* lowest known clear bit in the bitmap */ static unsigned int vm_low[VMAP_REGION_NR]; -mfn_t vmap_to_mfn(void *va) -{ - l1_pgentry_t *pl1e = virt_to_xen_l1e((unsigned long)(va)); - mfn_t ret = _mfn(l1e_get_pfn(*pl1e)); - unmap_xen_pagetable(pl1e); - return ret; -} - -struct page_info *vmap_to_page(void *va) -{ - return mfn_to_page(vmap_to_mfn(va)); -} - void __init vm_init_type(enum vmap_region type, void *start, void *end) { unsigned int i, nr; @@ -332,7 +319,7 @@ void vfree(void *va) for ( i = 0; i < pages; i++ ) { - struct page_info *page = vmap_to_page(va + i * PAGE_SIZE); + struct page_info *page = virt_to_page_walk(va + i * PAGE_SIZE); ASSERT(page); page_list_add(page, &pg_list); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index a4b3c9b7af..76ba56bdc3 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -643,6 +643,8 @@ void free_xen_pagetable(mfn_t mfn); } while (0) l1_pgentry_t *virt_to_xen_l1e(unsigned long v); +unsigned long virt_to_mfn_walk(void *va); +struct page_info *virt_to_page_walk(void *va); DECLARE_PER_CPU(mfn_t, root_pgt_mfn); diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index 3d69727a9d..369560e620 100644 --- a/xen/include/xen/vmap.h +++ b/xen/include/xen/vmap.h @@ -23,9 +23,6 @@ void *vmalloc_xen(size_t size); void *vzalloc(size_t size); void vfree(void *va); -mfn_t vmap_to_mfn(void *va); -struct page_info *vmap_to_page(void *va); - void __iomem *ioremap(paddr_t, size_t); static inline void iounmap(void __iomem *va)