From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 01C792BAE; Wed, 19 Apr 2017 07:56:57 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Apr 2017 22:56:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,219,1488873600"; d="scan'208";a="1158097146" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga002.fm.intel.com with ESMTP; 18 Apr 2017 22:56:55 -0700 Date: Wed, 19 Apr 2017 13:53:49 +0800 From: Yuanhan Liu To: Jianfeng Tan Cc: dev@dpdk.org, olivier.matz@6wind.com, stable@dpdk.org Message-ID: <20170419055349.GA31523@yliu-dev.sh.intel.com> References: <1492092776-57008-1-git-send-email-jianfeng.tan@intel.com> <1492569033-140348-1-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1492569033-140348-1-git-send-email-jianfeng.tan@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v2] net/virtio-user: fix not working on 32-bit system X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2017 05:56:59 -0000 On Wed, Apr 19, 2017 at 02:30:33AM +0000, Jianfeng Tan wrote: > virtio-user cannot work on 32-bit system as higher 32-bit of the > addr field (64-bit) in the desc is filled with non-zero value > which should not happen for a 32-bit system. > > In case of virtio-user, we use buf_addr of mbuf to fill the > virtqueue desc addr. This is a regression bug. For 32-bit system, > the first 4 bytes of mbuf is buf_addr, with following 8 bytes for > buf_phyaddr. With below wrong definition, both buf_addr and lower > 4 bytes buf_phyaddr are obtained to fill the virtqueue desc. > #define VIRTIO_MBUF_ADDR(mb, vq) \ > (*(uint64_t *)((uintptr_t)(mb) + (vq)->offset)) > > Fixes: 25f80d108780 ("net/virtio: fix packet corruption") > Cc: stable@dpdk.org > > Signed-off-by: Jianfeng Tan > --- > drivers/net/virtio/virtqueue.h | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h > index f9e3736..2e67460 100644 > --- a/drivers/net/virtio/virtqueue.h > +++ b/drivers/net/virtio/virtqueue.h > @@ -69,10 +69,16 @@ struct rte_mbuf; > > #ifdef RTE_VIRTIO_USER > /** > - * Return the physical address (or virtual address in case of > - * virtio-user) of mbuf data buffer. > + * > + * Return the physical address of mbuf data buffer for virtio pci: > + * on 32-bit system, offset equals 4, return the second four bytes of mbuf; > + * on 64-bit system, offset equals 8, return the second eight bytes of mbuf. > + * Return the virtual address of mbuf data buffer for virtio-user. > + * on 32-bit system, offset equals 0, return the first four bytes of mbuf; > + * on 64-bit system, offset equals 0, return the first eight bytes of mbuf; I've expected it to be plain english, something like following: /* * Return the physical address (or virtual address in case of * virtio-user) of mbuf data buffer. * * The address is firstly casted to the word size (sizeof(uintptr_t)) * before casting it to uint64_t. This is to make it work with different * combination of word size (64 bit and 32 bit) and virtio device * (virtio-pci and virtio-user). */ Okay to you? --yliu