[Mesa-dev] [PATCH v2 3/3] i965: if DEBUG_OUT_OF_BOUND_CHK is up, check that noise padding for each bo used in batchbuffer is correct

kevin.rogovin at intel.com kevin.rogovin at intel.com
Wed Dec 13 10:18:38 UTC 2017


From: Kevin Rogovin <kevin.rogovin at intel.com>

v2:
 Comments indicating that brw_bo_padding_is_good() will do the required
 waiting for GPU commands to finish

Signed-off-by: Kevin Rogovin <kevin.rogovin at intel.com>
---
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 91a6506a89..689ae2362a 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -758,6 +758,7 @@ execbuffer(int fd,
    };
 
    unsigned long cmd = DRM_IOCTL_I915_GEM_EXECBUFFER2;
+   bool detected_out_of_bounds_write = false;
 
    if (in_fence != -1) {
       execbuf.rsvd2 = in_fence;
@@ -787,6 +788,24 @@ execbuffer(int fd,
              batch->validation_list[i].offset);
          bo->gtt_offset = batch->validation_list[i].offset;
       }
+
+      if (unlikely(INTEL_DEBUG & DEBUG_OUT_OF_BOUND_CHK)) {
+         /* brw_bo_padding_is_good() performs the necessary
+          * syncing itself to make sure that the padding read
+          * is correct.
+          */
+         if (!brw_bo_padding_is_good(bo)) {
+            detected_out_of_bounds_write = true;
+            fprintf(stderr,
+                    "Detected buffer out-of-bounds write from brw_bo %p "
+                    "(GEM %u, label = \"%s\")\n",
+                    bo, bo->gem_handle, bo->name);
+         }
+      }
+   }
+
+   if (unlikely(detected_out_of_bounds_write)) {
+      abort();
    }
 
    if (ret == 0 && out_fence != NULL)
-- 
2.15.0



More information about the mesa-dev mailing list