FAILED: patch "[PATCH] drm/xe/pt: Reset current_op in xe_pt_update_ops_init()" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 6384271ac1ac0099198d15df79212a19ebdb929d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072945-jaybird-vaguely-739f@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6384271ac1ac0099198d15df79212a19ebdb929d Mon Sep 17 00:00:00 2001
From: Zongyao Bai <[email protected]>
Date: Tue, 14 Jul 2026 23:24:32 +0000
Subject: [PATCH] drm/xe/pt: Reset current_op in xe_pt_update_ops_init()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
xe_pt_update_ops_init() fails to reset current_op to 0. On the vm_bind path, ops_execute() calls xe_pt_update_ops_prepare() inside the xe_validation_guard() / drm_exec_until_all_locked() loop. When that loop retries due to lock contention or OOM eviction (drm_exec_retry_on_contention() / xe_validation_retry_on_oom()), xe_pt_update_ops_prepare() runs again on the same vops, and each call to bind_op_prepare() increments current_op without resetting it.
After N retries current_op exceeds the array size allocated by xe_vma_ops_alloc(), causing an out-of-bounds write into SLUB-poisoned memory and a subsequent UAF crash in xe_migrate_update_pgtables_cpu() when reading the corrupted pt_op->bind.
Also reset needs_svm_lock and needs_invalidation which are derived in the same prepare pass and would otherwise cause wrong migrate ops selection and redundant TLB invalidation on retry.
Fix this by resetting current_op, needs_svm_lock and needs_invalidation in xe_pt_update_ops_init().
v2 (Matt):
- Add details in commit message.
- Add Fixes tag and Cc to [email protected]
drivers/gpu/drm/xe/xe_pt.c +3 -0
@@ -2365,8 +2365,11 @@ static void xe_pt_update_ops_init(struct xe_vm_pgtable_update_ops *pt_update_ops) {init_llist_head (&pt_update_ops->deferred); + pt_update_ops->current_op =0 ; pt_update_ops->start = ~0x0ull ; pt_update_ops->last =0x0ull ; + pt_update_ops->needs_svm_lock = false; + pt_update_ops->needs_invalidation = false;xe_page_reclaim_list_init (&pt_update_ops->prl); }
Sasha Levin
maintainerPATCH 1/4 drm/xe: Use SVM range helpers in PT layer
From: Matthew Brost <[email protected]>
[ Upstream commit 9ea9b45701ab50049a722450abc28346d1121e6e ]
We have helpers SVM range start, end, and size. Use them in the PT layer rather than directly looking at the struct.
Stable-dep-of: 6384271ac1ac ("drm/xe/pt: Reset current_op in xe_pt_update_ops_init()")
--- drivers/gpu/drm/xe/xe_pt.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/xe/xe_pt.c +14 -14
@@ -715,7 +715,7 @@ xe_pt_stage_bind(struct xe_tile *tile, struct xe_vma *vma, .vm = vm, .tile = tile, .curs = &curs, - .va_curs_start = range ? range->base.itree.start : + .va_curs_start = range ?xe_svm_range_start (range) : xe_vma_start(vma), .vma = vma, .wupd.entries = entries,
@@ -734,7 +734,7 @@ xe_pt_stage_bind(struct xe_tile *tile, struct xe_vma *vma, }if (xe_svm_range_has_dma_mapping (range)) {xe_res_first_dma (range->base.pages.dma_addr,0 , - range->base.itree.last +1 - range->base.itree.start, +xe_svm_range_size (range), &curs);xe_svm_range_debug (range,"BIND PREPARE - MIXED" ); }else {
@@ -778,8 +778,8 @@ xe_pt_stage_bind(struct xe_tile *tile, struct xe_vma *vma, walk_pt: ret =xe_pt_walk_range (&pt->base, pt->level, - range ? range->base.itree.start :xe_vma_start (vma), - range ? range->base.itree.last +1 :xe_vma_end (vma), + range ?xe_svm_range_start (range) :xe_vma_start (vma), + range ?xe_svm_range_end (range) :xe_vma_end (vma), &xe_walk.base); *num_entries = xe_walk.wupd.num_used_entries;
@@ -983,8 +983,8 @@ bool xe_pt_zap_ptes_range(struct xe_tile *tile, struct xe_vm *vm,if (!(pt_mask &BIT (tile->id)))return false; - (void )xe_pt_walk_shared (&pt->base, pt->level, range->base.itree.start, - range->base.itree.last +1 , &xe_walk.base); + (void )xe_pt_walk_shared (&pt->base, pt->level,xe_svm_range_start (range), +xe_svm_range_end (range), &xe_walk.base);return xe_walk.needs_invalidate; }
@@ -1701,8 +1701,8 @@ static unsigned int xe_pt_stage_unbind(struct xe_tile *tile,struct xe_svm_range *range, struct xe_vm_pgtable_update *entries) { - u64 start = range ? range->base.itree.start : xe_vma_start(vma); -u64 end = range ? range->base.itree.last +1 :xe_vma_end (vma); + u64 start = range ? xe_svm_range_start(range) : xe_vma_start(vma); +u64 end = range ?xe_svm_range_end (range) :xe_vma_end (vma); struct xe_pt_stage_unbind_walk xe_walk = { .base = { .ops = &xe_pt_stage_unbind_ops,
@@ -1912,7 +1912,7 @@ static int bind_range_prepare(struct xe_vm *vm, struct xe_tile *tile,vm_dbg (&xe_vma_vm (vma)->xe->drm,"Preparing bind, with range [%lx...%lx)\n" , - range->base.itree.start, range->base.itree.last); +xe_svm_range_start (range),xe_svm_range_end (range) -1 ); pt_op->vma =NULL ; pt_op->bind = true;
@@ -1927,8 +1927,8 @@ static int bind_range_prepare(struct xe_vm *vm, struct xe_tile *tile, pt_op->num_entries, true);xe_pt_update_ops_rfence_interval (pt_update_ops, - range->base.itree.start, - range->base.itree.last +1 ); +xe_svm_range_start (range), +xe_svm_range_end (range)); ++pt_update_ops->current_op; pt_update_ops->needs_svm_lock = true;
@@ -2023,7 +2023,7 @@ static int unbind_range_prepare(struct xe_vm *vm,vm_dbg (&vm->xe->drm,"Preparing unbind, with range [%lx...%lx)\n" , - range->base.itree.start, range->base.itree.last); +xe_svm_range_start (range),xe_svm_range_end (range) -1 ); pt_op->vma =XE_INVALID_VMA ; pt_op->bind = false;
@@ -2034,8 +2034,8 @@ static int unbind_range_prepare(struct xe_vm *vm,xe_vm_dbg_print_entries (tile_to_xe (tile), pt_op->entries, pt_op->num_entries, false); -xe_pt_update_ops_rfence_interval (pt_update_ops, range->base.itree.start, - range->base.itree.last +1 ); +xe_pt_update_ops_rfence_interval (pt_update_ops,xe_svm_range_start (range), +xe_svm_range_end (range)); ++pt_update_ops->current_op; pt_update_ops->needs_svm_lock = true; pt_update_ops->needs_invalidation |= xe_vm_has_scratch(vm) ||
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 drm/xe: Stub out new pagefault layer
From: Matthew Brost <[email protected]>
[ Upstream commit 620a09fb0bddf387f418663478b48ca4ba62b6d6 ]
Stub out the new page fault layer and add kernel documentation. This is intended as a replacement for the GT page fault layer, enabling multiple producers to hook into a shared page fault consumer interface.
v2:
- Fix kernel doc typo (checkpatch)
- Remove comment around GT (Stuart)
- Add explaination around reclaim (Francois)
- Add comment around u8 vs enum (Francois)
- Include engine instance (Stuart)
v3:
- Fix XE_PAGEFAULT_TYPE_ATOMIC_ACCESS_VIOLATION kernel doc (Stuart)
Stable-dep-of: 6384271ac1ac ("drm/xe/pt: Reset current_op in xe_pt_update_ops_init()")
--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_pagefault.c | 65 +++++++++++ drivers/gpu/drm/xe/xe_pagefault.h | 19 ++++ drivers/gpu/drm/xe/xe_pagefault_types.h | 136 ++++++++++++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_pagefault.c create mode 100644 drivers/gpu/drm/xe/xe_pagefault.h create mode 100644 drivers/gpu/drm/xe/xe_pagefault_types.h
drivers/gpu/drm/xe/Makefile +1 -0
@@ -94,6 +94,7 @@ xe-y += xe_bb.o \ xe_nvm.o \ xe_oa.o \ xe_observation.o \ + xe_pagefault.o \ xe_pat.o \ xe_pci.o \ xe_pcode.o \
drivers/gpu/drm/xe/xe_pagefault.c new file +65 -0
65 lines not on this page · raw message
drivers/gpu/drm/xe/xe_pagefault.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef _XE_PAGEFAULT_H_ +#define _XE_PAGEFAULT_H_ + +struct xe_device ; +struct xe_gt ; +struct xe_pagefault ; + +int xe_pagefault_init (struct xe_device *xe); + +void xe_pagefault_reset (struct xe_device *xe,struct xe_gt *gt); + +int xe_pagefault_handler (struct xe_device *xe,struct xe_pagefault *pf); + +#endif
drivers/gpu/drm/xe/xe_pagefault_types.h new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 drm/xe: Add page reclamation info to device info
In reply to Sasha LevinFrom: Oak Zeng <[email protected]>
[ Upstream commit 9b1a0e0a15c97987fdf56a615f3d13995bafd042 ]
Starting from Xe3p, HW adds a feature assisting range based page reclamation. Introduce a bit in device info to indicate whether device has such capability.
Stable-dep-of: 6384271ac1ac ("drm/xe/pt: Reset current_op in xe_pt_update_ops_init()")
--- drivers/gpu/drm/xe/xe_device_types.h | 2 ++ drivers/gpu/drm/xe/xe_pci.c | 1 + drivers/gpu/drm/xe/xe_pci_types.h | 1 + 3 files changed, 4 insertions(+)
drivers/gpu/drm/xe/xe_device_types.h +2 -0
@@ -305,6 +305,8 @@ struct xe_device {* pcode mailbox commands. */ u8 has_mbx_power_limits:1; +/** @info.has_page_reclaim_hw_assist: Device supports page reclamation feature */ + u8 has_page_reclaim_hw_assist:1;/** @info.has_pxp: Device has PXP support */ u8 has_pxp:1;/** @info.has_range_tlb_inval: Has range based TLB invalidations */
drivers/gpu/drm/xe/xe_pci.c +1 -0
@@ -591,6 +591,7 @@ static int xe_info_init_early(struct xe_device *xe, xe->info.has_heci_cscfi = desc->has_heci_cscfi; xe->info.has_late_bind = desc->has_late_bind; xe->info.has_llc = desc->has_llc; + xe->info.has_page_reclaim_hw_assist = desc->has_page_reclaim_hw_assist; xe->info.has_pxp = desc->has_pxp; xe->info.has_sriov = desc->has_sriov; xe->info.skip_guc_pc = desc->skip_guc_pc;
drivers/gpu/drm/xe/xe_pci_types.h +1 -0
@@ -42,6 +42,7 @@ struct xe_device_desc { u8 has_late_bind:1; u8 has_llc:1; u8 has_mbx_power_limits:1; + u8 has_page_reclaim_hw_assist:1; u8 has_pxp:1; u8 has_sriov:1; u8 needs_scratch:1;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 drm/xe/pt: Reset current_op in xe_pt_update_ops_init()
In reply to Sasha LevinFrom: Zongyao Bai <[email protected]>
[ Upstream commit 6384271ac1ac0099198d15df79212a19ebdb929d ]
xe_pt_update_ops_init() fails to reset current_op to 0. On the vm_bind path, ops_execute() calls xe_pt_update_ops_prepare() inside the xe_validation_guard() / drm_exec_until_all_locked() loop. When that loop retries due to lock contention or OOM eviction (drm_exec_retry_on_contention() / xe_validation_retry_on_oom()), xe_pt_update_ops_prepare() runs again on the same vops, and each call to bind_op_prepare() increments current_op without resetting it.
After N retries current_op exceeds the array size allocated by xe_vma_ops_alloc(), causing an out-of-bounds write into SLUB-poisoned memory and a subsequent UAF crash in xe_migrate_update_pgtables_cpu() when reading the corrupted pt_op->bind.
Also reset needs_svm_lock and needs_invalidation which are derived in the same prepare pass and would otherwise cause wrong migrate ops selection and redundant TLB invalidation on retry.
Fix this by resetting current_op, needs_svm_lock and needs_invalidation in xe_pt_update_ops_init().
v2 (Matt):
- Add details in commit message.
- Add Fixes tag and Cc to [email protected]
--- drivers/gpu/drm/xe/xe_pt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/xe/xe_pt.c +3 -0
@@ -2143,8 +2143,11 @@ static void xe_pt_update_ops_init(struct xe_vm_pgtable_update_ops *pt_update_ops) {init_llist_head (&pt_update_ops->deferred); + pt_update_ops->current_op =0 ; pt_update_ops->start = ~0x0ull ; pt_update_ops->last =0x0ull ; + pt_update_ops->needs_svm_lock = false; + pt_update_ops->needs_invalidation = false; }/**
Signature · 1 line
2.53.0