[igt-dev] [PATCH i-g-t 2/2] i915/gem_create: Exercise an impossible allocation

Chris Wilson chris at chris-wilson.co.uk
Wed Jan 20 11:11:15 UTC 2021


The largest processor in the works can support 57b of address space, far
more memory than we can afford to use in CI! It is safe to assume that
we will not have 64b processors for some time, so we can use the top bit
to exercise our oversized object detection.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/gem_create.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
index 432ccdefa..3610b3cda 100644
--- a/tests/i915/gem_create.c
+++ b/tests/i915/gem_create.c
@@ -90,6 +90,17 @@ static void invalid_size_test(int fd)
 	igt_assert_eq(create.handle, 0);
 }
 
+static void massive_test(int fd)
+{
+	struct drm_i915_gem_create create = { };
+
+	/* No system has this much memory... Yet small enough not to wrap */
+	create.size = -1ull << 32;
+	igt_assert_eq(create_ioctl(fd, &create), -E2BIG);
+
+	igt_assert_eq(create.handle, 0);
+}
+
 /*
  * Creating an object with non-aligned size request and assert the buffer is
  * page aligned. And test the write into the padded extra memory.
@@ -289,6 +300,9 @@ igt_main
 	igt_subtest("create-invalid-size")
 		invalid_size_test(fd);
 
+	igt_subtest("create-massive")
+		massive_test(fd);
+
 	igt_subtest("create-valid-nonaligned")
 		valid_nonaligned_size(fd);
 
-- 
2.30.0



More information about the igt-dev mailing list