SWDEV-357122 - fix failure in vdi so as to handle unreasonable input size in MallocManagedNegativeTest
Change-Id: I1ed1916b652afc67327b0935c3c60fc2a404df30
This commit is contained in:
committad av
Julia Jiang
förälder
05b2bd7995
incheckning
dacd55f3d7
@@ -2254,6 +2254,10 @@ void* Device::svmAlloc(amd::Context& context, size_t size, size_t alignment, cl_
|
||||
}
|
||||
// if the device supports SVM FGS, return the committed CPU address directly.
|
||||
Memory* gpuMem = getRocMemory(mem);
|
||||
if (gpuMem == nullptr) {
|
||||
LogError("failed to create GPU memory from svm hidden buffer!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (mem->getSvmPtr() != nullptr) {
|
||||
// add the information to context so that we can use it later.
|
||||
|
||||
@@ -752,6 +752,9 @@ bool Buffer::create(bool alloc_local) {
|
||||
// AMD HMM path. Just allocate system memory and KFD will manage it
|
||||
deviceMemory_ = amd::Os::reserveMemory(
|
||||
0, size(), amd::Os::pageSize(), amd::Os::MEM_PROT_RW);
|
||||
if (deviceMemory_ == NULL) {
|
||||
return false;
|
||||
}
|
||||
amd::Os::commitMemory(deviceMemory_, size(), amd::Os::MEM_PROT_RW);
|
||||
// Currently HMM requires cirtain initial calls to mark sysmem allocation as
|
||||
// GPU accessible or prefetch memory into GPU
|
||||
|
||||
@@ -201,6 +201,10 @@ static inline int memProtToOsProt(Os::MemProt prot) {
|
||||
|
||||
address Os::reserveMemory(address start, size_t size, size_t alignment, MemProt prot) {
|
||||
size = alignUp(size, pageSize());
|
||||
// check for invalid input size
|
||||
if (size == 0) {
|
||||
return NULL;
|
||||
}
|
||||
alignment = std::max(pageSize(), alignUp(alignment, pageSize()));
|
||||
assert(isPowerOfTwo(alignment) && "not a power of 2");
|
||||
|
||||
|
||||
Referens i nytt ärende
Block a user