2
0

Fix for pntr attri query from a peer device (#2722)

* Fix for pntr attri query from a peer device

Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>

* SWDEV-577116 : Fix qeury on peer device

- if access is disabled query should return error.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Este cometimento está contido em:
Shadi Dashmiz
2026-01-27 15:25:14 -05:00
cometido por GitHub
ascendente f37b100c34
cometimento b816d10802
+12 -1
Ver ficheiro
@@ -3604,7 +3604,8 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute,
}
case HIP_POINTER_ATTRIBUTE_DEVICE_POINTER: {
if (memObj) {
device::Memory* devMem = memObj->getDeviceMemory(*hip::getCurrentDevice()->devices()[0]);
amd::Device* currentDevice = hip::getCurrentDevice()->devices()[0];
device::Memory* devMem = memObj->getDeviceMemory(*currentDevice);
// getDeviceMemory can fail, hence validate the sanity of the mem obtained
if (nullptr == devMem) {
@@ -3612,6 +3613,16 @@ hipError_t ihipPointerGetAttributes(void* data, hipPointer_attribute attribute,
"getDeviceMemory for ptr failed : %p", ptr);
return hipErrorMemoryAllocation;
}
// Check if this is a cross-device access without peer access enabled
const std::vector<amd::Device*>& memDevices = memObj->getContext().devices();
if (memDevices.size() == 1 && memDevices[0] != currentDevice) {
device::Memory* origDevMem = memObj->getDeviceMemory(*memDevices[0]);
if (origDevMem != nullptr && !origDevMem->getAllowedPeerAccess()) {
return hipErrorInvalidValue;
}
}
*reinterpret_cast<hipDeviceptr_t*>(data) =
reinterpret_cast<hipDeviceptr_t*>(devMem->virtualAddress() + offset);
} else {