intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1
@ 2021-01-20 11:11 Chris Wilson
  2021-01-20 11:11 ` [Intel-gfx] [PATCH i-g-t 2/2] i915/gem_create: Exercise an impossible allocation Chris Wilson
  2021-01-20 11:56 ` [Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1 Matthew Auld
  0 siblings, 2 replies; 4+ messages in thread
From: Chris Wilson @ 2021-01-20 11:11 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, matthew.auld, Chris Wilson

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

Signed-off-by: Chris Wilson <chris@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

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

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

* [Intel-gfx] [PATCH i-g-t 2/2] i915/gem_create: Exercise an impossible allocation
  2021-01-20 11:11 [Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1 Chris Wilson
@ 2021-01-20 11:11 ` Chris Wilson
  2021-01-20 11:58   ` Matthew Auld
  2021-01-20 11:56 ` [Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1 Matthew Auld
  1 sibling, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2021-01-20 11:11 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, matthew.auld, Chris Wilson

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@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

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

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

* Re: [Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1
  2021-01-20 11:11 [Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1 Chris Wilson
  2021-01-20 11:11 ` [Intel-gfx] [PATCH i-g-t 2/2] i915/gem_create: Exercise an impossible allocation Chris Wilson
@ 2021-01-20 11:56 ` Matthew Auld
  1 sibling, 0 replies; 4+ messages in thread
From: Matthew Auld @ 2021-01-20 11:56 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, Intel Graphics Development, Matthew Auld

On Wed, 20 Jan 2021 at 11:11, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Check that we correctly reject an object size that will intentionally
> wrap upon aligning to a page.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [Intel-gfx] [PATCH i-g-t 2/2] i915/gem_create: Exercise an impossible allocation
  2021-01-20 11:11 ` [Intel-gfx] [PATCH i-g-t 2/2] i915/gem_create: Exercise an impossible allocation Chris Wilson
@ 2021-01-20 11:58   ` Matthew Auld
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Auld @ 2021-01-20 11:58 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev, Intel Graphics Development, Matthew Auld

On Wed, 20 Jan 2021 at 11:11, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> 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@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2021-01-20 11:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 11:11 [Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1 Chris Wilson
2021-01-20 11:11 ` [Intel-gfx] [PATCH i-g-t 2/2] i915/gem_create: Exercise an impossible allocation Chris Wilson
2021-01-20 11:58   ` Matthew Auld
2021-01-20 11:56 ` [Intel-gfx] [PATCH i-g-t 1/2] i915/gem_create: Check wrap condition for -1 Matthew Auld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).