drm/xe: Add wa_14028434957 to Graphics Version 35.11
Subsystems (2)
PATCH 1/1 drm/xe: Add wa_14028434957 to Graphics Version 35.11
Prevent the SNIB AER latch from swallowing back-to-back uncorrectable non-fatal errors.
Firmware bypasses the faulty AER path by routing these errors directly via MSI. This patch intercepts the MSI and reuses the existing GFSP error containment logic.
Because GFSP mailbox queries can sleep, handling is deferred to a workqueue (nonfatal_msi_work) to ensure hardirq safety. If a reset is required, the device is wedged (a stopgap until VR driver quiescing support allows for an actual Secondary Bus Reset).
--- drivers/gpu/drm/xe/xe_device_wa_oob.rules | 1 + drivers/gpu/drm/xe/xe_drm_ras_types.h | 5 +++ drivers/gpu/drm/xe/xe_hw_error.c | 39 +++++++++++++++++++++++ 3 files changed, 45 insertions(+)
drivers/gpu/drm/xe/xe_device_wa_oob.rules +1 -0
@@ -7,3 +7,4 @@ 14026633728 PLATFORM(CRESCENTISLAND) 14026746987 PLATFORM(CRESCENTISLAND) 14026779378 PLATFORM(CRESCENTISLAND) +14028434957 PLATFORM(CRESCENTISLAND)
drivers/gpu/drm/xe/xe_drm_ras_types.h +5 -0
@@ -9,6 +9,8 @@#include <linux/atomic.h> #include <drm/xe_drm.h> +#include <linux/workqueue.h> +struct drm_ras_node ;/* Error categories reported by hardware */
@@ -46,6 +48,9 @@ struct xe_drm_ras {/** @disable_vram_page_offline: cached configfs policy, immutable after init */ bool disable_vram_page_offline; + +/** @nonfatal_msi_work: Worker to process uncorrectable non-fatal errors */ + struct work_struct nonfatal_msi_work; };#endif
drivers/gpu/drm/xe/xe_hw_error.c +39 -0
@@ -5,6 +5,8 @@#include <linux/bitmap.h> +#include <drm/drm_managed.h> +#include "regs/xe_gsc_regs.h" #include "regs/xe_hw_error_regs.h" #include "regs/xe_irq_regs.h"
@@ -14,7 +16,9 @@#include "xe_drm_ras.h" #include "xe_hw_error.h" #include "xe_mmio.h" +#include "xe_ras.h" #include "xe_survivability_mode.h" +#include "xe_wa.h" #define GT_HW_ERROR_MAX_ERR_BITS 16#define HEC_UNCORR_FW_ERR_BITS 4
@@ -173,6 +177,27 @@ static void csc_hw_error_work(struct work_struct *work)xe_survivability_mode_runtime_enable (xe); } +static void nonfatal_msi_work (struct work_struct *work) +{ +struct xe_drm_ras *ras =container_of (work,typeof (*ras), nonfatal_msi_work); +struct xe_device *xe =container_of (ras,typeof (*xe), ras); +enum xe_ras_recovery_action action =xe_ras_process_errors (xe); + +/* +* TODO: Request an SBR instead of wedging, once VR driver +* quiescing support is in place. +*/ +if (action !=XE_RAS_RECOVERY_ACTION_RECOVERED ) +xe_device_declare_wedged (xe); +} + +static void hw_error_fini (struct drm_device *drm,void *arg) +{ +struct xe_device *xe = arg; + +cancel_work_sync (&xe->ras.nonfatal_msi_work); +} +static void csc_hw_error_handler (struct xe_tile *tile,const enum hardware_error hw_err) {const enum drm_xe_ras_error_severity severity =hw_err_to_severity (hw_err);
@@ -436,6 +461,15 @@ static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er* here for those platforms. */ if (xe->info.has_sysctrl) { +/* +* Defer non-fatal MSI handling to process context because the GFSP +* query can sleep. +*/ +if (hw_err ==HARDWARE_ERROR_NONFATAL &&XE_DEVICE_WA (xe,14028434957 )) { +schedule_work (&xe->ras.nonfatal_msi_work); +return ; + } +drm_err_ratelimited (&xe->drm,HW_ERR "Invalid error routing\n" );return ; }
@@ -546,6 +580,11 @@ void xe_hw_error_init(struct xe_device *xe) {struct xe_tile *tile =xe_device_get_root_tile (xe); +INIT_WORK (&xe->ras.nonfatal_msi_work, nonfatal_msi_work); + +if (drmm_add_action_or_reset (&xe->drm, hw_error_fini, xe)) +drm_err (&xe->drm,"Failed to register hw_error_fini\n" ); +if (!IS_DGFX (xe) ||IS_SRIOV_VF (xe))return ;
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] drm: missing error return after drmm_add_action_or_reset() failure leads to leaked work and UAF…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] drm: missing error return after drmm_add_action_or_reset() failure leads to leaked work and UAF
- [High] xe: Use-after-free/MMIO fault due to deferred workqueue cancellation in drmm
- [High] xe: nonfatal_msi_work accesses MMIO without waking device, causing suspended MMIO accesses
- [High] drm/xe: UAF and uninitialized work_struct in csc_hw_error_work
--
commit c1e7bdf12138e40e4c7ecaaa2d05a9ee296aa085
Author: Varun Gupta <[email protected]>
Subject: drm/xe: Add wa_14028434957 to Graphics Version 35.11
This patch bypasses a faulty AER path by intercepting uncorrectable non-fatal MSI errors and routing them to a deferred workqueue. The new workqueue reuses the GFSP error containment logic and wedges the device if a reset is required.
Quoted 4 lines
drivers/gpu/drm/xe/xe_hw_error.c +0
-0
[ ... ]
drivers/gpu/drm/xe/xe_hw_error.c static void csc_hw_error_work(struct work_struct *work) · line 184
Quoted 9 lines
drivers/gpu/drm/xe/xe_hw_error.c +5
-0@@ -173,6 +177,27 @@ static void csc_hw_error_work(struct work_struct *work)xe_survivability_mode_runtime_enable (xe); } +static void nonfatal_msi_work (struct work_struct *work) +{ +struct xe_drm_ras *ras =container_of (work,typeof (*ras), nonfatal_msi_work); +struct xe_device *xe =container_of (ras,typeof (*xe), ras); +enum xe_ras_recovery_action action =xe_ras_process_errors (xe);
[Severity: High]
Does this workqueue execution need to resume the device first?
Because this runs asynchronously in a worker thread, the runtime PM reference from the interrupt might already be released, allowing the device to auto-suspend to D3. The nested call to xe_sysctrl_send_command() uses guard(xe_pm_runtime_noresume)(xe), which blocks future suspends but does not wake a device that is already suspended. This means MMIO accesses to SYSCTRL_MB_CTRL might target suspended hardware.
Other workers like xe_sysctrl_work() seem to use guard(xe_pm_runtime)(xe) to explicitly wake the device.
Quoted 4 lines
drivers/gpu/drm/xe/xe_hw_error.c +4
-0+ +/* +* TODO: Request an SBR instead of wedging, once VR driver +* quiescing support is in place.
drivers/gpu/drm/xe/xe_hw_error.c static void csc_hw_error_work(struct work_struct *work) · line 198
Quoted 10 lines
drivers/gpu/drm/xe/xe_hw_error.c +10
-0+*/ +if (action !=XE_RAS_RECOVERY_ACTION_RECOVERED ) +xe_device_declare_wedged (xe); +} + +static void hw_error_fini (struct drm_device *drm,void *arg) +{ +struct xe_device *xe = arg; + +cancel_work_sync (&xe->ras.nonfatal_msi_work);
[Severity: High]
Should this function also cancel csc_hw_error_work?
The code initializes csc_hw_error_work in xe_hw_error_init(), but it doesn't appear to be cancelled during teardown. With a fini function now added, leaving csc_hw_error_work uncancelled might allow it to run after the xe_device structures are freed.
Also, it looks like csc_hw_error_work is only initialized for the root tile in xe_hw_error_init():
struct xe_tile *tile = xe_device_get_root_tile(xe);
...
INIT_WORK(&tile->csc_hw_error_work, csc_hw_error_work);If a non-root tile receives a hardware error and schedules this work, might it operate on an uninitialized work_struct?
Quoted 2 lines
drivers/gpu/drm/xe/xe_hw_error.c +2
-0+} +
[ ... ]
drivers/gpu/drm/xe/xe_hw_error.c static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er · line 469
Quoted 10 lines
drivers/gpu/drm/xe/xe_hw_error.c +6
-0@@ -436,6 +461,15 @@ static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er* here for those platforms. */ if (xe->info.has_sysctrl) { +/* +* Defer non-fatal MSI handling to process context because the GFSP +* query can sleep. +*/ +if (hw_err ==HARDWARE_ERROR_NONFATAL &&XE_DEVICE_WA (xe,14028434957 )) { +schedule_work (&xe->ras.nonfatal_msi_work);
[Severity: High]
Could this work execute after the MMIO mappings have been unmapped?
Since hw_error_fini() is registered as a drmm action, its execution is deferred until the last DRM reference is dropped (like when userspace closes the device file). However, devres actions unmap the device's MMIO mappings synchronously during PCI unbind.
If this work is queued just before the IRQ is torn down and executes after the unbind finishes, the nested xe_ras_process_errors() could attempt to access unmapped MMIO regions via xe_sysctrl_send_command(), resulting in a fatal page fault.
Quoted 7 lines
drivers/gpu/drm/xe/xe_hw_error.c +3
-0+return ; + } +drm_err_ratelimited (&xe->drm,HW_ERR "Invalid error routing\n" );return ; }
drivers/gpu/drm/xe/xe_hw_error.c void xe_hw_error_init(struct xe_device *xe) · line 586
Quoted 7 lines
drivers/gpu/drm/xe/xe_hw_error.c +4
-0@@ -546,6 +580,11 @@ void xe_hw_error_init(struct xe_device *xe) {struct xe_tile *tile =xe_device_get_root_tile (xe); +INIT_WORK (&xe->ras.nonfatal_msi_work, nonfatal_msi_work); + +if (drmm_add_action_or_reset (&xe->drm, hw_error_fini, xe)) +drm_err (&xe->drm,"Failed to register hw_error_fini\n" );
[Severity: High]
Is a return statement missing here?
If drmm_add_action_or_reset() fails, it logs an error but initialization continues. This means the driver can be fully initialized without hw_error_fini() being registered. If nonfatal_msi_work gets scheduled, it will never be cancelled on teardown, potentially leading to a use-after-free regression.
Quoted 4 lines
drivers/gpu/drm/xe/xe_hw_error.c +1
-0+if (!IS_DGFX (xe) ||IS_SRIOV_VF (xe))return ;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 40 lines · On 09-Oct-26 12:43 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] drm: missing error return afterdrmm_add_action_or_reset()failure leads to leaked work and UAF
- [High] xe: Use-after-free/MMIO fault due to deferred workqueue cancellation in drmm
- [High] xe:nonfatal_msi_workaccesses MMIO without waking device, causing suspended MMIO accesses
- [High] drm/xe: UAF and uninitializedwork_structincsc_hw_error_work
--commit
c1e7bdf12138e40e4c7ecaaa2d05a9ee296aa085
Author: Varun Gupta <[email protected]>
Subject: drm/xe: Addwa_14028434957to Graphics Version 35.11This patch bypasses a faulty AER path by intercepting uncorrectable non-fatal MSI errors and routing them to a deferred workqueue. The new workqueue reuses the GFSP error containment logic and wedges the device if a reset is required.
Quoted 4 lines
drivers/gpu/drm/xe/xe_hw_error.c +0
-0[ ... ]
drivers/gpu/drm/xe/xe_hw_error.c static void csc_hw_error_work(struct work_struct *work) · line 184
Quoted 9 lines
drivers/gpu/drm/xe/xe_hw_error.c +5
-0@@ -173,6 +177,27 @@ static void csc_hw_error_work(struct work_struct *work)xe_survivability_mode_runtime_enable (xe); } +static void nonfatal_msi_work (struct work_struct *work) +{ +struct xe_drm_ras *ras =container_of (work,typeof (*ras), nonfatal_msi_work); +struct xe_device *xe =container_of (ras,typeof (*xe), ras); +enum xe_ras_recovery_action action =xe_ras_process_errors (xe);[Severity: High]
Does this workqueue execution need to resume the device first?Because this runs asynchronously in a worker thread, the runtime PM reference from the interrupt might already be released, allowing the device to auto-suspend to D3. The nested call to
xe_sysctrl_send_command()uses guard(xe_pm_runtime_noresume)(xe), which blocks future suspends but does not wake a device that is already suspended. This means MMIO accesses toSYSCTRL_MB_CTRLmight target suspended hardware.
Quoted 2 lines
Other workers like
xe_sysctrl_work()seem to use guard(xe_pm_runtime)(xe) to explicitly wake the device.
Noted, added PM guard in v2.
Quoted 25 lines
Quoted 4 lines
drivers/gpu/drm/xe/xe_hw_error.c +4
-0+ +/* +* TODO: Request an SBR instead of wedging, once VR driver +* quiescing support is in place. drivers/gpu/drm/xe/xe_hw_error.c static void csc_hw_error_work(struct work_struct *work) · line 198
Quoted 10 lines
drivers/gpu/drm/xe/xe_hw_error.c +10
-0+*/ +if (action !=XE_RAS_RECOVERY_ACTION_RECOVERED ) +xe_device_declare_wedged (xe); +} + +static void hw_error_fini (struct drm_device *drm,void *arg) +{ +struct xe_device *xe = arg; + +cancel_work_sync (&xe->ras.nonfatal_msi_work);[Severity: High]
Should this function also cancelcsc_hw_error_work?The code initializes
csc_hw_error_workinxe_hw_error_init(), but it doesn't appear to be cancelled during teardown. With a fini function now added, leavingcsc_hw_error_workuncancelled might allow it to run after thexe_devicestructures are freed.Also, it looks like
csc_hw_error_workis only initialized for the root tile inxe_hw_error_init():
Quoted 6 lines
struct xe_tile *tile = xe_device_get_root_tile(xe); ... INIT_WORK(&tile->csc_hw_error_work, csc_hw_error_work);If a non-root tile receives a hardware error and schedules this work, might it operate on an uninitialized
work_struct?
This looks like a pre-existing thing out of scope for this patch, will spin another patch if required.
Quoted 21 lines
Quoted 2 lines
drivers/gpu/drm/xe/xe_hw_error.c +2
-0+} +[ ... ]
drivers/gpu/drm/xe/xe_hw_error.c static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er · line 469
Quoted 10 lines
drivers/gpu/drm/xe/xe_hw_error.c +6
-0@@ -436,6 +461,15 @@ static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er* here for those platforms. */ if (xe->info.has_sysctrl) { +/* +* Defer non-fatal MSI handling to process context because the GFSP +* query can sleep. +*/ +if (hw_err ==HARDWARE_ERROR_NONFATAL &&XE_DEVICE_WA (xe,14028434957 )) { +schedule_work (&xe->ras.nonfatal_msi_work);[Severity: High]
Could this work execute after the MMIO mappings have been unmapped?Since
hw_error_fini()is registered as a drmm action, its execution is deferred until the last DRM reference is dropped (like when userspace closes the device file). However, devres actions unmap the device's MMIO mappings synchronously during PCI unbind.
Quoted 4 lines
If this work is queued just before the IRQ is torn down and executes after the unbind finishes, the nested
xe_ras_process_errors()could attempt to access unmapped MMIO regions viaxe_sysctrl_send_command(), resulting in a fatal page fault.
Noted, made needed change in v2.
Quoted 17 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_hw_error.c +3
-0+return ; + } +drm_err_ratelimited (&xe->drm,HW_ERR "Invalid error routing\n" );return ; }drivers/gpu/drm/xe/xe_hw_error.c void xe_hw_error_init(struct xe_device *xe) · line 586
Quoted 7 lines
drivers/gpu/drm/xe/xe_hw_error.c +4
-0@@ -546,6 +580,11 @@ void xe_hw_error_init(struct xe_device *xe) {struct xe_tile *tile =xe_device_get_root_tile (xe); +INIT_WORK (&xe->ras.nonfatal_msi_work, nonfatal_msi_work); + +if (drmm_add_action_or_reset (&xe->drm, hw_error_fini, xe)) +drm_err (&xe->drm,"Failed to register hw_error_fini\n" );[Severity: High]
Is a return statement missing here?
Quoted 5 lines
If
drmm_add_action_or_reset()fails, it logs an error but initialization continues. This means the driver can be fully initialized withouthw_error_fini()being registered. Ifnonfatal_msi_workgets scheduled, it will never be cancelled on teardown, potentially leading to a use-after-free regression.
Thought about doing this in v1 itself but went against it to avoid changing return types of functions, but looks like it is really needed to prevent UAF so implementing this in v2.
Thanks
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/xe/xe_hw_error.c +1
-0+if (!IS_DGFX (xe) ||IS_SRIOV_VF (xe))return ;
Patchwork
CI✗ CI.KUnit: failure for drm/xe: Add wa_14028434957 to Graphics Version 35.11
In reply to Varun Gupta== Series Details ==
== Series Details ==
Series: drm/xe: Add wa_14028434957 to Graphics Version 35.11
URL : https://patchwork.freedesktop.org/series/175804/
State : failure
== Summary ==
+ trap cleanup EXIT
+ kunitconfigs=('/kernel/drivers/gpu/tests/.kunitconfig' '/kernel/drivers/gpu/drm/xe/.kunitconfig' '/kernel/drivers/gpu/drm/tests/.kunitconfig' '/kernel/drivers/gpu/drm/ttm/tests/.kunitconfig' '/kernel/drivers/dma-buf/.kunitconfig')
+ for kcfg in "${kunitconfigs[@]}"
+ [[ ! -f /kernel/drivers/gpu/tests/.kunitconfig ]]
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/tests/.kunitconfig
[07:47:10] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [07:47:15] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48 [07:47:35] Starting KUnit Kernel (1/1)... [07:47:35] ============================================================ Running tests with: $ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [07:47:35] ================= gpu_buddy (14 subtests) ================== [07:47:35] [PASSED] gpu_test_buddy_alloc_limit [07:47:35] [PASSED] gpu_test_buddy_alloc_optimistic [07:47:35] [PASSED] gpu_test_buddy_alloc_pessimistic [07:47:35] [PASSED] gpu_test_buddy_alloc_pathological [07:47:35] [PASSED] gpu_test_buddy_alloc_contiguous [07:47:35] [PASSED] gpu_test_buddy_alloc_clear [07:47:35] [PASSED] gpu_test_buddy_alloc_range [07:47:36] [PASSED] gpu_test_buddy_alloc_range_bias [07:47:36] [PASSED] gpu_test_buddy_fragmentation_performance [07:47:37] [PASSED] gpu_test_buddy_dirty_tracker_performance [07:47:37] [PASSED] gpu_test_buddy_alloc_exceeds_max_order [07:47:37] [PASSED] gpu_test_buddy_offset_aligned_allocation [07:47:37] [PASSED] gpu_test_buddy_subtree_offset_alignment_stress [07:47:37] [PASSED] gpu_test_buddy_addr_to_block [07:47:37] ==================== [PASSED] gpu_buddy ==================== [07:47:37] ============================================================ [07:47:37] Testing complete. Ran 14 tests: passed: 14 [07:47:37] Elapsed time: 26.637s total, 4.488s configuring, 20.182s building, 1.925s running
+ for kcfg in "${kunitconfigs[@]}"
+ [[ ! -f /kernel/drivers/gpu/drm/xe/.kunitconfig ]]
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:In file included from ../include/linux/bitmap.h:8,
from ../drivers/gpu/drm/xe/xe_hw_error.c:6:
../drivers/gpu/drm/xe/xe_hw_error.c: In function ‘hw_error_source_handler’:
../drivers/gpu/drm/xe/xe_wa.h:52:18: error: ‘XE_DEVICE_WA_OOB_14028434957’ undeclared (first use in this function)
52 | test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->wa_active.oob); \
| ^~~~~~~~~~~~~~~~~../include/linux/bitops.h:43:32: note: in definition of macro ‘bitop’
43 | ((__builtin_constant_p(nr) && \
| ^~../drivers/gpu/drm/xe/xe_wa.h:52:9: note: in expansion of macro ‘test_bit’
52 | test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->wa_active.oob); \
| ^~~~~~~~../drivers/gpu/drm/xe/xe_hw_error.c:468:58: note: in expansion of macro ‘XE_DEVICE_WA’
468 | if (hw_err == HARDWARE_ERROR_NONFATAL && XE_DEVICE_WA(xe, 14028434957)) {
| ^~~~~~~~~~~~../drivers/gpu/drm/xe/xe_wa.h:52:18: note: each undeclared identifier is reported only once for each function it appears in
52 | test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->wa_active.oob); \
| ^~~~~~~~~~~~~~~~~../include/linux/bitops.h:43:32: note: in definition of macro ‘bitop’
43 | ((__builtin_constant_p(nr) && \
| ^~../drivers/gpu/drm/xe/xe_wa.h:52:9: note: in expansion of macro ‘test_bit’
52 | test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->wa_active.oob); \
| ^~~~~~~~../drivers/gpu/drm/xe/xe_hw_error.c:468:58: note: in expansion of macro ‘XE_DEVICE_WA’
468 | if (hw_err == HARDWARE_ERROR_NONFATAL && XE_DEVICE_WA(xe, 14028434957)) {
| ^~~~~~~~~~~~
make[7]: *** [../scripts/Makefile.build:290: drivers/gpu/drm/xe/xe_hw_error.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:551: drivers/gpu/drm/xe] Error 2 make[5]: *** [../scripts/Makefile.build:551: drivers/gpu/drm] Error 2 make[4]: *** [../scripts/Makefile.build:551: drivers/gpu] Error 2 make[3]: *** [../scripts/Makefile.build:551: drivers] Error 2
make[2]: *** [/kernel/Makefile:2229: .] Error 2
make[1]: *** [/kernel/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2
[07:47:37] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [07:47:39] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48 + cleanup ++ stat -c %u:%g /kernel + chown -R 1003:1003 /kernel