Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1609007 > unrolled thread

[RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1

Started byArnd Bergmann <arnd@arndb.de>
First post2017-03-24 23:10 +0100
Last post2017-03-26 05:20 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1 Arnd Bergmann <arnd@arndb.de> - 2017-03-24 23:10 +0100
    [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann <arnd@arndb.de> - 2017-03-24 23:10 +0100
    [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann <arnd@arndb.de> - 2017-03-24 23:10 +0100
      Re: [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for  uninitialized data David Miller <davem@davemloft.net> - 2017-03-26 05:10 +0200
    [RESEND PATCH 1/3] net: hns: fix uninitialized data use Arnd Bergmann <arnd@arndb.de> - 2017-03-24 23:10 +0100
      Re: [RESEND PATCH 1/3] net: hns: fix uninitialized data use David Miller <davem@davemloft.net> - 2017-03-26 05:20 +0200

#1609007 — [RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-24 23:10 +0100
Subject[RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1
Message-ID<toFzb-83Q-1@gated-at.bofh.it>
Building with gcc-7 found three new warnings in the hns ethernet and
rdma drivers. Only one of them appears to be an actual bug, the
other two are variations of a single problem, but are unfortunately
part of different subsystems.

I'm resending all three patches to both the ethernet and the rdma
maintainers, as the first submission was a bit confusing when only
part of the series arrived for a subset of maintainers, sorry about
that.

All three patches are address issues in released kernels
and apply to v4.11-rc3 or linux-next.

      Arnd

Arnd Bergmann
  net: hns: fix uninitialized data use
  net: hns: avoid gcc-7.0.1 warning for uninitialized data
  infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data

 drivers/infiniband/hw/hns/hns_roce_hw_v1.c         | 1 +
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

-- 
2.9.0

Cc: Lijun Ou <oulijun@huawei.com>
Cc: "Wei Hu(Xavier)" <xavier.huwei@huawei.com>
Cc: Daode Huang <huangdaode@hisilicon.com>
Cc: Kejian Yan <yankejian@huawei.com>
Cc: Qianqian Xie <xieqianqian@huawei.com>
Cc: Wei Yongjun <weiyongjun1@huawei.com>
Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
Cc: Salil Mehta <salil.mehta@huawei.com>

Cc: Doug Ledford <dledford@redhat.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-rdma@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org

[toc] | [next] | [standalone]


#1609009 — [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-24 23:10 +0100
Subject[RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data
Message-ID<toFzc-83Q-25@gated-at.bofh.it>
In reply to#1609007
hns_roce_v1_cq_set_ci() calls roce_set_bit() on an uninitialized field,
which will then change only a few of its bits, causing a warning with
the latest gcc:

infiniband/hw/hns/hns_roce_hw_v1.c: In function 'hns_roce_v1_cq_set_ci':
infiniband/hw/hns/hns_roce_hw_v1.c:1854:23: error: 'doorbell[1]' is used uninitialized in this function [-Werror=uninitialized]
  roce_set_bit(doorbell[1], ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_HW_SYNS_S, 1);

The code is actually correct since we always set all bits of the
port_vlan field, but gcc correctly points out that the first
access does contain uninitialized data.

This initializes the field to zero first before setting the
individual bits.

Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index ec68f56e8ee5..882073a6ec77 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -1851,6 +1851,7 @@ void hns_roce_v1_cq_set_ci(struct hns_roce_cq *hr_cq, u32 cons_index)
 	u32 doorbell[2];
 
 	doorbell[0] = cons_index & ((hr_cq->cq_depth << 1) - 1);
+	doorbell[1] = 0;
 	roce_set_bit(doorbell[1], ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_HW_SYNS_S, 1);
 	roce_set_field(doorbell[1], ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_CMD_M,
 		       ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_CMD_S, 3);
-- 
2.9.0

[toc] | [prev] | [next] | [standalone]


#1609010 — [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-24 23:10 +0100
Subject[RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data
Message-ID<toFzc-83Q-19@gated-at.bofh.it>
In reply to#1609007
hns_dsaf_set_mac_key() calls dsaf_set_field() on an uninitialized field,
which will then change only a few of its bits, causing a warning with
the latest gcc:

hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_mac_uc_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   (origin) &= (~(mask)); \
            ^~
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_mac_mc_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_add_mac_mc_port':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_del_mac_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_rm_mac_addr':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_del_mac_mc_port':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_get_mac_uc_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_get_mac_mc_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The code is actually correct since we always set all 16 bits of the
port_vlan field, but gcc correctly points out that the first
access does contain uninitialized data.

This initializes the field to zero first before setting the
individual bits.

Fixes: 5483bfcb169c ("net: hns: modify tcam table and set mac key")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index cd93657abe87..403ea9db6dbd 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -1519,6 +1519,7 @@ static void hns_dsaf_set_mac_key(
 	mac_key->high.bits.mac_3 = addr[3];
 	mac_key->low.bits.mac_4 = addr[4];
 	mac_key->low.bits.mac_5 = addr[5];
+	mac_key->low.bits.port_vlan = 0;
 	dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_VLAN_M,
 		       DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id);
 	dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M,
-- 
2.9.0

[toc] | [prev] | [next] | [standalone]


#1609272 — Re: [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data

FromDavid Miller <davem@davemloft.net>
Date2017-03-26 05:10 +0200
SubjectRe: [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data
Message-ID<tp6J4-23A-3@gated-at.bofh.it>
In reply to#1609010
From: Arnd Bergmann <arnd@arndb.de>
Date: Fri, 24 Mar 2017 23:02:50 +0100

> hns_dsaf_set_mac_key() calls dsaf_set_field() on an uninitialized field,
> which will then change only a few of its bits, causing a warning with
> the latest gcc:
> 
> hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_mac_uc_entry':
> hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    (origin) &= (~(mask)); \
>             ^~
> hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_mac_mc_entry':
> hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_add_mac_mc_port':
> hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_del_mac_entry':
> hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_rm_mac_addr':
> hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_del_mac_mc_port':
> hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_get_mac_uc_entry':
> hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_get_mac_mc_entry':
> hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> The code is actually correct since we always set all 16 bits of the
> port_vlan field, but gcc correctly points out that the first
> access does contain uninitialized data.
> 
> This initializes the field to zero first before setting the
> individual bits.
> 
> Fixes: 5483bfcb169c ("net: hns: modify tcam table and set mac key")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

[toc] | [prev] | [next] | [standalone]


#1609011 — [RESEND PATCH 1/3] net: hns: fix uninitialized data use

FromArnd Bergmann <arnd@arndb.de>
Date2017-03-24 23:10 +0100
Subject[RESEND PATCH 1/3] net: hns: fix uninitialized data use
Message-ID<toFzc-83Q-23@gated-at.bofh.it>
In reply to#1609007
When dev_dbg() is enabled, we print uninitialized data, as gcc-7.0.1
now points out:

ethernet/hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_promisc_tcam':
ethernet/hisilicon/hns/hns_dsaf_main.c:2947:75: error: 'tbl_tcam_data.low.val' may be used uninitialized in this function [-Werror=maybe-uninitialized]
ethernet/hisilicon/hns/hns_dsaf_main.c:2947:75: error: 'tbl_tcam_data.high.val' may be used uninitialized in this function [-Werror=maybe-uninitialized]

We also pass the data into hns_dsaf_tcam_mc_cfg(), which might later
use it (not sure about that), so it seems safer to just always initialize
the tbl_tcam_data structure.

Fixes: 1f5fa2dd1cfa ("net: hns: fix for promisc mode in HNS driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 90dbda792614..cd93657abe87 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -2924,10 +2924,11 @@ void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev,
 	/* find the tcam entry index for promisc */
 	entry_index = dsaf_promisc_tcam_entry(port);
 
+	memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data));
+	memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask));
+
 	/* config key mask */
 	if (enable) {
-		memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data));
-		memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask));
 		dsaf_set_field(tbl_tcam_data.low.bits.port_vlan,
 			       DSAF_TBL_TCAM_KEY_PORT_M,
 			       DSAF_TBL_TCAM_KEY_PORT_S, port);
-- 
2.9.0

[toc] | [prev] | [next] | [standalone]


#1609276 — Re: [RESEND PATCH 1/3] net: hns: fix uninitialized data use

FromDavid Miller <davem@davemloft.net>
Date2017-03-26 05:20 +0200
SubjectRe: [RESEND PATCH 1/3] net: hns: fix uninitialized data use
Message-ID<tp6SJ-27x-9@gated-at.bofh.it>
In reply to#1609011
From: Arnd Bergmann <arnd@arndb.de>
Date: Fri, 24 Mar 2017 23:02:49 +0100

> When dev_dbg() is enabled, we print uninitialized data, as gcc-7.0.1
> now points out:
> 
> ethernet/hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_promisc_tcam':
> ethernet/hisilicon/hns/hns_dsaf_main.c:2947:75: error: 'tbl_tcam_data.low.val' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> ethernet/hisilicon/hns/hns_dsaf_main.c:2947:75: error: 'tbl_tcam_data.high.val' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> We also pass the data into hns_dsaf_tcam_mc_cfg(), which might later
> use it (not sure about that), so it seems safer to just always initialize
> the tbl_tcam_data structure.
> 
> Fixes: 1f5fa2dd1cfa ("net: hns: fix for promisc mode in HNS driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web