From patchwork Fri Apr 22 15:58:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 66459 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp801348qge; Fri, 22 Apr 2016 08:59:59 -0700 (PDT) X-Received: by 10.55.52.11 with SMTP id b11mr25897964qka.64.1461340799842; Fri, 22 Apr 2016 08:59:59 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n84si3689261qke.161.2016.04.22.08.59.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2016 08:59:59 -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 1atdTf-00025v-Q5; Fri, 22 Apr 2016 15:58:43 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atdTe-00025i-QX for xen-devel@lists.xen.org; Fri, 22 Apr 2016 15:58:42 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 3A/D0-04060-23A4A175; Fri, 22 Apr 2016 15:58:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTdfQSyr cYFWTpsWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvGwq4Ox4DpXxb/Hq9kbGH9xdDFycQgJbGSU WHirjR3COQ3knG5g7WLk5GAT0JS48/kTE4gtIiAtce3zZUYQm1mgg1li1jWfLkYODmEBD4n3r wxAwiwCqhIfpx8CK+cVcJY4cmMNO4gtISAncfLYZLCRnAIuEnuuN4HVCAHVnP69i3ECI/cCRo ZVjOrFqUVlqUW6FnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIHeZQCCHYwX2p0 PMUpyMCmJ8n7WlAoX4kvKT6nMSCzOiC8qzUktPsQow8GhJMFr5gmUEyxKTU+tSMvMAYYZTFqC g0dJhFcMJM1bXJCYW5yZDpE6xagoJc5rB5IQAElklObBtcFC+xKjrJQwLyPQIUI8BalFuZklq PKvGMU5GJWEee94AE3hycwrgZv+CmgxE9DifxckQRaXJCKkpBoYZ5ZdM9guFuXwbk6/8tndH5 R/zf9Suf3exqSoBzfk4gRVyzgfTvtbcXtpuIq5zTLv6ee3RxdN2y0ceu5AWUnOwqO7mn5v8nK rlWKM8nnW6rR77SoBRUnNu2/tq4+7Hi2clKIVefxl0+Wlr+dPnKA4Q8V+6s8Wy1Ncb0+/sNya vfxFbucLhztzXymxFGckGmoxFxUnAgAzVcjpaAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1461340721!32544383!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.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28107 invoked from network); 22 Apr 2016 15:58:41 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-31.messagelabs.com with SMTP; 22 Apr 2016 15:58:41 -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 46C2049; Fri, 22 Apr 2016 08:57: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 0498B3F211; Fri, 22 Apr 2016 08:58:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 22 Apr 2016 16:58:32 +0100 Message-Id: <1461340713-9587-2-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461340713-9587-1-git-send-email-julien.grall@arm.com> References: <1461340713-9587-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, Keir Fraser , George Dunlap , andre.przywara@arm.com, Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Andrew Cooper , Wei Liu Subject: [Xen-devel] [for-4.7 v2 1/2] xen/bitops: Introduce GENMASK to generate mask 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 code has been imported from the header include/linux/bitops.h in Linux v4.6-rc3. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Keir Fraser Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu Changes in v2: - Remove GENMASK_ULL - Add Stefano's acked-by --- xen/include/xen/bitops.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index cb56f24..bd0883a 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -3,6 +3,14 @@ #include /* + * Create a contiguous bitmask starting at bit position @l and ending at + * position @h. For example + * GENMASK(30, 21) gives us the 32bit vector 0x01fe00000. + */ +#define GENMASK(h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +/* * ffs: find first bit set. This is defined the same way as * the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs).