Skip to contentSkip to conversation

drm/amdgpu: Add a GEM_CREATE mask and bugfix

PATCH In review Luben Tuikov 5 participants 9 messages Feb 15, 2020 – Feb 19, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Add a GEM_CREATE mask and bugfix

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
 include/uapi/drm/amdgpu_drm.h           |  2 ++
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -9
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
 	int r;
 
 	/* reject invalid gem flags */
-	if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-		      AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-		      AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-		      AMDGPU_GEM_CREATE_VRAM_CLEARED |
-		      AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-		      AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-		      AMDGPU_GEM_CREATE_ENCRYPTED))
-
+	if (flags & ~AMDGPU_GEM_CREATE_MASK)
 		return -EINVAL;
 
 	/* reject invalid gem domains */
 	if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
 		return -EINVAL;
 
-	if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
+	if (!amdgpu_is_tmz(adev) && flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
 		DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
 		return -EINVAL;
 	}
include/uapi/drm/amdgpu_drm.h +2 -0
index eaf94a421901..c8463cdf4448 100644
@@ -141,6 +141,8 @@ extern "C" {
  */
 #define AMDGPU_GEM_CREATE_ENCRYPTED		(1 << 10)
 
+#define AMDGPU_GEM_CREATE_MASK                  ((1 << 11)-1)
+
 struct drm_amdgpu_gem_create_in  {
 	/** the requested memory size */
 	__u64 bo_size;
Signature · 6 lines
2.25.0.232.gd8437c57fa

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw
Quoted 20 lines · Luben Tuikov

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
 include/uapi/drm/amdgpu_drm.h           |  2 ++
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
        int r;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -8
 
        /* reject invalid gem flags */
-       if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-                     AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-                     AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-                     AMDGPU_GEM_CREATE_VRAM_CLEARED |
-                     AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-                     AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-                     AMDGPU_GEM_CREATE_ENCRYPTED))
-

I'd rather keep the list explicit so no one ends up forgetting to update the mask the next time new flags are added.

Alex

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -1
+       if (flags & ~AMDGPU_GEM_CREATE_MASK)
                return -EINVAL;
 
        /* reject invalid gem domains */
        if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
                return -EINVAL;
 
-       if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
+       if (!amdgpu_is_tmz(adev) && flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
                DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
                return -EINVAL;
        }
include/uapi/drm/amdgpu_drm.h +2 -1
index eaf94a421901..c8463cdf4448 100644
@@ -141,6 +141,8 @@ extern "C" {
  */
 #define AMDGPU_GEM_CREATE_ENCRYPTED            (1 << 10)
 
+#define AMDGPU_GEM_CREATE_MASK                  ((1 << 11)-1)
+
 struct drm_amdgpu_gem_create_in  {
        /** the requested memory size */
        __u64 bo_size;
--

2.25.0.232.gd8437c57fa

Quoted 4 lines

_______________________________________________
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

#2 lore raw

Am 17.02.20 um 15:44 schrieb Alex Deucher:

Quoted 21 lines · Luben Tuikov
Quoted 20 lines

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
  include/uapi/drm/amdgpu_drm.h           |  2 ++
  2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
         int r;
 
Quoted 11 lines

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

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -8
         /* reject invalid gem flags */
-       if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-                     AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-                     AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-                     AMDGPU_GEM_CREATE_VRAM_CLEARED |
-                     AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-                     AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-                     AMDGPU_GEM_CREATE_ENCRYPTED))
-

I'd rather keep the list explicit so no one ends up forgetting to update the mask the next time new flags are added.

Additional to that this patch is bogus.

We intentionally filter out the flags here which userspace is allowed to specify in the GEM interface, but after this patch we would allow all flags to be specified.

Christian.

Quoted 31 lines

Alex

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -1
+       if (flags & ~AMDGPU_GEM_CREATE_MASK)
                 return -EINVAL;
 
         /* reject invalid gem domains */
         if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
                 return -EINVAL;
 
-       if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
+       if (!amdgpu_is_tmz(adev) && flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
                 DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
                 return -EINVAL;
         }
