amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: fill the alignment for secure buffer
@ 2020-01-15  7:07 Huang Rui
  2020-01-15  7:45 ` Christian König
  0 siblings, 1 reply; 5+ messages in thread
From: Huang Rui @ 2020-01-15  7:07 UTC (permalink / raw)
  To: amd-gfx
  Cc: Pierre-Eric Pelloux-Prayer, Aaron Liu, Huang Rui, Alex Deucher,
	Harry Wentland, Christian König

The alignment should match the page size for secure buffer.

Signed-off-by: Huang Rui <ray.huang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index f39012e..a03eead 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -261,9 +261,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
 		resv = vm->root.base.bo->tbo.base.resv;
 	}
 
-	if (flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
-		/* XXX: pad out alignment to meet TMZ requirements */
-	}
+	/* TMZ requires the secure buffer to align with page size at least */
+	if (flags & AMDGPU_GEM_CREATE_ENCRYPTED)
+		args->in.alignment = roundup(args->in.alignment,
+					     AMDGPU_GPU_PAGE_SIZE);
 
 	r = amdgpu_gem_object_create(adev, size, args->in.alignment,
 				     (u32)(0xffffffff & args->in.domains),
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: fill the alignment for secure buffer
  2020-01-15  7:07 [PATCH] drm/amdgpu: fill the alignment for secure buffer Huang Rui
@ 2020-01-15  7:45 ` Christian König
  2020-01-15  7:48   ` Huang Rui
  0 siblings, 1 reply; 5+ messages in thread
From: Christian König @ 2020-01-15  7:45 UTC (permalink / raw)
  To: Huang Rui, amd-gfx
  Cc: Alex Deucher, Pierre-Eric Pelloux-Prayer, Harry Wentland, Aaron Liu

Am 15.01.20 um 08:07 schrieb Huang Rui:
> The alignment should match the page size for secure buffer.

That is superfluous, buffer are aligned to a page size anyway.

Christian.

>
> Signed-off-by: Huang Rui <ray.huang@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> index f39012e..a03eead 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> @@ -261,9 +261,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
>   		resv = vm->root.base.bo->tbo.base.resv;
>   	}
>   
> -	if (flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
> -		/* XXX: pad out alignment to meet TMZ requirements */
> -	}
> +	/* TMZ requires the secure buffer to align with page size at least */
> +	if (flags & AMDGPU_GEM_CREATE_ENCRYPTED)
> +		args->in.alignment = roundup(args->in.alignment,
> +					     AMDGPU_GPU_PAGE_SIZE);
>   
>   	r = amdgpu_gem_object_create(adev, size, args->in.alignment,
>   				     (u32)(0xffffffff & args->in.domains),

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: fill the alignment for secure buffer
  2020-01-15  7:45 ` Christian König
@ 2020-01-15  7:48   ` Huang Rui
  2020-01-15 10:33     ` Christian König
  0 siblings, 1 reply; 5+ messages in thread
From: Huang Rui @ 2020-01-15  7:48 UTC (permalink / raw)
  To: Koenig, Christian
  Cc: Deucher, Alexander, Pelloux-prayer, Pierre-eric, Wentland, Harry,
	Liu, Aaron, amd-gfx

On Wed, Jan 15, 2020 at 03:45:50PM +0800, Koenig, Christian wrote:
> Am 15.01.20 um 08:07 schrieb Huang Rui:
> > The alignment should match the page size for secure buffer.
> 
> That is superfluous, buffer are aligned to a page size anyway.
> 

If use huge page, will buffer still be aligned?

Thanks,
Ray

