From: sashiko-bot@kernel.org
To: "Zongyao Bai" <zongyao.bai@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v5 1/4] drm/xe/forcewake: synchronize engine-cycle access with unplug
Date: Thu, 13 Aug 2026 00:21:46 +0000 [thread overview]
Message-ID: <20260813002147.04EC51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813000654.2712317-2-zongyao.bai@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete device unplug synchronization in query ioctls leading to potential MMIO access after unplug.
- [Medium] Missing array_index_nospec() on user-provided indices creates Spectre v1 gadgets.
--
--- Patch [1]: [PATCH v5 1/4] drm/xe/forcewake: synchronize engine-cycle access with unplug ---
commit cd6f1d67df5ef0b65b3a0c38b2fc6c7bd6e42c60
Author: Zongyao Bai <zongyao.bai@intel.com>
drm/xe/forcewake: synchronize engine-cycle access with unplug
This patch adds drm_dev_enter() and drm_dev_exit() to query_engine_cycles()
to protect forcewake and MMIO accesses against device unplug operations. It
also updates the probe failure path to use drm_dev_unplug() to ensure proper
synchronization.
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 71111ad324658..81b31325e5817 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
[ ... ]
> @@ -1166,7 +1166,7 @@ int xe_device_probe(struct xe_device *xe)
>
> err_unregister_display:
> xe_display_unregister(xe);
> - drm_dev_unregister(&xe->drm);
> + drm_dev_unplug(&xe->drm);
>
> return err;
> }
> diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
> index dc975f5953683..3c356bc48e2ab 100644
> --- a/drivers/gpu/drm/xe/xe_query.c
> +++ b/drivers/gpu/drm/xe/xe_query.c
[ ... ]
> @@ -143,28 +145,44 @@ query_engine_cycles(struct xe_device *xe,
> return -EINVAL;
>
> eci = &resp.eci;
> + if (!drm_dev_enter(&xe->drm, &dev_idx))
> + return -ENODEV;
> +
[Severity: High]
This is a pre-existing issue, but since this patch introduces device unplug
synchronization for query_engine_cycles(), should similar protection be added
to other queries like query_pxp_status() and query_oa_units()?
In xe_query.c, query_pxp_status() accesses hardware status without SRCU
protection:
query_pxp_status()
xe_pxp_get_readiness_status(xe->pxp);
Similarly, query_oa_units() reads MMIO indirectly:
query_oa_units()
xe_oa_timestamp_frequency()
xe_mmio_read32()
Without drm_dev_enter() protection, can these queries cause page faults if a
userspace process calls DRM_IOCTL_XE_DEVICE_QUERY concurrently with a device
unplug event?
> gt = xe_device_get_gt(xe, eci->gt_id);
> - if (!gt)
> - return -EINVAL;
> + if (!gt) {
> + err = -EINVAL;
> + goto out;
> + }
>
> - if (eci->engine_class >= ARRAY_SIZE(user_to_xe_engine_class))
> - return -EINVAL;
> + if (eci->engine_class >= ARRAY_SIZE(user_to_xe_engine_class)) {
> + err = -EINVAL;
> + goto out;
> + }
>
> hwe = xe_gt_hw_engine(gt, user_to_xe_engine_class[eci->engine_class],
> eci->engine_instance, true);
[Severity: Medium]
This is a pre-existing issue, but does the engine_class array access need
mitigation against speculative execution?
The eci->engine_class index comes directly from userspace and is used
to access the user_to_xe_engine_class array after a bounds check.
Could this be used to bypass bounds checks speculatively and leak
information via cache side channels?
Additionally, earlier in this function xe_device_get_gt() is called with
eci->gt_id, which also originates from userspace:
xe_device_get_gt()
if (gt_id >= xe->info.tile_count * xe->info.max_gt_per_tile)
return NULL;
tile = &xe->tiles[gt_id / xe->info.max_gt_per_tile];
Should array_index_nospec() be used for these userspace-provided indices?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260813000654.2712317-1-zongyao.bai@intel.com?part=1
next prev parent reply other threads:[~2026-08-13 0:21 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 21:38 [PATCH] drm/xe/forcewake: add delayed-release optimization Zongyao Bai
2026-06-01 22:37 ` ✓ CI.KUnit: success for " Patchwork
2026-06-01 23:15 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-02 8:13 ` ✓ Xe.CI.FULL: " Patchwork
2026-06-11 1:03 ` [PATCH v2] " Zongyao Bai
2026-06-11 11:59 ` Maarten Lankhorst
2026-06-18 21:18 ` Bai, Zongyao
2026-06-11 1:13 ` ✓ CI.KUnit: success for drm/xe/forcewake: add delayed-release optimization (rev2) Patchwork
2026-06-11 1:58 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-11 3:09 ` [PATCH] drm/xe/forcewake: add delayed-release optimization Matthew Brost
2026-06-11 3:15 ` Matthew Brost
2026-06-25 1:37 ` Bai, Zongyao
2026-06-11 11:29 ` ✓ Xe.CI.FULL: success for drm/xe/forcewake: add delayed-release optimization (rev2) Patchwork
2026-06-25 8:19 ` [PATCH v3] drm/xe/forcewake: add delayed-release optimization Zongyao Bai
2026-06-25 8:51 ` ✓ CI.KUnit: success for drm/xe/forcewake: add delayed-release optimization (rev3) Patchwork
2026-06-25 9:26 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-06-25 10:55 ` ✗ Xe.CI.FULL: " Patchwork
2026-07-20 22:13 ` [PATCH v4] drm/xe/forcewake: add delayed-release optimization Zongyao Bai
2026-07-21 22:43 ` Matthew Brost
2026-07-20 22:18 ` ✗ CI.checkpatch: warning for drm/xe/forcewake: add delayed-release optimization (rev4) Patchwork
2026-07-20 22:20 ` ✓ CI.KUnit: success " Patchwork
2026-07-20 22:54 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-21 5:00 ` ✓ Xe.CI.FULL: " Patchwork
2026-08-13 0:06 ` [PATCH v5 0/4] drm/xe/forcewake: add delayed-release optimization Zongyao Bai
2026-08-13 0:06 ` [PATCH v5 1/4] drm/xe/forcewake: synchronize engine-cycle access with unplug Zongyao Bai
2026-08-13 0:21 ` sashiko-bot [this message]
2026-08-13 0:06 ` [PATCH v5 2/4] drm/xe/forcewake: add delayed-release state machine Zongyao Bai
2026-08-13 0:23 ` sashiko-bot
2026-08-13 0:06 ` [PATCH v5 3/4] drm/xe/forcewake: flush delayed release at power boundaries Zongyao Bai
2026-08-13 0:23 ` sashiko-bot
2026-08-13 0:06 ` [PATCH v5 4/4] drm/xe/forcewake: enable configurable delayed forcewake release Zongyao Bai
2026-08-13 0:18 ` sashiko-bot
2026-08-13 0:13 ` ✗ CI.checkpatch: warning for drm/xe/forcewake: add delayed-release optimization (rev5) Patchwork
2026-08-13 0:15 ` ✓ CI.KUnit: success " 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=20260813002147.04EC51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zongyao.bai@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