diff --git a/app/src/enclave.rs b/app/src/enclave.rs index 1f5af365..36b67ec4 100644 --- a/app/src/enclave.rs +++ b/app/src/enclave.rs @@ -18,7 +18,7 @@ where }; let env = host::get_environment().unwrap(); let km = EnclaveKeyManager::new(&env.home)?; - match Enclave::create(&path, km, env.store.clone()) { + match Enclave::create(&path, opts.enclave_debug, km, env.store.clone()) { Ok(enclave) => Ok(enclave), Err(x) => { bail!( diff --git a/app/src/opts.rs b/app/src/opts.rs index 494a57f6..d740661c 100644 --- a/app/src/opts.rs +++ b/app/src/opts.rs @@ -14,6 +14,8 @@ pub struct Opts { /// 2. environment variable #[clap(long = "log_level", help = "Verbosity level of the logger")] pub log_level: Option, + #[clap(long = "enclave_debug", help = "Enable enclave debug mode")] + pub enclave_debug: bool, } impl Opts { diff --git a/modules/enclave-api/src/enclave.rs b/modules/enclave-api/src/enclave.rs index 07cf73d6..3e3999fb 100644 --- a/modules/enclave-api/src/enclave.rs +++ b/modules/enclave-api/src/enclave.rs @@ -35,11 +35,12 @@ impl Enclave { pub fn create( path: impl Into, + debug: bool, key_manager: EnclaveKeyManager, store: Arc>, ) -> SgxResult { let path = path.into(); - let enclave = host::create_enclave(path.clone())?; + let enclave = host::create_enclave(path.clone(), debug)?; Ok(Self::new(path, key_manager, store, enclave)) } diff --git a/modules/host/src/enclave.rs b/modules/host/src/enclave.rs index db41c962..d5257e6d 100644 --- a/modules/host/src/enclave.rs +++ b/modules/host/src/enclave.rs @@ -2,19 +2,16 @@ use sgx_types::{metadata::metadata_t, *}; use sgx_urts::SgxEnclave; use std::{ffi::CString, mem::MaybeUninit, path::PathBuf}; -pub fn create_enclave(path: impl Into) -> SgxResult { +pub fn create_enclave(path: impl Into, debug: bool) -> SgxResult { 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( path.into(), - debug, + debug.into(), &mut launch_token, &mut launch_token_updated, &mut misc_attr, diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index 4e06c215..f11185f8 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -81,7 +81,7 @@ mod tests { let env = host::get_environment().unwrap(); let km = EnclaveKeyManager::new(&env.home).unwrap(); - let enclave = Enclave::create(ENCLAVE_FILE, km, env.store.clone()).unwrap(); + let enclave = Enclave::create(ENCLAVE_FILE, true, km, env.store.clone()).unwrap(); match std::env::var(ENV_SETUP_NODES).map(|v| v.to_lowercase()) { Ok(v) if v == "false" => run_test(&enclave).unwrap(),