Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@linux.intel.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>, intel-gfx@lists.freedesktop.org
Cc: Chris Wilson <chris.p.wilson@intel.com>,
	Nirmoy Das <nirmoy.das@intel.com>
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/gt: update request engine before removing virtual GuC engine
Date: Fri, 7 Jul 2023 10:05:10 +0200	[thread overview]
Message-ID: <7de6f1eb-b5b1-69fd-4b6f-2b9d58e6bcf0@linux.intel.com> (raw)
In-Reply-To: <20230706151611.1024576-1-andrzej.hajda@intel.com>


On 7/6/2023 5:16 PM, Andrzej Hajda wrote:
> GuC virtual engines can be removed before request removal. On the other
> side driver expects rq->engine to be a valid pointer for a whole life of
> request. Setting rq->engine to an always valid engine should solve
> the issue.
>
> The patch fixes bug detected by KASAN with following signature:
> i915 0000:00:02.0: [drm:i915_drop_caches_set [i915]] Dropping caches: 0x0000005c [0x0000005c]
> BUG: KASAN: slab-use-after-free in i915_fence_release+0x2a2/0x2f0 [i915]
> Read of size 4 at addr ffff88813ffda6e8 by task kworker/u32:10/157
> ...
> Allocated by task 1184:
> ...
> guc_create_virtual+0x4d/0x1160 [i915]
> i915_gem_create_context+0x11ee/0x18c0 [i915]
> ...
> Freed by task 151:
> ...
> intel_guc_deregister_done_process_msg+0x324/0x6d0 [i915]
> ...
>
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7926
> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
Acked-by: Nirmoy Das <nirmoy.das@intel.com>
> ---
>   drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> index a0e3ef1c65d246..2c877ea5eda6f0 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -3461,6 +3461,8 @@ static void guc_prio_fini(struct i915_request *rq, struct intel_context *ce)
>   static void remove_from_context(struct i915_request *rq)
>   {
>   	struct intel_context *ce = request_to_scheduling_context(rq);
> +	struct intel_engine_cs *engine;
> +	intel_engine_mask_t tmp;
>   
>   	GEM_BUG_ON(intel_context_is_child(ce));
>   
> @@ -3478,6 +3480,15 @@ static void remove_from_context(struct i915_request *rq)
>   
>   	atomic_dec(&ce->guc_id.ref);
>   	i915_request_notify_execute_cb_imm(rq);
> +
> +	/*
> +	 * GuC virtual engine can disappear after this call, so let's assign
> +	 * something valid, as driver expects this to be always valid pointer.
> +	 */
> +	for_each_engine_masked(engine, rq->engine->gt, rq->execution_mask, tmp) {
> +		rq->engine = engine;
> +		break;
> +	}
>   }
>   
>   static const struct intel_context_ops guc_context_ops = {

  reply	other threads:[~2023-07-07  8:05 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 16:08 [Intel-gfx] [PATCH] drm/i915/gt: update request engine before removing virtual GuC engine Andrzej Hajda
2023-07-05 17:34 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for " Patchwork
2023-07-05 17:50 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-07-05 19:11 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2023-07-06 15:16 ` [Intel-gfx] [PATCH v2] " Andrzej Hajda
2023-07-07  8:05   ` Nirmoy Das [this message]
2023-07-11 10:18   ` Andi Shyti
2023-07-11 11:12     ` Andrzej Hajda
2023-07-11 11:34       ` Andi Shyti
2023-07-11 13:58         ` Andrzej Hajda
2023-07-11 15:27           ` Tvrtko Ursulin
2023-07-12 12:18             ` Andrzej Hajda
2023-07-12 12:35               ` Tvrtko Ursulin
2023-07-12 16:27                 ` Andrzej Hajda
2023-07-12 18:54                   ` John Harrison
2023-07-13  7:39                     ` Tvrtko Ursulin
2023-07-13  8:56                       ` Tvrtko Ursulin
2023-07-13 11:59                         ` Andrzej Hajda
2023-07-13 12:22                           ` Tvrtko Ursulin
2023-07-13 11:09                       ` Andrzej Hajda
2023-07-13 12:11                         ` Tvrtko Ursulin
2023-07-17 18:03                           ` John Harrison
2023-07-18 15:48                             ` Tvrtko Ursulin
2023-07-19 10:41                               ` Andrzej Hajda
2023-07-19 12:43                                 ` Tvrtko Ursulin
2023-07-24 19:40                                   ` John Harrison
2023-07-06 20:01 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gt: update request engine before removing virtual GuC engine (rev2) Patchwork
2023-07-06 20:13 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-07-07  2:52 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2023-07-10 12:51   ` Andrzej Hajda

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=7de6f1eb-b5b1-69fd-4b6f-2b9d58e6bcf0@linux.intel.com \
    --to=nirmoy.das@linux.intel.com \
    --cc=andrzej.hajda@intel.com \
    --cc=chris.p.wilson@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=nirmoy.das@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox