AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 1/2] drm/amdgpu: reject userptr BOs as userqueue write pointers
@ 2026-11-30  6:25 Jesse Zhang
  2026-11-30  6:25 ` [PATCH V2 2/2] drm/amdgpu: validate the WPTR BO before handing its address to the MES Jesse Zhang
  2026-11-30  6:51 ` [PATCH V2 1/2] drm/amdgpu: reject userptr BOs as userqueue write pointers sashiko-bot
  0 siblings, 2 replies; 4+ messages in thread
From: Jesse Zhang @ 2026-11-30  6:25 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Sunil Khatri, Jesse Zhang

Userptr BOs may not have their pages populated. Reject them before
validating the WPTR BO during queue creation and before CPU mapping it
in USERQ_SIGNAL. The latter also covers remapping the WPTR VA after
queue creation.

Fixes: 7264bc10c7c6 ("drm/amdgpu: dont pin wptr bo instead use eviction fence")
Fixes: a292fdecd728 ("drm/amdgpu: Implement userqueue signal/wait IOCTL")
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c      | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index dd976a50e053..78d33884a1b3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -402,6 +402,12 @@ static int amdgpu_userq_fence_read_wptr(struct amdgpu_device *adev,
 	}
 
 	bo = mapping->bo_va->base.bo;
+	/* Userptr pages may not be populated when reading the WPTR. */
+	if (amdgpu_ttm_tt_is_userptr(bo->tbo.ttm)) {
+		ret = -EINVAL;
+		goto lock_error;
+	}
+
 	ret = amdgpu_bo_kmap(bo, (void **)&ptr);
 	if (ret) {
 		DRM_ERROR("Failed mapping the userqueue wptr bo");
diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index 7abb9d95ef59..3d4bc3a902a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
@@ -73,7 +73,9 @@ mes_userq_create_wptr_mapping(struct amdgpu_device *adev,
 	}
 
 	wptr_obj->obj = amdgpu_bo_ref(wptr_mapping->bo_va->base.bo);
-	if (wptr_obj->obj->tbo.base.size > PAGE_SIZE) {
+	/* Userptr pages cannot be obtained by ttm_bo_validate(). */
+	if (wptr_obj->obj->tbo.base.size > PAGE_SIZE ||
+	    amdgpu_ttm_tt_is_userptr(wptr_obj->obj->tbo.ttm)) {
 		ret = -EINVAL;
 		goto fail_map;
 	}
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-30  6:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  6:25 [PATCH V2 1/2] drm/amdgpu: reject userptr BOs as userqueue write pointers Jesse Zhang
2026-11-30  6:25 ` [PATCH V2 2/2] drm/amdgpu: validate the WPTR BO before handing its address to the MES Jesse Zhang
2026-11-30  6:47   ` sashiko-bot
2026-11-30  6:51 ` [PATCH V2 1/2] drm/amdgpu: reject userptr BOs as userqueue write pointers sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox