From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id AE1D62B84; Fri, 14 Apr 2017 07:53:59 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 13 Apr 2017 22:53:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,197,1488873600"; d="scan'208";a="73994164" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 13 Apr 2017 22:53:58 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 13 Apr 2017 22:53:57 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 13 Apr 2017 22:53:57 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.217]) with mapi id 14.03.0319.002; Fri, 14 Apr 2017 13:53:55 +0800 From: "Tan, Jianfeng" To: Yuanhan Liu CC: "dev@dpdk.org" , "olivier.matz@6wind.com" , "stable@dpdk.org" Thread-Topic: [PATCH] net/virtio-user: fix not working on 32-bit system Thread-Index: AQHStF/xk5zTxFQGQEK1/vlMcRjm3qHD0h8AgACJeXA= Date: Fri, 14 Apr 2017 05:53:55 +0000 Message-ID: References: <1492092776-57008-1-git-send-email-jianfeng.tan@intel.com> <20170414053222.GK7333@yliu-dev.sh.intel.com> In-Reply-To: <20170414053222.GK7333@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-stable] [PATCH] net/virtio-user: fix not working on 32-bit system X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Apr 2017 05:54:00 -0000 > -----Original Message----- > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] > Sent: Friday, April 14, 2017 1:32 PM > To: Tan, Jianfeng > Cc: dev@dpdk.org; olivier.matz@6wind.com; stable@dpdk.org > Subject: Re: [PATCH] net/virtio-user: fix not working on 32-bit system >=20 > 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. >=20 > It took me a while to understand that you were trying to say "the first > 4 bytes __of mbuf__ is ...". Oops, yes, missed that. >=20 > > With below wrong definition, both virtual address > > and lower 4 bytes of physical addr are obtained. >=20 > 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. Yes. >=20 >=20 > > #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/virtqu= eue.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)))) >=20 > The "void **" cast makes it a bit complex (thus hard to read). I think > following should work? Yes, uintptr_t can work. I thought void ** is easier to understand, meaning= a convert to a pointer which pointing to a pointer. I usually use uintptr_= t only for converter from pointer to integer, not the opposite way. >=20 > (uint64_t(*(uintptr_t *)((uintptr_t)(mb) + (vq)->offset))) >=20 > Besides, it deserves a comment. Will add comment in next version. Thanks, Jianfeng >=20 > --yliu >=20 > > #else > > #define VIRTIO_MBUF_ADDR(mb, vq) ((mb)->buf_physaddr) > > #endif > > -- > > 2.7.4