From patchwork Tue Sep 12 10:03:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9948883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2FEC260360 for ; Tue, 12 Sep 2017 10:06:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CB0228ECB for ; Tue, 12 Sep 2017 10:06:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F2EB28ED3; Tue, 12 Sep 2017 10:06:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7879028ECC for ; Tue, 12 Sep 2017 10:06:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dri2g-0002nR-NI; Tue, 12 Sep 2017 10:03:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dri2f-0002n5-3s for xen-devel@lists.xen.org; Tue, 12 Sep 2017 10:03:41 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id 29/C3-03423-CF0B7B95; Tue, 12 Sep 2017 10:03:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTff3hu2 RBn/Wmlos+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmHr71mKbjJWfG0qYepgXElRxcjF4eQwGZG iYOPHzFBOKcZJaaeP8jSxcjJwSagKXHn8ycmEFtEQFri2ufLjCA2s8ByRonFu9O6GDk4hAX8J NZ/YQMxWQRUJW4uFgKp4BWwkFg0Yx4ziC0hIC+xq+0iK4jNKWApseLjLzYQWwio5vvLH4wTGL kXMDKsYtQoTi0qSy3SNTLQSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQI9C4DEOx g/LUs4BCjJAeTkijvkfXbI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8LIDg0VIsCg1PbUiLTMH GGYwaQkOHiURXiGQNG9xQWJucWY6ROoUoy5Hx827f5iEWPLy81KlxHkzQOYLgBRllObBjYCF/ CVGWSlhXkago4R4ClKLcjNLUOVfMYpzMCoJ894BmcKTmVcCt+kV0BFMQEfwXNoCckRJIkJKqo GRxzJueSpvr9D++V7hurG28iem6bTYNC22uZDMUPJZXut24v5EaQfLiY+EojYxnuNpz2kxZ4z Kqv+6qU8sNUfbfc15kefP/PRjgg+y11l85zfbyh9S2Pax6OH9E5euhlQ0rRG2epLca7+y5fkm h03sq3J9HTlvCltFBf/gz99lrZfx3mXxISWW4oxEQy3mouJEAL2PQwZ0AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1505210619!115519550!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36255 invoked from network); 12 Sep 2017 10:03:39 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-27.messagelabs.com with SMTP; 12 Sep 2017 10:03:39 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C63E15A2; Tue, 12 Sep 2017 03:03:39 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EB3F33F578; Tue, 12 Sep 2017 03:03:37 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Sep 2017 11:03:07 +0100 Message-Id: <20170912100330.2168-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170912100330.2168-1-julien.grall@arm.com> References: <20170912100330.2168-1-julien.grall@arm.com> Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v2 01/24] xen/x86: mm: Introduce {G, M}FN <-> {G, M}ADDR helpers X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The new wrappers will add more safety when converting an address to a frame number (either machine or guest). They are already existing for Arm and could be useful in common code. Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper Reviewed-by: Wei Liu --- Changes in v2: - Implement it in arch specific rather than in common code. Hence rename the patch. Cc: Andrew Cooper Cc: Jan Beulich --- xen/include/asm-x86/page.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index cde5c6b89b..45ca742678 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -250,6 +250,10 @@ void copy_page_sse2(void *, const void *); /* Convert between frame number and address formats. */ #define __pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT) #define __paddr_to_pfn(pa) ((unsigned long)((pa) >> PAGE_SHIFT)) +#define gfn_to_gaddr(gfn) __pfn_to_paddr(gfn_x(gfn)) +#define gaddr_to_gfn(ga) _gfn(__paddr_to_pfn(ga)) +#define mfn_to_maddr(mfn) __pfn_to_paddr(mfn_x(mfn)) +#define maddr_to_mfn(ma) _mfn(__paddr_to_pfn(ma)) /* * We define non-underscored wrappers for above conversion functions. These are