include/uapi/drm/amdgpu_drm.h +2 -1
index eaf94a421901..c8463cdf4448 100644
@@ -141,6 +141,8 @@ extern "C" {
   */
  #define AMDGPU_GEM_CREATE_ENCRYPTED            (1 << 10)
 
+#define AMDGPU_GEM_CREATE_MASK                  ((1 << 11)-1)
+
  struct drm_amdgpu_gem_create_in  {
         /** the requested memory size */
         __u64 bo_size;
--

2.25.0.232.gd8437c57fa

Quoted 8 lines
Quoted 4 lines

_______________________________________________
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

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

#3 lore raw
Quoted 34 lines · Christian König

Am 17.02.20 um 15:44 schrieb Alex Deucher:

Quoted 21 lines · Luben Tuikov
Quoted 20 lines

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
  include/uapi/drm/amdgpu_drm.h           |  2 ++
  2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
         int r;
 
Quoted 11 lines

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

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -8
         /* reject invalid gem flags */
-       if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-                     AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-                     AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-                     AMDGPU_GEM_CREATE_VRAM_CLEARED |
-                     AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-                     AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-                     AMDGPU_GEM_CREATE_ENCRYPTED))
-

I'd rather keep the list explicit so no one ends up forgetting to update the mask the next time new flags are added.

Quoted 1 line

Additional to that this patch is bogus.

So the only "additional" thing you're contributing to the review of this patch is calling it "bogus". Characterizing the patch with an adjective as "bogus" is very disturbing. What's next?

Quoted 4 lines

We intentionally filter out the flags here which userspace is allowed to specify in the GEM interface, but after this patch we would allow all flags to be specified.

I thought that that could be the case. But in your review why not recommend we have a mask to check user-settable flags? So the actual flags are collected and visible in one place and well understood that that is what is being checked and well-defined by a macro with an appropriate name?

Why did NO ONE comment on the bug fix below? No one.

Regards,
Luben

Quoted 45 lines

Christian.

Quoted 39 lines

Alex

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -1
+       if (flags & ~AMDGPU_GEM_CREATE_MASK)
                 return -EINVAL;
 
         /* reject invalid gem domains */
         if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
                 return -EINVAL;
 
-       if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
+       if (!amdgpu_is_tmz(adev) && flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
                 DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
                 return -EINVAL;
         }
include/uapi/drm/amdgpu_drm.h +2 -1
index eaf94a421901..c8463cdf4448 100644
@@ -141,6 +141,8 @@ extern "C" {
   */
  #define AMDGPU_GEM_CREATE_ENCRYPTED            (1 << 10)
 
+#define AMDGPU_GEM_CREATE_MASK                  ((1 << 11)-1)
+
  struct drm_amdgpu_gem_create_in  {
         /** the requested memory size */
         __u64 bo_size;
--

2.25.0.232.gd8437c57fa

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7Cb1fdc3970a224fc61fdc08d7b3bb4613%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175489240077250&amp;sdata=rE8A6jKAIX081ZhxxcMc%2BpGdXvsLUdrAW4AkLsTpNxg%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7Cb1fdc3970a224fc61fdc08d7b3bb4613%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175489240077250&amp;sdata=rE8A6jKAIX081ZhxxcMc%2BpGdXvsLUdrAW4AkLsTpNxg%3D&amp;reserved=0

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

maintainer
#4 lore raw

Am 18.02.20 um 22:46 schrieb Luben Tuikov:

Quoted 34 lines · Christian König
Quoted 33 lines

Am 17.02.20 um 15:44 schrieb Alex Deucher:

Quoted 32 lines · Luben Tuikov
Quoted 19 lines

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
   include/uapi/drm/amdgpu_drm.h           |  2 ++
   2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
          int r;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -8
 
          /* reject invalid gem flags */
-       if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-                     AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-                     AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-                     AMDGPU_GEM_CREATE_VRAM_CLEARED |
-                     AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-                     AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-                     AMDGPU_GEM_CREATE_ENCRYPTED))
-

I'd rather keep the list explicit so no one ends up forgetting to update the mask the next time new flags are added.

Quoted 4 lines
Quoted 1 line

Additional to that this patch is bogus.

So the only "additional" thing you're contributing to the review of this patch is calling it "bogus". Characterizing the patch with an adjective as "bogus" is very disturbing. What's next?

Well the patch is technical incorrect and breaks the code in a very subtle and hard to detect manner. Alex didn't noticed that either.

I'm not a native speaker of English, but as far as I have learned "bogus" is the right adjective for that.

Quoted 4 lines
Quoted 3 lines

