Skip to content

[clr] Reject VMM allocations in hipIpcGetMemHandle#4263

Open
darren-amd wants to merge 1 commit intodevelopfrom
darren-amd/reject-vmm
Open

[clr] Reject VMM allocations in hipIpcGetMemHandle#4263
darren-amd wants to merge 1 commit intodevelopfrom
darren-amd/reject-vmm

Conversation

@darren-amd
Copy link
Contributor

Cloned from: #3882. CI could not run as PR was from a forked repo.

VMM allocations must use hipMemExportToShareableHandle for IPC, not hipIpcGetMemHandle. Add a check in Device::IpcCreate.

VMM allocations must use hipMemExportToShareableHandle for IPC,
not hipIpcGetMemHandle. Add a check in Device::IpcCreate to reject
memory objects with the CL_MEM_VA_RANGE_AMD flag.

Co-authored-by: zyzshishui <104647851+zyzshishui@users.noreply.github.com>
Made-with: Cursor
Copilot AI review requested due to automatic review settings March 20, 2026 17:27
@darren-amd darren-amd requested a review from a team as a code owner March 20, 2026 17:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a guard in ROCclr’s IPC handle creation path to reject VMM (virtual address range) allocations, aligning with HIP’s requirement to use hipMemExportToShareableHandle instead of hipIpcGetMemHandle for VMM.

Changes:

  • Detect VMM allocations in Device::IpcCreate via CL_MEM_VA_RANGE_AMD.
  • Log and fail early when IPC is attempted on a VMM allocation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1055 to +1057
ClPrint(amd::LOG_DETAIL_DEBUG, amd::LOG_MEM,
"IPC is not supported for VMM allocations (dev_ptr: 0x%x)", dev_ptr);
return false;
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClPrint format string uses 0x%x for dev_ptr (a void*). Since ClPrint ultimately calls vsnprintf, this is undefined behavior and can truncate addresses on 64-bit. Use %p (and pass dev_ptr) or cast to uintptr_t and print with an integer format instead.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants