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: 112268 Delivered-To: patch@linaro.org Received: by 10.80.202.13 with SMTP id d13csp5674242edi; Tue, 12 Sep 2017 03:05:35 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBtr6bpdxTmP5RuF3F4lJ6GehjY6jK8m1Y9hnCiQrzmnWBQmgsxjO7rPF7D8dXfst8Mr3rg X-Received: by 10.107.151.81 with SMTP id z78mr20859707iod.157.1505210735088; Tue, 12 Sep 2017 03:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505210735; cv=none; d=google.com; s=arc-20160816; b=vTDpuWl8vlea4QN/ow3kUvkGWy67U8PoDa4hJzlkTtoqeWY7W2CdJbbWnTJ2DjWOOE L6auR5TrU3Q8mT+6H1lyIzJEwTcbxCVxp9DeUS4ETo3Zg2bIWNQ27kpKGen+YoVbYOg4 YbDUBYKOkWui6BCEHEBt/Ea40tlV/nG8lALTbuKKDgxIcZ4EEnm9VVztRopf4avzjoKP 3RHA1bvxrIXGF5EPGmqIfBTdlRBXZWo7qjYTScX3C6rjkZyQ/BVCACVcdcapwpQZgVvd GS5YxrQHPrUD06vy3xfMVwmbVXPvLz8E1CvVGfhcfSbqRjLk6RjHAWSGzA8g6FqgoQxN sryg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=N/Ied7LZhrKpic+wACZm7SjqYcHhj+C84/TDKnjhqro=; b=R4S/bHqBiXRLt3NUSlhF/qCUd1IT+kmEk06a39EE6JlPhrCXcfMKz1nE9XE+ASWmNj 7ydsUSu201580RYEOjqsw62YNKFa+bytaVfCvnCA17buSF2DzJn/0BUdgF6WWIw4BKYM BY0BzsMcEh32107nXRRKW83UWA23bFrF6MLJdvb9JfU4arbmP58uNFJU8wKIoU3Hf5BQ vYxFYa6s1KMAZwX0Fefv8VtAIKefcQWnkD92+tf+9UqPCPxElQQdrDgNfq0jY35szdCM iCazsGIv5ce4yF9GPnTspXKGmFJ3sKPXpFUvlCwxpfSI31ovKwgfHmRINd4d+rv48lca F7yg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w8si534243ite.79.2017.09.12.03.05.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 03:05:35 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org 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" 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