RE: [PATCH net] net: wangxun: use BIT_ULL() to prevent shift overflow on 32-bit archs
"Loktionov, Aleksandr" <[email protected]>
| Newsgroups | org.kernel.vger.netdev |
|---|---|
| Message-ID | <IA3PR11MB8986E3061021A79E94ED5A59E5A02@IA3PR11MB8986.namprd11.prod.outlook.com> |
> -----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") > Signed-off-by: Jiawen Wu <[email protected]> > --- > 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 <[email protected]>