-
Notifications
You must be signed in to change notification settings - Fork 271
cpuid not supported in sgx environment #183
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
Conversation
2f373a8
to
49b786d
Compare
Thank you for reporting it! But this approach will mean that it will not be possible to enable HW acceleration via compiler flags. I think it will be better to modify the |
My recommendation is to always use #[cfg(not(feature = "std"))]
macro_rules! is_x86_feature_detected {
($feat:literal) => {
{
#[cfg(all(target_vendor="fortanix", target_env="sgx"))] {
cfg!(target_feature = $feat)
}
#[cfg(not(all(target_vendor="fortanix", target_env="sgx")))] {
cpuid_bool::cpuid_bool!($feat)
}
}
};
} |
I've published |
That's not sufficient. You should call is_x86_feature_detected when available. |
@jethrogb |
You'll have to. As mentioned previously, CPUID is not supported on some platforms and as such those platforms can't be supported by |
What are other x86 targets apart from SGX which do not support CPUID instruction? In your snippet you special-case SGX as well, so I don't see why I have to use |
I'm only special-casing it in the case #[cfg(not(feature = "std"))]
macro_rules! is_x86_feature_detected {
($feat:literal) => {
cpuid_bool::cpuid_bool!($feat)
};
}
cpuid-bool won't work because it can't work. |
What? Can you please elaborate? |
I feel like I'm repeating myself here. cpuid-bool uses the CPUID instruction so it can't work on platforms that don't support it.
It is, in a way, “magic” as the platform is free to change the implementation of
I don't know. |
@jethrogb if I'm understanding right, it sounds like the issue is the Fortanix Rust target ( |
It doesn't today but it likely will in the future. |
I guess when the Fortranix target will add a custom implementation of the |
Should be fixed in RustCrypto/utils#68. We can revisit this problem when Fortranix target will introduce custom |
Why not fix it now? By not fixing it now, you're forcing people to have to deal with this (i.e. updating their dependencies) in the future. |
Because for the current state of things the problem is "fixed". It is quite possible that before the custom macro implementation we will get rust-lang/rfcs#2725 merged and implemented, so I don't want to make code more complex than necessary. |
cpuid is not supported in sgx environment.