Skip to content

Commit a7ee253

Browse files
bors[bot]Jethro Beekman
andauthored
Merge #369
369: Switch to stable asm! r=raoulstrackx a=jethrogb Once Rust 1.59 is released, this needs to be merged, minor versions need to be bumped where appropriate, and this should be released. * [x] Wait for Rust 1.59 * [x] Switch CI to stable * [x] Update documentation to stable Co-authored-by: Jethro Beekman <[email protected]>
2 parents a0dd815 + 1a4b156 commit a7ee253

File tree

12 files changed

+77
-102
lines changed

12 files changed

+77
-102
lines changed

.travis.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,32 @@ matrix:
2626
- clang-11
2727
- musl-tools
2828
rust:
29-
- nightly-2021-12-15
29+
- stable
3030
env:
3131
- RUST_BACKTRACE=1
3232
- CFLAGS_x86_64_fortanix_unknown_sgx="-isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening"
3333
- CC_x86_64_fortanix_unknown_sgx=clang-11
3434
before_script:
3535
- rustup target add x86_64-fortanix-unknown-sgx x86_64-unknown-linux-musl
36+
- rustup toolchain add nightly
37+
- rustup target add x86_64-fortanix-unknown-sgx --toolchain nightly
3638
script:
3739
- cargo test --verbose --locked --all --exclude sgxs-loaders && [ "$(echo $(nm -D target/debug/sgx-detect|grep __vdso_sgx_enter_enclave))" = "w __vdso_sgx_enter_enclave" ]
38-
- cargo test --verbose --locked -p sgx-isa --features sgxstd --target x86_64-fortanix-unknown-sgx --no-run
3940
- cargo test --verbose --locked -p sgxs-tools --features pe2sgxs --bin isgx-pe2sgx
4041
- cargo test --verbose --locked -p dcap-ql --features link
4142
- cargo test --verbose --locked -p dcap-ql --features verify
42-
- cargo build --verbose --locked -p aesm-client --target=x86_64-fortanix-unknown-sgx
43-
- cargo build --verbose --locked -p aesm-client --target=x86_64-fortanix-unknown-sgx --features sgx-isa/sgxstd
44-
- cargo test --locked -p nitro-attestation-verify
43+
# uses backtrace, which still requires nightly on SGX
44+
- cargo +nightly build --verbose --locked -p aesm-client --target=x86_64-fortanix-unknown-sgx
45+
# uses sgxstd feature
46+
- cargo +nightly build --verbose --locked -p aesm-client --target=x86_64-fortanix-unknown-sgx --features sgx-isa/sgxstd
47+
- cargo +nightly test --verbose --locked -p sgx-isa --features sgxstd --target x86_64-fortanix-unknown-sgx --no-run
4548
# Unfortunately running `faketime '2021-09-10 11:00:00 GMT' cargo test -p nitro-attestation-verify` causes a segmentation
4649
# fault while compiling. We only execute `faketime` during the tests
47-
- cargo test --locked -p nitro-attestation-verify --no-run && faketime '2021-09-08 11:00:00 GMT' $(find ./target/debug/deps -name "nitro_attestation_verify*" -executable)
48-
- cargo test --locked -p nitro-attestation-verify --no-run && faketime '2021-09-10 11:00:00 GMT' $(find ./target/debug/deps -name "nitro_attestation_verify*" -executable)
50+
#- cargo test --locked -p nitro-attestation-verify --no-run && faketime '2021-09-08 11:00:00 GMT' cargo test --locked -p nitro-attestation-verify --lib
51+
- cargo test --locked -p nitro-attestation-verify --no-run && faketime '2021-09-10 11:00:00 GMT' cargo test --locked -p nitro-attestation-verify --lib
4952
# NOTE: linking glibc version of OpenSSL with musl binary.
5053
# Unlikely to produce a working binary, but at least the build succeeds.
5154
- mkdir -p /tmp/muslinclude && ln -sf /usr/include/x86_64-linux-gnu/openssl /tmp/muslinclude/openssl && PKG_CONFIG_ALLOW_CROSS=1 CFLAGS=-I/tmp/muslinclude cargo build --locked -p fortanix-sgx-tools --target x86_64-unknown-linux-musl
52-
- cargo build --verbose --locked -p em-app --target=x86_64-fortanix-unknown-sgx
53-
- cargo build --verbose --locked -p em-app --target=x86_64-unknown-linux-gnu
54-
- cargo build --verbose --locked -p em-app --target=x86_64-unknown-linux-musl
55-
- cargo build --verbose --locked -p get-certificate --target=x86_64-fortanix-unknown-sgx
56-
- cargo build --verbose --locked -p get-certificate --target=x86_64-unknown-linux-gnu
57-
- cargo build --verbose --locked -p get-certificate --target=x86_64-unknown-linux-musl
58-
- cargo build --verbose --locked -p harmonize --target=x86_64-fortanix-unknown-sgx
59-
- cargo build --verbose --locked -p harmonize --target=x86_64-unknown-linux-gnu
60-
- cargo build --verbose --locked -p harmonize --target=x86_64-unknown-linux-musl
61-
- ./doc/generate-api-docs.sh
55+
- cargo build --verbose --locked -p em-app -p get-certificate -p harmonize --target=x86_64-unknown-linux-musl
56+
- cargo build --verbose --locked -p em-app -p get-certificate -p harmonize --target=x86_64-fortanix-unknown-sgx
57+
- ./doc/generate-api-docs.sh

