libhsakmt: child process destroy vm objects in all apertures

child process clone vm objects from svm->apertures if parent process
doesn't free memory before fork. fmm_clear_all_mem suppose to clear the
apertures in forked child process but this only works if gpu_vm is not
NULL. parent process call hsaKmtCloseKFD reset gpu_vm to NULL and then
fork, then child process will not clear svm->apertures.

As a result, the child process will allocate vm object with same address
and add to aperture, there are duplicate vm objects with same address
in aperture. Then mapping to GPU will find the wrong vm object and
create incorrect GPU mapping cause rocrtst IPC test VM fault. The issue
happened with HSA_USERPTR_FOR_PAGED_MEM=1.

The fix is to clear vm objects in all apertures in clear_after_fork.

Change-Id: I92e42a967075a634a3f475b915c8242d82077ecb
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
此提交包含在:
Philip Yang
2019-08-20 10:55:14 -04:00
父節點 7fc6a9f7c2
當前提交 a11cb2a633
+10 -10
查看文件
@@ -3559,17 +3559,7 @@ void fmm_clear_all_mem(void)
drm_render_fds[i] = 0;
}
/* Nothing is initialized. */
if (!gpu_mem)
return;
fmm_clear_aperture(&cpuvm_aperture);
for (i = 0; i < gpu_mem_count; i++) {
fmm_clear_aperture(&gpu_mem[i].gpuvm_aperture);
fmm_clear_aperture(&gpu_mem[i].scratch_physical);
}
fmm_clear_aperture(&svm.apertures[SVM_DEFAULT]);
fmm_clear_aperture(&svm.apertures[SVM_COHERENT]);
@@ -3598,6 +3588,16 @@ void fmm_clear_all_mem(void)
all_gpu_id_array_size = 0;
all_gpu_id_array = NULL;
/* Nothing is initialized. */
if (!gpu_mem)
return;
for (i = 0; i < gpu_mem_count; i++) {
fmm_clear_aperture(&gpu_mem[i].gpuvm_aperture);
fmm_clear_aperture(&gpu_mem[i].scratch_physical);
}
gpu_mem_count = 0;
free(gpu_mem);
gpu_mem = NULL;
}