Skip to content

[ARM] Enable and validate call-used register clearing - #24

Open
kumarak wants to merge 2 commits into
zeroize-arm-driverfrom
zeroize-arm-capabilities
Open

kumarak wants to merge 2 commits into
zeroize-arm-driverfrom
zeroize-arm-capabilities

Conversation

@kumarak

@kumarak kumarak commented Sep 14, 2026

Copy link
Copy Markdown
Member

ARM already has a register-clearing emitter, but the coordinator rejects it because the target does not advertise support. Enable capability dispatch and validate the emitter across ARM, Thumb-1, Thumb-2, VFP, NEON and MVE configurations. Thumb-1 configurations with VFP hardware support core-only modes; requests that may require inaccessible VFP instructions are diagnosed. Stack clearing remains unsupported.

Stacked on #20, with zeroize-arm-driver as the base branch.

Let targets whose emitters preserve unrequested sibling registers bypass the legacy sibling exclusion. ARM opts in so returning r0 no longer accidentally spares r1; existing X86/AArch64 behavior is retained. Preserve the return-address register even when it is absent from the calling convention's callee-saved list, and prevent ARM's zero-source selection from borrowing LR.

Tests cover all register modes, different live-outs at multiple returns, cleanup calls, FP return aliases, callee-saved registers, live flags, scratch exhaustion, return-address preservation, and both Clang request paths. FP tests also check object emission.

Validation:

  • ARM, Thumb and Thumb2 codegen suites: 2,501 passed, five expected failures, no unexpected failures.
  • Five X86 and one AArch64 register-clearing compatibility tests passed unchanged.
  • Three relevant Clang codegen/driver tests passed.
  • Four regression tests fail when the corresponding protections are temporarily disabled.

Refs https://github.com/trailofbits/vspells-ct-internal-notes/issues/52 and the register-support portion of https://github.com/trailofbits/vspells-ct-internal-notes/issues/55.

Implemented with assistance from Codex.

Advertise register-clearing support, retaining core-only modes on Thumb-1 targets with VFP hardware while diagnosing requests that may require inaccessible VFP instructions.

Allow alias-preserving emitters to bypass the legacy sibling exclusion so an ARM return in r0 does not leave r1 uncleared. Preserve the return-address register independently of the callee-saved list and keep LR out of ARM zero-source selection.

Cover all modes, FP aliases, multiple exits, cleanup calls, live flags, scratch exhaustion, return-address preservation, and both Clang request paths. The ARM/Thumb/Thumb2 suites pass 2501 tests with five expected failures; all 20 focused, compatibility, and Clang checks pass. Four regressions were verified to fail with the protections disabled.
Fix P1 vector-return corruption by removing live FP leaves after expanding overlapping register tuples and before selecting clearing widths. This preserves live Q-register return values while retaining clears of dead leaves.

Add NEON and MVE vector-return regressions with machine verification and object emission. The regression fails before the fix; all 21 focused LLVM and Clang checks pass afterward. Changed-line formatting and diff checks pass; independent Codex review found no actionable regressions.
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