All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedsktop.org
Subject: Re: [Intel-gfx] [PATCH i-g-t v2] i915/gem_ctx_exec: Cover all engines for nohangcheck
Date: Tue, 4 Feb 2020 16:24:42 +0000	[thread overview]
Message-ID: <c3283710-ec85-4dfc-3963-c8666c9b4fc4@linux.intel.com> (raw)
In-Reply-To: <20200204161916.1299225-1-chris@chris-wilson.co.uk>


On 04/02/2020 16:19, Chris Wilson wrote:
> No engine can be missed when verifying that a rogue user cannot cause a
> denial-of-service with nohangcheck.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> __for_each_physical_engine, keep the leaks
> ---
>   tests/i915/gem_ctx_exec.c | 38 ++++++++++++++++++++++++++++++++------
>   1 file changed, 32 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/i915/gem_ctx_exec.c b/tests/i915/gem_ctx_exec.c
> index b1ae65774..aeb8d2976 100644
> --- a/tests/i915/gem_ctx_exec.c
> +++ b/tests/i915/gem_ctx_exec.c
> @@ -42,6 +42,7 @@
>   
>   #include "igt_dummyload.h"
>   #include "igt_sysfs.h"
> +#include "sw_sync.h"
>   
>   IGT_TEST_DESCRIPTION("Test context batch buffer execution.");
>   
> @@ -203,9 +204,9 @@ static bool __enable_hangcheck(int dir, bool state)
>   
>   static void nohangcheck_hostile(int i915)
>   {
> -	int64_t timeout = NSEC_PER_SEC / 2;
> -	igt_spin_t *spin;
> +	const struct intel_execution_engine2 *e;
>   	igt_hang_t hang;
> +	int fence = -1;
>   	uint32_t ctx;
>   	int err = 0;
>   	int dir;
> @@ -215,6 +216,8 @@ static void nohangcheck_hostile(int i915)
>   	 * we forcibly terminate that context.
>   	 */
>   
> +	i915 = gem_reopen_driver(i915);
> +
>   	dir = igt_sysfs_open_parameters(i915);
>   	igt_require(dir != -1);
>   
> @@ -223,16 +226,35 @@ static void nohangcheck_hostile(int i915)
>   
>   	igt_require(__enable_hangcheck(dir, false));
>   
> -	spin = igt_spin_new(i915, ctx, .flags = IGT_SPIN_NO_PREEMPTION);
> +	__for_each_physical_engine(i915, e) {
> +		igt_spin_t *spin;
> +
> +		spin = igt_spin_new(i915, ctx,
> +				    .engine = e->flags,
> +				    .flags = (IGT_SPIN_NO_PREEMPTION |
> +					      IGT_SPIN_FENCE_OUT));
> +
> +		igt_assert(spin->out_fence != -1);
> +		if (fence < 0) {
> +			fence = spin->out_fence;
> +			spin->out_fence = -1;
> +		} else {
> +			int new;
> +
> +			new = sync_fence_merge(fence, spin->out_fence);
> +			close(fence);
> +
> +			fence = new;
> +		}
> +	}
>   	gem_context_destroy(i915, ctx);
> +	igt_assert(fence != -1);
>   
> -	if (gem_wait(i915, spin->handle, &timeout)) {
> +	if (sync_fence_wait(fence, MSEC_PER_SEC / 2)) {
>   		igt_debugfs_dump(i915, "i915_engine_info");
>   		err = -ETIME;
>   	}
>   
> -	igt_spin_free(i915, spin);
> -
>   	__enable_hangcheck(dir, true);
>   	gem_quiescent_gpu(i915);
>   	igt_disallow_hang(i915, hang);
> @@ -240,7 +262,11 @@ static void nohangcheck_hostile(int i915)
>   	igt_assert_f(err == 0,
>   		     "Hostile unpreemptable context was not cancelled immediately upon closure\n");
>   
> +	igt_assert_eq(sync_fence_status(fence), -EIO);
> +	close(fence);
> +
>   	close(dir);
> +	close(i915);
>   }
>   
>   igt_main
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2020-02-04 16:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04 15:24 [igt-dev] [PATCH i-g-t] i915/gem_ctx_exec: Cover all engines for nohangcheck Chris Wilson
2020-02-04 15:24 ` [Intel-gfx] " Chris Wilson
2020-02-04 15:57 ` [igt-dev] " Tvrtko Ursulin
2020-02-04 15:57   ` Tvrtko Ursulin
2020-02-04 16:03   ` [igt-dev] " Chris Wilson
2020-02-04 16:03     ` Chris Wilson
2020-02-04 16:19 ` [Intel-gfx] [PATCH i-g-t v2] " Chris Wilson
2020-02-04 16:24   ` Tvrtko Ursulin [this message]
2020-02-05 11:48   ` Tvrtko Ursulin
2020-02-05 11:52     ` Chris Wilson
2020-02-05 11:56       ` Chris Wilson
2020-02-04 16:42 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2020-02-06 16:12 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c3283710-ec85-4dfc-3963-c8666c9b4fc4@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedsktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.