[Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1

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


Check that we correctly reject an object size that will intentionally
wrap upon aligning to a page.

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

diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
index bf6531844..432ccdefa 100644
--- a/tests/i915/gem_create.c
+++ b/tests/i915/gem_create.c
@@ -79,11 +79,15 @@ static int create_ioctl(int fd, struct drm_i915_gem_create *create)
 
 static void invalid_size_test(int fd)
 {
-	struct drm_i915_gem_create create = {
-		.size = 0,
-	};
+	struct drm_i915_gem_create create = { };
 
+	create.size = 0; /* zero-sized objects are not allowed */
 	igt_assert_eq(create_ioctl(fd, &create), -EINVAL);
+
+	create.size = -1ull; /* will wrap to 0 on aligning to page */
+	igt_assert_eq(create_ioctl(fd, &create), -EINVAL);
+
+	igt_assert_eq(create.handle, 0);
 }
 
 /*
-- 
2.30.0



More information about the Intel-gfx mailing list