[PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
Dandamudi, Priyanka
priyanka.dandamudi at intel.com
Mon Apr 14 08:32:15 UTC 2025
> -----Original Message-----
> From: igt-dev <igt-dev-bounces at lists.freedesktop.org> On Behalf Of
> nakshtra.goyal at intel.com
> Sent: 14 April 2025 01:15 PM
> To: igt-dev at lists.freedesktop.org; Gandi, Ramadevi
> <ramadevi.gandi at intel.com>
> Cc: Ramadeva, Dwarakanath <dwarakanath.ramadeva at intel.com>
> Subject: [PATCH] tests/intel/xe_mmap: Adding igt exercise for RO page
>
> From: Nakshtra Goyal <nakshtra.goyal at 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 at 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
More information about the igt-dev
mailing list