[igt-dev] [PATCH i-g-t] i915/gem_create: Verify that all new objects are clear

Chris Wilson chris at chris-wilson.co.uk
Thu Feb 14 16:59:00 UTC 2019


The kernel must not return stale information back to userspace when they
create a new object. For that purpose, we always clear objects on
creation, so verify that this is so.

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

diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
index 25c5e8088..9d1a4af4f 100644
--- a/tests/i915/gem_create.c
+++ b/tests/i915/gem_create.c
@@ -141,6 +141,32 @@ static void invalid_nonaligned_size(int fd)
 	gem_close(fd, handle);
 }
 
+static void always_clear(int i915, int timeout)
+{
+	uint64_t max = intel_get_avail_ram_mb() << (20 - 12); /* in pages */
+
+	igt_until_timeout(timeout) {
+		uint64_t npages;
+		uint32_t handle;
+
+		npages = random();
+		npages <<= 32;
+		npages |= random();
+		npages %= max;
+
+		handle = gem_create(i915, npages << 12);
+		for (uint64_t page = 0; page < npages; page++) {
+			uint64_t x;
+
+			gem_read(i915, handle,
+				 page % (4096 - sizeof(x)),
+				 &x, sizeof(x));
+			igt_assert_eq_u64(x, 0);
+		}
+		gem_close(i915, handle);
+	}
+}
+
 igt_main
 {
 	int fd = -1;
@@ -162,4 +188,7 @@ igt_main
 
 	igt_subtest("create-invalid-nonaligned")
 		invalid_nonaligned_size(fd);
+
+	igt_subtest("create-clear")
+		always_clear(fd, 30);
 }
-- 
2.20.1



More information about the igt-dev mailing list