From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1897CA00D7; Thu, 31 Oct 2019 11:41:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D93381BFF3; Thu, 31 Oct 2019 11:41:37 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 313D11BEA8 for ; Thu, 31 Oct 2019 11:41:35 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2019 03:41:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,250,1569308400"; d="scan'208";a="206072265" Received: from dpdk-virtio-tbie-2.sh.intel.com (HELO ___) ([10.67.104.74]) by FMSMGA003.fm.intel.com with ESMTP; 31 Oct 2019 03:41:33 -0700 Date: Thu, 31 Oct 2019 18:42:21 +0800 From: Tiwei Bie To: Marvin Liu Cc: maxime.coquelin@redhat.com, zhihong.wang@intel.com, amorenoz@redhat.com, dev@dpdk.org Message-ID: <20191031104220.GA22299@___> References: <20191030110723.20195-1-yong.liu@intel.com> <20191030145602.1948-1-yong.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191030145602.1948-1-yong.liu@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH v3] vhost: fix vhost user virtqueue not accessible 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Oct 30, 2019 at 10:56:02PM +0800, Marvin Liu wrote: > Log feature is disabled in vhost user, so that log address was invalid > when checking. Check whether log address is valid can workaround it. > Also log address should be translated in packed ring virtqueue. > > Fixes: 04cfc7fdbfca ("vhost: translate incoming log address to gpa") > > Signed-off-by: Marvin Liu > --- > lib/librte_vhost/vhost_user.c | 30 +++++++++++++----------------- > 1 file changed, 13 insertions(+), 17 deletions(-) > > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > index 61ef699ac..7754d2467 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -641,11 +641,23 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index) > struct vhost_vring_addr *addr = &vq->ring_addrs; > uint64_t len, expected_len; > > + dev = numa_realloc(dev, vq_index); We need to update `vq->desc` first before doing numa_realloc. https://github.com/DPDK/dpdk/blob/19397c7bf2545e6adab41b657a1f1da3c7344e7b/lib/librte_vhost/vhost_user.c#L445 > + vq = dev->virtqueue[vq_index]; > + if (addr->flags & (1 << VHOST_VRING_F_LOG)) { `vq` can be reallocated by numa_realloc. We need to update the `addr` pointer before using it. Thanks, Tiwei > + vq->log_guest_addr = > + translate_log_addr(dev, vq, addr->log_guest_addr); > + if (vq->log_guest_addr == 0) { > + RTE_LOG(DEBUG, VHOST_CONFIG, > + "(%d) failed to map log_guest_addr.\n", > + dev->vid); > + return dev; > + } > + } > + > if (vq_is_packed(dev)) { > len = sizeof(struct vring_packed_desc) * vq->size; > vq->desc_packed = (struct vring_packed_desc *)(uintptr_t) > ring_addr_to_vva(dev, vq, addr->desc_user_addr, &len); > - vq->log_guest_addr = 0; > if (vq->desc_packed == NULL || > len != sizeof(struct vring_packed_desc) * > vq->size) { > @@ -655,10 +667,6 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index) > return dev; > } > > - dev = numa_realloc(dev, vq_index); > - vq = dev->virtqueue[vq_index]; > - addr = &vq->ring_addrs; > - > len = sizeof(struct vring_packed_desc_event); > vq->driver_event = (struct vring_packed_desc_event *) > (uintptr_t)ring_addr_to_vva(dev, > @@ -701,10 +709,6 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index) > return dev; > } > > - dev = numa_realloc(dev, vq_index); > - vq = dev->virtqueue[vq_index]; > - addr = &vq->ring_addrs; > - > len = sizeof(struct vring_avail) + sizeof(uint16_t) * vq->size; > if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX)) > len += sizeof(uint16_t); > @@ -741,14 +745,6 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index) > vq->last_avail_idx = vq->used->idx; > } > > - vq->log_guest_addr = > - translate_log_addr(dev, vq, addr->log_guest_addr); > - if (vq->log_guest_addr == 0) { > - RTE_LOG(DEBUG, VHOST_CONFIG, > - "(%d) failed to map log_guest_addr .\n", > - dev->vid); > - return dev; > - } > vq->access_ok = 1; > > VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n", > -- > 2.17.1 >