From patchwork Thu Jul 7 13:49:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 14631 X-Patchwork-Delegate: yuanhan.liu@linux.intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 636FD2BA7; Thu, 7 Jul 2016 15:49:21 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DBE2811A2 for ; Thu, 7 Jul 2016 15:49:19 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 07 Jul 2016 06:49:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,324,1464678000"; d="scan'208"; a="1012502469" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 07 Jul 2016 06:49:19 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u67DnHqx018169; Thu, 7 Jul 2016 14:49:17 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u67DnGAi032038; Thu, 7 Jul 2016 14:49:16 +0100 Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id u67DnGir032034; Thu, 7 Jul 2016 14:49:16 +0100 X-Authentication-Warning: sivswdev02.ir.intel.com: fyigit set sender to ferruh.yigit@intel.com using -f From: Ferruh Yigit To: dev@dpdk.org Cc: Yuanhan Liu , Huawei Xie Date: Thu, 7 Jul 2016 14:49:08 +0100 Message-Id: <1467899348-31998-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] net/virtio: fix gcc6 i686 compiler error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This is for target i686-native-linuxapp-gcc and gcc6, Compilation error is: == Build drivers/net/virtio CC virtio_rxtx_simple.o In file included from .../build/include/rte_mempool.h:77:0, from .../drivers/net/virtio/virtio_rxtx_simple.c:46: .../drivers/net/virtio/virtio_rxtx_simple.c: In function ‘virtio_xmit_pkts_simple’: .../build/include/rte_memcpy.h:551:2: error: array subscript is above array bounds [-Werror=array-bounds] rte_mov16((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 * 16); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Call stack is as following: virtio_xmit_pkts_simple virtio_xmit_cleanup rte_mempool_put_bulk rte_mempool_generic_put __mempool_generic_put rte_memcpy The array used as source buffer in virtio_xmit_cleanup (free) is a pointer array with 32 elements, in 32bit this makes 128 bytes. in rte_memcpy() implementation, there a code piece as following: if (size > 256) { rte_move128(...); rte_move128(...); <--- [1] .... } The compiler traces the array all through the call stack and knows the size of array is 128 and generates a warning on above [1] which tries to access beyond byte 128. But unfortunately it ignores the "(size > 256)" check. Giving a hint to compiler that variable "size" is related to the size of the source buffer fixes compiler warning. Fixes: 863bfb474493 ("mempool: optimize copy in cache") Signed-off-by: Ferruh Yigit --- drivers/net/virtio/virtio_rxtx_simple.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_rxtx_simple.c b/drivers/net/virtio/virtio_rxtx_simple.c index 242ad90..d8fcc15 100644 --- a/drivers/net/virtio/virtio_rxtx_simple.c +++ b/drivers/net/virtio/virtio_rxtx_simple.c @@ -301,7 +301,7 @@ static inline void virtio_xmit_cleanup(struct virtqueue *vq) { uint16_t i, desc_idx; - int nb_free = 0; + uint32_t nb_free = 0; struct rte_mbuf *m, *free[VIRTIO_TX_MAX_FREE_BUF_SZ]; desc_idx = (uint16_t)(vq->vq_used_cons_idx & @@ -319,13 +319,16 @@ virtio_xmit_cleanup(struct virtqueue *vq) free[nb_free++] = m; else { rte_mempool_put_bulk(free[0]->pool, - (void **)free, nb_free); + (void **)free, + RTE_MIN(RTE_DIM(free), + nb_free)); free[0] = m; nb_free = 1; } } } - rte_mempool_put_bulk(free[0]->pool, (void **)free, nb_free); + rte_mempool_put_bulk(free[0]->pool, (void **)free, + RTE_MIN(RTE_DIM(free), nb_free)); } else { for (i = 1; i < VIRTIO_TX_FREE_NR; i++) { m = (struct rte_mbuf *)vq->vq_descx[desc_idx++].cookie;