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 91B552BAF; Tue, 6 Dec 2016 03:27:38 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 05 Dec 2016 18:27:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,750,1477983600"; d="scan'208";a="794640081" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by FMSMGA003.fm.intel.com with ESMTP; 05 Dec 2016 18:27:36 -0800 Date: Tue, 6 Dec 2016 10:28:29 +0800 From: Yuanhan Liu To: Haifeng Lin Cc: dev@dpdk.org, maxime.coquelin@redhat.com, jerry.lilijun@huawei.com, stable@dpdk.org Message-ID: <20161206022829.GO24403@yliu-dev.sh.intel.com> References: <1480592522-26096-1-git-send-email-haifeng.lin@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1480592522-26096-1-git-send-email-haifeng.lin@huawei.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v2] vhost: fix add_guest_pages bug 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: Tue, 06 Dec 2016 02:27:39 -0000 On Thu, Dec 01, 2016 at 07:42:02PM +0800, Haifeng Lin wrote: > When reg_size < page_size the function read in > rte_mem_virt2phy would not return, becausue > host_user_addr is invalid. > > Signed-off-by: Haifeng Lin > --- > v2: > fix TYPO_SPELLING warning > --- > lib/librte_vhost/vhost_user.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > index 6b83c15..ce55e85 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -447,14 +447,14 @@ add_guest_pages(struct virtio_net *dev, struct virtio_memory_region *reg, > reg_size -= size; > > while (reg_size > 0) { > + size = reg_size >= page_size ? page_size : reg_size; I'd use RTE_MIN(reg_size, page_size) here. Also, this patch miss a fixline (http://dpdk.org/dev): Fixes: e246896178e6 ("vhost: get guest/host physical address mappings") Applied to dpdk-next-virtio, with above fixed. Thanks for the fix! --yliu > host_phys_addr = rte_mem_virt2phy((void *)(uintptr_t) > host_user_addr); > - add_one_guest_page(dev, guest_phys_addr, host_phys_addr, > - page_size); > + add_one_guest_page(dev, guest_phys_addr, host_phys_addr, size); > > - host_user_addr += page_size; > - guest_phys_addr += page_size; > - reg_size -= page_size; > + host_user_addr += size; > + guest_phys_addr += size; > + reg_size -= size; > } > } > > -- > 1.8.3.1 >