All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH v2] i915/gem_exec_params: add test_invalid_batch
@ 2020-03-05 20:53 ` Matthew Auld
  0 siblings, 0 replies; 6+ messages in thread
From: Matthew Auld @ 2020-03-05 20:53 UTC (permalink / raw)
  To: igt-dev; +Cc: intel-gfx

Sanity check that kernel rejects invalid batch_start_offset and
batch_len.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/gem_exec_params.c | 47 ++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/tests/i915/gem_exec_params.c b/tests/i915/gem_exec_params.c
index cf7ea306..45581738 100644
--- a/tests/i915/gem_exec_params.c
+++ b/tests/i915/gem_exec_params.c
@@ -268,6 +268,50 @@ static void mmapped(int i915)
 	gem_close(i915, buf);
 }
 
+static uint32_t batch_create_size(int fd, uint32_t size)
+{
+	const uint32_t bbe = MI_BATCH_BUFFER_END;
+	uint32_t handle;
+
+	handle = gem_create(fd, size);
+	gem_write(fd, handle, 0, &bbe, sizeof(bbe));
+
+	return handle;
+}
+
+static void __invalid_batch_start(int fd,
+				  struct drm_i915_gem_execbuffer2 *execbuf,
+				  uint32_t start_offset,
+				  uint32_t batch_len)
+{
+	execbuf->batch_start_offset = start_offset;
+	execbuf->batch_len = batch_len;
+	igt_assert_eq(__gem_execbuf(fd, execbuf), -EINVAL);
+}
+
+static void test_invalid_batch_start(int fd)
+{
+	uint32_t size = 4096;
+	struct drm_i915_gem_exec_object2 exec = {
+		.handle = batch_create_size(fd, size),
+	};
+	struct drm_i915_gem_execbuffer2 execbuf = {
+		.buffers_ptr = to_user_pointer(&exec),
+		.buffer_count = 1,
+	};
+
+	__invalid_batch_start(fd, &execbuf, 0, -1);
+	__invalid_batch_start(fd, &execbuf, -1, 0);
+	__invalid_batch_start(fd, &execbuf, -1, -1);
+	__invalid_batch_start(fd, &execbuf, -1U & ~0x7, 0);
+	__invalid_batch_start(fd, &execbuf, 0, -1U & ~0x7);
+	__invalid_batch_start(fd, &execbuf, size, 0);
+	__invalid_batch_start(fd, &execbuf, size, size);
+
+	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 +551,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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-06 13:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-05 20:53 [Intel-gfx] [PATCH v2] i915/gem_exec_params: add test_invalid_batch Matthew Auld
2020-03-05 20:53 ` [igt-dev] " Matthew Auld
2020-03-05 21:12 ` [igt-dev] ✗ GitLab.Pipeline: failure for " Patchwork
2020-03-05 21:21 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2020-03-06  6:37 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure " Patchwork
2020-03-06 13:08 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.