All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
@ 2020-11-05 17:00 ` Jason Gunthorpe
  0 siblings, 0 replies; 10+ messages in thread
From: Jason Gunthorpe @ 2020-11-05 17:00 UTC (permalink / raw)
  To: David Airlie, Bartlomiej Zolnierkiewicz, Daniel Vetter,
	dri-devel, linux-fbdev, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Tom Lendacky

commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
pgprot_decrypted()") moves the pgprot_decrypted() into
io_remap_pfn_range(). Delete any, now confusing, open coded calls that
directly precede io_remap_pfn_range():

- drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()

- fb_mmap() immediately calls vm_iomap_memory() which is a convenience
  wrapper for io_remap_pfn_range()

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/gpu/drm/drm_vm.c         | 3 ---
 drivers/video/fbdev/core/fbmem.c | 5 -----
 2 files changed, 8 deletions(-)

rc3 will have the dependent patch, this should not be merged to DRM until it
has the rc3 commits.

There are three other pgprot_decrypted() calls in DRM, I could not figure out
what was what there, but other than very special cases I would expect code to
use io_remap_pfn_range() instead.

diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 1a636963378947..6d5a03b3223800 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -70,9 +70,6 @@ static pgprot_t drm_io_prot(struct drm_local_map *map,
 {
 	pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
 
-	/* We don't want graphics memory to be mapped encrypted */
-	tmp = pgprot_decrypted(tmp);
-
 #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \
     defined(__mips__)
 	if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING))
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 8268bbee8cae11..63a27a67a05cfa 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1386,11 +1386,6 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
 	mutex_unlock(&info->mm_lock);
 
 	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
-	/*
-	 * The framebuffer needs to be accessed decrypted, be sure
-	 * SME protection is removed
-	 */
-	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
 	fb_pgprotect(file, vma, start);
 
 	return vm_iomap_memory(vma, start, len);
-- 
2.29.2


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

* [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
@ 2020-11-05 17:00 ` Jason Gunthorpe
  0 siblings, 0 replies; 10+ messages in thread
From: Jason Gunthorpe @ 2020-11-05 17:00 UTC (permalink / raw)
  To: David Airlie, Bartlomiej Zolnierkiewicz, Daniel Vetter,
	dri-devel, linux-fbdev, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Tom Lendacky

commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
pgprot_decrypted()") moves the pgprot_decrypted() into
io_remap_pfn_range(). Delete any, now confusing, open coded calls that
directly precede io_remap_pfn_range():

- drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()

- fb_mmap() immediately calls vm_iomap_memory() which is a convenience
  wrapper for io_remap_pfn_range()

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/gpu/drm/drm_vm.c         | 3 ---
 drivers/video/fbdev/core/fbmem.c | 5 -----
 2 files changed, 8 deletions(-)

rc3 will have the dependent patch, this should not be merged to DRM until it
has the rc3 commits.

There are three other pgprot_decrypted() calls in DRM, I could not figure out
what was what there, but other than very special cases I would expect code to
use io_remap_pfn_range() instead.

diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 1a636963378947..6d5a03b3223800 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -70,9 +70,6 @@ static pgprot_t drm_io_prot(struct drm_local_map *map,
 {
 	pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
 
-	/* We don't want graphics memory to be mapped encrypted */
-	tmp = pgprot_decrypted(tmp);
-
 #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \
     defined(__mips__)
 	if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING))
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 8268bbee8cae11..63a27a67a05cfa 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1386,11 +1386,6 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
 	mutex_unlock(&info->mm_lock);
 
 	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
-	/*
-	 * The framebuffer needs to be accessed decrypted, be sure
-	 * SME protection is removed
-	 */
-	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
 	fb_pgprotect(file, vma, start);
 
 	return vm_iomap_memory(vma, start, len);
-- 
2.29.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
  2020-11-05 17:00 ` Jason Gunthorpe
@ 2020-11-05 19:17   ` Daniel Vetter
  -1 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2020-11-05 19:17 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: David Airlie, Bartlomiej Zolnierkiewicz, Daniel Vetter,
	dri-devel, linux-fbdev, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Tom Lendacky

