All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/ttm: revert "Fix COW check"
@ 2021-07-16  7:06 Christian König
  2021-07-16 13:14 ` Alex Deucher
  0 siblings, 1 reply; 3+ messages in thread
From: Christian König @ 2021-07-16  7:06 UTC (permalink / raw)
  To: Felix.Kuehling; +Cc: dri-devel

This reverts commit 85fd4a8a84316166640102676a356755ddec80e0.

Daniel pointed out that even PROT_READ can cause a BUG_ON() with this.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c  |  3 +--
 drivers/gpu/drm/nouveau/nouveau_gem.c    |  3 +--
 drivers/gpu/drm/radeon/radeon_gem.c      |  3 +--
 drivers/gpu/drm/ttm/ttm_bo_vm.c          | 14 +-------------
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c |  1 -
 include/drm/ttm/ttm_bo_api.h             |  4 ----
 6 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 0d65c9d2144e..9cf4beaf646c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -79,8 +79,7 @@ static const struct vm_operations_struct amdgpu_gem_vm_ops = {
 	.fault = amdgpu_gem_fault,
 	.open = ttm_bo_vm_open,
 	.close = ttm_bo_vm_close,
-	.access = ttm_bo_vm_access,
-	.mprotect = ttm_bo_vm_mprotect
+	.access = ttm_bo_vm_access
 };
 
 static void amdgpu_gem_object_free(struct drm_gem_object *gobj)
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 164ea564bb7a..5b27845075a1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -70,8 +70,7 @@ static const struct vm_operations_struct nouveau_ttm_vm_ops = {
 	.fault = nouveau_ttm_fault,
 	.open = ttm_bo_vm_open,
 	.close = ttm_bo_vm_close,
-	.access = ttm_bo_vm_access,
-	.mprotect = ttm_bo_vm_mprotect
+	.access = ttm_bo_vm_access
 };
 
 void
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index c19ad07eb7b5..458f92a70887 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -77,8 +77,7 @@ static const struct vm_operations_struct radeon_gem_vm_ops = {
 	.fault = radeon_gem_fault,
 	.open = ttm_bo_vm_open,
 	.close = ttm_bo_vm_close,
-	.access = ttm_bo_vm_access,
-	.mprotect = ttm_bo_vm_mprotect
+	.access = ttm_bo_vm_access
 };
 
 static void radeon_gem_object_free(struct drm_gem_object *gobj)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index fb325bad5db6..f56be5bc0861 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -542,29 +542,17 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
 }
 EXPORT_SYMBOL(ttm_bo_vm_access);
 
-int ttm_bo_vm_mprotect(struct vm_area_struct *vma, unsigned long start,
-		       unsigned long end, unsigned long newflags)
-{
-	/* Enforce no COW since would have really strange behavior with it. */
-	if (is_cow_mapping(newflags) && (newflags & VM_WRITE))
-		return -EINVAL;
-
-	return 0;
-}
-EXPORT_SYMBOL(ttm_bo_vm_mprotect);
-
 static const struct vm_operations_struct ttm_bo_vm_ops = {
 	.fault = ttm_bo_vm_fault,
 	.open = ttm_bo_vm_open,
 	.close = ttm_bo_vm_close,
 	.access = ttm_bo_vm_access,
-	.mprotect = ttm_bo_vm_mprotect,
 };
 
 int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
 {
 	/* Enforce no COW since would have really strange behavior with it. */
-	if (is_cow_mapping(vma->vm_flags) && (vma->vm_flags & VM_WRITE))
+	if (is_cow_mapping(vma->vm_flags))
 		return -EINVAL;
 
 	ttm_bo_get(bo);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
index e4bf7dc99320..e6b1f98ec99f 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
@@ -61,7 +61,6 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
 		.fault = vmw_bo_vm_fault,
 		.open = ttm_bo_vm_open,
 		.close = ttm_bo_vm_close,
-		.mprotect = ttm_bo_vm_mprotect,
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 		.huge_fault = vmw_bo_vm_huge_fault,
 #endif
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 40eb95875355..f681bbdbc698 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -605,10 +605,6 @@ void ttm_bo_vm_close(struct vm_area_struct *vma);
 
 int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
 		     void *buf, int len, int write);
-
-int ttm_bo_vm_mprotect(struct vm_area_struct *vma, unsigned long start,
-		       unsigned long end, unsigned long newflags);
-
 bool ttm_bo_delayed_delete(struct ttm_device *bdev, bool remove_all);
 
 vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf, pgprot_t prot);
-- 
2.25.1


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

* Re: [PATCH] drm/ttm: revert "Fix COW check"
  2021-07-16  7:06 [PATCH] drm/ttm: revert "Fix COW check" Christian König
@ 2021-07-16 13:14 ` Alex Deucher
  2021-07-20 13:51   ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Deucher @ 2021-07-16 13:14 UTC (permalink / raw)
  To: Christian König; +Cc: Kuehling, Felix, Maling list - DRI developers

