diff --git a/include/ccf/pal/mem.h b/include/ccf/pal/mem.h index 947c26717e9..ee8f76c81e3 100644 --- a/include/ccf/pal/mem.h +++ b/include/ccf/pal/mem.h @@ -28,8 +28,6 @@ namespace ccf::pal size_t peak_allocated_heap_size = 0; }; -#if !defined(INSIDE_ENCLAVE) || defined(VIRTUAL_ENCLAVE) - static inline void* safe_memcpy(void* dest, const void* src, size_t count) { return ::memcpy(dest, src, count); @@ -63,27 +61,4 @@ namespace ccf::pal return true; } - -#else - - static inline void* safe_memcpy(void* dest, const void* src, size_t count) - { - return oe_memcpy_with_barrier(dest, src, count); - } - - static bool get_mallinfo(MallocInfo& info) - { - oe_mallinfo_t oe_info; - auto rc = oe_allocator_mallinfo(&oe_info); - if (rc != OE_OK) - { - return false; - } - info.max_total_heap_size = oe_info.max_total_heap_size; - info.current_allocated_heap_size = oe_info.current_allocated_heap_size; - info.peak_allocated_heap_size = oe_info.peak_allocated_heap_size; - return true; - } - -#endif } \ No newline at end of file diff --git a/src/enclave/virtual_enclave.h b/src/enclave/virtual_enclave.h index fa4daf7aff9..609a0a3d8fd 100644 --- a/src/enclave/virtual_enclave.h +++ b/src/enclave/virtual_enclave.h @@ -29,38 +29,11 @@ T get_enclave_exported_function( return (T)sym; } -// If this build does not also include OE definitions, then recreate them here. -// It should not matter if these do not match precisely OE's, so long as they -// can be used consistently by the virtual build. -using oe_result_t = int; -constexpr oe_result_t OE_OK = 0; -constexpr oe_result_t OE_FAILURE = 1; - -using oe_enclave_t = void; -using oe_log_level_t = size_t; - -enum oe_enclave_type_t -{ - OE_ENCLAVE_TYPE_SGX = 2, -}; - -#define oe_result_str(x) x - #ifdef __cplusplus extern "C" { #endif - typedef void (*oe_ocall_func_t)( - const uint8_t* input_buffer, - size_t input_buffer_size, - uint8_t* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written); - - /*ocall function table*/ - static oe_ocall_func_t __ccf_ocall_function_table[] = {nullptr}; - inline void* load_virtual_enclave(const char* path) { auto virtual_enclave_handle = dlopen( @@ -91,9 +64,8 @@ extern "C" } } - inline oe_result_t virtual_create_node( + inline CreateNodeStatus virtual_create_node( void* virtual_enclave_handle, - CreateNodeStatus* status, void* enclave_config, uint8_t* ccf_config, size_t ccf_config_size, @@ -139,7 +111,7 @@ extern "C" get_enclave_exported_function( virtual_enclave_handle, "enclave_create_node"); - *status = create_node_func( + CreateNodeStatus status = create_node_func( enclave_config, ccf_config, ccf_config_size, @@ -160,26 +132,18 @@ extern "C" time_location, work_beacon); - // Only return OE_OK when the error isn't OE related - switch (*status) - { - case CreateNodeStatus::EnclaveInitFailed: - case CreateNodeStatus::MemoryNotOutsideEnclave: - return OE_FAILURE; - default: - return OE_OK; - } + return status; } - inline oe_result_t virtual_run(void* virtual_enclave_handle, bool* _retval) + inline bool virtual_run(void* virtual_enclave_handle) { using run_func_t = bool (*)(); static run_func_t run_func = get_enclave_exported_function( virtual_enclave_handle, "enclave_run"); - *_retval = run_func(); - return *_retval ? OE_OK : OE_FAILURE; + bool retval = run_func(); + return retval; } #ifdef __cplusplus diff --git a/src/host/enclave.h b/src/host/enclave.h index 60682337e8c..9ac034e09df 100644 --- a/src/host/enclave.h +++ b/src/host/enclave.h @@ -124,23 +124,21 @@ namespace host auto config_s = nlohmann::json(ccf_config).dump(); #define CREATE_NODE_ARGS \ - &status, (void*)&enclave_config, (uint8_t*)config_s.data(), config_s.size(), \ + (void*)&enclave_config, (uint8_t*)config_s.data(), config_s.size(), \ startup_snapshot.data(), startup_snapshot.size(), node_cert.data(), \ node_cert.size(), &node_cert_len, service_cert.data(), \ service_cert.size(), &service_cert_len, enclave_version_buf.data(), \ enclave_version_buf.size(), &enclave_version_len, start_type, log_level, \ num_worker_thread, time_location, work_beacon - oe_result_t err = OE_FAILURE; - // Assume that constructor correctly set the appropriate field, and call // appropriate function if (virtual_handle != nullptr) { - err = virtual_create_node(virtual_handle, CREATE_NODE_ARGS); + status = virtual_create_node(virtual_handle, CREATE_NODE_ARGS); } - if (err != OE_OK || status != CreateNodeStatus::OK) + if (status != CreateNodeStatus::OK) { // Logs have described the errors already, we just need to allow the // host to read them (via read_all()). @@ -171,18 +169,16 @@ namespace host // from a thread bool run() { - bool ret = true; - oe_result_t err = OE_FAILURE; + bool ret = false; if (virtual_handle != nullptr) { - err = virtual_run(virtual_handle, &ret); + ret = virtual_run(virtual_handle); } - if (err != OE_OK) + if (!ret) { - throw std::logic_error( - fmt::format("Failed to call in enclave_run: {}", oe_result_str(err))); + throw std::logic_error(fmt::format("Failure in virtual_run")); } return ret; diff --git a/tests/infra/remote.py b/tests/infra/remote.py index a4e60140f34..4f7e85a1242 100644 --- a/tests/infra/remote.py +++ b/tests/infra/remote.py @@ -264,15 +264,6 @@ def get_result(self, line_count): return self._get_perf(result) -CCF_TO_OE_LOG_LEVEL = { - "trace": "VERBOSE", - "debug": "INFO", - "info": "WARNING", - "fail": "ERROR", - "fatal": "FATAL", -} - - class CCFRemote(object): BIN = "cchost" TEMPLATE_CONFIGURATION_FILE = "config.jinja" @@ -361,10 +352,6 @@ def __init__( snp_uvm_security_context_dir ) - oe_log_level = CCF_TO_OE_LOG_LEVEL.get(kwargs.get("log_level")) - if oe_log_level: - env["OE_LOG_LEVEL"] = oe_log_level - self.name = f"{label}_{local_node_id}" self.start_type = start_type self.local_node_id = local_node_id