Skip to contentSkip to conversation

drm/amdgpu: fill the alignment for secure buffer

PATCH In review Huang Rui 3 participants 5 messages Jan 15, 2020

Subsystems (2)
lore
Share & tools
lore

Huang Rui

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fill the alignment for secure buffer

The alignment should match the page size for secure buffer.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -3
index f39012e..a03eead 100644
@@ -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),
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#1 lore raw

Am 15.01.20 um 08:07 schrieb Huang Rui:

Quoted 1 line

The alignment should match the page size for secure buffer.

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

Christian.

Quoted 14 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index f39012e..a03eead 100644
@@ -261,9 +261,10 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
  		resv = vm->root.base.bo->tbo.base.resv;
  	}
 

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 270

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -3
-	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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#2 lore raw
Quoted 5 lines · Christian

Am 15.01.20 um 08:07 schrieb Huang Rui:

Quoted 1 line

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

Quoted 24 lines

Christian.

Quoted 22 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -3
index f39012e..a03eead 100644
@@ -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);
 
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 270

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
  	r = amdgpu_gem_object_create(adev, size, args->in.alignment,
  				     (u32)(0xffffffff & args->in.domains),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#3 lore raw

Am 15.01.20 um 08:48 schrieb Huang Rui:

Quoted 6 lines · Christian
Quoted 4 lines

Am 15.01.20 um 08:07 schrieb Huang Rui:

Quoted 1 line

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.

Quoted 27 lines

Thanks,
Ray

Quoted 23 lines

Christian.

Quoted 21 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
   1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -3
index f39012e..a03eead 100644
@@ -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);
 
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 270

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
   	r = amdgpu_gem_object_create(adev, size, args->in.alignment,
   				     (u32)(0xffffffff & args->in.domains),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw
Quoted 10 lines · Christian König

Am 15.01.20 um 08:48 schrieb Huang Rui:

Quoted 6 lines · Christian
Quoted 4 lines

Am 15.01.20 um 08:07 schrieb Huang Rui:

Quoted 1 line

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

Quoted 30 lines

Christian.

Quoted 27 lines

Thanks,
Ray

Quoted 23 lines

Christian.

Quoted 21 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++++---
   1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +4 -3
index f39012e..a03eead 100644
@@ -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);
 
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data, · line 270

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
    r = amdgpu_gem_object_create(adev, size, args->in.alignment,
                                 (u32)(0xffffffff & args->in.domains),

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx