public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] i915/gem_userptr_blits: Check for allowed GTT mmaps
@ 2019-10-01 17:49 Chris Wilson
  2019-10-01 19:21 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Chris Wilson @ 2019-10-01 17:49 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, Tvrtko Ursulin

Having decided to close the GTT mmap of userptr objects loophole in the
kernel, we need to adjust the test suite to avoid tripping over GTT
mmaps when required.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/i915/gem_userptr_blits.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 3fad7d1b3..3f5edaeab 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -69,11 +69,33 @@
 
 static uint32_t userptr_flags = LOCAL_I915_USERPTR_UNSYNCHRONIZED;
 
+static bool can_gtt_mmap;
+
 #define WIDTH 512
 #define HEIGHT 512
 
 static uint32_t linear[WIDTH*HEIGHT];
 
+static bool has_gtt_mmap(int i915)
+{
+	void *ptr, *map;
+	uint32_t handle;
+
+	igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0);
+
+	gem_userptr(i915, ptr, 4096, 0, 0, &handle);
+	igt_assert(handle != 0);
+
+	map = __gem_mmap__gtt(i915, handle, 4096, PROT_WRITE);
+	if (map)
+		munmap(map, 4096);
+
+	gem_close(i915, handle);
+	free(ptr);
+
+	return map != NULL;
+}
+
 static void gem_userptr_test_unsynchronized(void)
 {
 	userptr_flags = LOCAL_I915_USERPTR_UNSYNCHRONIZED;
@@ -853,7 +875,7 @@ static void *umap(int fd, uint32_t handle)
 {
 	void *ptr;
 
-	if (gem_has_llc(fd)) {
+	if (can_gtt_mmap) {
 		ptr = gem_mmap__gtt(fd, handle, sizeof(linear),
 				    PROT_READ | PROT_WRITE);
 	} else {
@@ -884,7 +906,7 @@ check_bo(int fd1, uint32_t handle1, int is_userptr, int fd2, uint32_t handle2)
 	sigbus_start = (unsigned long)ptr2;
 	igt_assert(memcmp(ptr1, ptr2, sizeof(linear)) == 0);
 
-	if (gem_has_llc(fd1)) {
+	if (can_gtt_mmap) {
 		counter++;
 		memset(ptr1, counter, size);
 		memset(ptr2, counter, size);
@@ -971,7 +993,7 @@ static int test_dmabuf(void)
 	free_userptr_bo(fd1, handle);
 	close(fd1);
 
-	if (gem_has_llc(fd2)) {
+	if (can_gtt_mmap) {
 		struct sigaction sigact, orig_sigact;
 
 		memset(&sigact, 0, sizeof(sigact));
@@ -1225,7 +1247,7 @@ static void test_readonly_mmap(int i915)
 	original = g_compute_checksum_for_data(G_CHECKSUM_SHA1, pages, sz);
 
 	ptr = __gem_mmap__gtt(i915, handle, sz, PROT_WRITE);
-	igt_assert(ptr == NULL);
+	igt_require(ptr != NULL);
 
 	ptr = gem_mmap__gtt(i915, handle, sz, PROT_READ);
 	gem_close(i915, handle);
@@ -1834,6 +1856,8 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL)
 		igt_require_gem(fd);
 		gem_require_blitter(fd);
 
+		can_gtt_mmap = has_gtt_mmap(fd) && gem_has_llc(fd);
+
 		size = sizeof(linear);
 
 		aperture_size = gem_aperture_size(fd);
-- 
2.23.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

end of thread, other threads:[~2019-10-02 13:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-01 17:49 [igt-dev] [PATCH i-g-t] i915/gem_userptr_blits: Check for allowed GTT mmaps Chris Wilson
2019-10-01 19:21 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-10-02  5:05 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2019-10-02  8:42 ` [igt-dev] [PATCH i-g-t] " Tvrtko Ursulin
2019-10-02  8:47   ` Chris Wilson
2019-10-02  8:50 ` [Intel-gfx] [PATCH i-g-t v2] " Chris Wilson
2019-10-02  9:18   ` [igt-dev] " Tvrtko Ursulin
2019-10-02  9:40 ` [igt-dev] ✓ Fi.CI.BAT: success for i915/gem_userptr_blits: Check for allowed GTT mmaps (rev2) Patchwork
2019-10-02 13:51 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox