From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <olivier.matz@6wind.com>
Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67])
 by dpdk.org (Postfix) with ESMTP id C35F52B9A
 for <dev@dpdk.org>; Tue, 19 Jul 2016 15:11:34 +0200 (CEST)
Received: from alille-653-1-293-182.w90-1.abo.wanadoo.fr ([90.1.53.182]
 helo=[192.168.1.13])
 by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <olivier.matz@6wind.com>)
 id 1bPUqc-0004i4-Gm; Tue, 19 Jul 2016 15:14:09 +0200
To: "Tan, Jianfeng" <jianfeng.tan@intel.com>, "dev@dpdk.org" <dev@dpdk.org>,
 "Xie, Huawei" <huawei.xie@intel.com>,
 "yuanhan.liu@linux.intel.com" <yuanhan.liu@linux.intel.com>
References: <1468931519-7381-1-git-send-email-olivier.matz@6wind.com>
 <ED26CBA2FAD1BF48A8719AEF02201E361062162F@SHSMSX103.ccr.corp.intel.com>
From: Olivier Matz <olivier.matz@6wind.com>
Message-ID: <d9d58218-1b2a-1991-898d-ddda26f641f0@6wind.com>
Date: Tue, 19 Jul 2016 15:11:24 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Icedove/45.1.0
MIME-Version: 1.0
In-Reply-To: <ED26CBA2FAD1BF48A8719AEF02201E361062162F@SHSMSX103.ccr.corp.intel.com>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Subject: Re: [dpdk-dev] [PATCH] virtio: fix packet corruption
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 19 Jul 2016 13:11:34 -0000

Hi Jianfeng,

On 07/19/2016 03:03 PM, Tan, Jianfeng wrote:
> Hi Oliver,
> 
>> -----Original Message-----
>> From: Olivier Matz [mailto:olivier.matz@6wind.com]
>> Sent: Tuesday, July 19, 2016 8:32 PM
>> To: dev@dpdk.org; Tan, Jianfeng; Xie, Huawei; yuanhan.liu@linux.intel.com
>> Subject: [PATCH] virtio: fix packet corruption
>>
>> The support of virtio-user changed the way the mbuf dma address is
>> retrieved, using a physical address in case of virtio-pci and a virtual
>> address in case of virtio-user.
>>
>> This change introduced some possible memory corruption in packets,
>> replacing:
>>   m->buf_physaddr + RTE_PKTMBUF_HEADROOM
>> by:
>>   m->buf_physaddr + m->data_off     (through a macro)
>>
>> This patch fixes this issue, restoring the original behavior.
> 
> Could you be more specific on why we cannot use m->data_off here?

There is no guarantee that m->data_off == RTE_PKTMBUF_HEADROOM here as
virtqueue_enqueue_recv_refill() is called on a mbuf that is just
allocated with rte_mbuf_raw_alloc(). An alternative would be to set
data_off to RTE_PKTMBUF_HEADROOM, but as it's a fix and we are close to
the release, I prefered to restore the initial behavior.

I did not include the test plan because it relies on patch that are not
submitted yet (offload patches, they will be upstreamed very soon). It
is a quite simple test case with testpmd.

Regards,
Olivier