All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Haifeng Lin <haifeng.lin@huawei.com>
Cc: dev@dpdk.org, maxime.coquelin@redhat.com,
	jerry.lilijun@huawei.com, stable@dpdk.org
Subject: Re: [PATCH v2] vhost: fix add_guest_pages bug
Date: Tue, 6 Dec 2016 10:28:29 +0800	[thread overview]
Message-ID: <20161206022829.GO24403@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1480592522-26096-1-git-send-email-haifeng.lin@huawei.com>

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 <haifeng.lin@huawei.com>
> ---
> 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
> 

  reply	other threads:[~2016-12-06  2:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-01 11:42 [PATCH v2] vhost: fix add_guest_pages bug Haifeng Lin
2016-12-06  2:28 ` Yuanhan Liu [this message]
2016-12-06  5:40   ` linhaifeng
2016-12-06  5:44     ` Yuanhan Liu

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=20161206022829.GO24403@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=dev@dpdk.org \
    --cc=haifeng.lin@huawei.com \
    --cc=jerry.lilijun@huawei.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.