Skip to content

Commit

Permalink
add enclave_debug flag to cli
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Jan 15, 2024
1 parent 3bd77b9 commit ba13d19
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/src/enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
2 changes: 2 additions & 0 deletions app/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub struct Opts {
/// 2. environment variable
#[clap(long = "log_level", help = "Verbosity level of the logger")]
pub log_level: Option<String>,
#[clap(long = "enclave_debug", help = "Enable enclave debug mode")]
pub enclave_debug: bool,
}

impl Opts {
Expand Down
3 changes: 2 additions & 1 deletion modules/enclave-api/src/enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ impl<S: CommitStore> Enclave<S> {

pub fn create(
path: impl Into<PathBuf>,
debug: bool,
key_manager: EnclaveKeyManager,
store: Arc<RwLock<HostStore>>,
) -> SgxResult<Self> {
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))
}

Expand Down
7 changes: 2 additions & 5 deletions modules/host/src/enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>) -> SgxResult<SgxEnclave> {
pub fn create_enclave(path: impl Into<PathBuf>, debug: bool) -> 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(
path.into(),
debug,
debug.into(),
&mut launch_token,
&mut launch_token_updated,
&mut misc_attr,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit ba13d19

Please sign in to comment.