We intentionally filter out the flags here which userspace is allowed to specify in the GEM interface, but after this patch we would allow all flags to be specified.

I thought that that could be the case.

Then why did you send out a patch which is seriously broken like that?

I mean if I hadn't noticed it by chance we would have committed this and added a potentially security problematic bug to the IOCTL interface.

Quoted 5 lines

But in your review why not
recommend we have a mask to check user-settable flags? So the actual flags are collected and visible in one place and well understood that that is what is being checked and well-defined by a macro with an appropriate name?

See the flags tested here are the flags currently accepted by the amdgpu_gem_create_ioctl() function. It doesn't say anything about what the kernel would accept in the future.

So when we move that into the UAPI header we give userspace a technically incorrect value.

Quoted 1 line

Why did NO ONE comment on the bug fix below? No one.

Because you mixed up a style change into some bug fix. That people go for the problematic parts during code review is not really surprising at all.

Regards,
Christian.

Quoted 46 lines

Regards,
Luben

Quoted 42 lines

Christian.

Quoted 38 lines

Alex

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -1
+       if (flags & ~AMDGPU_GEM_CREATE_MASK)
                  return -EINVAL;
 
          /* reject invalid gem domains */
          if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
                  return -EINVAL;
 
-       if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
+       if (!amdgpu_is_tmz(adev) && flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
                  DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
                  return -EINVAL;
          }
include/uapi/drm/amdgpu_drm.h +2 -1
index eaf94a421901..c8463cdf4448 100644
@@ -141,6 +141,8 @@ extern "C" {
    */
   #define AMDGPU_GEM_CREATE_ENCRYPTED            (1 << 10)
 
+#define AMDGPU_GEM_CREATE_MASK                  ((1 << 11)-1)
+
   struct drm_amdgpu_gem_create_in  {
          /** the requested memory size */
          __u64 bo_size;
--

2.25.0.232.gd8437c57fa

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7Cb1fdc3970a224fc61fdc08d7b3bb4613%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175489240077250&amp;sdata=rE8A6jKAIX081ZhxxcMc%2BpGdXvsLUdrAW4AkLsTpNxg%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7Cb1fdc3970a224fc61fdc08d7b3bb4613%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175489240077250&amp;sdata=rE8A6jKAIX081ZhxxcMc%2BpGdXvsLUdrAW4AkLsTpNxg%3D&amp;reserved=0

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

#5 lore raw
Quoted 66 lines · Christian König

Am 18.02.20 um 22:46 schrieb Luben Tuikov:

Quoted 34 lines · Christian König
Quoted 33 lines

Am 17.02.20 um 15:44 schrieb Alex Deucher:

Quoted 32 lines · Luben Tuikov
Quoted 19 lines

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
   include/uapi/drm/amdgpu_drm.h           |  2 ++
   2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
          int r;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -8
 
          /* reject invalid gem flags */
-       if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-                     AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-                     AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-                     AMDGPU_GEM_CREATE_VRAM_CLEARED |
-                     AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-                     AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-                     AMDGPU_GEM_CREATE_ENCRYPTED))
-

I'd rather keep the list explicit so no one ends up forgetting to update the mask the next time new flags are added.

Quoted 4 lines
Quoted 1 line

Additional to that this patch is bogus.

So the only "additional" thing you're contributing to the review of this patch is calling it "bogus". Characterizing the patch with an adjective as "bogus" is very disturbing. What's next?

Well the patch is technical incorrect and breaks the code in a very subtle and hard to detect manner. Alex didn't noticed that either.

I'm not a native speaker of English, but as far as I have learned "bogus" is the right adjective for that.

Quoted 4 lines
Quoted 3 lines

We intentionally filter out the flags here which userspace is allowed to specify in the GEM interface, but after this patch we would allow all flags to be specified.

I thought that that could be the case.

Then why did you send out a patch which is seriously broken like that?

I mean if I hadn't noticed it by chance we would have committed this and added a potentially security problematic bug to the IOCTL interface.

Quoted 5 lines

But in your review why not
recommend we have a mask to check user-settable flags? So the actual flags are collected and visible in one place and well understood that that is what is being checked and well-defined by a macro with an appropriate name?

See the flags tested here are the flags currently accepted by the amdgpu_gem_create_ioctl() function. It doesn't say anything about what the kernel would accept in the future.

Quoted 8 lines

