linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range_buggy
@ 2019-01-11 15:13 Souptick Joarder
  2019-01-14 23:31 ` Boris Ostrovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Souptick Joarder @ 2019-01-11 15:13 UTC (permalink / raw)
  To: akpm, willy, mhocko, boris.ostrovsky, jgross, linux, robin.murphy
  Cc: xen-devel, linux-kernel, linux-mm

Convert to use vm_insert_range_buggy() to map range of kernel
memory to user vma.

This driver has ignored vm_pgoff. We could later "fix" these drivers
to behave according to the normal vm_pgoff offsetting simply by
removing the _buggy suffix on the function name and if that causes
regressions, it gives us an easy way to revert.

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
 drivers/xen/privcmd-buf.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c
index de01a6d..a9d7e97 100644
--- a/drivers/xen/privcmd-buf.c
+++ b/drivers/xen/privcmd-buf.c
@@ -166,12 +166,8 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
 	if (vma_priv->n_pages != count)
 		ret = -ENOMEM;
 	else
-		for (i = 0; i < vma_priv->n_pages; i++) {
-			ret = vm_insert_page(vma, vma->vm_start + i * PAGE_SIZE,
-					     vma_priv->pages[i]);
-			if (ret)
-				break;
-		}
+		ret = vm_insert_range_buggy(vma, vma_priv->pages,
+						vma_priv->n_pages);
 
 	if (ret)
 		privcmd_buf_vmapriv_free(vma_priv);
-- 
1.9.1


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

* Re: [PATCH 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range_buggy
  2019-01-11 15:13 [PATCH 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range_buggy Souptick Joarder
@ 2019-01-14 23:31 ` Boris Ostrovsky
  2019-01-15  5:41   ` Souptick Joarder
  0 siblings, 1 reply; 3+ messages in thread
From: Boris Ostrovsky @ 2019-01-14 23:31 UTC (permalink / raw)
  To: Souptick Joarder, akpm, willy, mhocko, jgross, linux, robin.murphy
  Cc: xen-devel, linux-kernel, linux-mm

On 1/11/19 10:13 AM, Souptick Joarder wrote:
> Convert to use vm_insert_range_buggy() to map range of kernel
> memory to user vma.
>
> This driver has ignored vm_pgoff. We could later "fix" these drivers
> to behave according to the normal vm_pgoff offsetting simply by
> removing the _buggy suffix on the function name and if that causes
> regressions, it gives us an easy way to revert.
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> ---
>  drivers/xen/privcmd-buf.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c
> index de01a6d..a9d7e97 100644
> --- a/drivers/xen/privcmd-buf.c
> +++ b/drivers/xen/privcmd-buf.c
> @@ -166,12 +166,8 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
>  	if (vma_priv->n_pages != count)
>  		ret = -ENOMEM;
>  	else
> -		for (i = 0; i < vma_priv->n_pages; i++) {
> -			ret = vm_insert_page(vma, vma->vm_start + i * PAGE_SIZE,
> -					     vma_priv->pages[i]);
> -			if (ret)
> -				break;
> -		}
> +		ret = vm_insert_range_buggy(vma, vma_priv->pages,
> +						vma_priv->n_pages);

This can use the non-buggy version. But since the original code was
indeed buggy in this respect I can submit this as a separate patch later.

So

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>


>  
>  	if (ret)
>  		privcmd_buf_vmapriv_free(vma_priv);


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

* Re: [PATCH 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range_buggy
  2019-01-14 23:31 ` Boris Ostrovsky
@ 2019-01-15  5:41   ` Souptick Joarder
  0 siblings, 0 replies; 3+ messages in thread
From: Souptick Joarder @ 2019-01-15  5:41 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: Andrew Morton, Matthew Wilcox, Michal Hocko, Juergen Gross,
	Russell King - ARM Linux, robin.murphy, xen-devel, linux-kernel,
	Linux-MM

On Tue, Jan 15, 2019 at 5:01 AM Boris Ostrovsky
<boris.ostrovsky@oracle.com> wrote:
>
> On 1/11/19 10:13 AM, Souptick Joarder wrote:
> > Convert to use vm_insert_range_buggy() to map range of kernel
> > memory to user vma.
> >
> > This driver has ignored vm_pgoff. We could later "fix" these drivers
> > to behave according to the normal vm_pgoff offsetting simply by
> > removing the _buggy suffix on the function name and if that causes
> > regressions, it gives us an easy way to revert.
> >
> > Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> > ---
> >  drivers/xen/privcmd-buf.c | 8 ++------
> >  1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c
> > index de01a6d..a9d7e97 100644
> > --- a/drivers/xen/privcmd-buf.c
> > +++ b/drivers/xen/privcmd-buf.c
> > @@ -166,12 +166,8 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
> >       if (vma_priv->n_pages != count)
> >               ret = -ENOMEM;
> >       else
> > -             for (i = 0; i < vma_priv->n_pages; i++) {
> > -                     ret = vm_insert_page(vma, vma->vm_start + i * PAGE_SIZE,
> > -                                          vma_priv->pages[i]);
> > -                     if (ret)
> > -                             break;
> > -             }
> > +             ret = vm_insert_range_buggy(vma, vma_priv->pages,
> > +                                             vma_priv->n_pages);
>
> This can use the non-buggy version. But since the original code was
> indeed buggy in this respect I can submit this as a separate patch later.
>
> So
>
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

Thanks Boris.
>
>
> >
> >       if (ret)
> >               privcmd_buf_vmapriv_free(vma_priv);
>

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

end of thread, other threads:[~2019-01-15  5:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 15:13 [PATCH 9/9] xen/privcmd-buf.c: Convert to use vm_insert_range_buggy Souptick Joarder
2019-01-14 23:31 ` Boris Ostrovsky
2019-01-15  5:41   ` Souptick Joarder

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