From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C9AAE11A2 for ; Tue, 26 Apr 2016 05:47:44 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 25 Apr 2016 20:47:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,535,1455004800"; d="scan'208";a="966481224" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 25 Apr 2016 20:47:43 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 25 Apr 2016 20:47:43 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 25 Apr 2016 20:47:43 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.229]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.184]) with mapi id 14.03.0248.002; Tue, 26 Apr 2016 11:47:41 +0800 From: "Tan, Jianfeng" To: Yuanhan Liu CC: "dev@dpdk.org" , "Xie, Huawei" Thread-Topic: [PATCH v2] virtio: fix segfault when transmit pkts Thread-Index: AQHRnpt3tVg1bOl7/Eeb0LgBJc/Efp+bGCyAgACG90A= Date: Tue, 26 Apr 2016 03:47:41 +0000 Message-ID: References: <1461242170-146337-1-git-send-email-jianfeng.tan@intel.com> <1461551865-15930-1-git-send-email-jianfeng.tan@intel.com> <20160426034309.GC7832@yliu-dev.sh.intel.com> In-Reply-To: <20160426034309.GC7832@yliu-dev.sh.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] virtio: fix segfault when transmit pkts 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: , X-List-Received-Date: Tue, 26 Apr 2016 03:47:45 -0000 Hi Yuanhan, > -----Original Message----- > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] > Sent: Tuesday, April 26, 2016 11:43 AM > To: Tan, Jianfeng > Cc: dev@dpdk.org; Xie, Huawei > Subject: Re: [PATCH v2] virtio: fix segfault when transmit pkts >=20 > On Mon, Apr 25, 2016 at 02:37:45AM +0000, Jianfeng Tan wrote: > > Issue: when using virtio nic to transmit pkts, it causes segment fault. > > > > How to reproduce: > > Basically, we need to construct a case with vm send packets to vhost-us= er, > > and this issue does not happen when transmitting packets using indirect > > desc. Besides, make sure all descriptors are exhausted before vhost > > dequeues any packets. > > > > a. start testpmd with vhost. > > $ testpmd -c 0x3 -n 4 --socket-mem 1024,0 --no-pci \ > > --vdev 'eth_vhost0,iface=3D/tmp/sock0,queues=3D1' -- -i --nb-cores= =3D1 > > > > b. start a qemu with a virtio nic connected with the vhost-user port, j= ust > > make sure mrg_rxbuf is enabled. > > > > c. enable testpmd on the host. > > testpmd> set fwd io > > testpmd> start (better without start vhost-user) > > > > d. start testpmd in VM. > > $testpmd -c 0x3 -n 4 -m 1024 -- -i --disable-hw-vlan-filter --txqflag= s=3D0xf01 > > testpmd> set fwd txonly > > testpmd> start > > > > How to fix: this bug is because inside virtqueue_enqueue_xmit(), the fl= ag > of > ^^^^^^^ > > desc has been updated inside the do {} while (), not necessary to updat= e > after > > the loop. >=20 > That's not a right "because": you were stating a fact of the right way > to do setup desc flags, but not the cause of this bug. >=20 > > (And if we do that after the loop, if all descs could have run out, > > idx is VQ_RING_DESC_CHAIN_END (32768), use this idx to reference the > start_dp > > array will lead to segment fault.) >=20 > And that's the cause. So, you should state the cause first, then the fix > (which we already have), but not in the verse order you just did. >=20 > So, I'd like to reword the commit log a bit, to something like following. > What do you think of it? If no objection, I could merge it soon. Thanks > for the fix, BTW! >=20 Your refinement sounds much better, thanks! Jianfeng