[dpdk-dev] vhost: fix offset while mmaping log base address

Message ID 20180208165938.44860-1-tomaszx.kulasek@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Tomasz Kulasek Feb. 8, 2018, 4:59 p.m. UTC
  QEMU always set offset to 0 but for sanity we should take the offset
into account.

Fixes: 54f9e32305d4 ("vhost: handle dirty pages logging request")
Cc: yuanhan.liu@linux.intel.com
Cc: stable@dpdk.org

Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 lib/librte_vhost/vhost_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jianfeng Tan Feb. 9, 2018, 1:54 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Kulasek
> Sent: Friday, February 9, 2018 1:00 AM
> To: yliu@fridaylinux.org
> Cc: dev@dpdk.org; yuanhan.liu@linux.intel.com; stable@dpdk.org;
> Wodkowski, PawelX
> Subject: [dpdk-dev] [PATCH] vhost: fix offset while mmaping log base
> address
> 
> QEMU always set offset to 0 but for sanity we should take the offset
> into account.
> 
> Fixes: 54f9e32305d4 ("vhost: handle dirty pages logging request")
> Cc: yuanhan.liu@linux.intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>

Reviewed-by: Jianfeng Tan <jianfeng.tan@intel.com>

Thanks!

> ---
>  lib/librte_vhost/vhost_user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 65ee33919..674f2ffe8 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -991,7 +991,7 @@ vhost_user_set_log_base(struct virtio_net *dev,
> struct VhostUserMsg *msg)
>  	 * mmap from 0 to workaround a hugepage mmap bug: mmap will
>  	 * fail when offset is not page size aligned.
>  	 */
> -	addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
> 0);
> +	addr = mmap(0, size + off, PROT_READ | PROT_WRITE,
> MAP_SHARED, fd, 0);
>  	close(fd);
>  	if (addr == MAP_FAILED) {
>  		RTE_LOG(ERR, VHOST_CONFIG, "mmap log base failed!\n");
> --
> 2.14.1
  
Maxime Coquelin Feb. 19, 2018, 9:03 p.m. UTC | #2
On 02/08/2018 05:59 PM, Tomasz Kulasek wrote:
> QEMU always set offset to 0 but for sanity we should take the offset
> into account.
> 
> Fixes: 54f9e32305d4 ("vhost: handle dirty pages logging request")
> Cc: yuanhan.liu@linux.intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> ---
>   lib/librte_vhost/vhost_user.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

and applied to dpdk-next-virtio/master.

Thanks,
Maxime
  

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 65ee33919..674f2ffe8 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -991,7 +991,7 @@  vhost_user_set_log_base(struct virtio_net *dev, struct VhostUserMsg *msg)
 	 * mmap from 0 to workaround a hugepage mmap bug: mmap will
 	 * fail when offset is not page size aligned.
 	 */
-	addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+	addr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
 	close(fd);
 	if (addr == MAP_FAILED) {
 		RTE_LOG(ERR, VHOST_CONFIG, "mmap log base failed!\n");