[PATCH i-g-t v2 26/66] tests/xe_eudebug: Add basic-vm-access-parameters test

Piatkowski, Dominik Karol dominik.karol.piatkowski at intel.com
Thu Aug 1 12:42:13 UTC 2024


Reviewed-by: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>

> -----Original Message-----
> From: Manszewski, Christoph <christoph.manszewski at intel.com>
> Sent: Tuesday, July 30, 2024 1:45 PM
> To: igt-dev at lists.freedesktop.org
> Cc: Kempczynski, Zbigniew <zbigniew.kempczynski at intel.com>; Kamil
> Konieczny <kamil.konieczny at linux.intel.com>; Grzegorzek, Dominik
> <dominik.grzegorzek at intel.com>; Patelczyk, Maciej
> <maciej.patelczyk at intel.com>; Piatkowski, Dominik Karol
> <dominik.karol.piatkowski at intel.com>; Sikora, Pawel
> <pawel.sikora at intel.com>; Hajda, Andrzej <andrzej.hajda at intel.com>;
> Kolanupaka Naveena <kolanupaka.naveena at intel.com>; Kuoppala, Mika
> <mika.kuoppala at intel.com>; Mun, Gwan-gyeong <gwan-
> gyeong.mun at intel.com>
> Subject: [PATCH i-g-t v2 26/66] tests/xe_eudebug: Add basic-vm-access-
> parameters test
> 
> From: Pawel Sikora <pawel.sikora at intel.com>
> 
> This new test checks negative scenarios of VM_OPEN ioctl and pread/pwrite
> usage.
> 
> Signed-off-by: Pawel Sikora <pawel.sikora at intel.com>
> Cc: Christoph Manszewski <christoph.manszewski at intel.com>
> ---
>  tests/intel/xe_eudebug.c | 143
> +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 143 insertions(+)
> 
> diff --git a/tests/intel/xe_eudebug.c b/tests/intel/xe_eudebug.c index
> d4036ba05..ab856727e 100644
> --- a/tests/intel/xe_eudebug.c
> +++ b/tests/intel/xe_eudebug.c
> @@ -1168,6 +1168,146 @@ static void test_vm_access(int fd, unsigned int
> flags, int num_clients)
>  					 false,
> XE_EUDEBUG_FILTER_EVENT_VM_BIND_OP);
>  }
> 
> +static void debugger_test_vma_parameters(struct xe_eudebug_debugger *d,
> +					 uint64_t client_handle,
> +					 uint64_t vm_handle,
> +					 uint64_t va_start,
> +					 uint64_t va_length)
> +{
> +	struct drm_xe_eudebug_vm_open vo = { 0, };
> +	uint64_t *v;
> +	uint64_t items = va_length / sizeof(uint64_t);
> +	int fd;
> +	int r, i;
> +
> +	v = malloc(va_length);
> +	igt_assert(v);
> +
> +	/* Negative VM open - bad client handle */
> +	vo.client_handle = client_handle + 123;
> +	vo.vm_handle = vm_handle;
> +	fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
> +	igt_assert(fd < 0);
> +
> +	/* Negative VM open - bad vm handle */
> +	vo.client_handle = client_handle;
> +	vo.vm_handle = vm_handle + 123;
> +	fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
> +	igt_assert(fd < 0);
> +
> +	/* Positive VM open */
> +	vo.client_handle = client_handle;
> +	vo.vm_handle = vm_handle;
> +	fd = igt_ioctl(d->fd, DRM_XE_EUDEBUG_IOCTL_VM_OPEN, &vo);
> +	igt_assert_lte(0, fd);
> +
> +	/* Negative pread - bad fd */
> +	r = pread(fd + 123, v, va_length, va_start);
> +	igt_assert(r < 0);
> +
> +	/* Negative pread - bad va_start */
> +	r = pread(fd, v, va_length, 0);
> +	igt_assert(r < 0);
> +
> +	/* Negative pread - bad va_start */
> +	r = pread(fd, v, va_length, va_start - 1);
> +	igt_assert(r < 0);
> +
> +	/* Positive pread - zero va_length */
> +	r = pread(fd, v, 0, va_start);
> +	igt_assert_eq(r, 0);
> +
> +	/* Negative pread - out of range */
> +	r = pread(fd, v, va_length + 1, va_start);
> +	igt_assert_eq(r, va_length);
> +
> +	/* Negative pread - bad va_start */
> +	r = pread(fd, v, 1, va_start + va_length);
> +	igt_assert(r < 0);
> +
> +	/* Positive pread - whole range */
> +	r = pread(fd, v, va_length, va_start);
> +	igt_assert_eq(r, va_length);
> +
> +	/* Positive pread */
> +	r = pread(fd, v, 1, va_start + va_length - 1);
> +	igt_assert_eq(r, 1);
> +
> +	for (i = 0; i < items; i++)
> +		igt_assert_eq(v[i], va_start + i);
> +
> +	for (i = 0; i < items; i++)
> +		v[i] = va_start + i + 1;
> +
> +	/* Negative pwrite - bad fd */
> +	r = pwrite(fd + 123, v, va_length, va_start);
> +	igt_assert(r < 0);
> +
> +	/* Negative pwrite - bad va_start */
> +	r = pwrite(fd, v, va_length, -1);
> +	igt_assert(r < 0);
> +
> +	/* Negative pwrite - zero va_start */
> +	r = pwrite(fd, v, va_length, 0);
> +	igt_assert(r < 0);
> +
> +	/* Negative pwrite - bad va_length */
> +	r = pwrite(fd, v, va_length + 1, va_start);
> +	igt_assert_eq(r, va_length);
> +
> +	/* Positive pwrite - zero va_length */
> +	r = pwrite(fd, v, 0, va_start);
> +	igt_assert_eq(r, 0);
> +
> +	/* Positive pwrite */
> +	r = pwrite(fd, v, va_length, va_start);
> +	igt_assert_eq(r, va_length);
> +	fsync(fd);
> +
> +	close(fd);
> +	free(v);
> +}
> +
> +static void vm_trigger_access_parameters(struct xe_eudebug_debugger *d,
> +		       struct drm_xe_eudebug_event *e) {
> +	struct drm_xe_eudebug_event_vm_bind_op *eo = (void *)e;
> +
> +	if (e->flags & DRM_XE_EUDEBUG_EVENT_CREATE) {
> +		struct drm_xe_eudebug_event_vm_bind *eb;
> +
> +		igt_debug("vm bind op event received with ref %lld, addr
> 0x%llx, range 0x%llx\n",
> +			  eo->vm_bind_ref_seqno,
> +			  eo->addr,
> +			  eo->range);
> +
> +		eb = (struct drm_xe_eudebug_event_vm_bind *)
> +			xe_eudebug_event_log_find_seqno(d->log, eo-
> >vm_bind_ref_seqno);
> +		igt_assert(eb);
> +
> +		debugger_test_vma_parameters(d, eb->client_handle, eb-
> >vm_handle,
> +						   eo->addr, eo->range);
> +		xe_eudebug_debugger_signal_stage(d, eo->addr);
> +	}
> +}
> +
> +/**
> + * SUBTEST: basic-vm-access-parameters
> + * Description:
> + *      Check negative scenarios of VM_OPEN ioctl and pread/pwrite usage.
> + */
> +static void test_vm_access_parameters(int fd, unsigned int flags, int
> +num_clients) {
> +	struct drm_xe_engine_class_instance *hwe;
> +
> +	xe_for_each_engine(fd, hwe)
> +		test_client_with_trigger(fd, flags, num_clients,
> +					 vm_access_client,
> +
> DRM_XE_EUDEBUG_EVENT_VM_BIND_OP,
> +					 vm_trigger_access_parameters, hwe,
> +					 false,
> XE_EUDEBUG_FILTER_EVENT_VM_BIND_OP);
> +}
> +
>  #define PAGE_SIZE 4096
>  #define MDATA_SIZE
> (WORK_IN_PROGRESS_DRM_XE_DEBUG_METADATA_NUM * PAGE_SIZE)
> static void metadata_access_client(struct xe_eudebug_client *c) @@ -1332,6
> +1472,9 @@ igt_main
>  	igt_subtest("basic-vm-access")
>  		test_vm_access(fd, 0, 1);
> 
> +	igt_subtest("basic-vm-access-parameters")
> +		test_vm_access_parameters(fd, 0, 1);
> +
>  	igt_subtest("multiple-sessions")
>  		test_basic_sessions(fd, CREATE_VMS |
> CREATE_EXEC_QUEUES, 4, true);
> 
> --
> 2.34.1



More information about the igt-dev mailing list