libhsakmt: Prevent hsaKmtRegisterMemory* from registering non-userptr

hsaKmtRegisterMemory* can only register OS allocated userptr.

v2: Apply changes to all hsaKmtRegisterMemory* stuff.(Philip)

v3: Unlock aperture->fmm_mutex to aviod deadlock.

Suggested-by: Felix Kuehling <Felix.Kuehling@amd.com>
Change-Id: I1045af7edb4da8206cb878f64c0176ba4fc59f60
Signed-off-by: Lang Yu <Lang.Yu@amd.com>
Signed-off-by: Chris Freehill <cfreehil@amd.com>
This commit is contained in:
Lang Yu
2024-04-17 09:19:23 +08:00
committed by Chris Freehill
parent 3f00c88910
commit 4844a70d94
+4
View File
@@ -3533,6 +3533,10 @@ HSAKMT_STATUS fmm_register_memory(void *address, uint64_t size_in_bytes,
} else if (object->userptr) {
/* Update an existing userptr */
++object->registration_count;
} else {
/* Not a userptr when we are expecting one */
pthread_mutex_unlock(&aperture->fmm_mutex);
return HSAKMT_STATUS_INVALID_HANDLE;
}
/* Successful vm_find_object returns with aperture locked */