> Christian.
> 
> >
> > Signed-off-by: Huang Rui <ray.huang@amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
> >   1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> > index f39012e..a03eead 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> > @@ -261,9 +261,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
> >   		resv = vm->root.base.bo->tbo.base.resv;
> >   	}
> >   
> > -	if (flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
> > -		/* XXX: pad out alignment to meet TMZ requirements */
> > -	}
> > +	/* TMZ requires the secure buffer to align with page size at least */
> > +	if (flags & AMDGPU_GEM_CREATE_ENCRYPTED)
> > +		args->in.alignment = roundup(args->in.alignment,
> > +					     AMDGPU_GPU_PAGE_SIZE);
> >   
> >   	r = amdgpu_gem_object_create(adev, size, args->in.alignment,
> >   				     (u32)(0xffffffff & args->in.domains),
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: fill the alignment for secure buffer
  2020-01-15  7:48   ` Huang Rui
@ 2020-01-15 10:33     ` Christian König
  2020-01-15 16:33       ` Alex Deucher
  0 siblings, 1 reply; 5+ messages in thread
From: Christian König @ 2020-01-15 10:33 UTC (permalink / raw)
  To: Huang Rui
  Cc: Deucher, Alexander, Pelloux-prayer, Pierre-eric, Wentland, Harry,
	Liu, Aaron, amd-gfx

Am 15.01.20 um 08:48 schrieb Huang Rui:
> On Wed, Jan 15, 2020 at 03:45:50PM +0800, Koenig, Christian wrote:
>> Am 15.01.20 um 08:07 schrieb Huang Rui:
>>> The alignment should match the page size for secure buffer.
>> That is superfluous, buffer are aligned to a page size anyway.
>>
> If use huge page, will buffer still be aligned?

Yes, the minimum alignment is always one page.

Christian.

>
> Thanks,
> Ray
>
>> Christian.
>>
>>> Signed-off-by: Huang Rui <ray.huang@amd.com>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
>>>    1 file changed, 4 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
>>> index f39012e..a03eead 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
>>> @@ -261,9 +261,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
>>>    		resv = vm->root.base.bo->tbo.base.resv;
>>>    	}
>>>    
>>> -	if (flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
>>> -		/* XXX: pad out alignment to meet TMZ requirements */
>>> -	}
>>> +	/* TMZ requires the secure buffer to align with page size at least */
>>> +	if (flags & AMDGPU_GEM_CREATE_ENCRYPTED)
>>> +		args->in.alignment = roundup(args->in.alignment,
>>> +					     AMDGPU_GPU_PAGE_SIZE);
>>>    
>>>    	r = amdgpu_gem_object_create(adev, size, args->in.alignment,
>>>    				     (u32)(0xffffffff & args->in.domains),

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu: fill the alignment for secure buffer
  2020-01-15 10:33     ` Christian König
@ 2020-01-15 16:33       ` Alex Deucher
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2020-01-15 16:33 UTC (permalink / raw)
  To: Christian König
  Cc: Pelloux-prayer, Pierre-eric, Liu, Aaron, amd-gfx, Huang Rui,
	Deucher, Alexander, Wentland, Harry

On Wed, Jan 15, 2020 at 5:34 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 15.01.20 um 08:48 schrieb Huang Rui:
> > On Wed, Jan 15, 2020 at 03:45:50PM +0800, Koenig, Christian wrote:
> >> Am 15.01.20 um 08:07 schrieb Huang Rui:
> >>> The alignment should match the page size for secure buffer.
> >> That is superfluous, buffer are aligned to a page size anyway.
> >>
> > If use huge page, will buffer still be aligned?
>
> Yes, the minimum alignment is always one page.

We can drop the empty code block and XXX comment however.

Alex

>
> Christian.
>
> >
> > Thanks,
> > Ray
> >
> >> Christian.
> >>
> >>> Signed-off-by: Huang Rui <ray.huang@amd.com>
> >>> ---
> >>>    drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
> >>>    1 file changed, 4 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> >>> index f39012e..a03eead 100644
> >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
> >>> @@ -261,9 +261,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
> >>>             resv = vm->root.base.bo->tbo.base.resv;
> >>>     }
> >>>
> >>> -   if (flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
> >>> -           /* XXX: pad out alignment to meet TMZ requirements */
> >>> -   }
> >>> +   /* TMZ requires the secure buffer to align with page size at least */
> >>> +   if (flags & AMDGPU_GEM_CREATE_ENCRYPTED)
> >>> +           args->in.alignment = roundup(args->in.alignment,
> >>> +                                        AMDGPU_GPU_PAGE_SIZE);
> >>>
> >>>     r = amdgpu_gem_object_create(adev, size, args->in.alignment,
> >>>                                  (u32)(0xffffffff & args->in.domains),
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2020-01-15 16:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15  7:07 [PATCH] drm/amdgpu: fill the alignment for secure buffer Huang Rui
2020-01-15  7:45 ` Christian König
2020-01-15  7:48   ` Huang Rui
2020-01-15 10:33     ` Christian König
2020-01-15 16:33       ` Alex Deucher

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