DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tiwei Bie <tiwei.bie@intel.com>
To: Marvin Liu <yong.liu@intel.com>
Cc: maxime.coquelin@redhat.com, zhihong.wang@intel.com,
	amorenoz@redhat.com, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3] vhost: fix vhost user virtqueue not accessible
Date: Thu, 31 Oct 2019 18:42:21 +0800	[thread overview]
Message-ID: <20191031104220.GA22299@___> (raw)
In-Reply-To: <20191030145602.1948-1-yong.liu@intel.com>

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 <yong.liu@intel.com>
> ---
>  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
> 

  reply	other threads:[~2019-10-31 10:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25 16:20 [dpdk-dev] [PATCH] vhost: fix vhost user virtqueue not accessable Marvin Liu
2019-10-25 12:20 ` Adrian Moreno
2019-10-28  2:13   ` Liu, Yong
2019-10-29 10:02     ` Adrian Moreno
2019-10-30 11:07 ` [dpdk-dev] [PATCH v2] vhost: fix vhost user virtqueue not accessible Marvin Liu
2019-10-30  6:58   ` Tiwei Bie
2019-10-30 14:56   ` [dpdk-dev] [PATCH v3] " Marvin Liu
2019-10-31 10:42     ` Tiwei Bie [this message]
2019-10-31 14:54       ` Liu, Yong
2019-10-31 17:47         ` Adrian Moreno
2019-11-01  7:16           ` Liu, Yong
2019-11-04  8:44             ` Adrian Moreno
2019-11-04 10:13     ` [dpdk-dev] [PATCH v4] " Marvin Liu
2019-11-04  8:47       ` Adrian Moreno
2019-11-06 20:16         ` Maxime Coquelin
2019-11-06 20:59       ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191031104220.GA22299@___ \
    --to=tiwei.bie@intel.com \
    --cc=amorenoz@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=yong.liu@intel.com \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).