From patchwork Mon Jun 20 13:37:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9187429 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 A17256075E for ; Mon, 20 Jun 2016 13:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CF7A25221 for ; Mon, 20 Jun 2016 13:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 814852766D; Mon, 20 Jun 2016 13:39:59 +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 F280625221 for ; Mon, 20 Jun 2016 13:39:58 +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 1bEzP1-0005Xr-Pq; Mon, 20 Jun 2016 13:38:11 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEzP0-0005XI-5h for xen-devel@lists.xen.org; Mon, 20 Jun 2016 13:38:10 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id 47/3F-12849-1C1F7675; Mon, 20 Jun 2016 13:38:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTffAx/R wg8OrTSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ox95/YyFhziqWjePoe1gXEvVxcjF4eQwCZG idUfp7N0MXICOacZJeb9VgCx2QQ0Je58/sQEYosISEtc+3yZEcRmFrjEJPFxCi+ILSwQJfHp3 zFWEJtFQFVi6aer7CA2r4CLROecfWD1EgJyEiePTQar4RRwlTj47Ac7xC4Xif5fu5gmMHIvYG RYxahenFpUllqka6GXVJSZnlGSm5iZo2toaKKXm1pcnJiempOYVKyXnJ+7iRHoXQYg2MG4cZL zIUZJDiYlUd7pT9LDhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnw8rwBygkWpaanVqRl5gDDDCYt wcGjJMIbBJLmLS5IzC3OTIdInWJUlBLnPfQaKCEAksgozYNrg4X2JUZZKWFeRqBDhHgKUotyM 0tQ5V8xinMwKgnzSoKM58nMK4Gb/gpoMRPQ4mX9YItLEhFSUg2MKbVXfswq9TnexWO04g/LSY XMVZE8zc9YF59oqtHgT7jz1OmTSNd6d65Viiv7mEJLtKdnO6VX1hlYXi1cJCshfzW433jms/U 3zv3acP0+r4b9no9LhaJ9D6pdlvEOzBATMPbmlqyeJN4eV/ozcdX//NnpfC0LI/53SzL+8fjF aD1lShL3Xl4lluKMREMt5qLiRAD3lBzGaAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1466429888!40212309!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18492 invoked from network); 20 Jun 2016 13:38:08 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-27.messagelabs.com with SMTP; 20 Jun 2016 13:38:08 -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 2F802BA8; Mon, 20 Jun 2016 06:38:23 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3914B3F246; Mon, 20 Jun 2016 06:37:36 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 20 Jun 2016 14:37:19 +0100 Message-Id: <1466429845-28240-3-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466429845-28240-1-git-send-email-julien.grall@arm.com> References: <1466429845-28240-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 2/8] xen/mm: Introduce a bunch of helpers for the typesafes mfn and gfn 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 Those helpers will be useful to do common operations without having to unbox/box manually the GFNs/MFNs. Signed-off-by: Julien Grall Acked-by: Jan Beulich --- Cc: Stefano Stabellini Cc: Jan Beulich Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Konrad Rzeszutek Wilk Cc: Tim Deegan Cc: Wei Liu Changes in v2: - Rename min_gfn/max_gfn to gfn_min/gfn_max - Add more helpers for gfn and mfn --- xen/include/xen/mm.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 3cf646a..58b5c75 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -61,6 +61,11 @@ TYPE_SAFE(unsigned long, mfn); #undef mfn_t #endif +#define mfn_add(mfn, i) _mfn(mfn_x(mfn) + (i)) +#define mfn_max(x, y) _mfn(max(mfn_x(x), mfn_x(y))) +#define mfn_min(x, y) _mfn(min(mfn_x(x), mfn_x(y))) +#define mfn_eq(x, y) (mfn_x(x) == mfn_x(y)) + TYPE_SAFE(unsigned long, gfn); #define PRI_gfn "05lx" #define INVALID_GFN (~0UL) @@ -70,6 +75,11 @@ TYPE_SAFE(unsigned long, gfn); #undef gfn_t #endif +#define gfn_add(gfn, i) _gfn(gfn_x(gfn) + (i)) +#define gfn_max(x, y) _gfn(max(gfn_x(x), gfn_x(y))) +#define gfn_min(x, y) _gfn(min(gfn_x(x), gfn_x(y))) +#define gfn_eq(x, y) (gfn_x(x) == gfn_x(y)) + TYPE_SAFE(unsigned long, pfn); #define PRI_pfn "05lx" #define INVALID_PFN (~0UL)