Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/ixgbe Fix some problems found by KUBSan:



details:   https://anonhg.NetBSD.org/src/rev/0d359aa83ea4
branches:  trunk
changeset: 842766:0d359aa83ea4
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Jul 24 06:07:57 2019 +0000

description:
Fix some problems found by KUBSan:
- Set TQSM and RQSM (TX/RX queue statistics mapping) correctly.
- Set IVAR (Interrupt Vector Allocation Register) correctly in
  ixgbe_set_ivar().
- Define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART correctly. This macro is used
  in ixgbe_restart_an_internal_phy_x550em().
- Define IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN correctly. This macro is used
  in ixgbe_setup_ixfi_x550em_x().
- Define IXGBE_SB_IOSF_CTRL_BUSY correctly. This macro is used in
  ixgbe_iosf_wait() (X550EM only).

diffstat:

 sys/dev/pci/ixgbe/ixgbe.c      |  14 +++++++-------
 sys/dev/pci/ixgbe/ixgbe_type.h |   8 ++++----
 2 files changed, 11 insertions(+), 11 deletions(-)

diffs (82 lines):

diff -r b48022466d04 -r 0d359aa83ea4 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Wed Jul 24 05:47:39 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Wed Jul 24 06:07:57 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.193 2019/07/17 03:26:24 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.194 2019/07/24 06:07:57 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -609,7 +609,7 @@
 
                /* Set RQSMR (Receive Queue Statistic Mapping) register */
                reg = IXGBE_READ_REG(hw, IXGBE_RQSMR(regnum));
-               reg &= ~(0x000000ff << (regshift * 8));
+               reg &= ~(0x000000ffUL << (regshift * 8));
                reg |= i << (regshift * 8);
                IXGBE_WRITE_REG(hw, IXGBE_RQSMR(regnum), reg);
 
@@ -698,7 +698,7 @@
                else
                        tqsmreg = IXGBE_TQSM(regnum);
                reg = IXGBE_READ_REG(hw, tqsmreg);
-               reg &= ~(0x000000ff << (regshift * 8));
+               reg &= ~(0x000000ffUL << (regshift * 8));
                reg |= i << (regshift * 8);
                IXGBE_WRITE_REG(hw, tqsmreg, reg);
 
@@ -4200,14 +4200,14 @@
                if (type == -1) { /* MISC IVAR */
                        index = (entry & 1) * 8;
                        ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
-                       ivar &= ~(0xFF << index);
-                       ivar |= (vector << index);
+                       ivar &= ~(0xffUL << index);
+                       ivar |= ((u32)vector << index);
                        IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
                } else {        /* RX/TX IVARS */
                        index = (16 * (entry & 1)) + (8 * type);
                        ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(entry >> 1));
-                       ivar &= ~(0xFF << index);
-                       ivar |= (vector << index);
+                       ivar &= ~(0xffUL << index);
+                       ivar |= ((u32)vector << index);
                        IXGBE_WRITE_REG(hw, IXGBE_IVAR(entry >> 1), ivar);
                }
                break;
diff -r b48022466d04 -r 0d359aa83ea4 sys/dev/pci/ixgbe/ixgbe_type.h
--- a/sys/dev/pci/ixgbe/ixgbe_type.h    Wed Jul 24 05:47:39 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_type.h    Wed Jul 24 06:07:57 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_type.h,v 1.40 2019/07/02 08:32:18 msaitoh Exp $ */
+/* $NetBSD: ixgbe_type.h,v 1.41 2019/07/24 06:07:58 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -4457,7 +4457,7 @@
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR          (1 << 26)
 #define IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE              (1 << 28)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE           (1 << 29)
-#define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART          (1 << 31)
+#define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART          (1UL << 31)
 
 #define IXGBE_KRM_AN_CNTL_1_SYM_PAUSE                  (1 << 28)
 #define IXGBE_KRM_AN_CNTL_1_ASM_PAUSE                  (1 << 29)
@@ -4487,7 +4487,7 @@
 #define IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN     (1 << 1)
 #define IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN      (1 << 2)
 #define IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN             (1 << 3)
-#define IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN             (1 << 31)
+#define IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN             (1UL << 31)
 
 #define IXGBE_SB_IOSF_INDIRECT_CTRL    0x00011144
 #define IXGBE_SB_IOSF_INDIRECT_DATA    0x00011148
@@ -4503,7 +4503,7 @@
 #define IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT 28
 #define IXGBE_SB_IOSF_CTRL_TARGET_SELECT_MASK  0x7
 #define IXGBE_SB_IOSF_CTRL_BUSY_SHIFT          31
-#define IXGBE_SB_IOSF_CTRL_BUSY                (1 << IXGBE_SB_IOSF_CTRL_BUSY_SHIFT)
+#define IXGBE_SB_IOSF_CTRL_BUSY                (1UL << IXGBE_SB_IOSF_CTRL_BUSY_SHIFT)
 #define IXGBE_SB_IOSF_TARGET_KR_PHY    0
 
 #define IXGBE_NW_MNG_IF_SEL            0x00011178



Home | Main Index | Thread Index | Old Index