So when we move that into the UAPI header we give userspace a technically incorrect value.

Quoted 1 line

Why did NO ONE comment on the bug fix below? No one.

Because you mixed up a style change into some bug fix. That people go for the problematic parts during code review is not really surprising at all.

I wouldn't have expected a petulant-childlike response.
I would've expected a leadership-like position, something like:
Split your patch into two. The second part is okay with the addition of DRM_PRINT_ONCE, and the first part admits bits which we don't want user space to control.

Regards,
Luben

Quoted 51 lines

Regards,
Christian.

Quoted 46 lines

Regards,
Luben

Quoted 42 lines

Christian.

Quoted 38 lines

Alex

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -1
+       if (flags & ~AMDGPU_GEM_CREATE_MASK)
                  return -EINVAL;
 
          /* reject invalid gem domains */
          if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
                  return -EINVAL;
 
-       if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
+       if (!amdgpu_is_tmz(adev) && flags & AMDGPU_GEM_CREATE_ENCRYPTED) {
                  DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
                  return -EINVAL;
          }
include/uapi/drm/amdgpu_drm.h +2 -1
index eaf94a421901..c8463cdf4448 100644
@@ -141,6 +141,8 @@ extern "C" {
    */
   #define AMDGPU_GEM_CREATE_ENCRYPTED            (1 << 10)
 
+#define AMDGPU_GEM_CREATE_MASK                  ((1 << 11)-1)
+
   struct drm_amdgpu_gem_create_in  {
          /** the requested memory size */
          __u64 bo_size;
--

2.25.0.232.gd8437c57fa

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7Cb1fdc3970a224fc61fdc08d7b3bb4613%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175489240077250&amp;sdata=rE8A6jKAIX081ZhxxcMc%2BpGdXvsLUdrAW4AkLsTpNxg%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7Cb1fdc3970a224fc61fdc08d7b3bb4613%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175489240077250&amp;sdata=rE8A6jKAIX081ZhxxcMc%2BpGdXvsLUdrAW4AkLsTpNxg%3D&amp;reserved=0

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

#6 lore raw
In reply to Luben Tuikov
Quoted 46 lines · Luben Tuikov
Quoted 34 lines · Christian König

Am 17.02.20 um 15:44 schrieb Alex Deucher:

Quoted 21 lines · Luben Tuikov
Quoted 20 lines

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
  include/uapi/drm/amdgpu_drm.h           |  2 ++
  2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
         int r;
 
Quoted 11 lines

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

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -8
         /* reject invalid gem flags */
-       if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-                     AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-                     AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-                     AMDGPU_GEM_CREATE_VRAM_CLEARED |
-                     AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-                     AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-                     AMDGPU_GEM_CREATE_ENCRYPTED))
-

I'd rather keep the list explicit so no one ends up forgetting to update the mask the next time new flags are added.

Quoted 1 line

Additional to that this patch is bogus.

So the only "additional" thing you're contributing to the review of this patch is calling it "bogus". Characterizing the patch with an adjective as "bogus" is very disturbing. What's next?

Quoted 4 lines

We intentionally filter out the flags here which userspace is allowed to specify in the GEM interface, but after this patch we would allow all flags to be specified.

Quoted 8 lines

I thought that that could be the case. But in your review why not recommend we have a mask to check user-settable flags? So the actual flags are collected and visible in one place and well understood that that is what is being checked and well-defined by a macro with an appropriate name?

Why did NO ONE comment on the bug fix below? No one.

I missed the bugfix patch before, sorry. (There are many patches from amd-gfx one day, if you didn't cc me, the mail may be missed). So I found the issue after sync up with drm-next and then give the fix. Hope you can understand and don't take it to heart.

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

#7 lore raw
In reply to Alex Deucher
Quoted 35 lines · Alex Deucher
Quoted 20 lines · Luben Tuikov

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
 include/uapi/drm/amdgpu_drm.h           |  2 ++
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
        int r;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -8
 
        /* reject invalid gem flags */
-       if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-                     AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-                     AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-                     AMDGPU_GEM_CREATE_VRAM_CLEARED |
-                     AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-                     AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-                     AMDGPU_GEM_CREATE_ENCRYPTED))
-

I'd rather keep the list explicit so no one ends up forgetting to update the mask the next time new flags are added.

Quoted 1 line

Alex

What about the bugfix below?

