-
Notifications
You must be signed in to change notification settings - Fork 9
Use is_x86_feature_detected
instead of CPUID
#5
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
Comments
I remember not using it for some reason, but can’t remember what it was, exactly. That macro’s |
Indeed it is. And this crate wants to support |
Well, caching hasn’t much value for this crate as the CPUID instruction is only called when constructing an instance of Adding |
Some platforms such as SGX don't support CPUID. It would be good to standardize on a single way to get capability information (preferably using is_x86_feature_detected) instead of each crate rolling its own. |
Well, I don’t see why Perhaps make an issue about that on rust-lang/rust? |
It's not in |
Okay, so after some thinking For rdrand it is not a problem, as no OS support is necessary and thus With regards to the instruction specifically, no matter how much I’m thinking about it, It seems that Intel people install a signal handler and emulate such instructions instead. This to me, makes much more sense than trying to eradicate use of these fairly standard instructions from any Rust code base that exists out there. All that being said, I will gladly accept PRs that add support for this weird target, provided they do not make code unmaintainable and, hopefully, are tested somehow. /me grumbles about people misusing target triples. |
Solution wise, to me it seems much more sensible to just add
|
Sure it does, "constructing" and RNG with RDRAND is cheap. CPUID might not be (VM emulation, etc.).
I don't understand your point here. There are plenty of things that are not in core but are in std that are accepted standards in the Rust community.
This is a hack, instructions can't be securely emulated with SGX. It's like asking someone over the phone whether you can drive or not. In particular, the We've filed PRs #6 and #7 for your consideration. I have an extremely strong preference for merging #6. |
This has been fixed by #6. |
@jethrogb @akash-fortanix v0.4.0 has been released. |
Rust provides a macro
is_x86_feature_detected
to figure out what features are supported. It knows about platform-specific ways to detect features and caches the results for future invocations. This should be used instead of callingcpuid
directly.The text was updated successfully, but these errors were encountered: