drm/amdgpu: reject CS on a VM that KFD has acquired
Subsystems (2)
PATCH 1/1 drm/amdgpu: reject CS on a VM that KFD has acquired
KFD's userptr and SVM notifiers stop KFD queues only. On the eviction path they leave the GPU page tables valid, so a DRM_IOCTL_AMDGPU_CS job on the acquired VM can keep writing through a translation after the memory is gone. Jobs submitted before ACQUIRE_VM are already waited for in init_kfd_vm().
Refuse later submissions with -EPERM before validating buffers, so the rejection does not move backing store or leave the KFD VM with stale page tables.
Signed-off-by Yongqiang Sun <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +14 -0
@@ -964,6 +964,20 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, } } +/* +* KFD acquired this VM. Its notifiers stop KFD queues only, and for +* an eviction they leave the page tables valid, so a kernel-queue job +* submitted here can keep using translations after the memory is gone. +* Jobs submitted before the acquire are already waited for in +* init_kfd_vm(). Reject before vm_validate or ttm_bo_validate moves +* anything: a later failure would leave the KFD VM with new backing +* store and stale page tables. +*/ +if (vm->is_compute_context) { + r = -EPERM ; + goto out_free_user_pages; + } +amdgpu_bo_list_for_each_userptr_entry (e, list) {struct mm_struct *usermm;
Signature · 1 line
2.43.0