From: Greg Kroah-Hartman Date: Wed, 29 Jul 2026 10:56:44 +0000 (+0200) Subject: 6.18-stable patches X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=c5d720ec3100ccdafa4ac2ead4acd894a675441c;p=thirdparty%2Fkernel%2Fstable-queue.git 6.18-stable patches added patches: drm-amdgpu-fix-amdgpu_bo_move-when-old_mem-and-new_mem-are-both-gtt.patch drm-amdgpu-gfx9-fix-ring-and-ib-test-fail-after-mode2.patch drm-amdgpu-validate-cp_gfx_shadow-chunk-size-in-cs-pass1.patch drm-displayid-fix-tiled-display-topology-id-size.patch drm-i915-gem-add-missing-nospec-on-parallel-submit-slot.patch drm-nouveau-acr-fix-missing-nvkm_done-in-error-path-of-nvkm_acr_oneinit.patch drm-nouveau-fix-reversed-error-cleanup-order-in-ucopy-functions.patch drm-radeon-fix-r100_copy_blit-for-large-bos.patch drm-sysfb-avoid-possible-truncation-with-calculating-visible-size.patch drm-sysfb-avoid-truncating-maximum-stride.patch drm-sysfb-do-not-page-align-visible-size-of-the-framebuffer.patch drm-sysfb-return-errno-code-from-drm_sysfb_get_visible_size.patch --- diff --git a/queue-6.18/drm-amdgpu-fix-amdgpu_bo_move-when-old_mem-and-new_mem-are-both-gtt.patch b/queue-6.18/drm-amdgpu-fix-amdgpu_bo_move-when-old_mem-and-new_mem-are-both-gtt.patch new file mode 100644 index 0000000000..ab0eede470 --- /dev/null +++ b/queue-6.18/drm-amdgpu-fix-amdgpu_bo_move-when-old_mem-and-new_mem-are-both-gtt.patch @@ -0,0 +1,60 @@ +From ee94a65f192c05c543b4d3ad7137cd696b5c18fc Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timur=20Krist=C3=B3f?= +Date: Mon, 25 May 2026 13:33:18 +0200 +Subject: drm/amdgpu: Fix amdgpu_bo_move() when old_mem and new_mem are both GTT +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Timur Kristóf + +commit ee94a65f192c05c543b4d3ad7137cd696b5c18fc upstream. + +The UVD code relies on GTT to GTT moves in order to ensure +that its BOs don't cross 256M segments. + +Fixes: bfe5e585b44f ("drm/ttm: move last binding into the drivers.") +Signed-off-by: Timur Kristóf +Reviewed-by: Christian König +Signed-off-by: Alex Deucher +(cherry picked from commit 21fd45e5e2628d00b478590bcc3d14d3de5d45b6) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +@@ -505,6 +505,15 @@ static int amdgpu_bo_move(struct ttm_buf + + if (new_mem->mem_type == TTM_PL_TT || + new_mem->mem_type == AMDGPU_PL_PREEMPT) { ++ if (old_mem && (old_mem->mem_type == TTM_PL_TT || ++ old_mem->mem_type == AMDGPU_PL_PREEMPT)) { ++ r = ttm_bo_wait_ctx(bo, ctx); ++ if (r) ++ return r; ++ ++ amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm); ++ } ++ + r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem); + if (r) + return r; +@@ -537,6 +546,15 @@ static int amdgpu_bo_move(struct ttm_buf + amdgpu_bo_move_notify(bo, evict, new_mem); + ttm_resource_free(bo, &bo->resource); + ttm_bo_assign_mem(bo, new_mem); ++ return 0; ++ } ++ if ((old_mem->mem_type == TTM_PL_TT || ++ old_mem->mem_type == AMDGPU_PL_PREEMPT) && ++ (new_mem->mem_type == TTM_PL_TT || ++ new_mem->mem_type == AMDGPU_PL_PREEMPT)) { ++ amdgpu_bo_move_notify(bo, evict, new_mem); ++ ttm_resource_free(bo, &bo->resource); ++ ttm_bo_assign_mem(bo, new_mem); + return 0; + } + diff --git a/queue-6.18/drm-amdgpu-gfx9-fix-ring-and-ib-test-fail-after-mode2.patch b/queue-6.18/drm-amdgpu-gfx9-fix-ring-and-ib-test-fail-after-mode2.patch new file mode 100644 index 0000000000..b99e6c7c02 --- /dev/null +++ b/queue-6.18/drm-amdgpu-gfx9-fix-ring-and-ib-test-fail-after-mode2.patch @@ -0,0 +1,97 @@ +From 85ed06d990ff73212b5a91a406671cabd962e521 Mon Sep 17 00:00:00 2001 +From: Jiqian Chen +Date: Thu, 4 Jun 2026 18:30:23 +0800 +Subject: drm/amdgpu/gfx9: Fix Ring and IB test fail after mode2 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Jiqian Chen + +commit 85ed06d990ff73212b5a91a406671cabd962e521 upstream. + +For Renior APU with gfx9, in some test scenarios with disabling +ring_reset, like accessing an unmapped invalid address, it can +trigger a gpu job timeout event, then driver uses Mode2 reset +to reset GPU, but after Mode2 compute Ring test and IB test fail +randomly. It because the HQDs of MECs are always active before or +after Mode2, that causes MECs use stale HQDs when MECs are unhalted +before driver restore MQDs, and causes CPC and CPF are still stuck +after Mode2, then causes compute Ring and IB tests fail. + +So, add sequences to deactivate HQDs of MECs in suspend IP function +of the resetting process. + +v2: Move all sequences into a new function gfx_v9_0_cp_mode2_clear_state (Ray Huang) + To check reset Mode2 method in the if condition (Ray Huang) +v3: Move all sequences before Mode2 instead of after Mode2 (Timur Kristóf) +v4: Call amdgpu_gfx_rlc_enter/exit_safe_mode int the begin and end of + gfx_v9_0_deactivate_kcq_hqd (Alex Deucher) + +Signed-off-by: Jiqian Chen +Reviewed-by: Huang Rui +Reviewed-by: Timur Kristóf +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +(cherry picked from commit c3988a7ad4799514447294f04f063b422e0551df) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 39 ++++++++++++++++++++++++++++++++++ + 1 file changed, 39 insertions(+) + +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +@@ -4045,6 +4045,41 @@ static int gfx_v9_0_hw_init(struct amdgp + return r; + } + ++static void gfx_v9_0_deactivate_kcq_hqd(struct amdgpu_device *adev) ++{ ++ amdgpu_gfx_rlc_enter_safe_mode(adev, 0); ++ for (int i = 0; i < adev->gfx.num_compute_rings; i++) { ++ u32 tmp; ++ struct amdgpu_ring *ring = &adev->gfx.compute_ring[i]; ++ ++ mutex_lock(&adev->srbm_mutex); ++ soc15_grbm_select(adev, ring->me, ring->pipe, ring->queue, 0, 0); ++ tmp = RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE); ++ /* disable the queue if it's active */ ++ if (tmp & CP_HQD_ACTIVE__ACTIVE_MASK) { ++ int j; ++ ++ WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 1); ++ for (j = 0; j < adev->usec_timeout; j++) { ++ tmp = RREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE); ++ if (!(tmp & CP_HQD_ACTIVE__ACTIVE_MASK)) ++ break; ++ udelay(1); ++ } ++ if (j == AMDGPU_MAX_USEC_TIMEOUT) { ++ DRM_DEBUG("comp_%u_%u_%u dequeue request failed.\n", ++ ring->me, ring->pipe, ring->queue); ++ /* Manual disable if dequeue request times out */ ++ WREG32_SOC15(GC, 0, mmCP_HQD_ACTIVE, 0); ++ } ++ WREG32_SOC15(GC, 0, mmCP_HQD_DEQUEUE_REQUEST, 0); ++ } ++ soc15_grbm_select(adev, 0, 0, 0, 0, 0); ++ mutex_unlock(&adev->srbm_mutex); ++ } ++ amdgpu_gfx_rlc_exit_safe_mode(adev, 0); ++} ++ + static int gfx_v9_0_hw_fini(struct amdgpu_ip_block *ip_block) + { + struct amdgpu_device *adev = ip_block->adev; +@@ -4071,6 +4106,10 @@ static int gfx_v9_0_hw_fini(struct amdgp + return 0; + } + ++ if ((adev->flags & AMD_IS_APU) && amdgpu_in_reset(adev) && ++ amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_MODE2) ++ gfx_v9_0_deactivate_kcq_hqd(adev); ++ + /* Use deinitialize sequence from CAIL when unbinding device from driver, + * otherwise KIQ is hanging when binding back + */ diff --git a/queue-6.18/drm-amdgpu-validate-cp_gfx_shadow-chunk-size-in-cs-pass1.patch b/queue-6.18/drm-amdgpu-validate-cp_gfx_shadow-chunk-size-in-cs-pass1.patch new file mode 100644 index 0000000000..a899d9e1ed --- /dev/null +++ b/queue-6.18/drm-amdgpu-validate-cp_gfx_shadow-chunk-size-in-cs-pass1.patch @@ -0,0 +1,57 @@ +From 84c4c36acd5c4b2558b5069f869a165b2c655c84 Mon Sep 17 00:00:00 2001 +From: Mario Limonciello +Date: Fri, 12 Jun 2026 21:07:24 -0500 +Subject: drm/amdgpu: validate CP_GFX_SHADOW chunk size in CS pass1 + +From: Mario Limonciello + +commit 84c4c36acd5c4b2558b5069f869a165b2c655c84 upstream. + +Add a minimum-length check for the AMDGPU_CHUNK_ID_CP_GFX_SHADOW chunk in +amdgpu_cs_pass1(), matching the gate already present for the IB, FENCE and +BO_HANDLES chunk types. + +The CP_GFX_SHADOW case previously shared a bare break with the dependency +and syncobj chunk types, which do not dereference a fixed-size struct. When +userspace submits this chunk with length_dw == 0, vmemdup_array_user() is +called with size 0 and returns ZERO_SIZE_PTR, which passes the IS_ERR() +check. amdgpu_cs_p2_shadow() then dereferences chunk->kdata as a struct +drm_amdgpu_cs_chunk_cp_gfx_shadow (reading shadow->flags), faulting on the +ZERO_SIZE_PTR and causing a NULL-pointer dereference. + +This is reachable by an unprivileged process in the render group. Reject +undersized chunks with -EINVAL during pass1 so the bad submission is +rejected before pass2 ever dereferences the data. + +Fixes: ac9287055ff1 ("drm/amdgpu: add gfx shadow CS IOCTL support") +Reviewed-by: Alex Deucher +Signed-off-by: Mario Limonciello +Signed-off-by: Alex Deucher +(cherry picked from commit 7f61b2eef7415eccdb40850aca0de94211948657) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +@@ -260,13 +260,17 @@ static int amdgpu_cs_pass1(struct amdgpu + goto free_partial_kdata; + break; + ++ case AMDGPU_CHUNK_ID_CP_GFX_SHADOW: ++ if (size < sizeof(struct drm_amdgpu_cs_chunk_cp_gfx_shadow)) ++ goto free_partial_kdata; ++ break; ++ + case AMDGPU_CHUNK_ID_DEPENDENCIES: + case AMDGPU_CHUNK_ID_SYNCOBJ_IN: + case AMDGPU_CHUNK_ID_SYNCOBJ_OUT: + case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES: + case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_WAIT: + case AMDGPU_CHUNK_ID_SYNCOBJ_TIMELINE_SIGNAL: +- case AMDGPU_CHUNK_ID_CP_GFX_SHADOW: + break; + + default: diff --git a/queue-6.18/drm-displayid-fix-tiled-display-topology-id-size.patch b/queue-6.18/drm-displayid-fix-tiled-display-topology-id-size.patch new file mode 100644 index 0000000000..20a8f49018 --- /dev/null +++ b/queue-6.18/drm-displayid-fix-tiled-display-topology-id-size.patch @@ -0,0 +1,129 @@ +From 90c0486a82e27393f9eaf3bb350f51a0bd38cb6b Mon Sep 17 00:00:00 2001 +From: Jani Nikula +Date: Wed, 10 Jun 2026 17:15:49 +0300 +Subject: drm/displayid: fix Tiled Display Topology ID size + +From: Jani Nikula + +commit 90c0486a82e27393f9eaf3bb350f51a0bd38cb6b upstream. + +The Tiled Display Topology ID of a DisplayID Tiled Display Topology Data +Block consists of three fields: + +- Tiled Display Manufacturer/Vendor ID Field (3 bytes) +- Tiled Display Product ID Code Field (2 bytes) +- Tiled Display Serial Number Field (4 bytes) + +i.e. a total of 9 bytes, not 8. + +The DisplayID Tiled Display Topology ID is used as the tile group +identifier. + +Update both struct displayid_tiled_block topology_id member and struct +drm_tile_group group_data member to full 9 bytes. + +The group data was missing the last byte of the serial number. I don't +know whether there are known bug reports that might be linked to this, +but it's plausible the last byte could be the differentiating part for +the tile groups, and fewer tile groups might have been created than +intended. + +Fixes: b49b55bd4fba ("drm/displayid: add displayid defines and edid extension (v2)") +Fixes: 138f9ebb9755 ("drm: add tile_group support. (v3)") +Cc: Dave Airlie +Cc: stable@vger.kernel.org # v3.19+ +Reviewed-by: Dave Airlie +Link: https://patch.msgid.link/20260610141549.555605-1-jani.nikula@intel.com +Signed-off-by: Jani Nikula +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/drm_connector.c | 12 ++++++------ + drivers/gpu/drm/drm_displayid_internal.h | 2 +- + include/drm/drm_connector.h | 6 +++--- + 3 files changed, 10 insertions(+), 10 deletions(-) + +--- a/drivers/gpu/drm/drm_connector.c ++++ b/drivers/gpu/drm/drm_connector.c +@@ -3554,7 +3554,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group); + /** + * drm_mode_get_tile_group - get a reference to an existing tile group + * @dev: DRM device +- * @topology: 8-bytes unique per monitor. ++ * @topology_id: 9-byte unique ID per monitor. + * + * Use the unique bytes to get a reference to an existing tile group. + * +@@ -3562,14 +3562,14 @@ EXPORT_SYMBOL(drm_mode_put_tile_group); + * tile group or NULL if not found. + */ + struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, +- const char topology[8]) ++ const char topology_id[9]) + { + struct drm_tile_group *tg; + int id; + + mutex_lock(&dev->mode_config.idr_mutex); + idr_for_each_entry(&dev->mode_config.tile_idr, tg, id) { +- if (!memcmp(tg->group_data, topology, 8)) { ++ if (!memcmp(tg->group_data, topology_id, sizeof(tg->group_data))) { + if (!kref_get_unless_zero(&tg->refcount)) + tg = NULL; + mutex_unlock(&dev->mode_config.idr_mutex); +@@ -3584,7 +3584,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group); + /** + * drm_mode_create_tile_group - create a tile group from a displayid description + * @dev: DRM device +- * @topology: 8-bytes unique per monitor. ++ * @topology_id: 9-byte unique ID per monitor. + * + * Create a tile group for the unique monitor, and get a unique + * identifier for the tile group. +@@ -3593,7 +3593,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group); + * new tile group or NULL. + */ + struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, +- const char topology[8]) ++ const char topology_id[9]) + { + struct drm_tile_group *tg; + int ret; +@@ -3603,7 +3603,7 @@ struct drm_tile_group *drm_mode_create_t + return NULL; + + kref_init(&tg->refcount); +- memcpy(tg->group_data, topology, 8); ++ memcpy(tg->group_data, topology_id, sizeof(tg->group_data)); + tg->dev = dev; + + mutex_lock(&dev->mode_config.idr_mutex); +--- a/drivers/gpu/drm/drm_displayid_internal.h ++++ b/drivers/gpu/drm/drm_displayid_internal.h +@@ -109,7 +109,7 @@ struct displayid_tiled_block { + u8 topo[3]; + u8 tile_size[4]; + u8 tile_pixel_bezel[5]; +- u8 topology_id[8]; ++ u8 topology_id[9]; + } __packed; + + struct displayid_detailed_timings_1 { +--- a/include/drm/drm_connector.h ++++ b/include/drm/drm_connector.h +@@ -2502,13 +2502,13 @@ struct drm_tile_group { + struct kref refcount; + struct drm_device *dev; + int id; +- u8 group_data[8]; ++ u8 group_data[9]; + }; + + struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, +- const char topology[8]); ++ const char topology_id[9]); + struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, +- const char topology[8]); ++ const char topology_id[9]); + void drm_mode_put_tile_group(struct drm_device *dev, + struct drm_tile_group *tg); + diff --git a/queue-6.18/drm-i915-gem-add-missing-nospec-on-parallel-submit-slot.patch b/queue-6.18/drm-i915-gem-add-missing-nospec-on-parallel-submit-slot.patch new file mode 100644 index 0000000000..bc4b16018c --- /dev/null +++ b/queue-6.18/drm-i915-gem-add-missing-nospec-on-parallel-submit-slot.patch @@ -0,0 +1,41 @@ +From 914a76a9f08366434bf595700f62026b7a19a9cc Mon Sep 17 00:00:00 2001 +From: Joonas Lahtinen +Date: Mon, 22 Jun 2026 16:25:39 +0300 +Subject: drm/i915/gem: Add missing nospec on parallel submit slot + +From: Joonas Lahtinen + +commit 914a76a9f08366434bf595700f62026b7a19a9cc upstream. + +Add missing Spectre mitigation for userspace controlled parallel +submission slot. + +Discovered using AI-assisted static analysis confirmed by Intel +Product Security. + +Reported-by: Martin Hodo +Fixes: e5e32171a2cf ("drm/i915/guc: Connect UAPI to GuC multi-lrc interface") +Cc: Matthew Brost +Cc: Tvrtko Ursulin +Signed-off-by: Joonas Lahtinen +Reviewed-by: Matthew Brost +Reviewed-by: Tvrtko Ursulin +Cc: # v5.16+ +Link: https://patch.msgid.link/20260622132539.165558-1-joonas.lahtinen@linux.intel.com +(cherry picked from commit 15b9353deff3cf72331c387780de3cf9c316b643) +Signed-off-by: Joonas Lahtinen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/i915/gem/i915_gem_context.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c ++++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c +@@ -612,6 +612,7 @@ set_proto_ctx_engines_parallel_submit(st + return -EINVAL; + } + ++ slot = array_index_nospec(slot, set->num_engines); + if (set->engines[slot].type != I915_GEM_ENGINE_TYPE_INVALID) { + drm_dbg(&i915->drm, + "Invalid placement[%d], already occupied\n", slot); diff --git a/queue-6.18/drm-nouveau-acr-fix-missing-nvkm_done-in-error-path-of-nvkm_acr_oneinit.patch b/queue-6.18/drm-nouveau-acr-fix-missing-nvkm_done-in-error-path-of-nvkm_acr_oneinit.patch new file mode 100644 index 0000000000..d6482119ee --- /dev/null +++ b/queue-6.18/drm-nouveau-acr-fix-missing-nvkm_done-in-error-path-of-nvkm_acr_oneinit.patch @@ -0,0 +1,44 @@ +From c3027973f692077a1b66a9fb26d6a7c46c0dc72c Mon Sep 17 00:00:00 2001 +From: Wentao Liang +Date: Sat, 6 Jun 2026 15:56:06 +0000 +Subject: drm/nouveau/acr: fix missing nvkm_done() in error path of nvkm_acr_oneinit() + +From: Wentao Liang + +commit c3027973f692077a1b66a9fb26d6a7c46c0dc72c upstream. + +In nvkm_acr_oneinit(), nvkm_kmap(acr->wpr) is invoked unconditionally +at line 309 to obtain a mapping reference. Additionally, when both +acr->wpr_fw and acr->wpr_comp are present, a second nvkm_kmap() is +called inside the conditional block. Both mappings are expected to be +released by nvkm_done(acr->wpr) at line 320 before the function returns +successfully. + +However, when a mismatch is detected during the loop within the +conditional block, the function returns -EINVAL at line 318 without +calling nvkm_done(). This results in a leak of the kmap reference(s) +acquired earlier. + +Fix the issue by invoking nvkm_done(acr->wpr) prior to the early return +to ensure proper release of the mapping references. + +Fixes: 22dcda45a3d1 ("drm/nouveau/acr: implement new subdev to replace "secure boot"") +Cc: stable@vger.kernel.org +Signed-off-by: Wentao Liang +Link: https://patch.msgid.link/20260606155606.77593-1-vulab@iscas.ac.cn +Signed-off-by: Danilo Krummrich +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/nouveau/nvkm/subdev/acr/base.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/acr/base.c ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/acr/base.c +@@ -315,6 +315,7 @@ nvkm_acr_oneinit(struct nvkm_subdev *sub + i, us, fw); + } + } ++ nvkm_done(acr->wpr); + return -EINVAL; + } + nvkm_done(acr->wpr); diff --git a/queue-6.18/drm-nouveau-fix-reversed-error-cleanup-order-in-ucopy-functions.patch b/queue-6.18/drm-nouveau-fix-reversed-error-cleanup-order-in-ucopy-functions.patch new file mode 100644 index 0000000000..c5f04e926b --- /dev/null +++ b/queue-6.18/drm-nouveau-fix-reversed-error-cleanup-order-in-ucopy-functions.patch @@ -0,0 +1,66 @@ +From ab99ead646b1b833ecd57fe577a2816f2e848167 Mon Sep 17 00:00:00 2001 +From: Junrui Luo +Date: Wed, 10 Jun 2026 18:01:28 +0800 +Subject: drm/nouveau: fix reversed error cleanup order in ucopy functions + +From: Junrui Luo + +commit ab99ead646b1b833ecd57fe577a2816f2e848167 upstream. + +nouveau_uvmm_vm_bind_ucopy() and nouveau_exec_ucopy() place their error +cleanup labels in allocation order rather than reverse allocation order. +On a u_memcpya() failure for in_sync.s, the goto to err_free_ops (or +err_free_pushs) frees the first allocation and then falls through to +err_free_ins, which calls u_free() on args->in_sync.s. + +Since args->in_sync.s still holds the ERR_PTR returned by the failed +u_memcpya(), and ERR_PTR values are not caught by ZERO_OR_NULL_PTR(), +kvfree() proceeds to dereference it, which can result in a kernel oops. +A failure for out_sync.s instead jumps to err_free_ins and skips freeing +the first allocation, leading to a memory leak. + +Fix by swapping the cleanup label order so resources are freed in the +correct reverse allocation sequence. + +Fixes: b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI") +Reported-by: Yuhao Jiang +Cc: stable@vger.kernel.org +Signed-off-by: Junrui Luo +Link: https://patch.msgid.link/SYBPR01MB7881484D91A6F80271415F71AF1A2@SYBPR01MB7881.ausprd01.prod.outlook.com +Signed-off-by: Danilo Krummrich +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/nouveau/nouveau_exec.c | 4 ++-- + drivers/gpu/drm/nouveau/nouveau_uvmm.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +--- a/drivers/gpu/drm/nouveau/nouveau_exec.c ++++ b/drivers/gpu/drm/nouveau/nouveau_exec.c +@@ -331,10 +331,10 @@ nouveau_exec_ucopy(struct nouveau_exec_j + + return 0; + +-err_free_pushs: +- u_free(args->push.s); + err_free_ins: + u_free(args->in_sync.s); ++err_free_pushs: ++ u_free(args->push.s); + return ret; + } + +--- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c ++++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c +@@ -1711,10 +1711,10 @@ nouveau_uvmm_vm_bind_ucopy(struct nouvea + + return 0; + +-err_free_ops: +- u_free(args->op.s); + err_free_ins: + u_free(args->in_sync.s); ++err_free_ops: ++ u_free(args->op.s); + return ret; + } + diff --git a/queue-6.18/drm-radeon-fix-r100_copy_blit-for-large-bos.patch b/queue-6.18/drm-radeon-fix-r100_copy_blit-for-large-bos.patch new file mode 100644 index 0000000000..d7845fd95c --- /dev/null +++ b/queue-6.18/drm-radeon-fix-r100_copy_blit-for-large-bos.patch @@ -0,0 +1,82 @@ +From f896e86273dbbebb5eac966b4a201b5c62a02e9a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= +Date: Wed, 10 Jun 2026 10:32:45 +0200 +Subject: drm/radeon: fix r100_copy_blit for large BOs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pavel Ondračka + +commit f896e86273dbbebb5eac966b4a201b5c62a02e9a upstream. + +r100_copy_blit() copies BOs as 1024-pixel-wide ARGB8888 blits, so one +GPU page becomes one blit row. Large copies are split into chunks of at +most 8191 rows. + +The kernel register header names the packet coordinate dwords SRC_Y_X +and DST_Y_X. In the BITBLT_MULTI description in +R5xx_Acceleration_v1.5.pdf docs, these correspond to [SRC_X1 | SRC_Y1] +and [DST_X1 | DST_Y1], which are signed 13-bit coordinates in the +-8192..8191 range. The old code kept SRC/DST_PITCH_OFFSET at the BO base +and used SRC_Y_X/DST_Y_X as the chunk address, so large BO moves could +exceed that coordinate range. + +Compute per-chunk SRC/DST_PITCH_OFFSET bases and emit zero source and +destination coordinates. r100_copy_blit() already packs +SRC/DST_PITCH_OFFSET as pitch plus base offset, so large chunk addresses +belong there rather than in the coordinate fields. + +This fixes Prison Architect corruption with 4096x4096 mipped textures +after they are evicted to GTT under memory pressure on RV530. + +Closes: https://gitlab.freedesktop.org/mesa/mesa/-/work_items/6716 +Acked-by: Christian König +Signed-off-by: Pavel Ondračka +Signed-off-by: Alex Deucher +(cherry picked from commit 87be26aee76239c6da03e599f238a426897f78ad) +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/radeon/r100.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +--- a/drivers/gpu/drm/radeon/r100.c ++++ b/drivers/gpu/drm/radeon/r100.c +@@ -906,6 +906,7 @@ struct radeon_fence *r100_copy_blit(stru + { + struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; + struct radeon_fence *fence; ++ uint64_t cur_src_offset, cur_dst_offset; + uint32_t cur_pages; + uint32_t stride_bytes = RADEON_GPU_PAGE_SIZE; + uint32_t pitch; +@@ -934,6 +935,10 @@ struct radeon_fence *r100_copy_blit(stru + cur_pages = 8191; + } + num_gpu_pages -= cur_pages; ++ cur_src_offset = src_offset + ++ (uint64_t)num_gpu_pages * RADEON_GPU_PAGE_SIZE; ++ cur_dst_offset = dst_offset + ++ (uint64_t)num_gpu_pages * RADEON_GPU_PAGE_SIZE; + + /* pages are in Y direction - height + page width in X direction - width */ +@@ -950,13 +955,13 @@ struct radeon_fence *r100_copy_blit(stru + RADEON_DP_SRC_SOURCE_MEMORY | + RADEON_GMC_CLR_CMP_CNTL_DIS | + RADEON_GMC_WR_MSK_DIS); +- radeon_ring_write(ring, (pitch << 22) | (src_offset >> 10)); +- radeon_ring_write(ring, (pitch << 22) | (dst_offset >> 10)); ++ radeon_ring_write(ring, (pitch << 22) | (cur_src_offset >> 10)); ++ radeon_ring_write(ring, (pitch << 22) | (cur_dst_offset >> 10)); + radeon_ring_write(ring, (0x1fff) | (0x1fff << 16)); + radeon_ring_write(ring, 0); + radeon_ring_write(ring, (0x1fff) | (0x1fff << 16)); +- radeon_ring_write(ring, num_gpu_pages); +- radeon_ring_write(ring, num_gpu_pages); ++ radeon_ring_write(ring, 0); ++ radeon_ring_write(ring, 0); + radeon_ring_write(ring, cur_pages | (stride_pixels << 16)); + } + radeon_ring_write(ring, PACKET0(RADEON_DSTCACHE_CTLSTAT, 0)); diff --git a/queue-6.18/drm-sysfb-avoid-possible-truncation-with-calculating-visible-size.patch b/queue-6.18/drm-sysfb-avoid-possible-truncation-with-calculating-visible-size.patch new file mode 100644 index 0000000000..329a09c941 --- /dev/null +++ b/queue-6.18/drm-sysfb-avoid-possible-truncation-with-calculating-visible-size.patch @@ -0,0 +1,49 @@ +From b771974988ec7ce077a7246fa0fa588c246fe581 Mon Sep 17 00:00:00 2001 +From: Thomas Zimmermann +Date: Thu, 18 Jun 2026 10:41:58 +0200 +Subject: drm/sysfb: Avoid possible truncation with calculating visible size + +From: Thomas Zimmermann + +commit b771974988ec7ce077a7246fa0fa588c246fe581 upstream. + +Calculating the visible size of the system framebuffer can result in +truncation of the result. The calculation uses 32-bit arithmetics, +which can overflow if the values for height and stride are large. Fix +the issue by multiplying with mul_u32_u32(). + +Signed-off-by: Thomas Zimmermann +Fixes: 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays") +Fixes: a84eb6abe2b6 ("drm/sysfb: Add vesadrm for VESA displays") +Reported-by: Sashiko +Closes: https://lore.kernel.org/dri-devel/20260617114027.1F2A71F000E9@smtp.kernel.org/ +Cc: Thomas Zimmermann +Cc: Javier Martinez Canillas +Cc: dri-devel@lists.freedesktop.org +Cc: # v6.16+ +Reviewed-by: Javier Martinez Canillas +Link: https://patch.msgid.link/20260618084327.46567-3-tzimmermann@suse.de +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c ++++ b/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c +@@ -2,6 +2,7 @@ + + #include + #include ++#include + #include + #include + +@@ -73,7 +74,7 @@ EXPORT_SYMBOL(drm_sysfb_get_stride_si); + u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, + unsigned int height, unsigned int stride, u64 size) + { +- u64 vsize = height * stride; ++ u64 vsize = mul_u32_u32(height, stride); + + return drm_sysfb_get_validated_size0(dev, "visible size", vsize, size); + } diff --git a/queue-6.18/drm-sysfb-avoid-truncating-maximum-stride.patch b/queue-6.18/drm-sysfb-avoid-truncating-maximum-stride.patch new file mode 100644 index 0000000000..c5783191ae --- /dev/null +++ b/queue-6.18/drm-sysfb-avoid-truncating-maximum-stride.patch @@ -0,0 +1,52 @@ +From 9206b22fb959f4a9cf1921f34aed0df1dcb1ab04 Mon Sep 17 00:00:00 2001 +From: Thomas Zimmermann +Date: Thu, 18 Jun 2026 10:42:00 +0200 +Subject: drm/sysfb: Avoid truncating maximum stride + +From: Thomas Zimmermann + +commit 9206b22fb959f4a9cf1921f34aed0df1dcb1ab04 upstream. + +Passing a maximum as 64-bit type to drm_sysfb_get_validated_int0() +can truncate the value to 32 bits. Use drm_sysfb_get_validated_size0(), +which uses 64-bit arithmetics. Then test the returned stride against +the limits of int to avoid truncations in the returned value. A valid +stride is in the range of [1, INT_MAX] inclusive. + +Signed-off-by: Thomas Zimmermann +Reported-by: Sashiko +Closes: https://lore.kernel.org/dri-devel/20260617114016.5A5991F000E9@smtp.kernel.org/ +Fixes: 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays") +Fixes: a84eb6abe2b6 ("drm/sysfb: Add vesadrm for VESA displays") +Cc: Thomas Zimmermann +Cc: Javier Martinez Canillas +Cc: dri-devel@lists.freedesktop.org +Cc: # v6.16+ +Reviewed-by: Javier Martinez Canillas +Link: https://patch.msgid.link/20260618084327.46567-5-tzimmermann@suse.de +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c ++++ b/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c +@@ -56,11 +56,17 @@ int drm_sysfb_get_stride_si(struct drm_d + unsigned int width, unsigned int height, u64 size) + { + u64 lfb_linelength = si->lfb_linelength; ++ s64 stride; + + if (!lfb_linelength) + lfb_linelength = drm_format_info_min_pitch(format, 0, width); + +- return drm_sysfb_get_validated_int0(dev, "stride", lfb_linelength, div64_u64(size, height)); ++ stride = drm_sysfb_get_validated_size0(dev, "stride", lfb_linelength, ++ div64_u64(size, height)); ++ if (stride < INT_MIN || stride > INT_MAX) ++ return -EINVAL; ++ ++ return (int)stride; /* stride or negative errno code */ + } + EXPORT_SYMBOL(drm_sysfb_get_stride_si); + diff --git a/queue-6.18/drm-sysfb-do-not-page-align-visible-size-of-the-framebuffer.patch b/queue-6.18/drm-sysfb-do-not-page-align-visible-size-of-the-framebuffer.patch new file mode 100644 index 0000000000..20f935a52d --- /dev/null +++ b/queue-6.18/drm-sysfb-do-not-page-align-visible-size-of-the-framebuffer.patch @@ -0,0 +1,39 @@ +From 134844856c399bfa9462a159dcf860bfdb748055 Mon Sep 17 00:00:00 2001 +From: Thomas Zimmermann +Date: Thu, 18 Jun 2026 10:41:57 +0200 +Subject: drm/sysfb: Do not page-align visible size of the framebuffer + +From: Thomas Zimmermann + +commit 134844856c399bfa9462a159dcf860bfdb748055 upstream. + +Only return the actually visible size of the system framebuffer in +drm_sysfb_get_visible_size_si(). Drivers use this size value for +reserving access to framebuffer memory. Increasing the value can +make later attempts to do so fail. + +Signed-off-by: Thomas Zimmermann +Fixes: 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays") +Fixes: a84eb6abe2b6 ("drm/sysfb: Add vesadrm for VESA displays") +Reviewed-by: Javier Martinez Canillas +Cc: Thomas Zimmermann +Cc: Javier Martinez Canillas +Cc: dri-devel@lists.freedesktop.org +Cc: # v6.16+ +Link: https://patch.msgid.link/20260618084327.46567-2-tzimmermann@suse.de +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c ++++ b/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c +@@ -67,7 +67,7 @@ EXPORT_SYMBOL(drm_sysfb_get_stride_si); + u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, + unsigned int height, unsigned int stride, u64 size) + { +- u64 vsize = PAGE_ALIGN(height * stride); ++ u64 vsize = height * stride; + + return drm_sysfb_get_validated_size0(dev, "visible size", vsize, size); + } diff --git a/queue-6.18/drm-sysfb-return-errno-code-from-drm_sysfb_get_visible_size.patch b/queue-6.18/drm-sysfb-return-errno-code-from-drm_sysfb_get_visible_size.patch new file mode 100644 index 0000000000..76aad34d01 --- /dev/null +++ b/queue-6.18/drm-sysfb-return-errno-code-from-drm_sysfb_get_visible_size.patch @@ -0,0 +1,105 @@ +From 7bab0f09d753f098977bbba3955d694c2e2c25da Mon Sep 17 00:00:00 2001 +From: Thomas Zimmermann +Date: Thu, 18 Jun 2026 10:41:59 +0200 +Subject: drm/sysfb: Return errno code from drm_sysfb_get_visible_size() + +From: Thomas Zimmermann + +commit 7bab0f09d753f098977bbba3955d694c2e2c25da upstream. + +Change the return type of drm_sysfb_get_visible_size() to s64 so +that it returns a possible errno code from _get_validated_size0(). +Fix callers to handle the errno code. + +The currently returned unsigned type converts an errno code to a +very large size value, which drivers interpret as visible size of +the system framebuffer. Later efforts to reserve the framebuffer +resource fail. + +The bug has been present since efidrm and vesadrm got merged. It +was then part of each driver. + +Signed-off-by: Thomas Zimmermann +Fixes: 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays") +Fixes: a84eb6abe2b6 ("drm/sysfb: Add vesadrm for VESA displays") +Reviewed-by: Javier Martinez Canillas +Cc: Thomas Zimmermann +Cc: Javier Martinez Canillas +Cc: dri-devel@lists.freedesktop.org +Cc: # v6.16+ +Link: https://patch.msgid.link/20260618084327.46567-4-tzimmermann@suse.de +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 2 +- + drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c | 2 +- + drivers/gpu/drm/sysfb/efidrm.c | 7 ++++--- + drivers/gpu/drm/sysfb/vesadrm.c | 6 +++--- + 4 files changed, 9 insertions(+), 8 deletions(-) + +--- a/drivers/gpu/drm/sysfb/drm_sysfb_helper.h ++++ b/drivers/gpu/drm/sysfb/drm_sysfb_helper.h +@@ -39,7 +39,7 @@ struct resource *drm_sysfb_get_memory_si + int drm_sysfb_get_stride_si(struct drm_device *dev, const struct screen_info *si, + const struct drm_format_info *format, + unsigned int width, unsigned int height, u64 size); +-u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, ++s64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, + unsigned int height, unsigned int stride, u64 size); + const struct drm_format_info *drm_sysfb_get_format_si(struct drm_device *dev, + const struct drm_sysfb_format *formats, +--- a/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c ++++ b/drivers/gpu/drm/sysfb/drm_sysfb_screen_info.c +@@ -71,7 +71,7 @@ int drm_sysfb_get_stride_si(struct drm_d + } + EXPORT_SYMBOL(drm_sysfb_get_stride_si); + +-u64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, ++s64 drm_sysfb_get_visible_size_si(struct drm_device *dev, const struct screen_info *si, + unsigned int height, unsigned int stride, u64 size) + { + u64 vsize = mul_u32_u32(height, stride); +--- a/drivers/gpu/drm/sysfb/efidrm.c ++++ b/drivers/gpu/drm/sysfb/efidrm.c +@@ -143,7 +143,8 @@ static struct efidrm_device *efidrm_devi + const struct screen_info *si; + const struct drm_format_info *format; + int width, height, stride; +- u64 vsize, mem_flags; ++ s64 vsize; ++ u64 mem_flags; + struct resource resbuf; + struct resource *res; + struct efidrm_device *efi; +@@ -195,8 +196,8 @@ static struct efidrm_device *efidrm_devi + if (stride < 0) + return ERR_PTR(stride); + vsize = drm_sysfb_get_visible_size_si(dev, si, height, stride, resource_size(res)); +- if (!vsize) +- return ERR_PTR(-EINVAL); ++ if (vsize < 0) ++ return ERR_PTR(vsize); + + drm_dbg(dev, "framebuffer format=%p4cc, size=%dx%d, stride=%d bytes\n", + &format->format, width, height, stride); +--- a/drivers/gpu/drm/sysfb/vesadrm.c ++++ b/drivers/gpu/drm/sysfb/vesadrm.c +@@ -392,7 +392,7 @@ static struct vesadrm_device *vesadrm_de + const struct screen_info *si; + const struct drm_format_info *format; + int width, height, stride; +- u64 vsize; ++ s64 vsize; + struct resource resbuf; + struct resource *res; + struct vesadrm_device *vesa; +@@ -445,8 +445,8 @@ static struct vesadrm_device *vesadrm_de + if (stride < 0) + return ERR_PTR(stride); + vsize = drm_sysfb_get_visible_size_si(dev, si, height, stride, resource_size(res)); +- if (!vsize) +- return ERR_PTR(-EINVAL); ++ if (vsize < 0) ++ return ERR_PTR(vsize); + + drm_dbg(dev, "framebuffer format=%p4cc, size=%dx%d, stride=%d bytes\n", + &format->format, width, height, stride); diff --git a/queue-6.18/series b/queue-6.18/series index 385811b320..c8086d2b69 100644 --- a/queue-6.18/series +++ b/queue-6.18/series @@ -339,3 +339,15 @@ drm-amdgpu-gfx-fix-cleaner-shader-ib-buffer-overflow.patch drm-amdgpu-uvd-fix-forcing-msg-fb-bos-into-vcpu-segment-when-it-isn-t-at-0-v2.patch drm-amdgpu-uvd-place-vcpu-bo-only-in-vram-for-uvd-4.x-and-older.patch drm-amdgpu-check-amdgpu_vm_bo_find-result-in-get_mapping_info.patch +drm-sysfb-do-not-page-align-visible-size-of-the-framebuffer.patch +drm-sysfb-avoid-truncating-maximum-stride.patch +drm-amdgpu-gfx9-fix-ring-and-ib-test-fail-after-mode2.patch +drm-amdgpu-fix-amdgpu_bo_move-when-old_mem-and-new_mem-are-both-gtt.patch +drm-amdgpu-validate-cp_gfx_shadow-chunk-size-in-cs-pass1.patch +drm-nouveau-fix-reversed-error-cleanup-order-in-ucopy-functions.patch +drm-sysfb-avoid-possible-truncation-with-calculating-visible-size.patch +drm-sysfb-return-errno-code-from-drm_sysfb_get_visible_size.patch +drm-displayid-fix-tiled-display-topology-id-size.patch +drm-i915-gem-add-missing-nospec-on-parallel-submit-slot.patch +drm-nouveau-acr-fix-missing-nvkm_done-in-error-path-of-nvkm_acr_oneinit.patch +drm-radeon-fix-r100_copy_blit-for-large-bos.patch