Early return for invalid pointer queries
If a user queries the pointer info on an invalid pointer,
hsaKmtQueryPointerInfo will return error or unknown pointer. The other
fields in HsaPointerInfo are invalid, so we do not return them to the
user.
Also removing the assert and returning unknown pointer instead. As the
assert will not trigger in release builds.
hsaKmtQueryPointerInfo may also return unknown pointer for userptrs as
they are not always tracked by thunk. Adjusting code to still treat
these pointers as valid in this case.
Change-Id: Idf5cd8b61cd532d31b072f449839d223369bb138
[ROCm/ROCR-Runtime commit: 18547173e9]
Цей коміт міститься в:
@@ -536,10 +536,13 @@ hsa_status_t MemoryRegion::AllowAccess(uint32_t num_agents,
|
||||
info.size = sizeof(info);
|
||||
|
||||
ScopedAcquire<KernelMutex> lock(&access_lock_);
|
||||
|
||||
if (core::Runtime::runtime_singleton_->PtrInfo(const_cast<void*>(ptr), &info, malloc,
|
||||
&agent_count, &accessible,
|
||||
&blockInfo) == HSA_STATUS_SUCCESS) {
|
||||
if (blockInfo.length != size || info.sizeInBytes != size) {
|
||||
/* Thunk may return type = HSA_EXT_POINTER_TYPE_UNKNOWN for userptrs */
|
||||
if (info.type != HSA_EXT_POINTER_TYPE_UNKNOWN &&
|
||||
(blockInfo.length != size || info.sizeInBytes != size)) {
|
||||
for (int i = 0; i < num_agents; i++) union_agents.push_back(agents[i].handle);
|
||||
for (int i = 0; i < agent_count; i++) union_agents.push_back(accessible[i].handle);
|
||||
std::sort(union_agents.begin(), union_agents.end());
|
||||
|
||||
@@ -777,8 +777,11 @@ hsa_status_t Runtime::PtrInfo(const void* ptr, hsa_amd_pointer_info_t* info, voi
|
||||
// We don't care if this returns an error code.
|
||||
// The type will be HSA_EXT_POINTER_TYPE_UNKNOWN if so.
|
||||
auto err = hsaKmtQueryPointerInfo(ptr, &thunkInfo);
|
||||
assert(((err == HSAKMT_STATUS_SUCCESS) || (thunkInfo.Type == HSA_POINTER_UNKNOWN)) &&
|
||||
"Thunk ptr info error and not type HSA_POINTER_UNKNOWN.");
|
||||
if (err != HSAKMT_STATUS_SUCCESS || thunkInfo.Type == HSA_POINTER_UNKNOWN) {
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->type = HSA_EXT_POINTER_TYPE_UNKNOWN;
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (returnListData) {
|
||||
assert(thunkInfo.NMappedNodes <= agents_by_node_.size() &&
|
||||
|
||||
Посилання в новій задачі
Заблокувати користувача