On Fri, Jul 16, 2021 at 3:06 AM Christian König
<ckoenig.leichtzumerken@gmail.com> wrote:
>
> This reverts commit 85fd4a8a84316166640102676a356755ddec80e0.
>
> Daniel pointed out that even PROT_READ can cause a BUG_ON() with this.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c  |  3 +--
>  drivers/gpu/drm/nouveau/nouveau_gem.c    |  3 +--
>  drivers/gpu/drm/radeon/radeon_gem.c      |  3 +--
>  drivers/gpu/drm/ttm/ttm_bo_vm.c          | 14 +-------------
>  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c |  1 -
>  include/drm/ttm/ttm_bo_api.h             |  4 ----
>  6 files changed, 4 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> index 0d65c9d2144e..9cf4beaf646c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> @@ -79,8 +79,7 @@ static const struct vm_operations_struct amdgpu_gem_vm_ops = {
>         .fault = amdgpu_gem_fault,
>         .open = ttm_bo_vm_open,
>         .close = ttm_bo_vm_close,
> -       .access = ttm_bo_vm_access,
> -       .mprotect = ttm_bo_vm_mprotect
> +       .access = ttm_bo_vm_access
>  };
>
>  static void amdgpu_gem_object_free(struct drm_gem_object *gobj)
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index 164ea564bb7a..5b27845075a1 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -70,8 +70,7 @@ static const struct vm_operations_struct nouveau_ttm_vm_ops = {
>         .fault = nouveau_ttm_fault,
>         .open = ttm_bo_vm_open,
>         .close = ttm_bo_vm_close,
> -       .access = ttm_bo_vm_access,
> -       .mprotect = ttm_bo_vm_mprotect
> +       .access = ttm_bo_vm_access
>  };
>
>  void
> diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> index c19ad07eb7b5..458f92a70887 100644
> --- a/drivers/gpu/drm/radeon/radeon_gem.c
> +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> @@ -77,8 +77,7 @@ static const struct vm_operations_struct radeon_gem_vm_ops = {
>         .fault = radeon_gem_fault,
>         .open = ttm_bo_vm_open,
>         .close = ttm_bo_vm_close,
> -       .access = ttm_bo_vm_access,
> -       .mprotect = ttm_bo_vm_mprotect
> +       .access = ttm_bo_vm_access
>  };
>
>  static void radeon_gem_object_free(struct drm_gem_object *gobj)
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index fb325bad5db6..f56be5bc0861 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -542,29 +542,17 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
>  }
>  EXPORT_SYMBOL(ttm_bo_vm_access);
>
> -int ttm_bo_vm_mprotect(struct vm_area_struct *vma, unsigned long start,
> -                      unsigned long end, unsigned long newflags)
> -{
> -       /* Enforce no COW since would have really strange behavior with it. */
> -       if (is_cow_mapping(newflags) && (newflags & VM_WRITE))
> -               return -EINVAL;
> -
> -       return 0;
> -}
> -EXPORT_SYMBOL(ttm_bo_vm_mprotect);
> -
>  static const struct vm_operations_struct ttm_bo_vm_ops = {
>         .fault = ttm_bo_vm_fault,
>         .open = ttm_bo_vm_open,
>         .close = ttm_bo_vm_close,
>         .access = ttm_bo_vm_access,
> -       .mprotect = ttm_bo_vm_mprotect,
>  };
>
>  int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
>  {
>         /* Enforce no COW since would have really strange behavior with it. */
> -       if (is_cow_mapping(vma->vm_flags) && (vma->vm_flags & VM_WRITE))
> +       if (is_cow_mapping(vma->vm_flags))
>                 return -EINVAL;
>
>         ttm_bo_get(bo);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
> index e4bf7dc99320..e6b1f98ec99f 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
> @@ -61,7 +61,6 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
>                 .fault = vmw_bo_vm_fault,
>                 .open = ttm_bo_vm_open,
>                 .close = ttm_bo_vm_close,
> -               .mprotect = ttm_bo_vm_mprotect,
>  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>                 .huge_fault = vmw_bo_vm_huge_fault,
>  #endif
> diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> index 40eb95875355..f681bbdbc698 100644
> --- a/include/drm/ttm/ttm_bo_api.h
> +++ b/include/drm/ttm/ttm_bo_api.h
> @@ -605,10 +605,6 @@ void ttm_bo_vm_close(struct vm_area_struct *vma);
>
>  int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
>                      void *buf, int len, int write);
> -
> -int ttm_bo_vm_mprotect(struct vm_area_struct *vma, unsigned long start,
> -                      unsigned long end, unsigned long newflags);
> -
>  bool ttm_bo_delayed_delete(struct ttm_device *bdev, bool remove_all);
>
>  vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf, pgprot_t prot);
> --
> 2.25.1
>

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

