Skip to content
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

SGX detection confusion #9

Closed
josephlr opened this issue Feb 6, 2019 · 2 comments
Closed

SGX detection confusion #9

josephlr opened this issue Feb 6, 2019 · 2 comments

Comments

@josephlr
Copy link

josephlr commented Feb 6, 2019

Right now this create unconditionally fails if the target_env is SGX. However, RDRAND was introduced in Ivy Bridge and RDSEED was introduced in Brodwell, while SGX wasn't introduced until Skylake.

@nagisa @akash-fortanix @jethrogb was there a reason why we assume RDRAND/RDSEED is not supported on SGX chips? I understand not trusting CPUID, but there isn't a chip out there that has SGX but doesn't have RDRAND.

@jethrogb
Copy link

jethrogb commented Feb 7, 2019

While there is no extant hardware that has SGX but not RDRAND, this might not always be the case. Intel might design a new way for enclaves to get randomness securely in the future. This means you can't just assume RDRAND is available just by virtue of being compiled for SGX.

The is_x86_feature_detected implementation here is designed to mimic what the std macro does. The CPUID instruction generates #UD inside SGX, so if you're cross-compiling for SGX and don't have std, you can't make any assumptions about how you might detect RDRAND support. The conservative option must be chosen which is to assume it's not supported. To force RDRAND support, you should compile with -C target-feature=+rdrnd or set this in your target specification.

NB. For the x86_64-fortanix-unknown-sgx target, improvements to is_x86_feature_detected are being planned.

@jethrogb
Copy link

I think this issue can be closed.

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

No branches or pull requests

2 participants