Skip to contentSkip to conversation

net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs

PATCH Applied Jiawen Wu 3 participants 3 messages Aug 24 – Aug 27

Subsystems (3)
lore
Share & tools
lore

Jiawen Wu

author maintainer
#0 lore raw

PATCH 1/1 net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs

The macros TXGBE_INTR_MISC() and WX_INTR_Q() rely on the standard BIT() macro to generate interrupt masks based on the queue vector index.

On 32-bit architectures, BIT() evaluates to a 32-bit unsigned long. Since the number of queue vectors can be up to 63 on txgbe devices, performing a left shift of 32 or more results in an integer overflow and undefined behavior. This causes incorrect interrupt masking and unmasking logic for both the queue and miscellaneous interrupts on 32-bit systems.

Fix this by replacing BIT() with BIT_ULL() in these macros. This ensures that the bitwise shift is always performed safely on a 64-bit unsigned long long type, regardless of the underlying architecture.

Fixes e37546ad1f9b ("net: wangxun: revert the adjustment of the IRQ vector sequence")
---
 drivers/net/ethernet/wangxun/libwx/wx_type.h    | 2 +-
 drivers/net/ethernet/wangxun/txgbe/txgbe_type.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -1
index 65e3e55db1cf..0520288d18ab 100644
@@ -1427,7 +1427,7 @@ struct wx {
 };
 
 #define WX_INTR_ALL (~0ULL)
-#define WX_INTR_Q(i) BIT((i))
+#define WX_INTR_Q(i) BIT_ULL((i))
 
 /* register operations */
 #define wr32(a, reg, value)	writel((value), ((a)->hw_addr + (reg)))
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h +1 -1
index 877234e3fdc2..fddcb011fa2f 100644
@@ -303,7 +303,7 @@ struct txgbe_fdir_filter {
 #define TXGBE_DEFAULT_RX_WORK           128
 #endif
 
-#define TXGBE_INTR_MISC(A)    BIT((A)->num_q_vectors)
+#define TXGBE_INTR_MISC(A)    BIT_ULL((A)->num_q_vectors)
 #define TXGBE_INTR_QALL(A)    (TXGBE_INTR_MISC(A) - 1)
 
 #define TXGBE_MAX_EITR        GENMASK(11, 3)
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 70 lines

-----Original Message-----
From: Jiawen Wu <[email protected]>
Sent: Monday, August 24, 2026 9:21 AM
To: [email protected]
Cc: Mengyuan Lou <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Keller, Jacob E <[email protected]>; Simon Horman <[email protected]>; Loktionov, Aleksandr <[email protected]>; Fabio Baltieri <[email protected]>; Zaremba, Larysa <[email protected]>; Jiawen Wu <[email protected]>
Subject: [PATCH net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs

The macros TXGBE_INTR_MISC() and WX_INTR_Q() rely on the standard BIT() macro to generate interrupt masks based on the queue vector index.

On 32-bit architectures, BIT() evaluates to a 32-bit unsigned long. Since the number of queue vectors can be up to 63 on txgbe devices, performing a left shift of 32 or more results in an integer overflow and undefined behavior. This causes incorrect interrupt masking and unmasking logic for both the queue and miscellaneous interrupts on 32- bit systems.

Fix this by replacing BIT() with BIT_ULL() in these macros. This ensures that the bitwise shift is always performed safely on a 64-bit unsigned long long type, regardless of the underlying architecture.

Fixes e37546ad1f9b ("net: wangxun: revert the adjustment of the IRQ

vector sequence")

---
 drivers/net/ethernet/wangxun/libwx/wx_type.h    | 2 +-
 drivers/net/ethernet/wangxun/txgbe/txgbe_type.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/wangxun/libwx/wx_type.h +1 -1
index 65e3e55db1cf..0520288d18ab 100644
@@ -1427,7 +1427,7 @@ struct wx {
 };
 
 #define WX_INTR_ALL (~0ULL)
-#define WX_INTR_Q(i) BIT((i))
+#define WX_INTR_Q(i) BIT_ULL((i))
 
 /* register operations */
 #define wr32(a, reg, value)	writel((value), ((a)->hw_addr +

(reg)))

drivers/net/ethernet/wangxun/txgbe/txgbe_type.h +1 -2
index 877234e3fdc2..fddcb011fa2f 100644
@@ -303,7 +303,7 @@ struct txgbe_fdir_filter {
 #define TXGBE_DEFAULT_RX_WORK           128
 #endif
 
-#define TXGBE_INTR_MISC(A)    BIT((A)->num_q_vectors)
+#define TXGBE_INTR_MISC(A)    BIT_ULL((A)->num_q_vectors)
 #define TXGBE_INTR_QALL(A)    (TXGBE_INTR_MISC(A) - 1)
 
 #define TXGBE_MAX_EITR        GENMASK(11, 3)
--
Quoted 1 line

2.51.0

#2 lore raw
In reply to Jiawen Wu
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 11 lines · On Mon, 24 Aug 2026 15:21:19 +0800 you wrote:

The macros TXGBE_INTR_MISC() and WX_INTR_Q() rely on the standard BIT() macro to generate interrupt masks based on the queue vector index.

On 32-bit architectures, BIT() evaluates to a 32-bit unsigned long. Since the number of queue vectors can be up to 63 on txgbe devices, performing a left shift of 32 or more results in an integer overflow and undefined behavior. This causes incorrect interrupt masking and unmasking logic for both the queue and miscellaneous interrupts on 32-bit systems.

[...]

Here is the summary with links:
- [net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs

    https://git.kernel.org/netdev/net/c/63c885688f38

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html