Skip to content

Fix overflow in number of bytes for long DMA BD lengths#3034

Merged
andrej merged 3 commits into
Xilinx:mainfrom
andrej:overflow
May 11, 2026
Merged

Fix overflow in number of bytes for long DMA BD lengths#3034
andrej merged 3 commits into
Xilinx:mainfrom
andrej:overflow

Conversation

@andrej
Copy link
Copy Markdown
Collaborator

@andrej andrej commented Apr 17, 2026

closes #3033

Copy link
Copy Markdown
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

Fixes an integer overflow when computing DMA buffer-descriptor lengths (elements → bytes / 32-bit words) so large transfers are validated and reported correctly, addressing #3033.

Changes:

  • Widen BD length/offset calculations to 64-bit to prevent overflow during element-size multiplication.
  • Update verifier alignment arithmetic to use 64-bit byte offsets.
  • Add regression tests covering both “no false error” and “correct 64-bit diagnostic text” for very large lengths.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/bd-chains-and-dma-tasks/dma-tasks-to-npu/overflow-len-good.mlir Adds a regression test for a large transfer that would overflow 32-bit when converted to bytes.
test/bd-chains-and-dma-tasks/dma-tasks-to-npu/overflow-len-bad.mlir Adds a regression test ensuring diagnostics report the correct (non-truncated) byte counts.
lib/Targets/AIETargetXAIEV2.cpp Widens internal tracking of BD length/offset for XAIEV2 codegen.
lib/Dialect/AIE/IR/AIEDialect.cpp Uses a 64-bit accumulator for base+offset byte alignment checks in DMABDOp::verify().
include/aie/Dialect/AIE/IR/AIEOps.td Changes DMABDOp::getLenInBytes() to 64-bit and makes offset-in-bytes 64-bit to avoid overflow.

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

Comment thread test/bd-chains-and-dma-tasks/dma-tasks-to-npu/overflow-len-good.mlir Outdated
Comment thread lib/Targets/AIETargetXAIEV2.cpp
@andrej
Copy link
Copy Markdown
Collaborator Author

andrej commented Apr 20, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Collaborator

@hunhoffe hunhoffe left a comment

Choose a reason for hiding this comment

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

Looks good! I had a few questions, but nothing blocking.

Comment thread lib/Targets/AIETargetXAIEV2.cpp
Comment thread test/bd-chains-and-dma-tasks/dma-tasks-to-npu/overflow-len-good.mlir Outdated
Comment thread test/bd-chains-and-dma-tasks/dma-tasks-to-npu/overflow-len-bad.mlir
@hunhoffe hunhoffe added this to the IRON 1.3.2 milestone May 6, 2026
@andrej andrej requested a review from denolf as a code owner May 11, 2026 21:02
@andrej andrej added this pull request to the merge queue May 11, 2026
Merged via the queue into Xilinx:main with commit 614e8d8 May 11, 2026
71 checks passed
@andrej andrej deleted the overflow branch May 11, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer overflow in buffer descriptor length in compiler

3 participants