Skip to contentSkip to conversation

drivers: hv: vmbus: Fix build on GCC 11 failed by DMA_BIT_MASK(64) expansion

PATCH Superseded Vitaly Chikunov 2 participants 4 messages Feb 4, 2022

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: hv: vmbus: Fix build on GCC 11 failed by DMA_BIT_MASK(64) expansion

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.

---
 drivers/hv/vmbus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/vmbus_drv.c +1 -1
index 17bf55fe3169..2376ee484362 100644
@@ -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
  */
Signature · 1 line
2.33.0
#1 lore raw

From: Vitaly Chikunov <[email protected]> Sent: Thursday, February 3, 2022 4:58 PM

Quoted 6 lines

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]

Quoted 7 lines
  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

Quoted 26 lines
---
 drivers/hv/vmbus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/vmbus_drv.c +1 -2
index 17bf55fe3169..2376ee484362 100644
@@ -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

#2 lore raw

Michael,

Quoted 13 lines · Michael Kelley (LINUX)

From: Vitaly Chikunov <[email protected]> Sent: Thursday, February 3, 2022 4:58 PM

Quoted 12 lines

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))
                                                       ^ ~~~
Quoted 7 lines
Quoted 1 line

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,

Quoted 29 lines

Michael

Quoted 26 lines
---
 drivers/hv/vmbus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/vmbus_drv.c +1 -2
index 17bf55fe3169..2376ee484362 100644
@@ -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

#3 lore raw
In reply to Michael Kelley (LINUX)

Michael,

Quoted 13 lines · Michael Kelley (LINUX)

From: Vitaly Chikunov <[email protected]> Sent: Thursday, February 3, 2022 4:58 PM

Quoted 12 lines

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))
                                                       ^ ~~~
Quoted 7 lines
Quoted 1 line

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,

Quoted 29 lines

Michael

Quoted 26 lines
---
 drivers/hv/vmbus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/vmbus_drv.c +1 -2
index 17bf55fe3169..2376ee484362 100644
@@ -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