Why did no one comment on it?

Quoted 10 lines

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -1
+       if (flags & ~AMDGPU_GEM_CREATE_MASK)
                return -EINVAL;
 
        /* reject invalid gem domains */
        if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
                return -EINVAL;
 
-       if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
+       if (!amdgpu_is_tmz(adev) && flags & AMDGPU_GEM_CREATE_ENCRYPTED) {

This one right here?

What's going on?

Regards,
Luben

Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
                DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
                return -EINVAL;
        }
include/uapi/drm/amdgpu_drm.h +2 -1
index eaf94a421901..c8463cdf4448 100644
@@ -141,6 +141,8 @@ extern "C" {
  */
 #define AMDGPU_GEM_CREATE_ENCRYPTED            (1 << 10)
 
+#define AMDGPU_GEM_CREATE_MASK                  ((1 << 11)-1)
+
 struct drm_amdgpu_gem_create_in  {
        /** the requested memory size */
        __u64 bo_size;
--

2.25.0.232.gd8437c57fa

Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7C622cd0e399a041e8ad4908d7b3b7e97d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175474785178580&amp;sdata=CLlIUaQVOhMibxBtkHtbBZQ9d%2FjNBSRtZ8Db%2FYN2Hj8%3D&amp;reserved=0

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

#8 lore raw
Quoted 51 lines · Luben Tuikov
Quoted 35 lines · Alex Deucher
Quoted 20 lines · Luben Tuikov

Add a AMDGPU_GEM_CREATE_MASK and use it to check
for valid/invalid GEM create flags coming in from
userspace.

Fix a bug in checking whether TMZ is supported at
GEM create time.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 11 ++---------
 include/uapi/drm/amdgpu_drm.h           |  2 ++
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
index b51a060c637d..74bb79e64fa3 100644
@@ -221,21 +221,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
        int r;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -8
 
        /* reject invalid gem flags */
-       if (flags & ~(AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
-                     AMDGPU_GEM_CREATE_NO_CPU_ACCESS |
-                     AMDGPU_GEM_CREATE_CPU_GTT_USWC |
-                     AMDGPU_GEM_CREATE_VRAM_CLEARED |
-                     AMDGPU_GEM_CREATE_VM_ALWAYS_VALID |
-                     AMDGPU_GEM_CREATE_EXPLICIT_SYNC |
-                     AMDGPU_GEM_CREATE_ENCRYPTED))
-

I'd rather keep the list explicit so no one ends up forgetting to update the mask the next time new flags are added.

Quoted 1 line

Alex

What about the bugfix below?

Why did no one comment on it?

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -0
+       if (flags & ~AMDGPU_GEM_CREATE_MASK)
                return -EINVAL;
 
        /* reject invalid gem domains */
        if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
                return -EINVAL;
 
Quoted 6 lines
Quoted 2 lines

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

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -1
-       if (amdgpu_is_tmz(adev) && (flags & AMDGPU_GEM_CREATE_ENCRYPTED)) {
+       if (!amdgpu_is_tmz(adev) && flags & AMDGPU_GEM_CREATE_ENCRYPTED) {

This one right here?

What's going on?

Yes, this bug fix is correct, but the other change in this patch is not. I should have suggested that you split out just the bug fix. I thought you were going to resend just the fix after the feedback on the other portion, but I guess I should have been more explicit.

Alex

Quoted 23 lines

Regards,
Luben

Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0 -0
                DRM_ERROR("Cannot allocate secure buffer since TMZ is disabled\n");
                return -EINVAL;
        }
include/uapi/drm/amdgpu_drm.h +2 -1
index eaf94a421901..c8463cdf4448 100644
@@ -141,6 +141,8 @@ extern "C" {
  */
 #define AMDGPU_GEM_CREATE_ENCRYPTED            (1 << 10)
 
+#define AMDGPU_GEM_CREATE_MASK                  ((1 << 11)-1)
+
 struct drm_amdgpu_gem_create_in  {
        /** the requested memory size */
        __u64 bo_size;
--

2.25.0.232.gd8437c57fa

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cluben.tuikov%40amd.com%7C622cd0e399a041e8ad4908d7b3b7e97d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175474785178580&amp;sdata=CLlIUaQVOhMibxBtkHtbBZQ9d%2FjNBSRtZ8Db%2FYN2Hj8%3D&amp;reserved=0

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