summaryrefslogtreecommitdiff
path: root/lib/intel_batchbuffer.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-08-29 19:28:34 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-08-29 19:55:30 +0100
commitfbfa754e8dce1553e024310eb7b7ed9469ed238b (patch)
tree5cc357db8f4c39e04f1685974e85553ec40c50cc /lib/intel_batchbuffer.c
parent23d961e950e92bb00c7cb29fa73499af568e7571 (diff)
lib/batchbuffer: Guard intel_blt_copy with even more asserts
Assert that the source/destination bounds are within the pitch and size of the associated bo. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/intel_batchbuffer.c')
-rw-r--r--lib/intel_batchbuffer.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 84c4c538..b4598fbf 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -311,6 +311,20 @@ intel_blt_copy(struct intel_batchbuffer *batch,
uint32_t cmd_bits = 0;
uint32_t br13_bits;
+#define CHECK_RANGE(x) ((x) >= 0 && (x) < (1 << 15))
+ igt_assert(CHECK_RANGE(src_x1) && CHECK_RANGE(src_y1) &&
+ CHECK_RANGE(dst_x1) && CHECK_RANGE(dst_y1) &&
+ CHECK_RANGE(width) && CHECK_RANGE(height) &&
+ CHECK_RANGE(src_x1 + width) && CHECK_RANGE(src_y1 + height)
+ && CHECK_RANGE(dst_x1 + width) && CHECK_RANGE(dst_y1 +
+ height) &&
+ CHECK_RANGE(src_pitch) && CHECK_RANGE(dst_pitch));
+#undef CHECK_RANGE
+ igt_assert(bpp*(src_x1 + width) <= 8*src_pitch);
+ igt_assert(bpp*(dst_x1 + width) <= 8*dst_pitch);
+ igt_assert(src_pitch * (src_y1 + height) <= src_bo->size);
+ igt_assert(dst_pitch * (dst_y1 + height) <= dst_bo->size);
+
drm_intel_bo_get_tiling(src_bo, &src_tiling, &swizzle);
drm_intel_bo_get_tiling(dst_bo, &dst_tiling, &swizzle);
@@ -340,16 +354,6 @@ intel_blt_copy(struct intel_batchbuffer *batch,
igt_fail(1);
}
-#define CHECK_RANGE(x) ((x) >= 0 && (x) < (1 << 15))
- igt_assert(CHECK_RANGE(src_x1) && CHECK_RANGE(src_y1) &&
- CHECK_RANGE(dst_x1) && CHECK_RANGE(dst_y1) &&
- CHECK_RANGE(width) && CHECK_RANGE(height) &&
- CHECK_RANGE(src_x1 + width) && CHECK_RANGE(src_y1 + height)
- && CHECK_RANGE(dst_x1 + width) && CHECK_RANGE(dst_y1 +
- height) &&
- CHECK_RANGE(src_pitch) && CHECK_RANGE(dst_pitch));
-#undef CHECK_RANGE
-
BEGIN_BATCH(gen >= 8 ? 10 : 8);
OUT_BATCH(XY_SRC_COPY_BLT_CMD | cmd_bits |
(gen >= 8 ? 8 : 6));