Skip to contentSkip to conversation

drm/xe/lmtt: Unpublish page tables on allocation failure

PATCH New Ruoyu Wang 2 participants 2 messages Jul 7 – Jul 8

Subsystems (2)
lore
Share & tools
lore

Ruoyu Wang

author
#0 lore raw

PATCH 1/1 drm/xe/lmtt: Unpublish page tables on allocation failure

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")
---
 drivers/gpu/drm/xe/xe_lmtt.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_lmtt.c +10 -2
index 0c726eda93906..9b0f8d4b26abc 100644
@@ -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;
 }
 
Signature · 1 line
2.51.0
#1 lore raw

✗ LGCI.VerificationFailed: failure for drm/xe/lmtt: Unpublish page tables on allocation failure

== Series Details ==

== Series Details ==

Series: drm/xe/lmtt: Unpublish page tables on allocation failure
URL : https://patchwork.freedesktop.org/series/170008/
State : failure

== Summary ==

Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://intel-gfx-ci-public.igk.intel.com:8080/job/xe_pw_trigger/1209618/ (on master)