* [PATCH] drivers: hv: vmbus: Fix build on GCC 11 failed by DMA_BIT_MASK(64) expansion
@ 2022-02-04 0:57 Vitaly Chikunov
2022-02-04 1:48 ` Michael Kelley (LINUX)
0 siblings, 1 reply; 4+ messages in thread
From: Vitaly Chikunov @ 2022-02-04 0:57 UTC (permalink / raw)
To: linux-hyperv, K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger,
Wei Liu, Dexuan Cui
Cc: Vitaly Chikunov, Tianyu Lan, Michael Kelley, Long Li
GCC 11.2.1 cannot understand that value 64 is excluded from the shift
at compile time resulting in build error[1]:
drivers/hv/vmbus_drv.c:2082:29: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
^~~~~~~~~~~~~~~~
./include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
^ ~~~
Avoid using DMA_BIT_MASK macro for that corner case.
Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>
Cc: Michael Kelley <mikelley@microsoft.com>
Cc: Long Li <longli@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>
Link: https://lore.kernel.org/linux-hyperv/20220203235828.hcsj6najsl7yxmxa@altlinux.org/
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
---
drivers/hv/vmbus_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 17bf55fe3169..2376ee484362 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -2079,7 +2079,7 @@ struct hv_device *vmbus_device_create(const guid_t *type,
return child_device_obj;
}
-static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
+static u64 vmbus_dma_mask = ~0ULL;
/*
* vmbus_device_register - Register the child device
*/
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] drivers: hv: vmbus: Fix build on GCC 11 failed by DMA_BIT_MASK(64) expansion
2022-02-04 0:57 [PATCH] drivers: hv: vmbus: Fix build on GCC 11 failed by DMA_BIT_MASK(64) expansion Vitaly Chikunov
@ 2022-02-04 1:48 ` Michael Kelley (LINUX)
2022-02-04 1:54 ` Vitaly Chikunov
2022-02-04 2:03 ` Vitaly Chikunov
0 siblings, 2 replies; 4+ messages in thread
From: Michael Kelley (LINUX) @ 2022-02-04 1:48 UTC (permalink / raw)
To: Vitaly Chikunov, linux-hyperv@vger.kernel.org, KY Srinivasan,
Haiyang Zhang, Stephen Hemminger, Wei Liu, Dexuan Cui
Cc: Tianyu Lan, Long Li
From: Vitaly Chikunov <vt@altlinux.org> Sent: Thursday, February 3, 2022 4:58 PM
>
> GCC 11.2.1 cannot understand that value 64 is excluded from the shift
> at compile time resulting in build error[1]:
>
> drivers/hv/vmbus_drv.c:2082:29: error: shift count >= width of type [-Werror,-
> Wshift-count-overflow]
> static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
> ^~~~~~~~~~~~~~~~
> ./include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
> #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
> ^ ~~~
>
> Avoid using DMA_BIT_MASK macro for that corner case.
If we need a temporary hack to solve the build problem, I can live with
that. But I see 230 other places in kernel code where DMA_BIT_MASK(64)
is used, so I'm wondering if this particular hack is effective. We need a
more comprehensive solution that fixes the definition of
DMA_BIT_MASK() so it will work with a constant '64' as the parameter.
Michael
>
> Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>
> Cc: Michael Kelley <mikelley@microsoft.com>
> Cc: Long Li <longli@microsoft.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Link: https://lore.kernel.org/linux-hyperv/20220203235828.hcsj6najsl7yxmxa@altlinux.org/
> Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
> ---
> drivers/hv/vmbus_drv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 17bf55fe3169..2376ee484362 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -2079,7 +2079,7 @@ struct hv_device *vmbus_device_create(const guid_t *type,
> return child_device_obj;
> }
>
> -static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
> +static u64 vmbus_dma_mask = ~0ULL;
> /*
> * vmbus_device_register - Register the child device
> */
> --
> 2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: hv: vmbus: Fix build on GCC 11 failed by DMA_BIT_MASK(64) expansion
2022-02-04 1:48 ` Michael Kelley (LINUX)
@ 2022-02-04 1:54 ` Vitaly Chikunov
2022-02-04 2:03 ` Vitaly Chikunov
1 sibling, 0 replies; 4+ messages in thread
From: Vitaly Chikunov @ 2022-02-04 1:54 UTC (permalink / raw)
To: Michael Kelley (LINUX)
Cc: linux-hyperv@vger.kernel.org, KY Srinivasan, Haiyang Zhang,
Stephen Hemminger, Wei Liu, Dexuan Cui, Tianyu Lan, Long Li,
Dmitry V. Levin
Michael,
On Fri, Feb 04, 2022 at 01:48:32AM +0000, Michael Kelley (LINUX) wrote:
> From: Vitaly Chikunov <vt@altlinux.org> Sent: Thursday, February 3, 2022 4:58 PM
> >
> > GCC 11.2.1 cannot understand that value 64 is excluded from the shift
> > at compile time resulting in build error[1]:
> >
> > drivers/hv/vmbus_drv.c:2082:29: error: shift count >= width of type [-Werror,-
> > Wshift-count-overflow]
> > static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
> > ^~~~~~~~~~~~~~~~
> > ./include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
> > #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
> > ^ ~~~
> >
> > Avoid using DMA_BIT_MASK macro for that corner case.
>
> If we need a temporary hack to solve the build problem, I can live with
> that. But I see 230 other places in kernel code where DMA_BIT_MASK(64)
> is used, so I'm wondering if this particular hack is effective. We need a
> more comprehensive solution that fixes the definition of
> DMA_BIT_MASK() so it will work with a constant '64' as the parameter.
All other places seems to be inside of functions which, perhaps,
triggers different GCC logic. And only vmbus use is in global and static
context.
There is nothing to fix in DMA_BIT_MASK definition, because it's valid.
At least, I don't see other solutions.
Thanks,
>
> Michael
>
> >
> > Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>
> > Cc: Michael Kelley <mikelley@microsoft.com>
> > Cc: Long Li <longli@microsoft.com>
> > Cc: Wei Liu <wei.liu@kernel.org>
> > Link: https://lore.kernel.org/linux-hyperv/20220203235828.hcsj6najsl7yxmxa@altlinux.org/
> > Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
> > ---
> > drivers/hv/vmbus_drv.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index 17bf55fe3169..2376ee484362 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -2079,7 +2079,7 @@ struct hv_device *vmbus_device_create(const guid_t *type,
> > return child_device_obj;
> > }
> >
> > -static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
> > +static u64 vmbus_dma_mask = ~0ULL;
> > /*
> > * vmbus_device_register - Register the child device
> > */
> > --
> > 2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers: hv: vmbus: Fix build on GCC 11 failed by DMA_BIT_MASK(64) expansion
2022-02-04 1:48 ` Michael Kelley (LINUX)
2022-02-04 1:54 ` Vitaly Chikunov
@ 2022-02-04 2:03 ` Vitaly Chikunov
1 sibling, 0 replies; 4+ messages in thread
From: Vitaly Chikunov @ 2022-02-04 2:03 UTC (permalink / raw)
To: Michael Kelley (LINUX)
Cc: linux-hyperv@vger.kernel.org, KY Srinivasan, Haiyang Zhang,
Stephen Hemminger, Wei Liu, Dexuan Cui, Tianyu Lan, Long Li,
Dmitry V. Levin
Michael,
On Fri, Feb 04, 2022 at 01:48:32AM +0000, Michael Kelley (LINUX) wrote:
> From: Vitaly Chikunov <vt@altlinux.org> Sent: Thursday, February 3, 2022 4:58 PM
> >
> > GCC 11.2.1 cannot understand that value 64 is excluded from the shift
> > at compile time resulting in build error[1]:
> >
> > drivers/hv/vmbus_drv.c:2082:29: error: shift count >= width of type [-Werror,-
> > Wshift-count-overflow]
> > static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
> > ^~~~~~~~~~~~~~~~
> > ./include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
> > #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
> > ^ ~~~
> >
> > Avoid using DMA_BIT_MASK macro for that corner case.
>
> If we need a temporary hack to solve the build problem, I can live with
> that. But I see 230 other places in kernel code where DMA_BIT_MASK(64)
> is used, so I'm wondering if this particular hack is effective. We need a
> more comprehensive solution that fixes the definition of
> DMA_BIT_MASK() so it will work with a constant '64' as the parameter.
Ah, I suddenly realised that this build was using Clang 12.0.1, not GCC
11. So my patch description is wrong!
Thanks,
>
> Michael
>
> >
> > Cc: Tianyu Lan <Tianyu.Lan@microsoft.com>
> > Cc: Michael Kelley <mikelley@microsoft.com>
> > Cc: Long Li <longli@microsoft.com>
> > Cc: Wei Liu <wei.liu@kernel.org>
> > Link: https://lore.kernel.org/linux-hyperv/20220203235828.hcsj6najsl7yxmxa@altlinux.org/
> > Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
> > ---
> > drivers/hv/vmbus_drv.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index 17bf55fe3169..2376ee484362 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -2079,7 +2079,7 @@ struct hv_device *vmbus_device_create(const guid_t *type,
> > return child_device_obj;
> > }
> >
> > -static u64 vmbus_dma_mask = DMA_BIT_MASK(64);
> > +static u64 vmbus_dma_mask = ~0ULL;
> > /*
> > * vmbus_device_register - Register the child device
> > */
> > --
> > 2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-04 2:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-04 0:57 [PATCH] drivers: hv: vmbus: Fix build on GCC 11 failed by DMA_BIT_MASK(64) expansion Vitaly Chikunov
2022-02-04 1:48 ` Michael Kelley (LINUX)
2022-02-04 1:54 ` Vitaly Chikunov
2022-02-04 2:03 ` Vitaly Chikunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox