dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost: fix offset while mmaping log base address
@ 2018-02-08 16:59 Tomasz Kulasek
  2018-02-09  1:54 ` Tan, Jianfeng
  2018-02-19 21:03 ` Maxime Coquelin
  0 siblings, 2 replies; 8+ messages in thread
From: Tomasz Kulasek @ 2018-02-08 16:59 UTC (permalink / raw)
  To: yliu; +Cc: dev, yuanhan.liu, stable, Pawel Wodkowski

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(-)

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] vhost: fix offset while mmaping log base address
  2018-02-08 16:59 Tomasz Kulasek
@ 2018-02-09  1:54 ` Tan, Jianfeng
  2018-02-19 21:03 ` Maxime Coquelin
  1 sibling, 0 replies; 8+ messages in thread
From: Tan, Jianfeng @ 2018-02-09  1:54 UTC (permalink / raw)
  To: Kulasek, TomaszX, yliu@fridaylinux.org
  Cc: dev@dpdk.org, yuanhan.liu@linux.intel.com, stable@dpdk.org,
	Wodkowski, PawelX



> -----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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vhost: fix offset while mmaping log base address
  2018-02-08 16:59 Tomasz Kulasek
  2018-02-09  1:54 ` Tan, Jianfeng
@ 2018-02-19 21:03 ` Maxime Coquelin
  1 sibling, 0 replies; 8+ messages in thread
From: Maxime Coquelin @ 2018-02-19 21:03 UTC (permalink / raw)
  To: Tomasz Kulasek, yliu; +Cc: dev, yuanhan.liu, stable, Pawel Wodkowski



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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] vhost: fix offset while mmaping log base address
@ 2024-07-08  6:57 BillXiang
  2024-07-09 12:42 ` Chenbo Xia
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: BillXiang @ 2024-07-08  6:57 UTC (permalink / raw)
  To: Maxime Coquelin, Chenbo Xia, Jianfeng Tan, Tomasz Kulasek,
	Pawel Wodkowski
  Cc: dev, BillXiang

From: BillXiang <xiangwencheng@dayudpu.com>

For sanity the offset should be the last parameter of mmap.

Fixes: fbc4d24 ("vhost: fix offset while mmaping log base address")
Signed-off-by: BillXiang <xiangwencheng@dayudpu.com>
---
 lib/vhost/vhost_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 5f470da38a..0893ae80bb 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -2399,7 +2399,7 @@ vhost_user_set_log_base(struct virtio_net **pdev,
 	 * mmap from 0 to workaround a hugepage mmap bug: mmap will
 	 * fail when offset is not page size aligned.
 	 */
-	addr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+	addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, off);
 	alignment = get_blk_size(fd);
 	close(fd);
 	if (addr == MAP_FAILED) {
-- 
2.30.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] vhost: fix offset while mmaping log base address
  2024-07-08  6:57 [PATCH] vhost: fix offset while mmaping log base address BillXiang
@ 2024-07-09 12:42 ` Chenbo Xia
  2024-07-10  3:22 ` BillXiang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Chenbo Xia @ 2024-07-09 12:42 UTC (permalink / raw)
  To: BillXiang
  Cc: Maxime Coquelin, Jianfeng Tan, Tomasz Kulasek, Pawel Wodkowski,
	dev@dpdk.org



> On Jul 8, 2024, at 14:57, BillXiang <xiangwencheng@dayudpu.com> wrote:
> 
> External email: Use caution opening links or attachments
> 
> 
> From: BillXiang <xiangwencheng@dayudpu.com>
> 
> For sanity the offset should be the last parameter of mmap.
> 
> Fixes: fbc4d24 ("vhost: fix offset while mmaping log base address")

The commit id length should be 12.

Since QEMU always send offset 0, I think it’s no need to backport the
patch, so no cc-stable is fine.

With above fixed:

Reviewed-by: Chenbo Xia <chenbox@nvidia.com>

> Signed-off-by: BillXiang <xiangwencheng@dayudpu.com>
> ---
> lib/vhost/vhost_user.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 5f470da38a..0893ae80bb 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -2399,7 +2399,7 @@ vhost_user_set_log_base(struct virtio_net **pdev,
>         * mmap from 0 to workaround a hugepage mmap bug: mmap will
>         * fail when offset is not page size aligned.
>         */
> -       addr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> +       addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, off);
>        alignment = get_blk_size(fd);
>        close(fd);
>        if (addr == MAP_FAILED) {
> --
> 2.30.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vhost: fix offset while mmaping log base address
  2024-07-08  6:57 [PATCH] vhost: fix offset while mmaping log base address BillXiang
  2024-07-09 12:42 ` Chenbo Xia
@ 2024-07-10  3:22 ` BillXiang
  2024-09-19 12:03 ` Maxime Coquelin
  2024-09-19 12:04 ` Maxime Coquelin
  3 siblings, 0 replies; 8+ messages in thread
From: BillXiang @ 2024-07-10  3:22 UTC (permalink / raw)
  To: chenbox
  Cc: maxime.coquelin, jianfeng.tan, tomaszx.kulasek, pawelx.wodkowski,
	dev, BillXiang

From: BillXiang <xiangwencheng@dayudpu.com>

> From: "Chenbo Xia"<chenbox@nvidia.com>
> Date: Tue, Jul 9, 2024, 20:42
> Subject: Re: [PATCH] vhost: fix offset while mmaping log base address
> To: "BillXiang"<xiangwencheng@dayudpu.com>
> Cc: "Maxime Coquelin"<maxime.coquelin@redhat.com>, "Jianfeng Tan"<jianfeng.tan@intel.com>, "Tomasz Kulasek"<tomaszx.kulasek@intel.com>, "Pawel Wodkowski"<pawelx.wodkowski@intel.com>, "dev@dpdk.org"<dev@dpdk.org>
> > On Jul 8, 2024, at 14:57, BillXiang <xiangwencheng@dayudpu.com> wrote:
> >
> > External email: Use caution opening links or attachments
> >
> >
> > From: BillXiang <xiangwencheng@dayudpu.com>
> >
> > For sanity the offset should be the last parameter of mmap.
> >
> > Fixes: fbc4d24 ("vhost: fix offset while mmaping log base address")
>
> The commit id length should be 12.
>

Thanks, I will mind it.

> Since QEMU always send offset 0, I think it's no need to backport the
> patch, so no cc-stable is fine.
>

I just think the code is confusing and I'm wondering whether the offset 
sent by QEMU or maybe other VM can be non-zero.

If it's a mistake just fix it.

> With above fixed:
>
> Reviewed-by: Chenbo Xia <chenbox@nvidia.com>
>
> > Signed-off-by: BillXiang <xiangwencheng@dayudpu.com>
> > ---
> > lib/vhost/vhost_user.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> > index 5f470da38a..0893ae80bb 100644
> > --- a/lib/vhost/vhost_user.c
> > +++ b/lib/vhost/vhost_user.c
> > @@ -2399,7 +2399,7 @@ vhost_user_set_log_base(struct virtio_net **pdev,
> >     * mmap from 0 to workaround a hugepage mmap bug: mmap will
> >     * fail when offset is not page size aligned.
> >     */
> > -    addr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> > +    addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, off);
> >    alignment = get_blk_size(fd);
> >    close(fd);
> >    if (addr == MAP_FAILED) {
> > --
> > 2.30.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vhost: fix offset while mmaping log base address
  2024-07-08  6:57 [PATCH] vhost: fix offset while mmaping log base address BillXiang
  2024-07-09 12:42 ` Chenbo Xia
  2024-07-10  3:22 ` BillXiang
@ 2024-09-19 12:03 ` Maxime Coquelin
  2024-09-19 12:04 ` Maxime Coquelin
  3 siblings, 0 replies; 8+ messages in thread
From: Maxime Coquelin @ 2024-09-19 12:03 UTC (permalink / raw)
  To: BillXiang, Chenbo Xia, Jianfeng Tan, Tomasz Kulasek,
	Pawel Wodkowski; +Cc: dev



On 7/8/24 08:57, BillXiang wrote:
> From: BillXiang <xiangwencheng@dayudpu.com>
> 
> For sanity the offset should be the last parameter of mmap.
> 
> Fixes: fbc4d24 ("vhost: fix offset while mmaping log base address")
> Signed-off-by: BillXiang <xiangwencheng@dayudpu.com>
> ---
>   lib/vhost/vhost_user.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 5f470da38a..0893ae80bb 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -2399,7 +2399,7 @@ vhost_user_set_log_base(struct virtio_net **pdev,
>   	 * mmap from 0 to workaround a hugepage mmap bug: mmap will
>   	 * fail when offset is not page size aligned.
>   	 */
> -	addr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> +	addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, off);
>   	alignment = get_blk_size(fd);
>   	close(fd);
>   	if (addr == MAP_FAILED) {

Fixed the fixes tag and Cc'ed stable.

Applied to next-virtio/for-next-net.

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] vhost: fix offset while mmaping log base address
  2024-07-08  6:57 [PATCH] vhost: fix offset while mmaping log base address BillXiang
                   ` (2 preceding siblings ...)
  2024-09-19 12:03 ` Maxime Coquelin
@ 2024-09-19 12:04 ` Maxime Coquelin
  3 siblings, 0 replies; 8+ messages in thread
From: Maxime Coquelin @ 2024-09-19 12:04 UTC (permalink / raw)
  To: BillXiang, Chenbo Xia, Jianfeng Tan, Tomasz Kulasek,
	Pawel Wodkowski; +Cc: dev



On 7/8/24 08:57, BillXiang wrote:
> From: BillXiang <xiangwencheng@dayudpu.com>
> 
> For sanity the offset should be the last parameter of mmap.
> 
> Fixes: fbc4d24 ("vhost: fix offset while mmaping log base address")
> Signed-off-by: BillXiang <xiangwencheng@dayudpu.com>
> ---
>   lib/vhost/vhost_user.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Applied to next-virtio/for-next-net.

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-09-19 12:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-08  6:57 [PATCH] vhost: fix offset while mmaping log base address BillXiang
2024-07-09 12:42 ` Chenbo Xia
2024-07-10  3:22 ` BillXiang
2024-09-19 12:03 ` Maxime Coquelin
2024-09-19 12:04 ` Maxime Coquelin
  -- strict thread matches above, loose matches on Subject: below --
2018-02-08 16:59 Tomasz Kulasek
2018-02-09  1:54 ` Tan, Jianfeng
2018-02-19 21:03 ` Maxime Coquelin

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).