Cargo.lock

Lines changed: 13 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

em-app/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ uuid_sdkms = { package = "uuid", version = "0.7.4", features = ["v4", "serde"] }
3030
yasna = { version = "0.3", features = ["num-bigint", "bit-vec"] }
3131

3232
[target.x86_64-fortanix-unknown-sgx.dependencies]
33-
sgx_pkix = { version = "0.1.0" }
34-
sgx-isa = { version="0.3", features=["sgxstd"], default-features=false }
33+
sgx_pkix = { version = "0.1.0", path = "../intel-sgx/sgx_pkix" }
34+
sgx-isa = { version = "0.3", path = "../intel-sgx/sgx-isa", default-features = false }
3535

3636
[target.x86_64-unknown-linux-musl.dependencies]
3737
nsm-driver = { git = "https://github.com/aws/aws-nitro-enclaves-nsm-api", package = "nsm-driver", rev = "6745598d0e0e8af57e9b96ee2bf3d11b216fe649" }

fortanix-vme/tests/incoming_connection/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(io_error_uncategorized)]
21
use std::io::{ErrorKind, Read, Write};
32
use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpListener, TcpStream, ToSocketAddrs};
43
use std::os::unix::io::{AsRawFd, FromRawFd};
@@ -31,7 +30,7 @@ fn server_run<A: ToSocketAddrs>(addr: A) {
3130
assert_eq!(stream.local_addr().unwrap().port(), 3400);
3231

3332
let no_stream = unsafe { TcpStream::from_raw_fd(666.into()) };
34-
assert_eq!(no_stream.peer_addr().unwrap_err().kind(), ErrorKind::Uncategorized);
33+
no_stream.peer_addr().unwrap_err();
3534

3635
println!("Connection {}: Connected", id);
3736
let mut buff_in = [0u8; 4192];

intel-sgx/enclave-runner/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
66

77
#![deny(warnings)]
8-
#![feature(asm)]
98
#![doc(
109
html_logo_url = "https://edp.fortanix.com/img/docs/edp-logo.svg",
1110
html_favicon_url = "https://edp.fortanix.com/favicon.ico",

intel-sgx/enclave-runner/src/tcs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
66

77
use std;
8+
use std::arch::asm;
89
use std::cell::RefCell;
910
use std::convert::{TryFrom, TryInto};
1011
use std::fmt;

intel-sgx/enclave-runner/src/usercalls/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ async fn trap_attached_debugger(tcs: usize, debug_buf: *const u8) {
12261226
// Synchronized
12271227
unsafe {
12281228
let old = signal::sigaction(signal::SIGTRAP, &sig_action).unwrap();
1229-
asm!("
1229+
std::arch::asm!("
12301230
xchg %rbx, {0}
12311231
int3
12321232
xchg {0}, %rbx

intel-sgx/sgx-isa/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ serde = { version = "1.0.104", features = ["derive"], optional = true } # MIT/Ap
2727
[features]
2828
large_array_derive = []
2929
sgxstd = []
30-
nightly = []

intel-sgx/sgx-isa/src/arch.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
66
use core::mem::MaybeUninit;
7+
use core::arch::asm;
78
use super::Enclu;
89

910
/// Wrapper struct to force 16-byte alignment.
@@ -24,13 +25,15 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32>
2425
let mut out = MaybeUninit::uninit();
2526
let error;
2627

27-
llvm_asm!(
28-
"enclu"
29-
: "={eax}"(error)
30-
: "{eax}"(Enclu::EGetkey),
31-
"{rbx}"(request),
32-
"{rcx}"(out.as_mut_ptr())
33-
: "flags"
28+
asm!(
29+
// rbx is reserved by LLVM
30+
"xchg %rbx, {0}",
31+
"enclu",
32+
"mov {0}, %rbx",
33+
inout(reg) request => _,
34+
inlateout("eax") Enclu::EGetkey as u32 => error,
35+
in("rcx") out.as_mut_ptr(),
36+
options(att_syntax, nostack),
3437
);
3538

3639
match error {
@@ -52,13 +55,16 @@ pub fn ereport(
5255
unsafe {
5356
let mut report = MaybeUninit::uninit();
5457

55-
llvm_asm!(
56-
"enclu"
57-
: /* no output registers */
58-
: "{eax}"(Enclu::EReport),
59-
"{rbx}"(targetinfo),
60-
"{rcx}"(reportdata),
61-
"{rdx}"(report.as_mut_ptr())
58+
asm!(
59+
// rbx is reserved by LLVM
60+
"xchg %rbx, {0}",
61+
"enclu",
62+
"mov {0}, %rbx",
63+
inout(reg) targetinfo => _,
64+
in("eax") Enclu::EReport as u32,
65+
in("rcx") reportdata,
66+
in("rdx") report.as_mut_ptr(),
67+
options(att_syntax, preserves_flags, nostack),
6268
);
6369

6470
report.assume_init()

intel-sgx/sgx-isa/src/lib.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//! convenient.
1111
//!
1212
//! [isdm]: https://www-ssl.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html
13-
#![cfg_attr(feature = "nightly", feature(llvm_asm))]
14-
1513
#![no_std]
1614
#![doc(html_logo_url = "https://edp.fortanix.com/img/docs/edp-logo.svg",
1715
html_favicon_url = "https://edp.fortanix.com/favicon.ico",
@@ -30,9 +28,9 @@ extern crate serde;
3028
#[cfg(feature = "serde")]
3129
use serde::{Serialize, Deserialize};
3230

33-
#[cfg(all(feature = "sgxstd", target_env = "sgx"))]
31+
#[cfg(all(target_env = "sgx", feature = "sgxstd"))]
3432
use std::os::fortanix_sgx::arch;
35-
#[cfg(all(feature = "nightly", target_env = "sgx", not(feature = "sgxstd")))]
33+
#[cfg(all(target_env = "sgx", not(feature = "sgxstd")))]
3634
mod arch;
3735
use core::{convert::TryFrom, num::TryFromIntError, slice};
3836

@@ -225,9 +223,7 @@ macro_rules! struct_def {
225223
};
226224
(@align bytes $($other:tt)*) => {};
227225
(@align type $ty:ident name $name:ident) => {
228-
#[cfg(all(feature = "sgxstd", target_env = "sgx"))]
229-
/// **Note.** This implementation is only available on the SGX target
230-
/// with the `sgxstd` feature.
226+
#[cfg(target_env = "sgx")]
231227
impl AsRef<arch::$ty<[u8; $name::UNPADDED_SIZE]>> for $name {
232228
fn as_ref(&self) -> &arch::$ty<[u8; $name::UNPADDED_SIZE]> {
233229
unsafe {
@@ -678,7 +674,7 @@ impl Report {
678674
///
679675
/// let targetinfo_self = Targetinfo::from(Report::for_self());
680676
/// ```
681-
#[cfg(all(feature = "sgxstd", target_env = "sgx"))]
677+
#[cfg(target_env = "sgx")]
682678
pub fn for_self() -> Self {
683679
let reportdata = arch::Align128([0; 64]);
684680
let targetinfo = arch::Align512([0; 512]);
@@ -687,7 +683,7 @@ impl Report {
687683
Report::try_copy_from(&out.0).unwrap()
688684
}
689685

690-
#[cfg(all(feature = "sgxstd", target_env = "sgx"))]
686+
#[cfg(target_env = "sgx")]
691687
pub fn for_target(targetinfo: &Targetinfo, reportdata: &[u8; 64]) -> Report {
692688
let reportdata = arch::Align128(*reportdata);
693689
let out = arch::ereport(targetinfo.as_ref(), &reportdata);
@@ -700,7 +696,7 @@ impl Report {
700696
///
701697
/// Care should be taken that `check_mac` prevents timing attacks,
702698
/// in particular that the comparison happens in constant time.
703-
#[cfg(all(feature = "sgxstd", target_env = "sgx"))]
699+
#[cfg(target_env = "sgx")]
704700
pub fn verify<F, R>(&self, check_mac: F) -> R
705701
where
706702
F: FnOnce(&[u8; 16], &[u8; Report::TRUNCATED_SIZE], &[u8; 16]) -> R,
@@ -781,7 +777,7 @@ pub struct Keyrequest {
781777
impl Keyrequest {
782778
pub const UNPADDED_SIZE: usize = 512;
783779

784-
#[cfg(all(feature = "sgxstd", target_env = "sgx"))]
780+
#[cfg(target_env = "sgx")]
785781
pub fn egetkey(&self) -> Result<[u8; 16], ErrorCode> {
786782
match arch::egetkey(self.as_ref()) {
787783
Ok(k) => Ok(k.0),

0 commit comments

Comments
 (0)