Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
@ 2025-04-14  8:36 nakshtra.goyal
  2025-04-14 15:41 ` ✓ i915.CI.BAT: success for tests/intel/xe_mmap: Adding igt exercise for RO page (rev2) Patchwork
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: nakshtra.goyal @ 2025-04-14  8:36 UTC (permalink / raw)
  To: igt-dev, ramadevi.gandi; +Cc: dwarakanath.ramadeva

From: Nakshtra Goyal <nakshtra.goyal@intel.com>

Map a memory then make it read-only and verify kernel out for read-only
memory

Signed-off-by: Nakshtra Goyal <nakshtra.goyal@intel.com>
---
 tests/intel/xe_mmap.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tests/intel/xe_mmap.c b/tests/intel/xe_mmap.c
index 5fd641075..649a11544 100644
--- a/tests/intel/xe_mmap.c
+++ b/tests/intel/xe_mmap.c
@@ -338,6 +338,24 @@ static void test_small_bar(int fd)
 	gem_close(fd, bo);
 }
 
+static int
+__xe_query(int fd, struct drm_xe_device_query *q)
+{
+	if (igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, q))
+		return -errno;
+	return 0;
+}
+
+static int
+__xe_query_items(int fd, uint32_t *items, uint32_t n_items)
+{
+	struct drm_xe_device_query q = {
+		.size = n_items,
+		.data = to_user_pointer(items),
+	};
+	return __xe_query(fd, &q);
+}
+
 static void assert_caching(int fd, uint64_t placement, uint32_t flags,
 			   uint16_t cpu_caching, bool fail)
 {
@@ -357,7 +375,16 @@ static void assert_caching(int fd, uint64_t placement, uint32_t flags,
 	map = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, mmo);
 	igt_assert(map != MAP_FAILED);
 	map[0] = 0xdeadbeaf;
+	munmap(map, size);
 	gem_close(fd, handle);
+
+	/* Adding a Read-Only page check exercise */
+	map = mmap(0, size, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+	igt_assert(map != MAP_FAILED);
+	igt_assert_eq(0, mprotect(map, size, PROT_READ));
+	igt_assert_lt(__xe_query_items(fd, map, 1), 0);
+	munmap(map, size);
+
 }
 
 /**
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
@ 2025-04-14  7:45 nakshtra.goyal
  2025-04-14  8:32 ` Dandamudi, Priyanka
  2025-05-12 10:11 ` Jan Maslak
  0 siblings, 2 replies; 10+ messages in thread
From: nakshtra.goyal @ 2025-04-14  7:45 UTC (permalink / raw)
  To: igt-dev, ramadevi.gandi; +Cc: dwarakanath.ramadeva

From: Nakshtra Goyal <nakshtra.goyal@intel.com>

Map a memory then make it read-only and verify kernel out for read-only
memory

Signed-off-by: Nakshtra Goyal <nakshtra.goyal@intel.com>
---
 tests/intel/xe_mmap.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tests/intel/xe_mmap.c b/tests/intel/xe_mmap.c
index 5fd641075..649a11544 100644
--- a/tests/intel/xe_mmap.c
+++ b/tests/intel/xe_mmap.c
@@ -338,6 +338,24 @@ static void test_small_bar(int fd)
 	gem_close(fd, bo);
 }
 
+static int
+__xe_query(int fd, struct drm_xe_device_query *q)
+{
+	if (igt_ioctl(fd, DRM_IOCTL_XE_DEVICE_QUERY, q))
+		return -errno;
+	return 0;
+}
+
+static int
+__xe_query_items(int fd, uint32_t *items, uint32_t n_items)
+{
+	struct drm_xe_device_query q = {
+		.size = n_items,
+		.data = to_user_pointer(items),
+	};
+	return __xe_query(fd, &q);
+}
+
 static void assert_caching(int fd, uint64_t placement, uint32_t flags,
 			   uint16_t cpu_caching, bool fail)
 {
@@ -357,7 +375,16 @@ static void assert_caching(int fd, uint64_t placement, uint32_t flags,
 	map = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, mmo);
 	igt_assert(map != MAP_FAILED);
 	map[0] = 0xdeadbeaf;
+	munmap(map, size);
 	gem_close(fd, handle);
+
+	/* Adding a Read-Only page check exercise */
+	map = mmap(0, size, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+	igt_assert(map != MAP_FAILED);
+	igt_assert_eq(0, mprotect(map, size, PROT_READ));
+	igt_assert_lt(__xe_query_items(fd, map, 1), 0);
+	munmap(map, size);
+
 }
 
 /**
-- 
2.34.1


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

end of thread, other threads:[~2025-05-14  6:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14  8:36 [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page nakshtra.goyal
2025-04-14 15:41 ` ✓ i915.CI.BAT: success for tests/intel/xe_mmap: Adding igt exercise for RO page (rev2) Patchwork
2025-04-14 15:49 ` ✓ Xe.CI.BAT: " Patchwork
2025-04-14 19:04 ` ✗ i915.CI.Full: failure " Patchwork
2025-04-14 21:33 ` ✗ Xe.CI.Full: " Patchwork
2025-05-12 10:21 ` [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page Jan Maslak
2025-05-14  6:28 ` Dandamudi, Priyanka
  -- strict thread matches above, loose matches on Subject: below --
2025-04-14  7:45 nakshtra.goyal
2025-04-14  8:32 ` Dandamudi, Priyanka
2025-05-12 10:11 ` Jan Maslak

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