Repository navigation
feat(vex): serve arm64 RNDR and RNDRRS with --deterministic-rng - #56
Conversation
Decode MRS RNDR and RNDRRS (FEAT_RNG). With --deterministic-rng they draw 64 bits from the calling thread's PRNG stream and always report success (NZCV=0000), also on hosts without FEAT_RNG. Otherwise the host register is read and its NZCV is passed through. FEAT_RNG is advertised to the client only when the host has it: AT_HWCAP2 now keeps HWCAP2_RNG instead of being dropped, and the emulated ID_AA64ISAR0_EL1 keeps the RNDR field. Refs COD-4061
Merging this PR will not alter performance
Comparing Footnotes
|
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds ARM64
No actionable issues found. Review used code inspection; no tests were run.
|
GuillaumeLagrange
left a comment
There was a problem hiding this comment.
lgtm, although same remark as the other PR, I'd love for us to have an alpha/beta to release this as I see it it's quite risky.
Decode
MRS Xt, RNDRandMRS Xt, RNDRRS(FEAT_RNG) on arm64. With--deterministic-rng=yes, both draw 64 bits from the calling thread's PRNG stream and always succeed (NZCV=0000), like RDRAND/RDSEED on amd64. Without the option, the host register is read and its NZCV is passed through.Before this change, VEX did not decode these registers, so a program that executed RNDR without checking for FEAT_RNG got SIGILL. Programs that check fell back to
getrandom, because Valgrind droppedAT_HWCAP2and masked the RNDR field ofID_AA64ISAR0_EL1.Changes:
AT_HWCAP2now passes throughHWCAP2_RNG(all other bits are still cleared), and the emulatedID_AA64ISAR0_EL1keeps the RNDR field. This keeps client code paths the same as a native run on the same host.--helpline now says "hardware RNG insns" instead of "RDRAND/RDSEED";cmdline1/cmdline2expectations are updated.Verified on a
ubuntu-24.04-armGitHub runner without FEAT_RNG:none/tests/arm64/deterministic_rng,cmdline1andcmdline2pass. The host-passthrough path (host with FEAT_RNG, no--deterministic-rng) has not been run on hardware.Closes COD-4061