* [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; 6+ 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] 6+ messages in thread* RE: [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
2025-04-14 7:45 [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page nakshtra.goyal
@ 2025-04-14 8:32 ` Dandamudi, Priyanka
2025-05-12 10:11 ` Jan Maslak
1 sibling, 0 replies; 6+ messages in thread
From: Dandamudi, Priyanka @ 2025-04-14 8:32 UTC (permalink / raw)
To: Goyal, Nakshtra, igt-dev@lists.freedesktop.org, Gandi, Ramadevi
Cc: Ramadeva, Dwarakanath
> -----Original Message-----
> From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of
> nakshtra.goyal@intel.com
> Sent: 14 April 2025 01:15 PM
> To: igt-dev@lists.freedesktop.org; Gandi, Ramadevi
> <ramadevi.gandi@intel.com>
> Cc: Ramadeva, Dwarakanath <dwarakanath.ramadeva@intel.com>
> Subject: [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
>
> 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);
You had not written any thing before, but you are just trying to query then you will find error only write?
I think
First you need to write data, read it then change it to read it only then try to write it.
Or else can you explain this once?
> + munmap(map, size);
> +
> }
>
> /**
> --
> 2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
2025-04-14 7:45 [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page nakshtra.goyal
2025-04-14 8:32 ` Dandamudi, Priyanka
@ 2025-05-12 10:11 ` Jan Maslak
1 sibling, 0 replies; 6+ messages in thread
From: Jan Maslak @ 2025-05-12 10:11 UTC (permalink / raw)
To: nakshtra.goyal; +Cc: igt-dev, ramadevi.gandi, dwarakanath.ramadeva
On Mon, Apr 14, 2025 at 01:15:22PM +0530, nakshtra.goyal@intel.com wrote:
> 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);
> +
Unnecessary empty line.
Other than that, LGTM.
Reviewed-by: Jan Maslak <jan.maslak@intel.com>
> }
>
> /**
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
@ 2025-04-14 8:36 nakshtra.goyal
2025-05-12 10:21 ` Jan Maslak
2025-05-14 6:28 ` Dandamudi, Priyanka
0 siblings, 2 replies; 6+ 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] 6+ messages in thread* Re: [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
2025-04-14 8:36 nakshtra.goyal
@ 2025-05-12 10:21 ` Jan Maslak
2025-05-14 6:28 ` Dandamudi, Priyanka
1 sibling, 0 replies; 6+ messages in thread
From: Jan Maslak @ 2025-05-12 10:21 UTC (permalink / raw)
To: nakshtra.goyal; +Cc: igt-dev, ramadevi.gandi, dwarakanath.ramadeva
On Mon, Apr 14, 2025 at 02:06:27PM +0530, nakshtra.goyal@intel.com wrote:
> 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);
> +
Unnecessary empty line.
Other than that, LGTM.
Reviewed-by: Jan Maslak <jan.maslak@intel.com>
> }
>
> /**
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread* RE: [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
2025-04-14 8:36 nakshtra.goyal
2025-05-12 10:21 ` Jan Maslak
@ 2025-05-14 6:28 ` Dandamudi, Priyanka
1 sibling, 0 replies; 6+ messages in thread
From: Dandamudi, Priyanka @ 2025-05-14 6:28 UTC (permalink / raw)
To: Goyal, Nakshtra, igt-dev@lists.freedesktop.org, Gandi, Ramadevi
Cc: Ramadeva, Dwarakanath
> -----Original Message-----
> From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of
> nakshtra.goyal@intel.com
> Sent: 14 April 2025 02:06 PM
> To: igt-dev@lists.freedesktop.org; Gandi, Ramadevi
> <ramadevi.gandi@intel.com>
> Cc: Ramadeva, Dwarakanath <dwarakanath.ramadeva@intel.com>
> Subject: [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
>
> 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);
> +
> }
LGTM,
Reviewed-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
>
> /**
> --
> 2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-14 6:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14 7:45 [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page nakshtra.goyal
2025-04-14 8:32 ` Dandamudi, Priyanka
2025-05-12 10:11 ` Jan Maslak
-- strict thread matches above, loose matches on Subject: below --
2025-04-14 8:36 nakshtra.goyal
2025-05-12 10:21 ` Jan Maslak
2025-05-14 6:28 ` Dandamudi, Priyanka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox