dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: "Cavitt, Jonathan" <jonathan.cavitt@intel.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Cc: "Gupta, Saurabhg" <saurabhg.gupta@intel.com>,
	"Zuo, Alex" <alex.zuo@intel.com>
Subject: RE: [PATCH] drm/xe/rtp: Check hwe before calling match_func
Date: Fri, 29 May 2026 12:07:04 -0300	[thread overview]
Message-ID: <87a4tis19j.fsf@intel.com> (raw)
In-Reply-To: <SN6PR11MB2717B102CEDA7B2203A66DFEE5162@SN6PR11MB2717.namprd11.prod.outlook.com>

"Cavitt, Jonathan" <jonathan.cavitt@intel.com> writes:

> -----Original Message-----
> From: Sousa, Gustavo <gustavo.sousa@intel.com> 
> Sent: Thursday, May 28, 2026 3:30 PM
> To: Cavitt, Jonathan <jonathan.cavitt@intel.com>; dri-devel@lists.freedesktop.org
> Cc: Gupta, Saurabhg <saurabhg.gupta@intel.com>; Zuo, Alex <alex.zuo@intel.com>; Cavitt, Jonathan <jonathan.cavitt@intel.com>
> Subject: Re: [PATCH] drm/xe/rtp: Check hwe before calling match_func
>> 
>> Jonathan Cavitt <jonathan.cavitt@intel.com> writes:
>> 
>> > XE_RTP_MATCH_FUNC may attempt to dereference the target xe_hw_engine.
>> > Ensure the hwe is not NULL before calling the function, matching
>> > XE_RTP_MATCH_ENGINE_CLASS, for example.
>> >
>> > This covers a static analysis issue.
>> >
>> > Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
>> > Cc: Gustavo Sousa <gustavo.sousa@intel.com>
>> > ---
>> >  drivers/gpu/drm/xe/xe_rtp.c | 3 +++
>> >  1 file changed, 3 insertions(+)
>> >
>> > diff --git a/drivers/gpu/drm/xe/xe_rtp.c b/drivers/gpu/drm/xe/xe_rtp.c
>> > index dec9d94e6fb0..2cd26db113d9 100644
>> > --- a/drivers/gpu/drm/xe/xe_rtp.c
>> > +++ b/drivers/gpu/drm/xe/xe_rtp.c
>> > @@ -129,6 +129,9 @@ static bool rule_match_item(struct rule_match_ctx *match_ctx)
>> >  
>> >  		return hwe->class != r->engine_class;
>> >  	case XE_RTP_MATCH_FUNC:
>> > +		if (drm_WARN_ON(&xe->drm, !hwe))
>> > +			return false;
>> 
>> There are several functions passed via XE_RTP_MATCH_FUNC() (i.e. MATCH()
>> in definitions of RTP rules) that are meant to be used to do checks that
>> do not depend on hwe.  Returning false here is wrong as it will cause
>> those checks to be skipped.
>> 
>> The developer is responsible for not passing a function that uses hwe in
>> a context where it is NULL.
>
> Understood, though quick question: is this also the case for GT?

Yep. Some examples:

  * match_has_mert
  * xe_rtp_match_not_sriov_vf
  * xe_rtp_match_has_flat_ccs

--
Gustavo Sousa

> -Jonathan Cavitt
>
>> 
>> --
>> Gustavo Sousa
>> 
>> > +
>> >  		return r->match_func(xe, gt, hwe);
>> >  	default:
>> >  		drm_warn(&xe->drm, "Invalid RTP match %u\n",
>> > -- 
>> > 2.53.0
>> 

      reply	other threads:[~2026-05-29 15:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28 21:34 [PATCH] drm/xe/rtp: Check hwe before calling match_func Jonathan Cavitt
2026-05-28 21:46 ` Cavitt, Jonathan
2026-05-28 22:29 ` Gustavo Sousa
2026-05-29 14:03   ` Cavitt, Jonathan
2026-05-29 15:07     ` Gustavo Sousa [this message]

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=87a4tis19j.fsf@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=saurabhg.gupta@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