* Re: [PATCH] drm/ttm: revert "Fix COW check"
  2021-07-16 13:14 ` Alex Deucher
@ 2021-07-20 13:51   ` Daniel Vetter
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2021-07-20 13:51 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Christian König, Kuehling, Felix, Maling list - DRI developers

On Fri, Jul 16, 2021 at 09:14:31AM -0400, Alex Deucher wrote:
> On Fri, Jul 16, 2021 at 3:06 AM Christian König
> <ckoenig.leichtzumerken@gmail.com> wrote:
> >
> > This reverts commit 85fd4a8a84316166640102676a356755ddec80e0.
> >
> > Daniel pointed out that even PROT_READ can cause a BUG_ON() with this.
> >
> > Signed-off-by: Christian König <christian.koenig@amd.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> 
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c  |  3 +--
> >  drivers/gpu/drm/nouveau/nouveau_gem.c    |  3 +--
> >  drivers/gpu/drm/radeon/radeon_gem.c      |  3 +--
> >  drivers/gpu/drm/ttm/ttm_bo_vm.c          | 14 +-------------
> >  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c |  1 -
> >  include/drm/ttm/ttm_bo_api.h             |  4 ----
> >  6 files changed, 4 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> > index 0d65c9d2144e..9cf4beaf646c 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> > @@ -79,8 +79,7 @@ static const struct vm_operations_struct amdgpu_gem_vm_ops = {
> >         .fault = amdgpu_gem_fault,
> >         .open = ttm_bo_vm_open,
> >         .close = ttm_bo_vm_close,
> > -       .access = ttm_bo_vm_access,
> > -       .mprotect = ttm_bo_vm_mprotect
> > +       .access = ttm_bo_vm_access
> >  };
> >
> >  static void amdgpu_gem_object_free(struct drm_gem_object *gobj)
> > diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
> > index 164ea564bb7a..5b27845075a1 100644
> > --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> > @@ -70,8 +70,7 @@ static const struct vm_operations_struct nouveau_ttm_vm_ops = {
> >         .fault = nouveau_ttm_fault,
> >         .open = ttm_bo_vm_open,
> >         .close = ttm_bo_vm_close,
> > -       .access = ttm_bo_vm_access,
> > -       .mprotect = ttm_bo_vm_mprotect
> > +       .access = ttm_bo_vm_access
> >  };
> >
> >  void
> > diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> > index c19ad07eb7b5..458f92a70887 100644
> > --- a/drivers/gpu/drm/radeon/radeon_gem.c
> > +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> > @@ -77,8 +77,7 @@ static const struct vm_operations_struct radeon_gem_vm_ops = {
> >         .fault = radeon_gem_fault,
> >         .open = ttm_bo_vm_open,
> >         .close = ttm_bo_vm_close,
> > -       .access = ttm_bo_vm_access,
> > -       .mprotect = ttm_bo_vm_mprotect
> > +       .access = ttm_bo_vm_access
> >  };
> >
> >  static void radeon_gem_object_free(struct drm_gem_object *gobj)
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > index fb325bad5db6..f56be5bc0861 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > @@ -542,29 +542,17 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
> >  }
> >  EXPORT_SYMBOL(ttm_bo_vm_access);
> >
> > -int ttm_bo_vm_mprotect(struct vm_area_struct *vma, unsigned long start,
> > -                      unsigned long end, unsigned long newflags)
> > -{
> > -       /* Enforce no COW since would have really strange behavior with it. */
> > -       if (is_cow_mapping(newflags) && (newflags & VM_WRITE))
> > -               return -EINVAL;
> > -
> > -       return 0;
> > -}
> > -EXPORT_SYMBOL(ttm_bo_vm_mprotect);
> > -
> >  static const struct vm_operations_struct ttm_bo_vm_ops = {
> >         .fault = ttm_bo_vm_fault,
> >         .open = ttm_bo_vm_open,
> >         .close = ttm_bo_vm_close,
> >         .access = ttm_bo_vm_access,
> > -       .mprotect = ttm_bo_vm_mprotect,
> >  };
> >
> >  int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
> >  {
> >         /* Enforce no COW since would have really strange behavior with it. */
> > -       if (is_cow_mapping(vma->vm_flags) && (vma->vm_flags & VM_WRITE))
> > +       if (is_cow_mapping(vma->vm_flags))
> >                 return -EINVAL;
> >
> >         ttm_bo_get(bo);
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
> > index e4bf7dc99320..e6b1f98ec99f 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
> > @@ -61,7 +61,6 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
> >                 .fault = vmw_bo_vm_fault,
> >                 .open = ttm_bo_vm_open,
> >                 .close = ttm_bo_vm_close,
> > -               .mprotect = ttm_bo_vm_mprotect,
> >  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> >                 .huge_fault = vmw_bo_vm_huge_fault,
> >  #endif
> > diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
> > index 40eb95875355..f681bbdbc698 100644
> > --- a/include/drm/ttm/ttm_bo_api.h
> > +++ b/include/drm/ttm/ttm_bo_api.h
> > @@ -605,10 +605,6 @@ void ttm_bo_vm_close(struct vm_area_struct *vma);
> >
> >  int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
> >                      void *buf, int len, int write);
> > -
> > -int ttm_bo_vm_mprotect(struct vm_area_struct *vma, unsigned long start,
> > -                      unsigned long end, unsigned long newflags);
> > -
> >  bool ttm_bo_delayed_delete(struct ttm_device *bdev, bool remove_all);
> >
> >  vm_fault_t ttm_bo_vm_dummy_page(struct vm_fault *vmf, pgprot_t prot);
> > --
> > 2.25.1
> >

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

end of thread, other threads:[~2021-07-20 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16  7:06 [PATCH] drm/ttm: revert "Fix COW check" Christian König
2021-07-16 13:14 ` Alex Deucher
2021-07-20 13:51   ` Daniel Vetter

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.