Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/lmtt: Unpublish page tables on allocation failure
@ 2026-07-07 15:05 Ruoyu Wang
  2026-07-08 13:53 ` ✗ LGCI.VerificationFailed: failure for " Patchwork
  0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-07-07 15:05 UTC (permalink / raw)
  To: matthew.brost, thomas.hellstrom, rodrigo.vivi, airlied, simona
  Cc: michal.winiarski, michal.wajdeczko, intel-xe, dri-devel,
	linux-kernel, Ruoyu Wang

LMTT allocation publishes a newly allocated child page table before
recursing into the next level. If a lower-level allocation fails, the
error path freed the page table directly but left the parent's software
entry and hardware PTE pointing at it.

The caller's failure cleanup then calls xe_lmtt_drop_pages(), which can
walk the stale entry and destroy the same subtree again. The stale PTE
also remains visible until the next invalidation.

Clear the parent software entry, write an invalid PTE, invalidate the
hardware view, and then destroy the partially allocated subtree.

This issue was found by a static analysis checker and confirmed by
manual source review.

Fixes: b1d204058218 ("drm/xe/pf: Introduce Local Memory Translation Table")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/gpu/drm/xe/xe_lmtt.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_lmtt.c b/drivers/gpu/drm/xe/xe_lmtt.c
index 0c726eda93906..9b0f8d4b26abc 100644
--- a/drivers/gpu/drm/xe/xe_lmtt.c
+++ b/drivers/gpu/drm/xe/xe_lmtt.c
@@ -406,8 +406,13 @@ static int __lmtt_alloc_range(struct xe_lmtt *lmtt, struct xe_lmtt_pt *pd,
 
 		if (pt->level != 0) {
 			err = __lmtt_alloc_range(lmtt, pt, offset, next);
-			if (err)
+			if (err) {
+				pd->entries[idx] = NULL;
+				lmtt_write_pte(lmtt, pd, LMTT_PTE_INVALID, idx);
+				lmtt_invalidate_hw(lmtt);
+				lmtt_destroy_pt(lmtt, pt);
 				return err;
+			}
 		}
 
 		offset = next;
@@ -453,7 +458,10 @@ static int lmtt_alloc_range(struct xe_lmtt *lmtt, unsigned int vfid, u64 start,
 	return 0;
 
 out_free_pt:
-	lmtt_pt_free(pt);
+	pd->entries[vfid] = NULL;
+	lmtt_write_pte(lmtt, pd, LMTT_PTE_INVALID, vfid);
+	lmtt_invalidate_hw(lmtt);
+	lmtt_destroy_pt(lmtt, pt);
 	return err;
 }
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-08 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 15:05 [PATCH] drm/xe/lmtt: Unpublish page tables on allocation failure Ruoyu Wang
2026-07-08 13:53 ` ✗ LGCI.VerificationFailed: failure for " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox