* [RESEND PATCH 0/3] hisilicon hns warning fixes for gcc-7.0.1
@ 2017-03-24 22:02 Arnd Bergmann
[not found] ` <20170324220250.2193128-1-arnd-r2nGTMty4D4@public.gmane.org>
` (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-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA
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-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: "Wei Hu(Xavier)" <xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Daode Huang <huangdaode-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>
Cc: Kejian Yan <yankejian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Qianqian Xie <xieqianqian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Wei Yongjun <weiyongjun1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Yisen Zhuang <yisen.zhuang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Salil Mehta <salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Hal Rosenstock <hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <20170324220250.2193128-1-arnd-r2nGTMty4D4@public.gmane.org>]
* [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data
[not found] ` <20170324220250.2193128-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2017-03-24 22:02 ` Arnd Bergmann
[not found] ` <20170324220250.2193128-2-arnd-r2nGTMty4D4@public.gmane.org>
0 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-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA
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-r2nGTMty4D4@public.gmane.org>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ 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
[not found] ` <20170324220250.2193128-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2017-03-24 22:02 ` Arnd Bergmann
[not found] ` <20170324220250.2193128-3-arnd-r2nGTMty4D4@public.gmane.org>
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
[not found] ` <20170324220250.2193128-1-arnd-r2nGTMty4D4@public.gmane.org>
2017-03-24 22:02 ` [RESEND PATCH 1/3] net: hns: fix uninitialized data use Arnd Bergmann
@ 2017-03-24 22:02 ` Arnd Bergmann
[not found] ` <20170324220250.2193128-4-arnd-r2nGTMty4D4@public.gmane.org>
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
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
[not found] ` <20170324220250.2193128-1-arnd-r2nGTMty4D4@public.gmane.org>
2017-03-24 22:02 ` [RESEND PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
[not found] ` <20170324220250.2193128-2-arnd-r2nGTMty4D4@public.gmane.org>
2017-04-25 19:19 ` Doug Ledford
2017-03-24 22:02 ` [RESEND PATCH 1/3] net: hns: fix uninitialized data use Arnd Bergmann
[not found] ` <20170324220250.2193128-3-arnd-r2nGTMty4D4@public.gmane.org>
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
[not found] ` <20170324220250.2193128-4-arnd-r2nGTMty4D4@public.gmane.org>
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).