All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tejas Upadhyay" <tejas.upadhyay@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [V2] drm/xe: Skip clearing purged page-table BOs
Date: Mon, 07 Sep 2026 15:51:00 +0000	[thread overview]
Message-ID: <20260907155100.9F4091F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907153706.888679-2-tejas.upadhyay@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Incomplete fix leaving a NULL pointer dereference on the purge failure path.
--

commit 7b05185667ad1f435ac6e264d5925cdea78caa91
Author: Tejas Upadhyay <tejas.upadhyay@intel.com>

drm/xe: Skip clearing purged page-table BOs

This commit attempts to prevent accessing cleared vmaps during VM teardown 
by checking if the buffer object is purged before calling xe_map_memset().

> diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
> index 5d990c1c3740a..a9b9cd7ac2c87 100644
> --- a/drivers/gpu/drm/xe/xe_pt.c
> +++ b/drivers/gpu/drm/xe/xe_pt.c
[ ... ]
> @@ -236,9 +236,11 @@ void xe_pt_destroy(struct xe_pt *pt, u32 flags, struct llist_head *deferred)
>  */
> void xe_pt_clear(struct xe_device *xe, struct xe_pt *pt)
> {
> -	struct iosys_map *map = &pt->bo->vmap;
> +	struct xe_bo *bo = pt->bo;
> 
> -	xe_map_memset(xe, map, 0, 0, SZ_4K);
> +	xe_bo_assert_held(bo);
> +	if (!xe_bo_is_purged(bo))
> +		xe_map_memset(xe, &bo->vmap, 0, 0, SZ_4K);

[Severity: High]
This isn't a bug introduced by this patch, but does this incomplete fix still
leave a NULL pointer dereference if the purge operation fails?

If a VRAM fault triggers xe_ttm_vram_purge_page() on a root page table BO,
the sequence first unmaps the virtual mapping before attempting the purge:

xe_ttm_vram_mgr.c:xe_ttm_vram_purge_page() {
    ...
    xe_bo_set_purgeable_state(bo, XE_MADV_PURGEABLE_DONTNEED);
    ttm_bo_unmap_virtual(&bo->ttm);   /* nuke CPU mmap + VRAM IO mappings */
    if (xe_bo_is_pinned(bo))
        xe_bo_unpin(bo);
    ret = xe_ttm_bo_purge(&bo->ttm, &ctx);
    ...
}

During the ttm_bo_unmap_virtual() sequence, bo->vmap is cleared. If
xe_ttm_bo_purge() subsequently fails (for example, due to a memory allocation
failure in ttm_bo_validate()), the BO remains in the DONTNEED state rather
than becoming PURGED.

Later, when xe_vm_close() calls xe_pt_clear(), this newly added check
(!xe_bo_is_purged(bo)) will evaluate to true because the BO is only in the
DONTNEED state, not PURGED.

Could xe_map_memset() then be called with the cleared (NULL) bo->vmap,
causing a crash?

Would it be safer to explicitly guard against cleared mappings by checking
!iosys_map_is_null(&bo->vmap) here instead?

> }
> 
> /**

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260907153706.888679-2-tejas.upadhyay@intel.com?part=1

  parent reply	other threads:[~2026-09-07 15:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 15:37 [V2] drm/xe: Skip clearing purged page-table BOs Tejas Upadhyay
2026-09-07 15:46 ` ✓ CI.KUnit: success for drm/xe: Skip clearing purged page-table BOs (rev2) Patchwork
2026-09-07 15:51 ` sashiko-bot [this message]
2026-09-07 16:45 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-07 19:28 ` [V2] drm/xe: Skip clearing purged page-table BOs Ghimiray, Himal Prasad
2026-09-08  3:52   ` Ghimiray, Himal Prasad
2026-09-08  3:55     ` Matthew Brost
2026-09-08  3:56       ` Ghimiray, Himal Prasad
2026-09-07 19:41 ` ✓ Xe.CI.FULL: success for drm/xe: Skip clearing purged page-table BOs (rev2) 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=20260907155100.9F4091F00A3A@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 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.