about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-12-15 14:47:38 +0100
committerGitHub <noreply@github.com>2018-12-15 14:47:38 +0100
commit8d9dc2b74931a30ad3ee4be09e065468afc9a566 (patch)
tree42836d469af9d866902d2bdf465c3a3bff76036e
parentb5b67298ec536a7ce4382b8afbf59c145a4ed308 (diff)
parent5acab2d7d1bd210a2fd62334b07a4d154463d412 (diff)
downloadrust-8d9dc2b74931a30ad3ee4be09e065468afc9a566.tar.gz
rust-8d9dc2b74931a30ad3ee4be09e065468afc9a566.zip
Rollup merge of #56710 - jethrogb:jb/sgx-target-features, r=alexcrichton
Always set the RDRAND and RDSEED features on SGX

Not sure if this is 100% correct.

This [Intel article](https://software.intel.com/en-us/articles/intel-software-guard-extensions-tutorial-part-5-enclave-development) goes in great depth regarding using (untrusted) CPUID to see whether RDRAND/RDSEED is supported, and explains what happens to the enclave if the CPUID result is faked.

I'd say that an implementation of SGX that doesn't make RDRAND available to the enclave is so severely limited/broken that it's ok if you get #UD in that case. The case is less clear for RDSEED, but it so far every processor released by Intel with SGX support also has RDSEED (including Gemini Lake).

cc @briansmith
-rw-r--r--src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs b/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs
index 07383b3d648..5b6d8abc5ef 100644
--- a/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs
+++ b/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs
@@ -49,6 +49,7 @@ pub fn target() -> Result<Target, String> {
         max_atomic_width: Some(64),
         panic_strategy: PanicStrategy::Abort,
         cpu: "x86-64".into(),
+        features: "+rdrnd,+rdseed".into(),
         position_independent_executables: true,
         pre_link_args: iter::once(
                 (LinkerFlavor::Gcc, PRE_LINK_ARGS.iter().cloned().map(String::from).collect())