Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp611085pxa; Fri, 21 Aug 2020 16:15:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKtkL977MOw/p3FxGz4/A92DKMqIxramdkLVd8kINpjdEwYfH5QD+A08MsCMt8qZv9I5DB X-Received: by 2002:a17:906:5812:: with SMTP id m18mr5207812ejq.66.1598051742885; Fri, 21 Aug 2020 16:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598051742; cv=none; d=google.com; s=arc-20160816; b=lzGVmYEo45IzqQefdM7Hzid9RMZ7TiCUg8XSjsiz9y89GXZl/jIL+koYWXvOZb8J5l XuyNrP45X2oxabifP833g1qLHRX9B96QhvEgrzKQfd0SHJQHhUxP0euixM8BrGiLed7P pQ27NBaZ5/qFLNJLQcbkxeFDIm96JKc6PkzSjaqhIXCZDjyuOipTMoaeZTExIZtcD6nd PPyGL9cq3JN+2Lhfe0tX8fl+A6RJAS9XHMIKQhKchxVwK79lyBUQq76K3Y7sWHdnnzs0 /EVPvdfHg3APXjBN+jIE28wXmzb0b34Cg7ot6QXiYgcw8zPTm5zCFZs963iKDoOdhm9c ZZGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=m7RfewVLa8YXRGQn+dkSgkj1/tUR4KO62lCzO2eGme0=; b=0mdyjdUDnmXbIs3SkR0ZzT7h/S8UxitTl2PBp4jZ2fKjK+T9aOmT3CNrJ0Wu4JYrRN gBan2KNzOXnJgsTu6wMdd1vZ3FmzbSc3yFO4uqJueJx9/MajV/4nZf4cB5hFlxeJCbPl 7d+cf6cbuI7p9n0MfuM8oyMmU2JR181CMP2VAFMb9cPCikREA5zeVlEwJICw/l0ylbOc YQ3K08lSMigCLddjBpCmMbEmoNGMN9o7GeqKb/vtVpU81qnJ/0HeKMWhZCAPLWn2l6n2 JgW8wxzAhIFVudqIYDtcKL90v2Gj1dLUEqYkUT8OErOhSYy/PBb75R2pMlMSSRJCw1xq HAqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=SFkFEtDP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id se5si1973291ejb.744.2020.08.21.16.15.19; Fri, 21 Aug 2020 16:15:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=SFkFEtDP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbgHUXN2 (ORCPT + 99 others); Fri, 21 Aug 2020 19:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbgHUXN0 (ORCPT ); Fri, 21 Aug 2020 19:13:26 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC5BFC061573 for ; Fri, 21 Aug 2020 16:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=m7RfewVLa8YXRGQn+dkSgkj1/tUR4KO62lCzO2eGme0=; b=SFkFEtDPiTOFzC89MGpp0n9oGq mJvgsCKzGl00eAbqTVPpCyy9au4WCddYjJOixeUC+1Xel6PuGHY1pR/ZIXWe33lmrO8H1Wch+M9RM zHv9docnzihGwCvRHsI+QtWENI+YggQ4IWqycwtf+wi98kPeh904P/VHs3U0oxrRnzMUJKY9oUH+G /cVyZZ0zxgBPKkDSTrh9+aF2KQIiSMqxmJm9p6hvFc5cksZHMd6aC/+8l7fMFF99yfm7fyyY12/rT Ic6h5dclFxSdjl7FPnjlVO8Z7eXP9zwLji6+dcYrk/ybR+nCImqgNlNlv18vJPJCum8jJd6uMbK58 SLF8VZ6A==; Received: from [2601:1c0:6280:3f0::19c2] by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k9GDr-0001Qs-1n; Fri, 21 Aug 2020 23:13:23 +0000 Subject: Re: [PATCH] vdpa/mlx5: Avoid warnings about shifts on 32-bit platforms To: Nathan Chancellor , "Michael S. Tsirkin" , Jason Wang , Eli Cohen Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <20200821225018.940798-1-natechancellor@gmail.com> From: Randy Dunlap Message-ID: <1975c0a0-c19a-c91e-dc10-2918061cc4e7@infradead.org> Date: Fri, 21 Aug 2020 16:13:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200821225018.940798-1-natechancellor@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/21/20 3:50 PM, Nathan Chancellor wrote: > Clang warns several times when building for 32-bit ARM along the lines > of: > > drivers/vdpa/mlx5/net/mlx5_vnet.c:1462:31: warning: shift count >= width > of type [-Wshift-count-overflow] > ndev->mvdev.mlx_features |= BIT(VIRTIO_F_VERSION_1); > ^~~~~~~~~~~~~~~~~~~~~~~ > > This is related to the BIT macro, which uses an unsigned long literal, > which is 32-bit on ARM so having a shift equal to or larger than 32 will > cause this warning, such as the above, where VIRTIO_F_VERSION_1 is 32. > To avoid this, use BIT_ULL, which will be an unsigned long long. This > matches the size of the features field throughout this driver, which is > u64 so there should be no functional change. > > Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices") > Link: https://github.com/ClangBuiltLinux/linux/issues/1140 > Signed-off-by: Nathan Chancellor Reported-by: Randy Dunlap on 2020-AUG-10 for i386: https://lore.kernel.org/linux-next/5a7a0e6d-842a-78f6-aeac-c5b4c27b7186@infradead.org/ :( Acked-by: Randy Dunlap # build-tested Thanks. > --- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 50 +++++++++++++++---------------- > 1 file changed, 25 insertions(+), 25 deletions(-) > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index 9df69d5efe8c..70676a6d1691 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -16,19 +16,19 @@ > #define to_mvdev(__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev) > > #define VALID_FEATURES_MASK \ > - (BIT(VIRTIO_NET_F_CSUM) | BIT(VIRTIO_NET_F_GUEST_CSUM) | \ > - BIT(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT(VIRTIO_NET_F_MTU) | BIT(VIRTIO_NET_F_MAC) | \ > - BIT(VIRTIO_NET_F_GUEST_TSO4) | BIT(VIRTIO_NET_F_GUEST_TSO6) | \ > - BIT(VIRTIO_NET_F_GUEST_ECN) | BIT(VIRTIO_NET_F_GUEST_UFO) | BIT(VIRTIO_NET_F_HOST_TSO4) | \ > - BIT(VIRTIO_NET_F_HOST_TSO6) | BIT(VIRTIO_NET_F_HOST_ECN) | BIT(VIRTIO_NET_F_HOST_UFO) | \ > - BIT(VIRTIO_NET_F_MRG_RXBUF) | BIT(VIRTIO_NET_F_STATUS) | BIT(VIRTIO_NET_F_CTRL_VQ) | \ > - BIT(VIRTIO_NET_F_CTRL_RX) | BIT(VIRTIO_NET_F_CTRL_VLAN) | \ > - BIT(VIRTIO_NET_F_CTRL_RX_EXTRA) | BIT(VIRTIO_NET_F_GUEST_ANNOUNCE) | \ > - BIT(VIRTIO_NET_F_MQ) | BIT(VIRTIO_NET_F_CTRL_MAC_ADDR) | BIT(VIRTIO_NET_F_HASH_REPORT) | \ > - BIT(VIRTIO_NET_F_RSS) | BIT(VIRTIO_NET_F_RSC_EXT) | BIT(VIRTIO_NET_F_STANDBY) | \ > - BIT(VIRTIO_NET_F_SPEED_DUPLEX) | BIT(VIRTIO_F_NOTIFY_ON_EMPTY) | \ > - BIT(VIRTIO_F_ANY_LAYOUT) | BIT(VIRTIO_F_VERSION_1) | BIT(VIRTIO_F_ACCESS_PLATFORM) | \ > - BIT(VIRTIO_F_RING_PACKED) | BIT(VIRTIO_F_ORDER_PLATFORM) | BIT(VIRTIO_F_SR_IOV)) > + (BIT_ULL(VIRTIO_NET_F_CSUM) | BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) | \ > + BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT_ULL(VIRTIO_NET_F_MTU) | BIT_ULL(VIRTIO_NET_F_MAC) | \ > + BIT_ULL(VIRTIO_NET_F_GUEST_TSO4) | BIT_ULL(VIRTIO_NET_F_GUEST_TSO6) | \ > + BIT_ULL(VIRTIO_NET_F_GUEST_ECN) | BIT_ULL(VIRTIO_NET_F_GUEST_UFO) | BIT_ULL(VIRTIO_NET_F_HOST_TSO4) | \ > + BIT_ULL(VIRTIO_NET_F_HOST_TSO6) | BIT_ULL(VIRTIO_NET_F_HOST_ECN) | BIT_ULL(VIRTIO_NET_F_HOST_UFO) | \ > + BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) | BIT_ULL(VIRTIO_NET_F_STATUS) | BIT_ULL(VIRTIO_NET_F_CTRL_VQ) | \ > + BIT_ULL(VIRTIO_NET_F_CTRL_RX) | BIT_ULL(VIRTIO_NET_F_CTRL_VLAN) | \ > + BIT_ULL(VIRTIO_NET_F_CTRL_RX_EXTRA) | BIT_ULL(VIRTIO_NET_F_GUEST_ANNOUNCE) | \ > + BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) | BIT_ULL(VIRTIO_NET_F_HASH_REPORT) | \ > + BIT_ULL(VIRTIO_NET_F_RSS) | BIT_ULL(VIRTIO_NET_F_RSC_EXT) | BIT_ULL(VIRTIO_NET_F_STANDBY) | \ > + BIT_ULL(VIRTIO_NET_F_SPEED_DUPLEX) | BIT_ULL(VIRTIO_F_NOTIFY_ON_EMPTY) | \ > + BIT_ULL(VIRTIO_F_ANY_LAYOUT) | BIT_ULL(VIRTIO_F_VERSION_1) | BIT_ULL(VIRTIO_F_ACCESS_PLATFORM) | \ > + BIT_ULL(VIRTIO_F_RING_PACKED) | BIT_ULL(VIRTIO_F_ORDER_PLATFORM) | BIT_ULL(VIRTIO_F_SR_IOV)) > > #define VALID_STATUS_MASK \ > (VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK | \ > @@ -149,7 +149,7 @@ static bool mlx5_vdpa_debug; > > #define MLX5_LOG_VIO_FLAG(_feature) \ > do { \ > - if (features & BIT(_feature)) \ > + if (features & BIT_ULL(_feature)) \ > mlx5_vdpa_info(mvdev, "%s\n", #_feature); \ > } while (0) > > @@ -750,10 +750,10 @@ static bool vq_is_tx(u16 idx) > > static u16 get_features_12_3(u64 features) > { > - return (!!(features & BIT(VIRTIO_NET_F_HOST_TSO4)) << 9) | > - (!!(features & BIT(VIRTIO_NET_F_HOST_TSO6)) << 8) | > - (!!(features & BIT(VIRTIO_NET_F_CSUM)) << 7) | > - (!!(features & BIT(VIRTIO_NET_F_GUEST_CSUM)) << 6); > + return (!!(features & BIT_ULL(VIRTIO_NET_F_HOST_TSO4)) << 9) | > + (!!(features & BIT_ULL(VIRTIO_NET_F_HOST_TSO6)) << 8) | > + (!!(features & BIT_ULL(VIRTIO_NET_F_CSUM)) << 7) | > + (!!(features & BIT_ULL(VIRTIO_NET_F_GUEST_CSUM)) << 6); > } > > static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq) > @@ -1439,13 +1439,13 @@ static u64 mlx_to_vritio_features(u16 dev_features) > u64 result = 0; > > if (dev_features & MLX5_VIRTIO_NET_F_GUEST_CSUM) > - result |= BIT(VIRTIO_NET_F_GUEST_CSUM); > + result |= BIT_ULL(VIRTIO_NET_F_GUEST_CSUM); > if (dev_features & MLX5_VIRTIO_NET_F_CSUM) > - result |= BIT(VIRTIO_NET_F_CSUM); > + result |= BIT_ULL(VIRTIO_NET_F_CSUM); > if (dev_features & MLX5_VIRTIO_NET_F_HOST_TSO6) > - result |= BIT(VIRTIO_NET_F_HOST_TSO6); > + result |= BIT_ULL(VIRTIO_NET_F_HOST_TSO6); > if (dev_features & MLX5_VIRTIO_NET_F_HOST_TSO4) > - result |= BIT(VIRTIO_NET_F_HOST_TSO4); > + result |= BIT_ULL(VIRTIO_NET_F_HOST_TSO4); > > return result; > } > @@ -1459,15 +1459,15 @@ static u64 mlx5_vdpa_get_features(struct vdpa_device *vdev) > dev_features = MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, device_features_bits_mask); > ndev->mvdev.mlx_features = mlx_to_vritio_features(dev_features); > if (MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, virtio_version_1_0)) > - ndev->mvdev.mlx_features |= BIT(VIRTIO_F_VERSION_1); > - ndev->mvdev.mlx_features |= BIT(VIRTIO_F_ACCESS_PLATFORM); > + ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_VERSION_1); > + ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_ACCESS_PLATFORM); > print_features(mvdev, ndev->mvdev.mlx_features, false); > return ndev->mvdev.mlx_features; > } > > static int verify_min_features(struct mlx5_vdpa_dev *mvdev, u64 features) > { > - if (!(features & BIT(VIRTIO_F_ACCESS_PLATFORM))) > + if (!(features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM))) > return -EOPNOTSUPP; > > return 0; > > base-commit: 8a7c3213db068135e816a6a517157de6443290d6 > -- ~Randy