linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1
@ 2017-03-24 22:02 Arnd Bergmann
  2017-03-24 22:02 ` [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Arnd Bergmann @ 2017-03-24 22:02 UTC (permalink / raw)
  To: David S . Miller, Doug Ledford
  Cc: Arnd Bergmann, Lijun Ou, Wei Hu(Xavier),
	Daode Huang, Kejian Yan, Qianqian Xie, Wei Yongjun, Yisen Zhuang,
	Salil Mehta, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, netdev

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

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

* [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data
  2017-03-24 22:02 [RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1 Arnd Bergmann
@ 2017-03-24 22:02 ` Arnd Bergmann
  2017-04-25 19:19   ` Doug Ledford
  2017-03-24 22:02 ` [RESEND PATCH 1/3] net: hns: fix uninitialized data use Arnd Bergmann
  2017-03-24 22:02 ` [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
  2 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2017-03-24 22:02 UTC (permalink / raw)
  To: David S . Miller, Doug Ledford
  Cc: Arnd Bergmann, Lijun Ou, Wei Hu(Xavier),
	Daode Huang, Kejian Yan, Qianqian Xie, Wei Yongjun, Yisen Zhuang,
	Salil Mehta, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, netdev

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

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

* [RESEND PATCH 1/3] net: hns: fix uninitialized data use
  2017-03-24 22:02 [RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1 Arnd Bergmann
  2017-03-24 22:02 ` [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
@ 2017-03-24 22:02 ` Arnd Bergmann
  2017-03-26  3:05   ` David Miller
  2017-03-24 22:02 ` [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
  2 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2017-03-24 22:02 UTC (permalink / raw)
  To: David S . Miller, Doug Ledford
  Cc: Arnd Bergmann, Lijun Ou, Wei Hu(Xavier),
	Daode Huang, Kejian Yan, Qianqian Xie, Wei Yongjun, Yisen Zhuang,
	Salil Mehta, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, netdev

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

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

* [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data
  2017-03-24 22:02 [RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1 Arnd Bergmann
  2017-03-24 22:02 ` [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
  2017-03-24 22:02 ` [RESEND PATCH 1/3] net: hns: fix uninitialized data use Arnd Bergmann
@ 2017-03-24 22:02 ` Arnd Bergmann
  2017-03-26  3:05   ` David Miller
  2 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2017-03-24 22:02 UTC (permalink / raw)
  To: David S . Miller, Doug Ledford
  Cc: Arnd Bergmann, Lijun Ou, Wei Hu(Xavier),
	Daode Huang, Kejian Yan, Qianqian Xie, Wei Yongjun, Yisen Zhuang,
	Salil Mehta, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, netdev

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

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

* Re: [RESEND PATCH 1/3] net: hns: fix uninitialized data use
  2017-03-24 22:02 ` [RESEND PATCH 1/3] net: hns: fix uninitialized data use Arnd Bergmann
@ 2017-03-26  3:05   ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-03-26  3:05 UTC (permalink / raw)
  To: arnd
  Cc: dledford, oulijun, xavier.huwei, huangdaode, yankejian,
	xieqianqian, weiyongjun1, yisen.zhuang, salil.mehta, sean.hefty,
	hal.rosenstock, linux-rdma, linux-kernel, netdev

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.

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

* Re: [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data
  2017-03-24 22:02 ` [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
@ 2017-03-26  3:05   ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-03-26  3:05 UTC (permalink / raw)
  To: arnd
  Cc: dledford, oulijun, xavier.huwei, huangdaode, yankejian,
	xieqianqian, weiyongjun1, yisen.zhuang, salil.mehta, sean.hefty,
	hal.rosenstock, linux-rdma, linux-kernel, netdev

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.

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

* Re: [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data
  2017-03-24 22:02 ` [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
@ 2017-04-25 19:19   ` Doug Ledford
  0 siblings, 0 replies; 7+ messages in thread
From: Doug Ledford @ 2017-04-25 19:19 UTC (permalink / raw)
  To: Arnd Bergmann, David S . Miller
  Cc: Lijun Ou, Wei Hu(Xavier),
	Daode Huang, Kejian Yan, Qianqian Xie, Wei Yongjun, Yisen Zhuang,
	Salil Mehta, Sean Hefty, Hal Rosenstock, linux-rdma,
	linux-kernel, netdev

On Fri, 2017-03-24 at 23:02 +0100, Arnd Bergmann wrote:
> 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>

Thanks, applied.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

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

end of thread, other threads:[~2017-04-25 19:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-24 22:02 [RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1 Arnd Bergmann
2017-03-24 22:02 ` [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
2017-04-25 19:19   ` Doug Ledford
2017-03-24 22:02 ` [RESEND PATCH 1/3] net: hns: fix uninitialized data use Arnd Bergmann
2017-03-26  3:05   ` David Miller
2017-03-24 22:02 ` [RESEND PATCH 2/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
2017-03-26  3:05   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).