On Thu, Nov 05, 2020 at 01:00:19PM -0400, Jason Gunthorpe wrote:
> commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
> pgprot_decrypted()") moves the pgprot_decrypted() into
> io_remap_pfn_range(). Delete any, now confusing, open coded calls that
> directly precede io_remap_pfn_range():
> 
> - drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()
> 
> - fb_mmap() immediately calls vm_iomap_memory() which is a convenience
>   wrapper for io_remap_pfn_range()
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/gpu/drm/drm_vm.c         | 3 ---
>  drivers/video/fbdev/core/fbmem.c | 5 -----
>  2 files changed, 8 deletions(-)
> 
> rc3 will have the dependent patch, this should not be merged to DRM until it
> has the rc3 commits.
> 
> There are three other pgprot_decrypted() calls in DRM, I could not figure out
> what was what there, but other than very special cases I would expect code to
> use io_remap_pfn_range() instead.

There's 4 now, I think linux-next added one. It's another io_remap_pfn

Of the three you mentioned we have:
- ttm and i915 use vm_insert_pfn (and ttm also can do also do pud_mkhuge
  entries)
- drm_gem is for all other drivers, some also use vm_insert_pfn, the
  others I think use dma_mmap_* and friends, which I think underneath
  boild down to io_remap_pfn. Or at least should be taking care of this
  already.

I'll try and remember to merge this after -rc3. Yell if it's not in by
-rc4 please.
-Daniel

> 
> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index 1a636963378947..6d5a03b3223800 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -70,9 +70,6 @@ static pgprot_t drm_io_prot(struct drm_local_map *map,
>  {
>  	pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
>  
> -	/* We don't want graphics memory to be mapped encrypted */
> -	tmp = pgprot_decrypted(tmp);
> -
>  #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \
>      defined(__mips__)
>  	if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING))
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 8268bbee8cae11..63a27a67a05cfa 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -1386,11 +1386,6 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
>  	mutex_unlock(&info->mm_lock);
>  
>  	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
> -	/*
> -	 * The framebuffer needs to be accessed decrypted, be sure
> -	 * SME protection is removed
> -	 */
> -	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
>  	fb_pgprotect(file, vma, start);
>  
>  	return vm_iomap_memory(vma, start, len);
> -- 
> 2.29.2
> 

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

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

