Skip to contentSkip to conversation

aubdump: Don't bail if a GEM handle of 0 is passed into execbuf

PATCH In review Jason Ekstrand 2 participants 3 messages Mar 24, 2017 – Apr 14, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aubdump: Don't bail if a GEM handle of 0 is passed into execbuf

A gem handle of 0 can be used to check for whether or not 48-bit addressing is available. This keeps aubdump from failing on you if you try to do the check.

---
 tools/aubdump.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/aubdump.c +2 -3
index 8a89b8c..3aca7eb 100644
@@ -131,7 +131,6 @@ get_bo(uint32_t handle)
 
 	fail_if(handle >= MAX_BO_COUNT, "bo handle too large\n");
 	bo = &bos[handle];
-	fail_if(bo->size == 0, "invalid bo handle (%d) in execbuf\n", handle);
 
 	return bo;
 }
@@ -442,7 +441,7 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
 			offset = align_u32(offset + bo->size + 4095, 4096);
 		}
 
-		if (bo->map == NULL)
+		if (bo->map == NULL && bo->size > 0)
 			bo->map = gem_mmap(fd, obj->handle, 0, bo->size);
 		fail_if(bo->map == MAP_FAILED, "intel_aubdump: bo mmap failed\n");
 	}
@@ -583,7 +582,7 @@ maybe_init(void)
 	}
 	fclose(config);
 
-	bos = malloc(MAX_BO_COUNT * sizeof(bos[0]));
+	bos = calloc(MAX_BO_COUNT, sizeof(bos[0]));
 	fail_if(bos == NULL, "intel_aubdump: out of memory\n");
 }
 
Signature · 6 lines
2.5.0.400.gff86faf

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw

Patch is

Quoted 44 lines · Jason Ekstrand

A gem handle of 0 can be used to check for whether or not 48-bit addressing is available. This keeps aubdump from failing on you if you try to do the check.

---
 tools/aubdump.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/aubdump.c +2 -3
index 8a89b8c..3aca7eb 100644
@@ -131,7 +131,6 @@ get_bo(uint32_t handle)
 
 	fail_if(handle >= MAX_BO_COUNT, "bo handle too large\n");
 	bo = &bos[handle];
-	fail_if(bo->size == 0, "invalid bo handle (%d) in execbuf\n", handle);
 
 	return bo;
 }
@@ -442,7 +441,7 @@ dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)
 			offset = align_u32(offset + bo->size + 4095, 4096);
 		}
 
-		if (bo->map == NULL)
+		if (bo->map == NULL && bo->size > 0)
 			bo->map = gem_mmap(fd, obj->handle, 0, bo->size);
 		fail_if(bo->map == MAP_FAILED, "intel_aubdump: bo mmap failed\n");
 	}
@@ -583,7 +582,7 @@ maybe_init(void)
 	}
 	fclose(config);
 
-	bos = malloc(MAX_BO_COUNT * sizeof(bos[0]));
+	bos = calloc(MAX_BO_COUNT, sizeof(bos[0]));
 	fail_if(bos == NULL, "intel_aubdump: out of memory\n");
 }
 
Signature · 6 lines
2.5.0.400.gff86faf

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

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

#2 lore raw
Quoted 3 lines · Rafael Antognolli

Patch is

Thanks! Pushed.

Quoted 41 lines · Jason Ekstrand
Quoted 12 lines

A gem handle of 0 can be used to check for whether or not 48-bit addressing is available. This keeps aubdump from failing on you if you try to do the check.

---
 tools/aubdump.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/aubdump.c +0 -0
index 8a89b8c..3aca7eb 100644

tools/aubdump.c get_bo(uint32_t handle) · line 134

Quoted 4 lines
tools/aubdump.c +0 -1
@@ -131,7 +131,6 @@ get_bo(uint32_t handle)
 
      fail_if(handle >= MAX_BO_COUNT, "bo handle too large\n");
      bo = &bos[handle];
-     fail_if(bo->size == 0, "invalid bo handle (%d) in execbuf\n",

handle);

tools/aubdump.c dump_execbuffer2(int fd, struct

Quoted 4 lines
tools/aubdump.c +0 -0
      return bo;
 }
@@ -442,7 +441,7 @@ dump_execbuffer2(int fd, struct

drm_i915_gem_execbuffer2 *execbuffer2)

tools/aubdump.c dump_execbuffer2(int fd, struct drm_i915_gem_execbuffer2 *execbuffer2)

Quoted 7 lines
tools/aubdump.c +1 -1
                      offset = align_u32(offset + bo->size + 4095, 4096);
              }
 
-             if (bo->map == NULL)
+             if (bo->map == NULL && bo->size > 0)
                      bo->map = gem_mmap(fd, obj->handle, 0, bo->size);
              fail_if(bo->map == MAP_FAILED, "intel_aubdump: bo mmap

failed\n");

Quoted 10 lines
tools/aubdump.c +1 -1
      }
@@ -583,7 +582,7 @@ maybe_init(void)
      }
      fclose(config);
 
-     bos = malloc(MAX_BO_COUNT * sizeof(bos[0]));
+     bos = calloc(MAX_BO_COUNT, sizeof(bos[0]));
      fail_if(bos == NULL, "intel_aubdump: out of memory\n");
 }
 
Quoted 8 lines
Quoted 7 lines

--
2.5.0.400.gff86faf

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

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