[PATCH i-g-t v4 6/7] tests/intel/xe_pxp: Termination tests

Kamil Konieczny kamil.konieczny at linux.intel.com
Thu Feb 27 11:14:14 UTC 2025


Hi Daniele,
On 2025-02-24 at 16:31:37 -0800, Daniele Ceraolo Spurio wrote:
> There are several events that can cause the PXP key to be invalidated
> and trigger a PXP termination (suspend, PXP termination irq). After a
> termination, we expect the key to be different and the raw encrypted
> data to change for the same source data.
> Additionally, all PXP objects are invalidated during a termination and
> can no longer be used in submission or kept mapped to VMs; we therefore
> need to test both the execution and bind ioctls to make sure they work
> as expected after a termination.

I have few nits, mainly for libs changes, see below.

> 
> v2: move igt_require calls inside the subtest
> v3: block rpm for tests trying a different type of termination, rework
> invalid bind test to try a new vm as well (Alan)
> v4: move file open and igt_require() inside the subtest (Kamil)
> 
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
> Cc: Alan Previn <alan.previn.teres.alexis at intel.com>
> Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
>  lib/intel_batchbuffer.c |   8 +-
>  lib/intel_batchbuffer.h |   1 +
>  lib/xe/xe_ioctl.c       |  12 +-
>  lib/xe/xe_ioctl.h       |   2 +
>  tests/intel/xe_pxp.c    | 465 +++++++++++++++++++++++++++++++++++++++-
>  5 files changed, 475 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
> index ee499ee7f..68614ed6b 100644
> --- a/lib/intel_batchbuffer.c
> +++ b/lib/intel_batchbuffer.c
> @@ -2428,9 +2428,9 @@ static void update_offsets(struct intel_bb *ibb,
>  
>  #define LINELEN 76
>  

While you are here please add description to library function.

> -static int
> -__xe_bb_exec(struct intel_bb *ibb, uint64_t flags, bool sync)
> +int __xe_bb_exec(struct intel_bb *ibb, uint64_t flags, bool sync)
>  {
> +	int ret = 0;
>  	uint32_t engine = flags & (I915_EXEC_BSD_MASK | I915_EXEC_RING_MASK);
>  	uint32_t engine_id;
>  	struct drm_xe_sync syncs[2] = {
> @@ -2507,12 +2507,12 @@ __xe_bb_exec(struct intel_bb *ibb, uint64_t flags, bool sync)
>  	ibb->engine_syncobj = syncobj_create(ibb->fd, 0);
>  	syncs[1].handle = ibb->engine_syncobj;
>  
> -	xe_exec_sync(ibb->fd, engine_id, ibb->batch_offset, syncs, 2);
> +	ret = xe_exec_sync_failable(ibb->fd, engine_id, ibb->batch_offset, syncs, 2);
>  
>  	if (sync)
>  		intel_bb_sync(ibb);
>  
> -	return 0;
> +	return ret;
>  }
>  
>  static int
> diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
> index 178aaa9d8..6a7e8df4a 100644
> --- a/lib/intel_batchbuffer.h
> +++ b/lib/intel_batchbuffer.h
> @@ -508,6 +508,7 @@ void intel_bb_dump_cache(struct intel_bb *ibb);
>  
>  void intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
>  		   uint64_t flags, bool sync);
> +int __xe_bb_exec(struct intel_bb *ibb, uint64_t flags, bool sync);
>  
>  uint64_t intel_bb_get_object_offset(struct intel_bb *ibb, uint32_t handle);
>  bool intel_bb_object_offset_to_buf(struct intel_bb *ibb, struct intel_buf *buf);
> diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
> index 01ab7c758..cd7314eda 100644
> --- a/lib/xe/xe_ioctl.c
> +++ b/lib/xe/xe_ioctl.c
> @@ -462,8 +462,8 @@ void xe_exec(int fd, struct drm_xe_exec *exec)
>  	igt_assert_eq(__xe_exec(fd, exec), 0);
>  }
>  

Same here, add description.

> -void xe_exec_sync(int fd, uint32_t exec_queue, uint64_t addr,
> -		  struct drm_xe_sync *sync, uint32_t num_syncs)
> +int xe_exec_sync_failable(int fd, uint32_t exec_queue, uint64_t addr,
> +			  struct drm_xe_sync *sync, uint32_t num_syncs)
>  {
>  	struct drm_xe_exec exec = {
>  		.exec_queue_id = exec_queue,
> @@ -473,7 +473,13 @@ void xe_exec_sync(int fd, uint32_t exec_queue, uint64_t addr,
>  		.num_batch_buffer = 1,
>  	};
>  
> -	igt_assert_eq(__xe_exec(fd, &exec), 0);
> +	return __xe_exec(fd, &exec);
> +}
> +

Same here.

> +void xe_exec_sync(int fd, uint32_t exec_queue, uint64_t addr,
> +		  struct drm_xe_sync *sync, uint32_t num_syncs)
> +{
> +	igt_assert_eq(xe_exec_sync_failable(fd, exec_queue, addr, sync, num_syncs), 0);
>  }
>  
>  void xe_exec_wait(int fd, uint32_t exec_queue, uint64_t addr)
> diff --git a/lib/xe/xe_ioctl.h b/lib/xe/xe_ioctl.h
> index c8a2d81c5..9bdf73b2b 100644
> --- a/lib/xe/xe_ioctl.h
> +++ b/lib/xe/xe_ioctl.h
> @@ -91,6 +91,8 @@ int __xe_exec(int fd, struct drm_xe_exec *exec);
>  void xe_exec(int fd, struct drm_xe_exec *exec);
>  void xe_exec_sync(int fd, uint32_t exec_queue, uint64_t addr,
>  		  struct drm_xe_sync *sync, uint32_t num_syncs);
> +int xe_exec_sync_failable(int fd, uint32_t exec_queue, uint64_t addr,
> +		  struct drm_xe_sync *sync, uint32_t num_syncs);
>  void xe_exec_wait(int fd, uint32_t exec_queue, uint64_t addr);
>  int __xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
>  		     uint32_t exec_queue, int64_t *timeout);
> diff --git a/tests/intel/xe_pxp.c b/tests/intel/xe_pxp.c
> index 2ab920d07..18f582370 100644
> --- a/tests/intel/xe_pxp.c
> +++ b/tests/intel/xe_pxp.c
> @@ -3,7 +3,10 @@
>   * Copyright © 2024 Intel Corporation

Please extend year to 2024-2025

Regards,
Kamil

>   */
>  
> +#include <fcntl.h>
> +
>  #include "igt.h"
> +#include "igt_syncobj.h"
>  #include "intel_batchbuffer.h"
>  #include "intel_bufops.h"
>  #include "intel_mocs.h"
> @@ -81,6 +84,15 @@ static uint32_t create_pxp_rcs_queue(int fd, uint32_t vm)
>  	return q;
>  }
[...]


More information about the igt-dev mailing list