You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesatee.apache.org by di...@apache.org on 2019/11/20 06:42:58 UTC
[incubator-mesatee-sgx] branch v1.1.0-beta updated: v1.1.0-beta
update
This is an automated email from the ASF dual-hosted git repository.
dingyu pushed a commit to branch v1.1.0-beta
in repository https://gitbox.apache.org/repos/asf/incubator-mesatee-sgx.git
The following commit(s) were added to refs/heads/v1.1.0-beta by this push:
new ef51eff v1.1.0-beta update
ef51eff is described below
commit ef51eff7025d38a357a001e64890f1579eb0e6a1
Author: Yu Ding <di...@gmail.com>
AuthorDate: Tue Nov 19 22:42:36 2019 -0800
v1.1.0-beta update
---
rust-toolchain | 2 +-
samplecode/mutual-ra/app/Cargo.toml | 1 -
samplecode/mutual-ra/app/src/main.rs | 70 ++-----------
samplecode/pcl/pcl-seal/Makefile | 4 +-
samplecode/pcl/pcl-seal/app/Cargo.toml | 1 -
samplecode/pcl/pcl-seal/app/src/main.rs | 141 +++-----------------------
samplecode/switchless/app/src/main.rs | 14 +--
samplecode/unit-test/enclave/src/test_file.rs | 5 +-
samplecode/wasmi/Makefile | 2 +-
sgx_alloc/Cargo.toml | 2 +-
sgx_backtrace/Cargo.toml | 2 +-
sgx_backtrace_sys/Cargo.toml | 2 +-
sgx_cov/Cargo.toml | 2 +-
sgx_crypto_helper/Cargo.toml | 2 +-
sgx_demangle/Cargo.toml | 2 +-
sgx_libc/Cargo.toml | 2 +-
sgx_no_tstd/Cargo.toml | 2 +-
sgx_no_tstd/src/lib.rs | 7 --
sgx_rand/Cargo.toml | 2 +-
sgx_rand_derive/Cargo.toml | 2 +-
sgx_serialize/Cargo.toml | 2 +-
sgx_serialize_derive/Cargo.toml | 2 +-
sgx_serialize_derive_internals/Cargo.toml | 2 +-
sgx_tcrypto/Cargo.toml | 2 +-
sgx_tcrypto_helper/Cargo.toml | 8 +-
sgx_tdh/Cargo.toml | 2 +-
sgx_tkey_exchange/Cargo.toml | 2 +-
sgx_tprotected_fs/Cargo.toml | 2 +-
sgx_trts/Cargo.toml | 2 +-
sgx_tse/Cargo.toml | 2 +-
sgx_tseal/Cargo.toml | 2 +-
sgx_tservice/Cargo.toml | 2 +-
sgx_tstd/Cargo.toml | 2 +-
sgx_tstd/src/collections/hash/map.rs | 6 +-
sgx_tstd/src/lib.rs | 4 +-
sgx_tstd/src/panicking.rs | 21 ++--
sgx_tstd/src/prelude/v1.rs | 2 +-
sgx_tstd/src/sys/thread.rs | 16 ++-
sgx_tstd/src/sys_common/thread.rs | 28 +++++
sgx_tunittest/Cargo.toml | 2 +-
sgx_types/Cargo.toml | 2 +-
sgx_types/src/function.rs | 8 ++
sgx_types/src/types.rs | 13 ++-
sgx_ucrypto/Cargo.toml | 2 +-
sgx_unwind/Cargo.toml | 2 +-
sgx_urts/Cargo.toml | 2 +-
46 files changed, 141 insertions(+), 266 deletions(-)
diff --git a/rust-toolchain b/rust-toolchain
index 2818bd0..22e9048 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1 +1 @@
-nightly-2019-10-14
+nightly-2019-11-06
diff --git a/samplecode/mutual-ra/app/Cargo.toml b/samplecode/mutual-ra/app/Cargo.toml
index 7b55759..83388a7 100644
--- a/samplecode/mutual-ra/app/Cargo.toml
+++ b/samplecode/mutual-ra/app/Cargo.toml
@@ -7,7 +7,6 @@ build = "build.rs"
[dependencies]
sgx_types = { git = "https://github.com/baidu/rust-sgx-sdk.git" }
sgx_urts = { git = "https://github.com/baidu/rust-sgx-sdk.git" }
-dirs = "1.0.2"
[patch.'https://github.com/baidu/rust-sgx-sdk.git']
sgx_types = { path = "../../../sgx_types" }
diff --git a/samplecode/mutual-ra/app/src/main.rs b/samplecode/mutual-ra/app/src/main.rs
index 78a34b8..cf95cef 100644
--- a/samplecode/mutual-ra/app/src/main.rs
+++ b/samplecode/mutual-ra/app/src/main.rs
@@ -31,17 +31,13 @@
extern crate sgx_types;
extern crate sgx_urts;
-extern crate dirs;
use sgx_types::*;
use sgx_urts::SgxEnclave;
use std::os::unix::io::{IntoRawFd, AsRawFd};
-use std::fs;
use std::env;
-use std::path;
use std::net::{TcpListener, TcpStream, SocketAddr};
use std::str;
-use std::io::{Read, Write};
const BUFFER_SIZE: usize = 1024;
@@ -151,71 +147,17 @@ fn ocall_get_update_info (platform_blob: * const sgx_platform_info_t,
}
fn init_enclave() -> SgxResult<SgxEnclave> {
-
let mut launch_token: sgx_launch_token_t = [0; 1024];
let mut launch_token_updated: i32 = 0;
- // Step 1: try to retrieve the launch token saved by last transaction
- // if there is no token, then create a new one.
- //
- // try to get the token saved in $HOME */
- let mut home_dir = path::PathBuf::new();
- let use_token = match dirs::home_dir() {
- Some(path) => {
- println!("[+] Home dir is {}", path.display());
- home_dir = path;
- true
- },
- None => {
- println!("[-] Cannot get home dir");
- false
- }
- };
-
- let token_file: path::PathBuf = home_dir.join(ENCLAVE_TOKEN);;
- if use_token == true {
- match fs::File::open(&token_file) {
- Err(_) => {
- println!("[-] Open token file {} error! Will create one.", token_file.as_path().to_str().unwrap());
- },
- Ok(mut f) => {
- println!("[+] Open token file success! ");
- match f.read(&mut launch_token) {
- Ok(1024) => {
- println!("[+] Token file valid!");
- },
- _ => println!("[+] Token file invalid, will create new token file"),
- }
- }
- }
- }
-
- // Step 2: call sgx_create_enclave to initialize an enclave instance
+ // call sgx_create_enclave to initialize an enclave instance
// Debug Support: set 2nd parameter to 1
let debug = 1;
let mut misc_attr = sgx_misc_attribute_t {secs_attr: sgx_attributes_t { flags:0, xfrm:0}, misc_select:0};
- let enclave = try!(SgxEnclave::create(ENCLAVE_FILE,
- debug,
- &mut launch_token,
- &mut launch_token_updated,
- &mut misc_attr));
-
- // Step 3: save the launch token if it is updated
- if use_token == true && launch_token_updated != 0 {
- // reopen the file with write capablity
- match fs::File::create(&token_file) {
- Ok(mut f) => {
- match f.write_all(&launch_token) {
- Ok(()) => println!("[+] Saved updated launch token!"),
- Err(_) => println!("[-] Failed to save updated launch token!"),
- }
- },
- Err(_) => {
- println!("[-] Failed to save updated enclave token, but doesn't matter");
- },
- }
- }
-
- Ok(enclave)
+ SgxEnclave::create(ENCLAVE_FILE,
+ debug,
+ &mut launch_token,
+ &mut launch_token_updated,
+ &mut misc_attr)
}
enum Mode {
diff --git a/samplecode/pcl/pcl-seal/Makefile b/samplecode/pcl/pcl-seal/Makefile
index 0c1d90c..2aa9424 100644
--- a/samplecode/pcl/pcl-seal/Makefile
+++ b/samplecode/pcl/pcl-seal/Makefile
@@ -108,7 +108,7 @@ RustEnclave_Link_Libs := -L$(CUSTOM_LIBRARY_PATH) -lcompiler-rt-patch -lenclave
RustEnclave_Compile_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(RustEnclave_Include_Paths)
RustEnclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
-Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
- -Wl,--start-group -lsgx_tstdc -l$(Service_Library_Name) -l$(ProtectedFs_Library_Name) -l$(Crypto_Library_Name) $(RustEnclave_Link_Libs) -Wl,--end-group \
+ -Wl,--start-group -lsgx_tstdc -lsgx_tcxx -l$(Service_Library_Name) -l$(ProtectedFs_Library_Name) -l$(Crypto_Library_Name) $(RustEnclave_Link_Libs) -Wl,--end-group \
-Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \
-Wl,-pie,-eenclave_entry -Wl,--export-dynamic \
-Wl,--defsym,__ImageBase=0 \
@@ -158,7 +158,7 @@ $(App_Name): $(App_Enclave_u_Object) $(App_SRC_Files) $(PayloadEnclave_Name)
cp $(App_Rust_Path)/app ./bin
$(PayloadEnclave_Name):
- mkdir bin
+ mkdir -p bin
cp ../encrypted-hello/bin/enclave.signed.so $@
######## Enclave Objects ########
diff --git a/samplecode/pcl/pcl-seal/app/Cargo.toml b/samplecode/pcl/pcl-seal/app/Cargo.toml
index 6b8dd39..58308b1 100644
--- a/samplecode/pcl/pcl-seal/app/Cargo.toml
+++ b/samplecode/pcl/pcl-seal/app/Cargo.toml
@@ -7,7 +7,6 @@ build = "build.rs"
[dependencies]
sgx_types = { git = "https://github.com/baidu/rust-sgx-sdk.git" }
sgx_urts = { git = "https://github.com/baidu/rust-sgx-sdk.git" }
-dirs = "1.0.2"
itertools = "*"
[patch.'https://github.com/baidu/rust-sgx-sdk.git']
diff --git a/samplecode/pcl/pcl-seal/app/src/main.rs b/samplecode/pcl/pcl-seal/app/src/main.rs
index fedcf81..6903c4c 100644
--- a/samplecode/pcl/pcl-seal/app/src/main.rs
+++ b/samplecode/pcl/pcl-seal/app/src/main.rs
@@ -31,25 +31,19 @@
extern crate sgx_types;
extern crate sgx_urts;
-extern crate dirs;
extern crate itertools;
use sgx_types::*;
use sgx_urts::SgxEnclave;
use std::os::unix::io::{IntoRawFd, AsRawFd};
-use std::fs;
use std::env;
-use std::path;
use std::net::{TcpListener, TcpStream, SocketAddr};
use std::str;
-use std::io::{Read, Write};
use itertools::Itertools;
const PCL_SEALED_KEY_SIZE: usize = SGX_AESGCM_KEY_SIZE + SGX_PCL_GUID_SIZE;
static ENCLAVE_FILE: &'static str = "enclave.signed.so";
-static ENCLAVE_TOKEN: &'static str = "enclave.token";
static ENCRYPTED_ENCLAVE_FILE: &'static str = "payload.signed.so";
-static ENCRYPTED_ENCLAVE_TOKEN: &'static str = "payload.token";
extern {
fn key_provision(eid: sgx_enclave_id_t, retval: *mut sgx_status_t,
@@ -161,142 +155,34 @@ fn ocall_get_update_info (platform_blob: * const sgx_platform_info_t,
}
fn init_enclave() -> SgxResult<SgxEnclave> {
-
let mut launch_token: sgx_launch_token_t = [0; 1024];
let mut launch_token_updated: i32 = 0;
- // Step 1: try to retrieve the launch token saved by last transaction
- // if there is no token, then create a new one.
- //
- // try to get the token saved in $HOME */
- let mut home_dir = path::PathBuf::new();
- let use_token = match dirs::home_dir() {
- Some(path) => {
- println!("[+] Home dir is {}", path.display());
- home_dir = path;
- true
- },
- None => {
- println!("[-] Cannot get home dir");
- false
- }
- };
-
- let token_file: path::PathBuf = home_dir.join(ENCLAVE_TOKEN);;
- if use_token == true {
- match fs::File::open(&token_file) {
- Err(_) => {
- println!("[-] Open token file {} error! Will create one.", token_file.as_path().to_str().unwrap());
- },
- Ok(mut f) => {
- println!("[+] Open token file success! ");
- match f.read(&mut launch_token) {
- Ok(1024) => {
- println!("[+] Token file valid!");
- },
- _ => println!("[+] Token file invalid, will create new token file"),
- }
- }
- }
- }
-
- // Step 2: call sgx_create_enclave to initialize an enclave instance
+ // call sgx_create_enclave to initialize an enclave instance
// Debug Support: set 2nd parameter to 1
let debug = 1;
let mut misc_attr = sgx_misc_attribute_t {secs_attr: sgx_attributes_t { flags:0, xfrm:0}, misc_select:0};
- let enclave = try!(SgxEnclave::create(ENCLAVE_FILE,
- debug,
- &mut launch_token,
- &mut launch_token_updated,
- &mut misc_attr));
-
- // Step 3: save the launch token if it is updated
- if use_token == true && launch_token_updated != 0 {
- // reopen the file with write capablity
- match fs::File::create(&token_file) {
- Ok(mut f) => {
- match f.write_all(&launch_token) {
- Ok(()) => println!("[+] Saved updated launch token!"),
- Err(_) => println!("[-] Failed to save updated launch token!"),
- }
- },
- Err(_) => {
- println!("[-] Failed to save updated enclave token, but doesn't matter");
- },
- }
- }
-
- Ok(enclave)
+ SgxEnclave::create(ENCLAVE_FILE,
+ debug,
+ &mut launch_token,
+ &mut launch_token_updated,
+ &mut misc_attr)
}
fn init_encrypted_enclave(payload_file: &str,
- payload_token: &str,
payload_pcl_key: &Vec<u8>) -> SgxResult<SgxEnclave> {
let mut launch_token: sgx_launch_token_t = [0; 1024];
let mut launch_token_updated: i32 = 0;
- // Step 1: try to retrieve the launch token saved by last transaction
- // if there is no token, then create a new one.
- //
- // try to get the token saved in $HOME */
- let mut home_dir = path::PathBuf::new();
- let use_token = match dirs::home_dir() {
- Some(path) => {
- println!("[+] Home dir is {}", path.display());
- home_dir = path;
- true
- },
- None => {
- println!("[-] Cannot get home dir");
- false
- }
- };
-
- let token_file: path::PathBuf = home_dir.join(payload_token);;
- if use_token == true {
- match fs::File::open(&token_file) {
- Err(_) => {
- println!("[-] Open token file {} error! Will create one.", token_file.as_path().to_str().unwrap());
- },
- Ok(mut f) => {
- println!("[+] Open token file success! ");
- match f.read(&mut launch_token) {
- Ok(1024) => {
- println!("[+] Token file valid!");
- },
- _ => println!("[+] Token file invalid, will create new token file"),
- }
- }
- }
- }
-
- // Step 2: call sgx_create_enclave to initialize an enclave instance
+ // call sgx_create_enclave to initialize an enclave instance
// Debug Support: set 2nd parameter to 1
let debug = 1;
let mut misc_attr = sgx_misc_attribute_t {secs_attr: sgx_attributes_t { flags:0, xfrm:0}, misc_select:0};
- let enclave = try!(SgxEnclave::create_encrypt(payload_file,
- debug,
- &mut launch_token,
- &mut launch_token_updated,
- &mut misc_attr,
- payload_pcl_key.as_ptr() as *const sgx_sealed_data_t));
-
- // Step 3: save the launch token if it is updated
- if use_token == true && launch_token_updated != 0 {
- // reopen the file with write capablity
- match fs::File::create(&token_file) {
- Ok(mut f) => {
- match f.write_all(&launch_token) {
- Ok(()) => println!("[+] Saved updated launch token!"),
- Err(_) => println!("[-] Failed to save updated launch token!"),
- }
- },
- Err(_) => {
- println!("[-] Failed to save updated enclave token, but doesn't matter");
- },
- }
- }
-
- Ok(enclave)
+ SgxEnclave::create_encrypt(payload_file,
+ debug,
+ &mut launch_token,
+ &mut launch_token_updated,
+ &mut misc_attr,
+ payload_pcl_key.as_ptr() as *const sgx_sealed_data_t)
}
fn main() {
@@ -381,7 +267,6 @@ fn main() {
println!("get_sealed_pcl_key {:02X}", sealed_key_vec.iter().format(""));
let result = init_encrypted_enclave(ENCRYPTED_ENCLAVE_FILE,
- ENCRYPTED_ENCLAVE_TOKEN,
&sealed_key_vec);
let payload_enclave = match result {
Ok(r) => {
diff --git a/samplecode/switchless/app/src/main.rs b/samplecode/switchless/app/src/main.rs
index cd41e10..08bf1a6 100644
--- a/samplecode/switchless/app/src/main.rs
+++ b/samplecode/switchless/app/src/main.rs
@@ -44,18 +44,20 @@ extern {
fn ecall_empty_switchless(eid: sgx_enclave_id_t) -> sgx_status_t;
}
-fn init_enclave() -> SgxResult<SgxEnclave> {
+fn init_enclave(num_uworker : u32, num_tworker : u32) -> SgxResult<SgxEnclave> {
let mut launch_token: sgx_launch_token_t = [0; 1024];
let mut launch_token_updated: i32 = 0;
// call sgx_create_enclave to initialize an enclave instance
// Debug Support: set 2nd parameter to 1
let debug = 1;
let mut misc_attr = sgx_misc_attribute_t {secs_attr: sgx_attributes_t { flags:0, xfrm:0}, misc_select:0};
- SgxEnclave::create(ENCLAVE_FILE,
- debug,
- &mut launch_token,
- &mut launch_token_updated,
- &mut misc_attr)
+ SgxEnclave::create_with_workers(ENCLAVE_FILE,
+ debug,
+ &mut launch_token,
+ &mut launch_token_updated,
+ &mut misc_attr,
+ num_uworker,
+ num_tworker)
}
#[no_mangle]
diff --git a/samplecode/unit-test/enclave/src/test_file.rs b/samplecode/unit-test/enclave/src/test_file.rs
index f30a1cc..2b0cfdf 100644
--- a/samplecode/unit-test/enclave/src/test_file.rs
+++ b/samplecode/unit-test/enclave/src/test_file.rs
@@ -79,8 +79,9 @@ pub fn test_sgxfs() {
assert_eq!(opt.is_err(), true);
}
{
- let opt = SgxFile::open("/dev/isgx");
- assert_eq!(opt.is_ok(), true);
+ let opt1 = SgxFile::open("/dev/isgx");
+ let opt2 = SgxFile::open("/dev/sgx");
+ assert_eq!(opt1.is_ok() || opt2.is_ok(), true);
}
{
let opt = SgxFile::create("/");
diff --git a/samplecode/wasmi/Makefile b/samplecode/wasmi/Makefile
index 1ccf0ed..d6008e4 100644
--- a/samplecode/wasmi/Makefile
+++ b/samplecode/wasmi/Makefile
@@ -161,7 +161,7 @@ $(Signed_RustEnclave_Name): $(RustEnclave_Name)
.PHONY: enclave
enclave:
- git submodule init && git submodule update
+ (cd ../.. && git submodule init && git submodule update)
$(MAKE) -C ./enclave/
.PHONY: compiler-rt
diff --git a/sgx_alloc/Cargo.toml b/sgx_alloc/Cargo.toml
index b82dbdf..37134fd 100644
--- a/sgx_alloc/Cargo.toml
+++ b/sgx_alloc/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_alloc"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_backtrace/Cargo.toml b/sgx_backtrace/Cargo.toml
index 468b011..e65800c 100644
--- a/sgx_backtrace/Cargo.toml
+++ b/sgx_backtrace/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "sgx_backtrace"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_backtrace_sys/Cargo.toml b/sgx_backtrace_sys/Cargo.toml
index 765054d..165a4f8 100644
--- a/sgx_backtrace_sys/Cargo.toml
+++ b/sgx_backtrace_sys/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_backtrace_sys"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
build = "build.rs"
repository = "https://github.com/baidu/rust-sgx-sdk"
diff --git a/sgx_cov/Cargo.toml b/sgx_cov/Cargo.toml
index a240c13..204f8f2 100644
--- a/sgx_cov/Cargo.toml
+++ b/sgx_cov/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_cov"
-version = "0.1.0"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_crypto_helper/Cargo.toml b/sgx_crypto_helper/Cargo.toml
index dad1366..d8a833a 100644
--- a/sgx_crypto_helper/Cargo.toml
+++ b/sgx_crypto_helper/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_crypto_helper"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_demangle/Cargo.toml b/sgx_demangle/Cargo.toml
index ea46954..3807fc2 100644
--- a/sgx_demangle/Cargo.toml
+++ b/sgx_demangle/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "sgx_demangle"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_libc/Cargo.toml b/sgx_libc/Cargo.toml
index 487556f..5c1dc38 100644
--- a/sgx_libc/Cargo.toml
+++ b/sgx_libc/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_libc"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_no_tstd/Cargo.toml b/sgx_no_tstd/Cargo.toml
index ec1aa1e..4f812df 100644
--- a/sgx_no_tstd/Cargo.toml
+++ b/sgx_no_tstd/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_no_tstd"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
build = "build.rs"
repository = "https://github.com/baidu/rust-sgx-sdk"
diff --git a/sgx_no_tstd/src/lib.rs b/sgx_no_tstd/src/lib.rs
index 0b5fc0a..1ed83ba 100644
--- a/sgx_no_tstd/src/lib.rs
+++ b/sgx_no_tstd/src/lib.rs
@@ -26,13 +26,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//! # liballoc crate for Rust SGX SDK
-//!
-//! This crate equals to the `liballoc_system` crate in Rust.
-//! It connects Rust memory allocation to Intel SGX's sgx_tstd library.
-//! It is essential, because we depends on Intel SGX's SDK.
-//! 2018-06-22 Add liballoc components here
-
#![no_std]
#![cfg_attr(target_env = "sgx", feature(rustc_private))]
diff --git a/sgx_rand/Cargo.toml b/sgx_rand/Cargo.toml
index b3efa97..1f84112 100644
--- a/sgx_rand/Cargo.toml
+++ b/sgx_rand/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_rand"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_rand_derive/Cargo.toml b/sgx_rand_derive/Cargo.toml
index 00f4fe1..a6166ab 100644
--- a/sgx_rand_derive/Cargo.toml
+++ b/sgx_rand_derive/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_rand_derive"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_serialize/Cargo.toml b/sgx_serialize/Cargo.toml
index c14cb68..5408ff9 100644
--- a/sgx_serialize/Cargo.toml
+++ b/sgx_serialize/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_serialize"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_serialize_derive/Cargo.toml b/sgx_serialize_derive/Cargo.toml
index dec0b9f..fb17e2d 100644
--- a/sgx_serialize_derive/Cargo.toml
+++ b/sgx_serialize_derive/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_serialize_derive"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_serialize_derive_internals/Cargo.toml b/sgx_serialize_derive_internals/Cargo.toml
index 7aa5fc2..84ca81f 100644
--- a/sgx_serialize_derive_internals/Cargo.toml
+++ b/sgx_serialize_derive_internals/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_serialize_derive_internals"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_tcrypto/Cargo.toml b/sgx_tcrypto/Cargo.toml
index 823187a..8d6ed9a 100644
--- a/sgx_tcrypto/Cargo.toml
+++ b/sgx_tcrypto/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tcrypto"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_tcrypto_helper/Cargo.toml b/sgx_tcrypto_helper/Cargo.toml
index d0f88e6..9370e9e 100644
--- a/sgx_tcrypto_helper/Cargo.toml
+++ b/sgx_tcrypto_helper/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tcrypto_helper"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
@@ -18,9 +18,9 @@ default = ["mesalock_sgx"]
mesalock_sgx = []
[target.'cfg(not(target_env = "sgx"))'.dependencies]
-sgx_tcrypto = { rev = "v1.0.9", git = "https://github.com/baidu/rust-sgx-sdk.git" }
-sgx_tstd = { rev = "v1.0.9", git = "https://github.com/baidu/rust-sgx-sdk.git" }
-sgx_types = { rev = "v1.0.9", git = "https://github.com/baidu/rust-sgx-sdk.git" }
+sgx_tcrypto = { rev = "v1.1.0", git = "https://github.com/baidu/rust-sgx-sdk.git" }
+sgx_tstd = { rev = "v1.1.0", git = "https://github.com/baidu/rust-sgx-sdk.git" }
+sgx_types = { rev = "v1.1.0", git = "https://github.com/baidu/rust-sgx-sdk.git" }
[dependencies]
serde = { git = "https://github.com/mesalock-linux/serde-sgx" }
diff --git a/sgx_tdh/Cargo.toml b/sgx_tdh/Cargo.toml
index 42af08b..b77a8aa 100644
--- a/sgx_tdh/Cargo.toml
+++ b/sgx_tdh/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tdh"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_tkey_exchange/Cargo.toml b/sgx_tkey_exchange/Cargo.toml
index 85ee6b5..79d8ad3 100644
--- a/sgx_tkey_exchange/Cargo.toml
+++ b/sgx_tkey_exchange/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tkey_exchange"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_tprotected_fs/Cargo.toml b/sgx_tprotected_fs/Cargo.toml
index 7cca56e..67ff2af 100644
--- a/sgx_tprotected_fs/Cargo.toml
+++ b/sgx_tprotected_fs/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tprotected_fs"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_trts/Cargo.toml b/sgx_trts/Cargo.toml
index f2fac99..7b9bf70 100644
--- a/sgx_trts/Cargo.toml
+++ b/sgx_trts/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_trts"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_tse/Cargo.toml b/sgx_tse/Cargo.toml
index 676fa80..bd6e0e8 100644
--- a/sgx_tse/Cargo.toml
+++ b/sgx_tse/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tse"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_tseal/Cargo.toml b/sgx_tseal/Cargo.toml
index dbf33f5..15cad85 100644
--- a/sgx_tseal/Cargo.toml
+++ b/sgx_tseal/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tseal"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_tservice/Cargo.toml b/sgx_tservice/Cargo.toml
index df87966..8bdc1ac 100644
--- a/sgx_tservice/Cargo.toml
+++ b/sgx_tservice/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tservice"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_tstd/Cargo.toml b/sgx_tstd/Cargo.toml
index 50ee373..1b2af99 100644
--- a/sgx_tstd/Cargo.toml
+++ b/sgx_tstd/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tstd"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
build = "build.rs"
repository = "https://github.com/baidu/rust-sgx-sdk"
diff --git a/sgx_tstd/src/collections/hash/map.rs b/sgx_tstd/src/collections/hash/map.rs
index ae61a55..14daf67 100644
--- a/sgx_tstd/src/collections/hash/map.rs
+++ b/sgx_tstd/src/collections/hash/map.rs
@@ -1919,7 +1919,7 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
type Item = &'a K;
#[inline]
- fn next(&mut self) -> Option<(&'a K)> {
+ fn next(&mut self) -> Option<&'a K> {
self.inner.next().map(|(k, _)| k)
}
#[inline]
@@ -1942,7 +1942,7 @@ impl<'a, K, V> Iterator for Values<'a, K, V> {
type Item = &'a V;
#[inline]
- fn next(&mut self) -> Option<(&'a V)> {
+ fn next(&mut self) -> Option<&'a V> {
self.inner.next().map(|(_, v)| v)
}
#[inline]
@@ -1964,7 +1964,7 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> {
type Item = &'a mut V;
#[inline]
- fn next(&mut self) -> Option<(&'a mut V)> {
+ fn next(&mut self) -> Option<&'a mut V> {
self.inner.next().map(|(_, v)| v)
}
#[inline]
diff --git a/sgx_tstd/src/lib.rs b/sgx_tstd/src/lib.rs
index e7b483a..47d7a59 100644
--- a/sgx_tstd/src/lib.rs
+++ b/sgx_tstd/src/lib.rs
@@ -81,7 +81,6 @@
#![feature(lang_items)]
#![feature(log_syntax)]
#![feature(maybe_uninit_ref)]
-//#![feature(mem_take)]
#![feature(needs_panic_runtime)]
#![feature(never_type)]
#![feature(optin_builtin_traits)]
@@ -93,7 +92,6 @@
#![feature(slice_concat_ext)]
#![feature(str_internals)]
#![feature(thread_local)]
-//#![feature(todo_macro)]
#![feature(toowned_clone_into)]
#![feature(trace_macros)]
#![feature(try_reserve)]
@@ -107,9 +105,9 @@
#![feature(panic_info_message)]
#![feature(unicode_internals)]
#![feature(alloc_layout_extra)]
-#![feature(non_exhaustive)]
#![feature(vec_remove_item)]
#![feature(int_error_matching)]
+#![feature(drain_filter)]
#![default_lib_allocator]
// Explicitly import the prelude. The compiler uses this same unstable attribute
diff --git a/sgx_tstd/src/panicking.rs b/sgx_tstd/src/panicking.rs
index 2fefd66..2fe27a7 100644
--- a/sgx_tstd/src/panicking.rs
+++ b/sgx_tstd/src/panicking.rs
@@ -31,7 +31,7 @@
use sgx_trts::trts::rsgx_abort;
use core::panic::BoxMeUp;
-use core::mem;
+use core::mem::{self, ManuallyDrop};
use core::fmt;
use core::panic::{PanicInfo, Location};
use core::any::Any;
@@ -157,10 +157,9 @@ pub fn update_panic_count(amt: isize) -> usize {
/// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
- #[allow(unions_with_drop_fields)]
union Data<F, R> {
- f: F,
- r: R,
+ f: ManuallyDrop<F>,
+ r: ManuallyDrop<R>,
}
// We do some sketchy operations with ownership here for the sake of
@@ -191,7 +190,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
let mut any_data = 0;
let mut any_vtable = 0;
let mut data = Data {
- f,
+ f: ManuallyDrop::new(f)
};
let r = __rust_maybe_catch_panic(do_call::<F, R>,
@@ -201,7 +200,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
return if r == 0 {
debug_assert!(update_panic_count(0) == 0);
- Ok(data.r)
+ Ok(ManuallyDrop::into_inner(data.r))
} else {
update_panic_count(-1);
debug_assert!(update_panic_count(0) == 0);
@@ -214,8 +213,8 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
fn do_call<F: FnOnce() -> R, R>(data: *mut u8) {
unsafe {
let data = data as *mut Data<F, R>;
- let f = ptr::read(&mut (*data).f);
- ptr::write(&mut (*data).r, f());
+ let f = ptr::read(&mut *(*data).f);
+ ptr::write(&mut *(*data).r, f());
}
}
}
@@ -242,9 +241,10 @@ pub fn rust_begin_panic(info: &PanicInfo<'_>) -> ! {
pub fn begin_panic_fmt(msg: &fmt::Arguments<'_>,
file_line_col: &(&'static str, u32, u32)) -> ! {
let (file, line, col) = *file_line_col;
+ let location = Location::internal_constructor(file, line, col);
let info = PanicInfo::internal_constructor(
Some(msg),
- Location::internal_constructor(file, line, col),
+ &location
);
continue_panic_fmt(&info)
}
@@ -362,9 +362,10 @@ fn rust_panic_with_hook(payload: &mut dyn BoxMeUp,
}
{
+ let location = Location::internal_constructor(file, line, col);
let mut info = PanicInfo::internal_constructor(
message,
- Location::internal_constructor(file, line, col),
+ &location
);
info.set_payload(payload.get());
panic_handler(&info);
diff --git a/sgx_tstd/src/prelude/v1.rs b/sgx_tstd/src/prelude/v1.rs
index 86b186a..bebb750 100644
--- a/sgx_tstd/src/prelude/v1.rs
+++ b/sgx_tstd/src/prelude/v1.rs
@@ -88,7 +88,7 @@ pub use core::prelude::v1::{
PartialOrd,
RustcDecodable,
RustcEncodable,
- //bench,
+// bench,
global_allocator,
test,
test_case,
diff --git a/sgx_tstd/src/sys/thread.rs b/sgx_tstd/src/sys/thread.rs
index 0ba37aa..0731923 100644
--- a/sgx_tstd/src/sys/thread.rs
+++ b/sgx_tstd/src/sys/thread.rs
@@ -114,7 +114,7 @@ impl ThreadParam {
pub fn get_size(&self) -> usize { mem::size_of_val(self) }
}
- #[no_mangle]
+#[no_mangle]
pub extern "C" fn t_thread_main(arg: *mut c_void, len: c_int) -> *mut c_void {
if arg.is_null() || len as usize != mem::size_of::<ThreadParam>() {
return sgx_status_t::SGX_ERROR_INVALID_PARAMETER as u32 as *mut c_void;
@@ -126,8 +126,13 @@ pub extern "C" fn t_thread_main(arg: *mut c_void, len: c_int) -> *mut c_void {
Ok(p) => p,
Err(ret) => { return ret.raw_sgx_error().unwrap() as u32 as *mut c_void; }
};
- unsafe { start_thread(main as *mut u8); }
- ptr::null_mut()
+
+ if pop_thread_queue(main as *mut usize).is_some() {
+ unsafe { start_thread(main as *mut u8); }
+ ptr::null_mut()
+ } else {
+ sgx_status_t::SGX_ERROR_INVALID_PARAMETER as u32 as *mut c_void
+ }
}
impl Thread {
@@ -140,9 +145,12 @@ impl Thread {
if eid == 0 {
return Err(io::Error::from_sgx_error(sgx_status_t::SGX_ERROR_INVALID_ENCLAVE_ID));
}
- let tp = ThreadParam::new(eid, &*p as *const _ as *mut _)?;
+ let main = &*p as *const _ as *mut c_void;
+ let tp = ThreadParam::new(eid, main)?;
+ push_thread_queue(main as *mut usize);
let ret = libc::pthread_create(&mut native, ptr::null(), ptr::null_mut(), &tp as *const _ as *mut _, tp.get_size() as c_int);
return if ret != 0 {
+ let _ = pop_thread_queue(main as *mut usize);
Err(io::Error::from_raw_os_error(ret))
} else {
mem::forget(p); // ownership passed to pthread_create
diff --git a/sgx_tstd/src/sys_common/thread.rs b/sgx_tstd/src/sys_common/thread.rs
index 68a51a0..9e9750d 100644
--- a/sgx_tstd/src/sys_common/thread.rs
+++ b/sgx_tstd/src/sys_common/thread.rs
@@ -27,7 +27,35 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+use alloc_crate::collections::LinkedList;
+use crate::sync::SgxThreadSpinlock;
+
+static QUEUE_LOCK: SgxThreadSpinlock = SgxThreadSpinlock::new();
+static mut THREAD_QUEUE: Option<LinkedList<*mut usize>> = None;
+
pub unsafe fn start_thread(main: *mut u8) {
// Finally, let's run some code.
Box::from_raw(main as *mut Box<dyn FnOnce()>)()
+}
+
+pub fn push_thread_queue(main: *mut usize) {
+ unsafe {
+ QUEUE_LOCK.lock();
+ if THREAD_QUEUE.is_none() {
+ THREAD_QUEUE = Some(LinkedList::<*mut usize>::new());
+ }
+ THREAD_QUEUE.as_mut().map(|q| q.push_back(main));
+ QUEUE_LOCK.unlock();
+ }
+}
+
+pub fn pop_thread_queue(main: *mut usize) -> Option<*mut usize> {
+ unsafe {
+ QUEUE_LOCK.lock();
+ let p = THREAD_QUEUE.as_mut().map_or(None, |q| {
+ q.drain_filter(|x| (*x == main) && (**x == *main)).next()
+ });
+ QUEUE_LOCK.unlock();
+ p
+ }
}
\ No newline at end of file
diff --git a/sgx_tunittest/Cargo.toml b/sgx_tunittest/Cargo.toml
index 1733bb4..45fcb96 100644
--- a/sgx_tunittest/Cargo.toml
+++ b/sgx_tunittest/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_tunittest"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_types/Cargo.toml b/sgx_types/Cargo.toml
index 56fc7e2..2c98027 100644
--- a/sgx_types/Cargo.toml
+++ b/sgx_types/Cargo.toml
@@ -1,7 +1,7 @@
[package]
authors = ["Baidu"]
name = "sgx_types"
-version = "1.0.9"
+version = "1.1.0"
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
documentation = "https://dingelish.github.io/"
diff --git a/sgx_types/src/function.rs b/sgx_types/src/function.rs
index c5fac96..fcdd485 100644
--- a/sgx_types/src/function.rs
+++ b/sgx_types/src/function.rs
@@ -169,6 +169,14 @@ extern {
pub fn sgx_verify_report(report: * const sgx_report_t) -> sgx_status_t;
pub fn sgx_get_key(key_request: * const sgx_key_request_t, key: * mut sgx_key_128bit_t) -> sgx_status_t;
+
+ /* intel sgx sdk 2.7.1 */
+ //
+ // sgx_secure_align_api.h
+ //
+ pub fn sgx_aligned_malloc(size: size_t, alignment: size_t, data: * mut align_req_t, count: size_t) -> * mut c_void;
+ pub fn sgx_aligned_free(ptr: * mut c_void);
+ pub fn sgx_get_aligned_ptr(raw: * mut c_void, raw_size: size_t, allocate_size: size_t, alignment: size_t, data: * mut align_req_t, count: size_t) -> * mut c_void;
}
//#[link(name = "sgx_tcrypto")]
diff --git a/sgx_types/src/types.rs b/sgx_types/src/types.rs
index 9b0066d..05188a8 100644
--- a/sgx_types/src/types.rs
+++ b/sgx_types/src/types.rs
@@ -1448,4 +1448,15 @@ impl_enum! {
SGX_QL_QV_RESULT_UNSPECIFIED = 0x0000_A006,
SGX_QL_QV_RESULT_MAX = 0x0000_A0FF,
}
-}
\ No newline at end of file
+}
+
+/* intel sgx sdk 2.7.1 */
+//
+// sgx_secure_align_api.h
+//
+impl_struct! {
+ pub struct align_req_t {
+ pub offset: size_t,
+ pub len: size_t,
+ }
+}
diff --git a/sgx_ucrypto/Cargo.toml b/sgx_ucrypto/Cargo.toml
index 52df5cf..7939d92 100644
--- a/sgx_ucrypto/Cargo.toml
+++ b/sgx_ucrypto/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_ucrypto"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
diff --git a/sgx_unwind/Cargo.toml b/sgx_unwind/Cargo.toml
index 7551584..30e1250 100644
--- a/sgx_unwind/Cargo.toml
+++ b/sgx_unwind/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_unwind"
-version = "0.0.1"
+version = "0.1.0"
authors = ["Baidu"]
build = "build.rs"
repository = "https://github.com/baidu/rust-sgx-sdk"
diff --git a/sgx_urts/Cargo.toml b/sgx_urts/Cargo.toml
index d7a2e27..e9bb872 100644
--- a/sgx_urts/Cargo.toml
+++ b/sgx_urts/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sgx_urts"
-version = "1.0.9"
+version = "1.1.0"
authors = ["Baidu"]
repository = "https://github.com/baidu/rust-sgx-sdk"
license-file = "LICENSE"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@mesatee.apache.org
For additional commands, e-mail: commits-help@mesatee.apache.org