Skip to content

Unpoison Arm NEON inline-assembly outputs for MSan in Ruy. - #388

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_1030729360
Nov 27, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_1030729360

Conversation

@copybara-service

Copy link
Copy Markdown

Unpoison Arm NEON inline-assembly outputs for MSan in Ruy.

Arm NEON kernels and packing routines in Ruy write their outputs inside
asm volatile blocks that MemorySanitizer cannot instrument. When
callers pass an uninitialized destination buffer to ruy::Mul,
subsequent reads fail under MSan with use-of-uninitialized-value on
Arm.

Add RUY_HAVE_MSAN in asm_helpers.h and call __msan_unpoison on the
written destination tile after each Arm64 and Arm32 NEON/NEON-dotprod
kernel call and on the written packed data and sums buffers after
inline-assembly packing.

For strided destination matrices, unpoison only the [start_row, min(end_row, dst->layout.rows)) rows per column: stride padding
remains poisoned.

Under MSan, TestSet::EvalRuy now poisons the destination storage
before ruy::Mul and verifies that stride padding remains poisoned
afterward.

Arm NEON kernels and packing routines in Ruy write their outputs inside
`asm volatile` blocks that MemorySanitizer cannot instrument. When
callers pass an uninitialized destination buffer to `ruy::Mul`,
subsequent reads fail under MSan with `use-of-uninitialized-value` on
Arm.

Add `RUY_HAVE_MSAN` in `asm_helpers.h` and call `__msan_unpoison` on the
written destination tile after each Arm64 and Arm32 NEON/NEON-dotprod
kernel call and on the written packed data and sums buffers after
inline-assembly packing.

For strided destination matrices, unpoison only the `[start_row,
min(end_row, dst->layout.rows))` rows per column: stride padding
remains poisoned.

Under MSan, `TestSet::EvalRuy` now poisons the destination storage
before `ruy::Mul` and verifies that stride padding remains poisoned
afterward.

PiperOrigin-RevId: 1031222494
@copybara-service
copybara-service Bot merged commit 922de12 into master Nov 27, 2026
3 checks passed
@copybara-service
copybara-service Bot deleted the test_1030729360 branch November 27, 2026 13:56
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.

1 participant