[igt-dev] [PATCH] i915/gem_exec_params: add test_invalid_batch_start

Matthew Auld matthew.auld at intel.com
Wed Mar 4 20:52:43 UTC 2020


Sanity check that kernel rejects too large batch_start_offset.

Signed-off-by: Matthew Auld <matthew.auld at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/gem_exec_params.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/i915/gem_exec_params.c b/tests/i915/gem_exec_params.c
index cf7ea306..afc8d2c7 100644
--- a/tests/i915/gem_exec_params.c
+++ b/tests/i915/gem_exec_params.c
@@ -268,6 +268,23 @@ static void mmapped(int i915)
 	gem_close(i915, buf);
 }
 
+static void test_invalid_batch_start(int fd)
+{
+	struct drm_i915_gem_exec_object2 exec = {
+		.handle = batch_create(fd),
+	};
+	struct drm_i915_gem_execbuffer2 execbuf = {
+		.buffers_ptr = to_user_pointer(&exec),
+		.buffer_count = 1,
+		.batch_start_offset = 4096, /* space jump */
+	};
+
+	igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL);
+
+	gem_sync(fd, exec.handle);
+	gem_close(fd, exec.handle);
+}
+
 struct drm_i915_gem_execbuffer2 execbuf;
 struct drm_i915_gem_exec_object2 gem_exec[1];
 uint32_t batch[2] = {MI_BATCH_BUFFER_END};
@@ -507,6 +524,9 @@ igt_main
 	igt_subtest("batch-first")
 		test_batch_first(fd);
 
+	igt_subtest("invalid-batch-start-offset")
+		test_invalid_batch_start(fd);
+
 #define DIRT(name) \
 	igt_subtest(#name "-dirt") { \
 		execbuf.flags = 0; \
-- 
2.20.1



More information about the igt-dev mailing list