SWDEV-413997 - Handling cases where multiple phys_mem is mapped into a single virtual address.

Change-Id: Ie678e607a64f2e5c35a10b9083185f041c5527ac


[ROCm/clr commit: 49b4aef8c9]
This commit is contained in:
kjayapra-amd
2024-04-20 18:50:50 -04:00
committed by Karthik Jayaprakash
parent b1c0f73229
commit d49fa8d06b
2 changed files with 17 additions and 4 deletions
+14
View File
@@ -367,11 +367,25 @@ hipError_t ihipMemcpy_validate(void* dst, const void* src, size_t sizeBytes,
amd::Memory* srcMemory = getMemoryObject(src, sOffset);
size_t dOffset = 0;
amd::Memory* dstMemory = getMemoryObject(dst, dOffset);
// If the mem object is a VMM sub buffer (subbuffer has parent set),
// then use parent's size for validation.
if (srcMemory && srcMemory->parent() && (srcMemory->getMemFlags() & CL_MEM_VA_RANGE_AMD)) {
srcMemory = srcMemory->parent();
}
// If the mem object is a VMM sub buffer (subbuffer has parent set),
// then use parent's size for validation.
if (dstMemory && dstMemory->parent() && (dstMemory->getMemFlags() & CL_MEM_VA_RANGE_AMD)) {
dstMemory = dstMemory->parent();
}
// Return error if sizeBytes passed to memcpy is more than the actual size allocated
if ((dstMemory && sizeBytes > (dstMemory->getSize() - dOffset)) ||
(srcMemory && sizeBytes > (srcMemory->getSize() - sOffset))) {
return hipErrorInvalidValue;
}
//If src and dst ptr are null then kind must be either h2h or def.
if (!IsHtoHMemcpyValid(dst, src, kind)) {
return hipErrorInvalidValue;