From ed7f83562a30689ac29c105dbc5d1334df5a7c76 Mon Sep 17 00:00:00 2001 From: yuanwu Date: Sun, 19 Apr 2020 16:28:19 -0400 Subject: [PATCH] Check the MPX status of platform before enabling Signed-off-by: yuanwu --- src/libos/src/entry.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libos/src/entry.rs b/src/libos/src/entry.rs index 541d1d9c..2927a6ef 100644 --- a/src/libos/src/entry.rs +++ b/src/libos/src/entry.rs @@ -9,6 +9,7 @@ use std::sync::Once; use util::log::LevelFilter; use util::mem_util::from_untrusted::*; use util::sgx::allow_debug as sgx_allow_debug; +use sgx_tse::*; const ENCLAVE_PATH: &'static str = ".occlum/build/lib/libocclum-libos.signed.so"; @@ -42,8 +43,13 @@ pub extern "C" fn occlum_ecall_init(log_level: *const c_char) -> i32 { INIT_ONCE.call_once(|| { // Init the log infrastructure first so that log messages will be printed afterwards util::log::init(log_level); - // Init MPX for SFI - //util::mpx_util::mpx_enable(); + + // Init MPX for SFI if MPX is available + let report = rsgx_self_report(); + if (report.body.attributes.xfrm & SGX_XFRM_MPX != 0) { + util::mpx_util::mpx_enable(); + } + // Register exception handlers (support cpuid & rdtsc for now) register_exception_handlers();