From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id CC5B82BB1; Fri, 14 Apr 2017 07:35:19 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Apr 2017 22:35:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,197,1488873600"; d="scan'208";a="1119331698" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by orsmga001.jf.intel.com with ESMTP; 13 Apr 2017 22:35:17 -0700 Date: Fri, 14 Apr 2017 13:32:22 +0800 From: Yuanhan Liu To: Jianfeng Tan Cc: dev@dpdk.org, olivier.matz@6wind.com, stable@dpdk.org Message-ID: <20170414053222.GK7333@yliu-dev.sh.intel.com> References: <1492092776-57008-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: <1492092776-57008-1-git-send-email-jianfeng.tan@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] 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: Fri, 14 Apr 2017 05:35:20 -0000 On Thu, Apr 13, 2017 at 02:12:56PM +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. > > This is a regression bug. For 32-bit system, the first 4 bytes > is the virtual address, with following 8 bytes pointing to > physical addr. It took me a while to understand that you were trying to say "the first 4 bytes __of mbuf__ is ...". > With below wrong definition, both virtual address > and lower 4 bytes of physical addr are obtained. Again, it's not complete. Something like "in the case of virtio-user, buf_addr will be used for filling the desc addr, ...". will make it much easier to understand. > #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 | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h > index f9e3736..f43ea70 100644 > --- a/drivers/net/virtio/virtqueue.h > +++ b/drivers/net/virtio/virtqueue.h > @@ -72,7 +72,8 @@ struct rte_mbuf; > * Return the physical address (or virtual address in case of > * virtio-user) of mbuf data buffer. > */ > -#define VIRTIO_MBUF_ADDR(mb, vq) (*(uint64_t *)((uintptr_t)(mb) + (vq)->offset)) > +#define VIRTIO_MBUF_ADDR(mb, vq) \ > + ((uint64_t)((uintptr_t)(*(void **)((uintptr_t)(mb) + (vq)->offset)))) The "void **" cast makes it a bit complex (thus hard to read). I think following should work? (uint64_t(*(uintptr_t *)((uintptr_t)(mb) + (vq)->offset))) Besides, it deserves a comment. --yliu > #else > #define VIRTIO_MBUF_ADDR(mb, vq) ((mb)->buf_physaddr) > #endif > -- > 2.7.4