mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
amd/amdkfd: Trigger segfault for early userptr unmmapping
If applications unmap the memory before destroying the userptr, it needs trigger a segfault to notify user space to correct the free sequence in VM debug mode. v2: Send gpu access fault to user space v3: Report gpu address to user space, remove unnecessary params v4: update pr_err into one line, remove userptr log info Signed-off-by: Shane Xiao <shane.xiao@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
@@ -2559,6 +2559,18 @@ static int update_invalid_user_pages(struct amdkfd_process_info *process_info,
|
||||
if (ret != -EFAULT)
|
||||
return ret;
|
||||
|
||||
/* If applications unmap memory before destroying the userptr
|
||||
* from the KFD, trigger a segmentation fault in VM debug mode.
|
||||
*/
|
||||
if (amdgpu_ttm_adev(bo->tbo.bdev)->debug_vm_userptr) {
|
||||
pr_err("Pid %d unmapped memory before destroying userptr at GPU addr 0x%llx\n",
|
||||
pid_nr(process_info->pid), mem->va);
|
||||
|
||||
// Send GPU VM fault to user space
|
||||
kfd_signal_vm_fault_event_with_userptr(kfd_lookup_process_by_pid(process_info->pid),
|
||||
mem->va);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user