Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs
@ 2026-08-24  7:21 Jiawen Wu
  2026-08-24  8:35 ` Loktionov, Aleksandr
  2026-08-27 10:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jiawen Wu @ 2026-08-24  7:21 UTC (permalink / raw)
  To: netdev
  Cc: Mengyuan Lou, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jacob Keller, Simon Horman,
	Aleksandr Loktionov, Fabio Baltieri, Larysa Zaremba, Jiawen Wu

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")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 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(-)

diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h
index 65e3e55db1cf..0520288d18ab 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_type.h
+++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h
@@ -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)))
diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
index 877234e3fdc2..fddcb011fa2f 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
@@ -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)
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs
  2026-08-24  7:21 [PATCH net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs Jiawen Wu
@ 2026-08-24  8:35 ` Loktionov, Aleksandr
  2026-08-27 10:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Loktionov, Aleksandr @ 2026-08-24  8:35 UTC (permalink / raw)
  To: Jiawen Wu, netdev@vger.kernel.org
  Cc: Mengyuan Lou, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Keller, Jacob E, Simon Horman,
	Fabio Baltieri, Zaremba, Larysa



> -----Original Message-----
> From: Jiawen Wu <jiawenwu@trustnetic.com>
> Sent: Monday, August 24, 2026 9:21 AM
> To: netdev@vger.kernel.org
> Cc: Mengyuan Lou <mengyuanlou@net-swift.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; Keller, Jacob E <jacob.e.keller@intel.com>;
> Simon Horman <horms@kernel.org>; Loktionov, Aleksandr
> <aleksandr.loktionov@intel.com>; Fabio Baltieri
> <fabio.baltieri@gmail.com>; Zaremba, Larysa
> <larysa.zaremba@intel.com>; Jiawen Wu <jiawenwu@trustnetic.com>
> 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")
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> ---
>  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(-)
> 
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h
> b/drivers/net/ethernet/wangxun/libwx/wx_type.h
> index 65e3e55db1cf..0520288d18ab 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_type.h
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h
> @@ -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)))
> diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
> b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
> index 877234e3fdc2..fddcb011fa2f 100644
> --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
> +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
> @@ -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)
> --
> 2.51.0

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs
  2026-08-24  7:21 [PATCH net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs Jiawen Wu
  2026-08-24  8:35 ` Loktionov, Aleksandr
@ 2026-08-27 10:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-27 10:20 UTC (permalink / raw)
  To: Jiawen Wu
  Cc: netdev, mengyuanlou, andrew+netdev, davem, edumazet, kuba, pabeni,
	jacob.e.keller, horms, aleksandr.loktionov, fabio.baltieri,
	larysa.zaremba

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-27 10:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24  7:21 [PATCH net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs Jiawen Wu
2026-08-24  8:35 ` Loktionov, Aleksandr
2026-08-27 10:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox