Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/vmwgfx: Fix the lifetime of the bo cursor memory

The cleanup can be dispatched while the atomic update is still active,
which means that the memory acquired in the atomic update needs to
not be invalidated by the cleanup. The buffer objects in vmw_plane_state
instead of using the builtin map_and_cache were trying to handle
the lifetime of the mapped memory themselves, leading to crashes.

Use the map_and_cache instead of trying to manage the lifetime of the
buffer objects held by the vmw_plane_state.

Fixes kernel oops'es in IGT's kms_cursor_legacy forked-bo.

Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Fixes: bb6780aa5a1d ("drm/vmwgfx: Diff cursors when using cmds")
Cc: <stable@vger.kernel.org> # v6.2+
Reviewed-by: Martin Krastev <martin.krastev@broadcom.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240126200804.732454-6-zack.rusin@broadcom.com

+1 -12
+1 -12
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
··· 185 185 */ 186 186 static u32 *vmw_du_cursor_plane_acquire_image(struct vmw_plane_state *vps) 187 187 { 188 - bool is_iomem; 189 188 if (vps->surf) { 190 189 if (vps->surf_mapped) 191 190 return vmw_bo_map_and_cache(vps->surf->res.guest_memory_bo); 192 191 return vps->surf->snooper.image; 193 192 } else if (vps->bo) 194 - return ttm_kmap_obj_virtual(&vps->bo->map, &is_iomem); 193 + return vmw_bo_map_and_cache(vps->bo); 195 194 return NULL; 196 195 } 197 196 ··· 652 653 { 653 654 struct vmw_cursor_plane *vcp = vmw_plane_to_vcp(plane); 654 655 struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state); 655 - bool is_iomem; 656 656 657 657 if (vps->surf_mapped) { 658 658 vmw_bo_unmap(vps->surf->res.guest_memory_bo); 659 659 vps->surf_mapped = false; 660 - } 661 - 662 - if (vps->bo && ttm_kmap_obj_virtual(&vps->bo->map, &is_iomem)) { 663 - const int ret = ttm_bo_reserve(&vps->bo->tbo, true, false, NULL); 664 - 665 - if (likely(ret == 0)) { 666 - ttm_bo_kunmap(&vps->bo->map); 667 - ttm_bo_unreserve(&vps->bo->tbo); 668 - } 669 660 } 670 661 671 662 vmw_du_cursor_plane_unmap_cm(vps);