SWDEV-274199 - Enable SVM tracking
ROCr/KFD doesn't validate memory pointers. Enable validation inside
ROCclr, using SVM tracking mechanism.
Change-Id: I581e32ff37187f9ed8d9a302e8fd9f6ca935bdd7
[ROCm/clr commit: fbde61de7f]
This commit is contained in:
@@ -2201,7 +2201,10 @@ bool Device::SetSvmAttributesInt(const void* dev_ptr, size_t count,
|
||||
amd::MemoryAdvice advice, bool first_alloc, bool use_cpu) const {
|
||||
if ((settings().hmmFlags_ & Settings::Hmm::EnableSvmTracking) && !first_alloc) {
|
||||
amd::Memory* svm_mem = amd::MemObjMap::FindMemObj(dev_ptr);
|
||||
if (nullptr == svm_mem) {
|
||||
if ((nullptr == svm_mem) || ((svm_mem->getMemFlags() & CL_MEM_ALLOC_HOST_PTR) == 0) ||
|
||||
// Validate the range of provided memory
|
||||
((svm_mem->getSize() - (reinterpret_cast<const_address>(dev_ptr) -
|
||||
reinterpret_cast<address>(svm_mem->getSvmPtr()))) < count)) {
|
||||
LogPrintfError("SetSvmAttributes received unknown memory for update: %p!", dev_ptr);
|
||||
return false;
|
||||
}
|
||||
@@ -2278,7 +2281,10 @@ bool Device::GetSvmAttributes(void** data, size_t* data_sizes, int* attributes,
|
||||
size_t num_attributes, const void* dev_ptr, size_t count) const {
|
||||
if (settings().hmmFlags_ & Settings::Hmm::EnableSvmTracking) {
|
||||
amd::Memory* svm_mem = amd::MemObjMap::FindMemObj(dev_ptr);
|
||||
if (nullptr == svm_mem) {
|
||||
if ((nullptr == svm_mem) || ((svm_mem->getMemFlags() & CL_MEM_ALLOC_HOST_PTR) == 0) ||
|
||||
// Validate the range of provided memory
|
||||
((svm_mem->getSize() - (reinterpret_cast<const_address>(dev_ptr) -
|
||||
reinterpret_cast<address>(svm_mem->getSvmPtr()))) < count)) {
|
||||
LogPrintfError("GetSvmAttributes received unknown memory %p for state!", dev_ptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ Settings::Settings() {
|
||||
lcWavefrontSize64_ = true;
|
||||
imageBufferWar_ = false;
|
||||
|
||||
hmmFlags_ = (!flagIsDefault(ROC_HMM_FLAGS)) ? ROC_HMM_FLAGS : 0;
|
||||
hmmFlags_ = (!flagIsDefault(ROC_HMM_FLAGS)) ? ROC_HMM_FLAGS : Hmm::EnableSvmTracking;
|
||||
|
||||
rocr_backend_ = true;
|
||||
barrier_sync_ = (!flagIsDefault(ROC_BARRIER_SYNC)) ? ROC_BARRIER_SYNC : true;
|
||||
|
||||
Reference in New Issue
Block a user