* Re: [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
@ 2020-11-05 19:17   ` Daniel Vetter
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2020-11-05 19:17 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Tom Lendacky, linux-fbdev, Thomas Zimmermann,
	Bartlomiej Zolnierkiewicz, David Airlie, dri-devel

On Thu, Nov 05, 2020 at 01:00:19PM -0400, Jason Gunthorpe wrote:
> commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
> pgprot_decrypted()") moves the pgprot_decrypted() into
> io_remap_pfn_range(). Delete any, now confusing, open coded calls that
> directly precede io_remap_pfn_range():
> 
> - drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()
> 
> - fb_mmap() immediately calls vm_iomap_memory() which is a convenience
>   wrapper for io_remap_pfn_range()
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/gpu/drm/drm_vm.c         | 3 ---
>  drivers/video/fbdev/core/fbmem.c | 5 -----
>  2 files changed, 8 deletions(-)
> 
> rc3 will have the dependent patch, this should not be merged to DRM until it
> has the rc3 commits.
> 
> There are three other pgprot_decrypted() calls in DRM, I could not figure out
> what was what there, but other than very special cases I would expect code to
> use io_remap_pfn_range() instead.

There's 4 now, I think linux-next added one. It's another io_remap_pfn

Of the three you mentioned we have:
- ttm and i915 use vm_insert_pfn (and ttm also can do also do pud_mkhuge
  entries)
- drm_gem is for all other drivers, some also use vm_insert_pfn, the
  others I think use dma_mmap_* and friends, which I think underneath
  boild down to io_remap_pfn. Or at least should be taking care of this
  already.

I'll try and remember to merge this after -rc3. Yell if it's not in by
-rc4 please.
-Daniel

> 
> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index 1a636963378947..6d5a03b3223800 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -70,9 +70,6 @@ static pgprot_t drm_io_prot(struct drm_local_map *map,
>  {
>  	pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
>  
> -	/* We don't want graphics memory to be mapped encrypted */
> -	tmp = pgprot_decrypted(tmp);
> -
>  #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \
>      defined(__mips__)
>  	if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING))
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 8268bbee8cae11..63a27a67a05cfa 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -1386,11 +1386,6 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
>  	mutex_unlock(&info->mm_lock);
>  
>  	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
> -	/*
> -	 * The framebuffer needs to be accessed decrypted, be sure
> -	 * SME protection is removed
> -	 */
> -	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
>  	fb_pgprotect(file, vma, start);
>  
>  	return vm_iomap_memory(vma, start, len);
> -- 
> 2.29.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
  2020-11-05 19:17   ` Daniel Vetter
@ 2020-11-05 19:35     ` Jason Gunthorpe
  -1 siblings, 0 replies; 10+ messages in thread
From: Jason Gunthorpe @ 2020-11-05 19:35 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: David Airlie, Bartlomiej Zolnierkiewicz, dri-devel, linux-fbdev,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Tom Lendacky

On Thu, Nov 05, 2020 at 08:17:46PM +0100, Daniel Vetter wrote:
> On Thu, Nov 05, 2020 at 01:00:19PM -0400, Jason Gunthorpe wrote:
> > commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
> > pgprot_decrypted()") moves the pgprot_decrypted() into
> > io_remap_pfn_range(). Delete any, now confusing, open coded calls that
> > directly precede io_remap_pfn_range():
> > 
> > - drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()
> > 
> > - fb_mmap() immediately calls vm_iomap_memory() which is a convenience
> >   wrapper for io_remap_pfn_range()
> > 
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> >  drivers/gpu/drm/drm_vm.c         | 3 ---
> >  drivers/video/fbdev/core/fbmem.c | 5 -----
> >  2 files changed, 8 deletions(-)
> > 
> > rc3 will have the dependent patch, this should not be merged to DRM until it
> > has the rc3 commits.
> > 
> > There are three other pgprot_decrypted() calls in DRM, I could not figure out
> > what was what there, but other than very special cases I would expect code to
> > use io_remap_pfn_range() instead.
> 
> There's 4 now, I think linux-next added one. It's another io_remap_pfn
> 
> Of the three you mentioned we have:
> - ttm and i915 use vm_insert_pfn (and ttm also can do also do pud_mkhuge
>   entries)

You can't insert IO memory with vmf_insert_pfn_pmd_prot() (it
doesn't set the special flag) so why does it need decrypted?

Jason

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

* Re: [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
@ 2020-11-05 19:35     ` Jason Gunthorpe
  0 siblings, 0 replies; 10+ messages in thread
From: Jason Gunthorpe @ 2020-11-05 19:35 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Tom Lendacky, linux-fbdev, Bartlomiej Zolnierkiewicz,
	David Airlie, dri-devel, Thomas Zimmermann

On Thu, Nov 05, 2020 at 08:17:46PM +0100, Daniel Vetter wrote:
> On Thu, Nov 05, 2020 at 01:00:19PM -0400, Jason Gunthorpe wrote:
> > commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
> > pgprot_decrypted()") moves the pgprot_decrypted() into
> > io_remap_pfn_range(). Delete any, now confusing, open coded calls that
> > directly precede io_remap_pfn_range():
> > 
> > - drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()
> > 
> > - fb_mmap() immediately calls vm_iomap_memory() which is a convenience
> >   wrapper for io_remap_pfn_range()
> > 
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> >  drivers/gpu/drm/drm_vm.c         | 3 ---
> >  drivers/video/fbdev/core/fbmem.c | 5 -----
> >  2 files changed, 8 deletions(-)
> > 
> > rc3 will have the dependent patch, this should not be merged to DRM until it
> > has the rc3 commits.
> > 
> > There are three other pgprot_decrypted() calls in DRM, I could not figure out
> > what was what there, but other than very special cases I would expect code to
> > use io_remap_pfn_range() instead.
> 
> There's 4 now, I think linux-next added one. It's another io_remap_pfn
> 
> Of the three you mentioned we have:
> - ttm and i915 use vm_insert_pfn (and ttm also can do also do pud_mkhuge
>   entries)

You can't insert IO memory with vmf_insert_pfn_pmd_prot() (it
doesn't set the special flag) so why does it need decrypted?

Jason
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
  2020-11-05 19:35     ` Jason Gunthorpe
@ 2020-11-10 12:54       ` Daniel Vetter
  -1 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2020-11-10 12:54 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Daniel Vetter, David Airlie, Bartlomiej Zolnierkiewicz,
	dri-devel, linux-fbdev, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Tom Lendacky

On Thu, Nov 05, 2020 at 03:35:54PM -0400, Jason Gunthorpe wrote:
> On Thu, Nov 05, 2020 at 08:17:46PM +0100, Daniel Vetter wrote:
> > On Thu, Nov 05, 2020 at 01:00:19PM -0400, Jason Gunthorpe wrote:
> > > commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
> > > pgprot_decrypted()") moves the pgprot_decrypted() into
> > > io_remap_pfn_range(). Delete any, now confusing, open coded calls that
> > > directly precede io_remap_pfn_range():
> > > 
> > > - drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()
> > > 
> > > - fb_mmap() immediately calls vm_iomap_memory() which is a convenience
> > >   wrapper for io_remap_pfn_range()
> > > 
> > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > >  drivers/gpu/drm/drm_vm.c         | 3 ---
> > >  drivers/video/fbdev/core/fbmem.c | 5 -----
> > >  2 files changed, 8 deletions(-)
> > > 
> > > rc3 will have the dependent patch, this should not be merged to DRM until it
> > > has the rc3 commits.
> > > 
> > > There are three other pgprot_decrypted() calls in DRM, I could not figure out
> > > what was what there, but other than very special cases I would expect code to
> > > use io_remap_pfn_range() instead.
> > 
> > There's 4 now, I think linux-next added one. It's another io_remap_pfn
> > 
> > Of the three you mentioned we have:
> > - ttm and i915 use vm_insert_pfn (and ttm also can do also do pud_mkhuge
> >   entries)
> 
> You can't insert IO memory with vmf_insert_pfn_pmd_prot() (it
> doesn't set the special flag) so why does it need decrypted?

Well, see the other thread, we do ... :-/
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
@ 2020-11-10 12:54       ` Daniel Vetter
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2020-11-10 12:54 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Tom Lendacky, linux-fbdev, Thomas Zimmermann,
	Bartlomiej Zolnierkiewicz, David Airlie, dri-devel

On Thu, Nov 05, 2020 at 03:35:54PM -0400, Jason Gunthorpe wrote:
> On Thu, Nov 05, 2020 at 08:17:46PM +0100, Daniel Vetter wrote:
> > On Thu, Nov 05, 2020 at 01:00:19PM -0400, Jason Gunthorpe wrote:
> > > commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
> > > pgprot_decrypted()") moves the pgprot_decrypted() into
> > > io_remap_pfn_range(). Delete any, now confusing, open coded calls that
> > > directly precede io_remap_pfn_range():
> > > 
> > > - drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()
> > > 
> > > - fb_mmap() immediately calls vm_iomap_memory() which is a convenience
> > >   wrapper for io_remap_pfn_range()
> > > 
> > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > >  drivers/gpu/drm/drm_vm.c         | 3 ---
> > >  drivers/video/fbdev/core/fbmem.c | 5 -----
> > >  2 files changed, 8 deletions(-)
> > > 
> > > rc3 will have the dependent patch, this should not be merged to DRM until it
> > > has the rc3 commits.
> > > 
> > > There are three other pgprot_decrypted() calls in DRM, I could not figure out
> > > what was what there, but other than very special cases I would expect code to
> > > use io_remap_pfn_range() instead.
> > 
> > There's 4 now, I think linux-next added one. It's another io_remap_pfn
> > 
> > Of the three you mentioned we have:
> > - ttm and i915 use vm_insert_pfn (and ttm also can do also do pud_mkhuge
> >   entries)
> 
> You can't insert IO memory with vmf_insert_pfn_pmd_prot() (it
> doesn't set the special flag) so why does it need decrypted?

Well, see the other thread, we do ... :-/
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
  2020-11-05 17:00 ` Jason Gunthorpe
@ 2020-11-10 16:19   ` Daniel Vetter
  -1 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2020-11-10 16:19 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: David Airlie, Bartlomiej Zolnierkiewicz, Daniel Vetter,
	dri-devel, linux-fbdev, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Tom Lendacky

On Thu, Nov 05, 2020 at 01:00:19PM -0400, Jason Gunthorpe wrote:
> commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
> pgprot_decrypted()") moves the pgprot_decrypted() into
> io_remap_pfn_range(). Delete any, now confusing, open coded calls that
> directly precede io_remap_pfn_range():
> 
> - drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()
> 
> - fb_mmap() immediately calls vm_iomap_memory() which is a convenience
>   wrapper for io_remap_pfn_range()
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

Pushed to drm-misc-next now, thanks for your patch.
-Daniel

> ---
>  drivers/gpu/drm/drm_vm.c         | 3 ---
>  drivers/video/fbdev/core/fbmem.c | 5 -----
>  2 files changed, 8 deletions(-)
> 
> rc3 will have the dependent patch, this should not be merged to DRM until it
> has the rc3 commits.
> 
> There are three other pgprot_decrypted() calls in DRM, I could not figure out
> what was what there, but other than very special cases I would expect code to
> use io_remap_pfn_range() instead.
> 
> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index 1a636963378947..6d5a03b3223800 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -70,9 +70,6 @@ static pgprot_t drm_io_prot(struct drm_local_map *map,
>  {
>  	pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
>  
> -	/* We don't want graphics memory to be mapped encrypted */
> -	tmp = pgprot_decrypted(tmp);
> -
>  #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \
>      defined(__mips__)
>  	if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING))
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 8268bbee8cae11..63a27a67a05cfa 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -1386,11 +1386,6 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
>  	mutex_unlock(&info->mm_lock);
>  
>  	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
> -	/*
> -	 * The framebuffer needs to be accessed decrypted, be sure
> -	 * SME protection is removed
> -	 */
> -	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
>  	fb_pgprotect(file, vma, start);
>  
>  	return vm_iomap_memory(vma, start, len);
> -- 
> 2.29.2
> 

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

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

* Re: [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range()
@ 2020-11-10 16:19   ` Daniel Vetter
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Vetter @ 2020-11-10 16:19 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Tom Lendacky, linux-fbdev, Thomas Zimmermann,
	Bartlomiej Zolnierkiewicz, David Airlie, dri-devel

On Thu, Nov 05, 2020 at 01:00:19PM -0400, Jason Gunthorpe wrote:
> commit f8f6ae5d077a ("mm: always have io_remap_pfn_range() set
> pgprot_decrypted()") moves the pgprot_decrypted() into
> io_remap_pfn_range(). Delete any, now confusing, open coded calls that
> directly precede io_remap_pfn_range():
> 
> - drm_io_prot() is only in drm_mmap_locked() to call io_remap_pfn_range()
> 
> - fb_mmap() immediately calls vm_iomap_memory() which is a convenience
>   wrapper for io_remap_pfn_range()
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

Pushed to drm-misc-next now, thanks for your patch.
-Daniel

> ---
>  drivers/gpu/drm/drm_vm.c         | 3 ---
>  drivers/video/fbdev/core/fbmem.c | 5 -----
>  2 files changed, 8 deletions(-)
> 
> rc3 will have the dependent patch, this should not be merged to DRM until it
> has the rc3 commits.
> 
> There are three other pgprot_decrypted() calls in DRM, I could not figure out
> what was what there, but other than very special cases I would expect code to
> use io_remap_pfn_range() instead.
> 
> diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
> index 1a636963378947..6d5a03b3223800 100644
> --- a/drivers/gpu/drm/drm_vm.c
> +++ b/drivers/gpu/drm/drm_vm.c
> @@ -70,9 +70,6 @@ static pgprot_t drm_io_prot(struct drm_local_map *map,
>  {
>  	pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
>  
> -	/* We don't want graphics memory to be mapped encrypted */
> -	tmp = pgprot_decrypted(tmp);
> -
>  #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || \
>      defined(__mips__)
>  	if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING))
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index 8268bbee8cae11..63a27a67a05cfa 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -1386,11 +1386,6 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
>  	mutex_unlock(&info->mm_lock);
>  
>  	vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
> -	/*
> -	 * The framebuffer needs to be accessed decrypted, be sure
> -	 * SME protection is removed
> -	 */
> -	vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
>  	fb_pgprotect(file, vma, start);
>  
>  	return vm_iomap_memory(vma, start, len);
> -- 
> 2.29.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2020-11-10 16:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 17:00 [PATCH] drm: remove pgprot_decrypted() before calls to io_remap_pfn_range() Jason Gunthorpe
2020-11-05 17:00 ` Jason Gunthorpe
2020-11-05 19:17 ` Daniel Vetter
2020-11-05 19:17   ` Daniel Vetter
2020-11-05 19:35   ` Jason Gunthorpe
2020-11-05 19:35     ` Jason Gunthorpe
2020-11-10 12:54     ` Daniel Vetter
2020-11-10 12:54       ` Daniel Vetter
2020-11-10 16:19 ` Daniel Vetter
2020-11-10 16:19   ` 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.