Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wshift-count-overflow in drivers/vdpa/mlx5/net/mlx5_vnet.c #1140

Closed
nathanchance opened this issue Aug 21, 2020 · 1 comment
Closed

-Wshift-count-overflow in drivers/vdpa/mlx5/net/mlx5_vnet.c #1140

nathanchance opened this issue Aug 21, 2020 · 1 comment
Assignees
Labels
-Wshift-count-overflow [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.9 This bug was fixed in Linux 5.9

Comments

@nathanchance
Copy link
Member

Several instances along the lines of:

drivers/vdpa/mlx5/net/mlx5_vnet.c:187:18: warning: shift count >= width of type [-Wshift-count-overflow]
        if (features & ~VALID_FEATURES_MASK)
                        ^~~~~~~~~~~~~~~~~~~
drivers/vdpa/mlx5/net/mlx5_vnet.c:27:60: note: expanded from macro 'VALID_FEATURES_MASK'
         BIT(VIRTIO_NET_F_MQ) | BIT(VIRTIO_NET_F_CTRL_MAC_ADDR) | BIT(VIRTIO_NET_F_HASH_REPORT) |  \
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/vdso/bits.h:7:26: note: expanded from macro 'BIT'
#define BIT(nr)                 (UL(1) << (nr))
                                       ^  ~~~~

Patch submitted: https://lore.kernel.org/r/20200821225018.940798-1-natechancellor@gmail.com

@nathanchance nathanchance added [BUG] linux A bug that should be fixed in the mainline kernel. [PATCH] Submitted A patch has been submitted for review -Wshift-count-overflow labels Aug 21, 2020
@nathanchance nathanchance self-assigned this Aug 21, 2020
fengguang pushed a commit to 0day-ci/linux that referenced this issue Aug 21, 2020
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: 1a86b37 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Link: ClangBuiltLinux#1140
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
torvalds pushed a commit to torvalds/linux that referenced this issue Aug 26, 2020
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: 1a86b37 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Link: ClangBuiltLinux#1140
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Link: https://lore.kernel.org/r/20200821225018.940798-1-natechancellor@gmail.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Acked-by: Eli Cohen <elic@nvidia.com>
@nathanchance
Copy link
Member Author

@nathanchance nathanchance added [FIXED][LINUX] 5.9 This bug was fixed in Linux 5.9 and removed [PATCH] Submitted A patch has been submitted for review labels Aug 26, 2020
gregmarsden pushed a commit to oracle/linux-uek that referenced this issue Dec 18, 2020
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: 1a86b37 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Link: ClangBuiltLinux/linux#1140
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Link: https://lore.kernel.org/r/20200821225018.940798-1-natechancellor@gmail.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Acked-by: Eli Cohen <elic@nvidia.com>
(cherry picked from commit cbb5235)

Conflicts:
	drivers/vdpa/mlx5/net/mlx5_vnet.c

Remove virtio feature bits that are absent from UEK:
  VIRTIO_NET_F_RSS
  VIRTIO_NET_F_RSC_EXT
  VIRTIO_NET_F_HASH_REPORT

Orabug: 32121107

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Qing Huang <qing.huang@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wshift-count-overflow [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.9 This bug was fixed in Linux 5.9
Projects
None yet
Development

No branches or pull requests

1 participant