From: sashiko-bot@kernel.org
To: "Tejas Upadhyay" <tejas.upadhyay@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH V18 13/14] drm/xe/uapi: Expose ban reason in EXEC_QUEUE_GET_PROPERTY_BAN
Date: Wed, 26 Aug 2026 14:20:00 +0000 [thread overview]
Message-ID: <20260826142001.03D951F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826135136.204044-29-tejas.upadhyay@intel.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Critical] Concurrent iteration and mutation of `vm->exec_queues.list` using only `down_read` causes list and kernel stack corruption.
- [Medium] The PAGE_OFFLINE ban reason is hidden for non-LR queues until TDR fires, defeating the logic to prevent GPU_HANG masking.
- [Medium] Missing read memory barrier before checking `ban_reason` allows speculative out-of-order execution, causing the UAPI to report a stale status.
--
commit f03e51ea5f032e49889009d1894c9441c7fe6525
Author: Tejas Upadhyay <tejas.upadhyay@intel.com>
drm/xe/uapi: Expose ban reason in EXEC_QUEUE_GET_PROPERTY_BAN
Extend DRM_XE_EXEC_QUEUE_GET_PROPERTY_BAN to return a bitmask indicating
the reason for the ban, rather than a simple boolean. This allows
userspace to distinguish between different ban causes.
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 99d8c807ff056..0a6e2b81b5a53 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -1599,6 +1600,12 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job)
> else
> wedged = xe_device_wedged(xe);
>
> + /*
> + * Only tag as GPU hang if this is the original timeout, not a
> + * consequence of a prior kill (e.g., page-offline).
> + */
> + if (!exec_queue_killed(q))
> + atomic_or(DRM_XE_EXEC_QUEUE_BAN_REASON_GPU_HANG, &q->ban_reason);
[Severity: Medium]
Will this properly mask the GPU_HANG bit for non-LR (legacy) queues?
When xe_ttm_vram_purge_page() sets PAGE_OFFLINE on non-LR queues, it calls
xe_vm_kill(). However, xe_vm_kill() only explicitly iterates and kills LR
queues (those in &vm->preempt.exec_queues).
Since non-LR queues are not explicitly marked as killed, wouldn't this check
evaluate to true and still incorrectly append the GPU_HANG reason when the
doomed non-LR queue eventually times out?
> set_exec_queue_banned(q);
>
> /* Kick job / queue off hardware */
[ ... ]
> @@ -2580,13 +2590,29 @@ static void guc_exec_queue_multi_queue_drop_suspend(struct xe_exec_queue *q)
[ ... ]
> -static bool guc_exec_queue_reset_status(struct xe_exec_queue *q)
> +static u64 guc_exec_queue_reset_status(struct xe_exec_queue *q)
> {
[ ... ]
> - return exec_queue_reset(q) || exec_queue_killed_or_banned_or_wedged(q);
> + if (exec_queue_reset(q) || exec_queue_killed_or_banned_or_wedged(q)) {
> + u64 reason = atomic_read_acquire(&q->ban_reason);
> +
> + /* If no specific reason was recorded, default to GPU hang */
> + if (!reason)
> + reason = DRM_XE_EXEC_QUEUE_BAN_REASON_GPU_HANG;
> + return reason;
> + }
[Severity: Medium]
Does this sequence allow for a stale or speculative status read?
Because the condition (exec_queue_killed_or_banned_or_wedged) is evaluated
using a relaxed atomic read, there is only a control dependency before
atomic_read_acquire() on q->ban_reason.
On weakly-ordered architectures, the CPU can speculatively load q->ban_reason
before the state check. If the speculative read happens right as
xe_ttm_vram_purge_page() is updating the status, couldn't reason evaluate to 0
and spuriously default to GPU_HANG instead of PAGE_OFFLINE? Would an smp_rmb()
be required here to properly order the reads?
> diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> index af9e1fa868d7f..8f583f1631bf4 100644
> --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> @@ -596,7 +598,22 @@ static int xe_ttm_vram_purge_page(struct xe_device *xe, struct xe_bo *bo)
> xe_bo_unlock(bo);
> /* Ban VM if BO is PPGTT */
> if (vm && (flags & XE_BO_FLAG_PAGETABLE)) {
> + struct xe_exec_queue *eq;
> + int id;
> +
> down_write(&vm->lock);
> + if (xe->info.has_ctx_tlb_inval) {
> + down_read(&vm->exec_queues.lock);
> + for (id = 0; id < ARRAY_SIZE(vm->exec_queues.list); id++)
> + list_for_each_entry(eq, &vm->exec_queues.list[id],
> + vm_exec_queue_link)
> + atomic_or(q_flag, &eq->ban_reason);
> + up_read(&vm->exec_queues.lock);
[Severity: Critical]
Is it safe to iterate vm->exec_queues.list while holding only the lock in
read mode?
Currently, the MMU notifier paths like xe_svm_invalidate() submit TLB
invalidations by calling send_tlb_inval_ctx_ppgtt(). That function also takes
down_read(&vm->exec_queues.lock) but then it mutates the list, moving items
using list_move_tail(&q->vm_exec_queue_link, &tlb_inval_list) onto a local
stack variable.
If the shrinker triggers this purge_page path concurrently with the MMU
notifier, both will execute concurrently because they both hold the lock using
down_read().
Could the list_for_each_entry() iterator here follow pointers into the stack
frame of send_tlb_inval_ctx_ppgtt(), resulting in list/kernel stack
corruption and arbitrary memory writes when atomic_or() is called?
> + } else {
> + list_for_each_entry(eq, &vm->preempt.exec_queues, lr.link)
> + atomic_or(q_flag, &eq->ban_reason);
> + }
> + smp_wmb(); /* Force all queue bits to be visible before killing the VM */
> xe_vm_kill(vm, true);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826135136.204044-16-tejas.upadhyay@intel.com?part=13
next prev parent reply other threads:[~2026-08-26 14:20 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 13:51 [PATCH V18 00/14] Add memory page offlining support Tejas Upadhyay
2026-08-26 13:51 ` [PATCH V18 01/14] drm/xe: Link VRAM object with gpu buddy Tejas Upadhyay
2026-08-26 22:31 ` Andi Shyti
2026-08-26 13:51 ` [PATCH V18 02/14] drm/xe: Link LRC BO and its execution Queue Tejas Upadhyay
2026-08-26 22:34 ` Andi Shyti
2026-08-26 13:51 ` [PATCH V18 03/14] drm/xe: Extend BO purge to handle vram pages as well Tejas Upadhyay
2026-08-26 14:07 ` sashiko-bot
2026-08-26 22:42 ` Andi Shyti
2026-08-27 6:17 ` Upadhyay, Tejas
2026-08-27 14:40 ` Andi Shyti
2026-08-27 14:48 ` Upadhyay, Tejas
2026-08-28 5:25 ` Upadhyay, Tejas
2026-08-28 7:39 ` Andi Shyti
2026-08-28 17:29 ` Upadhyay, Tejas
2026-08-26 13:51 ` [PATCH V18 04/14] drm/xe/bo: Make xe_bo_is_user() public Tejas Upadhyay
2026-08-26 22:44 ` Andi Shyti
2026-08-26 13:51 ` [PATCH V18 05/14] drm/xe: Guard teardown paths against purged BOs Tejas Upadhyay
2026-08-26 14:12 ` sashiko-bot
2026-08-27 6:08 ` Ghimiray, Himal Prasad
2026-08-27 8:27 ` Upadhyay, Tejas
2026-08-26 13:51 ` [PATCH V18 06/14] drm/xe/vram: Extract buddy alloc and free helpers Tejas Upadhyay
2026-08-26 22:50 ` Andi Shyti
2026-08-26 13:51 ` [PATCH V18 07/14] drm/xe/vram: Add page offline data structures and lifecycle Tejas Upadhyay
2026-08-26 23:09 ` Andi Shyti
2026-08-27 6:19 ` Ghimiray, Himal Prasad
2026-08-26 13:51 ` [PATCH V18 08/14] drm/xe/vram: Add VRAM page offline fault handler Tejas Upadhyay
2026-08-26 14:05 ` sashiko-bot
2026-08-26 13:51 ` [PATCH V18 09/14] drm/xe/configfs: Add bad_page_reservation attribute Tejas Upadhyay
2026-08-27 6:42 ` Ghimiray, Himal Prasad
2026-08-27 15:00 ` Michal Wajdeczko
2026-08-28 17:48 ` Upadhyay, Tejas
2026-08-26 13:51 ` [PATCH V18 10/14] drm/xe/ras: Cache bad_page_reservation policy at init Tejas Upadhyay
2026-08-26 14:11 ` sashiko-bot
2026-08-27 6:45 ` Ghimiray, Himal Prasad
2026-08-26 13:51 ` [PATCH V18 11/14] drm/xe/vram: Check bad_page_reservation policy in fault handler Tejas Upadhyay
2026-08-26 14:08 ` sashiko-bot
2026-08-27 6:46 ` Ghimiray, Himal Prasad
2026-08-27 15:04 ` Michal Wajdeczko
2026-08-26 13:51 ` [PATCH V18 12/14] drm/xe: Expose bad VRAM pages via debugfs Tejas Upadhyay
2026-08-26 14:13 ` sashiko-bot
2026-08-27 15:16 ` Michal Wajdeczko
2026-08-28 19:06 ` Upadhyay, Tejas
2026-08-28 15:04 ` Rodrigo Vivi
2026-08-26 13:51 ` [PATCH V18 13/14] drm/xe/uapi: Expose ban reason in EXEC_QUEUE_GET_PROPERTY_BAN Tejas Upadhyay
2026-08-26 14:20 ` sashiko-bot [this message]
2026-08-27 18:26 ` Andi Shyti
2026-08-28 5:31 ` Upadhyay, Tejas
2026-08-26 13:51 ` [PATCH V18 14/14] drm/xe: Add fault-inject based VRAM page offline injection Tejas Upadhyay
2026-08-27 7:10 ` Ghimiray, Himal Prasad
2026-08-27 8:23 ` Upadhyay, Tejas
2026-08-26 14:37 ` ✗ CI.checkpatch: warning for Add memory page offlining support (rev21) Patchwork
2026-08-26 14:39 ` ✓ CI.KUnit: success " Patchwork
2026-08-26 15:21 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-26 19:01 ` ✓ Xe.CI.FULL: " 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=20260826142001.03D951F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tejas.upadhyay@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