From patchwork Wed Apr 5 23:18:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9665869 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 3202360352 for ; Wed, 5 Apr 2017 23:22:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 245002816B for ; Wed, 5 Apr 2017 23:22:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1939428584; Wed, 5 Apr 2017 23:22:46 +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 C23CA2857E for ; Wed, 5 Apr 2017 23:22:44 +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 1cvuED-0004P8-Cs; Wed, 05 Apr 2017 23:20:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cvuEB-0004OP-Ba for xen-devel@lists.xenproject.org; Wed, 05 Apr 2017 23:20:39 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id E2/47-05091-6CB75E85; Wed, 05 Apr 2017 23:20:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTfdY9dM Ig00r2C2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oynK/axF3TzVEy49Z2lgXEiVxcjF4eQwCZG ienfnjNCOHsZJS69fsvWxcjJwSagK7Hj5mtmEFtEIFRizs9HQDYHB7NApUT3In6QsLCAoUTn3 EawEhYBVYl3zccZQWxeATeJxUd/gJVLCMhJXPmXABLmFHCXeNl6jAXEFgIquTZxKssERu4FjA yrGDWKU4vKUot0jYz0kooy0zNKchMzc3QNDYz1clOLixPTU3MSk4r1kvNzNzECvVvPwMC4g3H qCb9DjJIcTEqivAo+TyKE+JLyUyozEosz4otKc1KLDzHKcHAoSfDaVD2NEBIsSk1PrUjLzAGG GUxagoNHSYT3PUiat7ggMbc4Mx0idYpRUUqcVxckIQCSyCjNg2uDhfYlRlkpYV5GBgYGIZ6C1 KLczBJU+VeM4hyMSsK8MSBTeDLzSuCmvwJazAS0+MmdhyCLSxIRUlINjE5l+QFXi2585PY3Zz mn91L5mmXpTZlVebmVh2RKGGV+7nr+5/8B+50yK3g/J/XJfJXaFbjQXflUemXZcuc7SWc/TPn b8c6p/tTmq0ulvm77sG+e5KP6R5LFb3J23/nIwPfT88P/eUc/91moHgrmWh9sfMf0pshp6T1P 213E5okHLSy8Urn3aowSS3FGoqEWc1FxIgDplaV4aAIAAA== X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1491434437!86873200!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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24044 invoked from network); 5 Apr 2017 23:20:37 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-31.messagelabs.com with SMTP; 5 Apr 2017 23:20:37 -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 0F9FEB16; Wed, 5 Apr 2017 16:20:37 -0700 (PDT) Received: from slackpad.lan (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C3F273F4FF; Wed, 5 Apr 2017 16:20:35 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 6 Apr 2017 00:18:53 +0100 Message-Id: <1491434362-30310-2-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1491434362-30310-1-git-send-email-andre.przywara@arm.com> References: <1491434362-30310-1-git-send-email-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org, Shanker Donthineni , Vijay Kilari Subject: [Xen-devel] [PATCH v5 01/30] bitops: add GENMASK_ULL 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 To safely handle 64-bit registers even on 32-bit systems, introduce a GENMASK_ULL variant (lifted from Linux). This adds a BITS_PER_LONG_LONG define as well. Also fix a bug in the comment for the existing GENMASK variant. Signed-off-by: Andre Przywara Reviewed-by: Stefano Stabellini --- xen/include/asm-arm/config.h | 2 ++ xen/include/xen/bitops.h | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h index b2edf95..1f730ce 100644 --- a/xen/include/asm-arm/config.h +++ b/xen/include/asm-arm/config.h @@ -19,6 +19,8 @@ #define BITS_PER_LONG (BYTES_PER_LONG << 3) #define POINTER_ALIGN BYTES_PER_LONG +#define BITS_PER_LONG_LONG (sizeof (long long) * BITS_PER_BYTE) + /* xen_ulong_t is always 64 bits */ #define BITS_PER_XEN_ULONG 64 diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index bd0883a..9261e06 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -5,11 +5,14 @@ /* * 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. + * GENMASK(30, 21) gives us the 32bit vector 0x7fe00000. */ #define GENMASK(h, l) \ (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) +#define GENMASK_ULL(h, l) \ + (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + /* * ffs: find first bit set. This is defined the same way as * the libc and compiler builtin ffs routines, therefore