-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AArch64 RNDR register backend #512
Conversation
Imo we should still keep the OS fallback variant, RDRAND is way more commonly available than RNDR is at this moment. Not having a fallback variant pretty much just restricts this to use-cases where someone knows 100% which specific CPU they're building for. I can post the updated PR after the weekend if you'd like. Also, instead of relying on the mrs emulation we could just make that backend depend on the |
The problem is that OS fallback will be OS-specific, e.g. in your PR it was Linux-only. I don't think we should duplicate the
I think this is fine. Otherwise, users should just use the "portable" OS API. With the fallback we just make crate's footprint bigger and code more convoluted. Also, potential performance improvements are not so clear cut, since IIUC access to RNDR register may be emulated using traps, which likely to be slower than just calling the Note that the
Personally, I don't think that we need a "RNDR with Linux fallback" backend. But it could be useful for input from potential users and other maintainers, so it may be worth to have such PR. The fallback probably should just use
Yes, I also thought about doing it. |
AArch64 platforms from version Armv8.4 onwards may implement FEAT_RNG. FEAT_RNG introduces the RNDR (and RNDRRS) register, reading from which returns a random number.
Add support for using the RNDR register as a backend for getrandom. The implementation is added as
rdrnd
opt-in backend.Currently, runtime detection of FEAT_RNG relies on the Linux Kernel's MRS emulation, on other targets users have to either enable the
std
crate feature, or therand
target feature at compile time.Based on #494, but does not include fallback to OS API if RNDR is not available for consistency with the RDRAND backend.