diff --git a/CMakeLists.txt b/CMakeLists.txt index 8314153a49..35c5a1453b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -267,11 +267,6 @@ if (NOT USE_SNMALLOC) set(USE_DLMALLOC true) endif () -option( - COMPILE_SYSTEM_EDL - "Build system ecalls and ocalls into OE libraries. If not set, they must be included by application EDL to use." - OFF) - option(BUILD_TESTS "Build OE tests" ON) # For EEID see https://github.com/openenclave/openenclave/pull/2647 @@ -378,18 +373,14 @@ include(add_enclave_test) add_subdirectory(include) add_subdirectory(host) -# Tests and samples have been ported to manually include system edl files. -# They can no longer be used when system EDL is builtin. -if (NOT COMPILE_SYSTEM_EDL) - if (BUILD_TESTS AND (NOT COMPONENT MATCHES OEHOSTVERIFY)) - add_subdirectory(tests) - endif () +if (BUILD_TESTS AND (NOT COMPONENT MATCHES OEHOSTVERIFY)) + add_subdirectory(tests) +endif () - # Skip samples when enabling the code coverage test. - # Otherwise, all the samples need to explicitly link against the libgcov library. - if (NOT CODE_COVERAGE) - add_subdirectory(samples) - endif () +# Skip samples when enabling the code coverage test. +# Otherwise, all the samples need to explicitly link against the libgcov library. +if (NOT CODE_COVERAGE) + add_subdirectory(samples) endif () if (NOT COMPONENT MATCHES OEHOSTVERFIY) diff --git a/enclave/core/CMakeLists.txt b/enclave/core/CMakeLists.txt index 25da9dd844..19249a4fdc 100644 --- a/enclave/core/CMakeLists.txt +++ b/enclave/core/CMakeLists.txt @@ -12,24 +12,13 @@ set(EDL_DIR ${PROJECT_SOURCE_DIR}/include/openenclave/edl) ##============================================================================== set(CORE_EDL_FILE ${EDL_DIR}/core.edl) -if (COMPILE_SYSTEM_EDL) - add_custom_command( - OUTPUT core_t.h core_t.c core_args.h - DEPENDS ${CORE_EDL_FILE} edger8r - COMMAND edger8r --search-path ${OE_INCLUDE_DIR} --trusted ${CORE_EDL_FILE}) - - add_custom_target(core_trusted_edl DEPENDS core_t.h core_t.c core_args.h) +add_custom_command( + OUTPUT core_t.h core_args.h + DEPENDS ${CORE_EDL_FILE} edger8r + COMMAND edger8r --header-only --search-path ${OE_INCLUDE_DIR} --trusted + ${CORE_EDL_FILE}) - list(APPEND PLATFORM_SRC core_t_wrapper.c) -else () - add_custom_command( - OUTPUT core_t.h core_args.h - DEPENDS ${CORE_EDL_FILE} edger8r - COMMAND edger8r --header-only --search-path ${OE_INCLUDE_DIR} --trusted - ${CORE_EDL_FILE}) - - add_custom_target(core_trusted_edl DEPENDS core_t.h core_args.h) -endif () +add_custom_target(core_trusted_edl DEPENDS core_t.h core_args.h) ##============================================================================== ## @@ -39,17 +28,7 @@ endif () ##============================================================================== set(SGX_EDL_FILE ${EDL_DIR}/sgx/platform.edl) -if (OE_SGX AND COMPILE_SYSTEM_EDL) - add_custom_command( - OUTPUT platform_t.h platform_t.c platform_args.h - DEPENDS ${SGX_EDL_FILE} edger8r - COMMAND edger8r --search-path ${OE_INCLUDE_DIR} --trusted ${SGX_EDL_FILE}) - - add_custom_target(platform_trusted_edl DEPENDS platform_t.h platform_t.c - platform_args.h) - - list(APPEND PLATFORM_SRC sgx/platform_t_wrapper.c) -elseif (OE_SGX) +if (OE_SGX) # Only generate headers add_custom_command( OUTPUT platform_t.h platform_args.h @@ -180,7 +159,6 @@ add_enclave_library( assert.c atexit.c backtrace.c - calls.c ctype.c debugmalloc.c hexdump.c @@ -325,10 +303,6 @@ if (USE_DEBUG_MALLOC) "USE_DEBUG_MALLOC is set, building oecore with memory leak detection.") endif () -if (COMPILE_SYSTEM_EDL) - enclave_compile_definitions(oecore PRIVATE OE_USE_BUILTIN_EDL) -endif () - if (WITH_EEID) enclave_compile_definitions(oecore PRIVATE OE_WITH_EXPERIMENTAL_EEID) endif () diff --git a/enclave/core/calls.c b/enclave/core/calls.c deleted file mode 100644 index a04a5b0637..0000000000 --- a/enclave/core/calls.c +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Open Enclave SDK contributors. -// Licensed under the MIT License. - -#include -#include -#include -#include - -#include "calls.h" - -/* If true, disable the debug malloc checking */ -bool oe_disable_debug_malloc_check; - -/* -**============================================================================== -** -** oe_register_ecall_function_table() -** -** Register an ecall table with the given table_id. -** -**============================================================================== -*/ - -ecall_table_t _ecall_tables[OE_MAX_ECALL_TABLES]; -static oe_spinlock_t _ecall_tables_lock = OE_SPINLOCK_INITIALIZER; - -oe_result_t oe_register_ecall_function_table( - uint64_t table_id, - const oe_ecall_func_t* ecalls, - size_t num_ecalls) -{ - oe_result_t result = OE_UNEXPECTED; - - if (table_id >= OE_MAX_ECALL_TABLES || !ecalls) - OE_RAISE(OE_INVALID_PARAMETER); - - oe_spin_lock(&_ecall_tables_lock); - _ecall_tables[table_id].ecalls = ecalls; - _ecall_tables[table_id].num_ecalls = num_ecalls; - oe_spin_unlock(&_ecall_tables_lock); - - result = OE_OK; - -done: - return result; -} diff --git a/enclave/core/calls.h b/enclave/core/calls.h index ef8c5f089e..ef40155c80 100644 --- a/enclave/core/calls.h +++ b/enclave/core/calls.h @@ -18,6 +18,4 @@ typedef struct _ecall_table size_t num_ecalls; } ecall_table_t; -extern ecall_table_t _ecall_tables[]; - #endif /* OE_CALLS_H */ diff --git a/enclave/core/core_t_wrapper.c b/enclave/core/core_t_wrapper.c deleted file mode 100644 index 4aa2c63ee4..0000000000 --- a/enclave/core/core_t_wrapper.c +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Open Enclave SDK contributors. -// Licensed under the MIT License. - -#include - -#include -#include -#include -#include -#include - -/* Rename the global ecalls table. */ -#define __oe_ecalls_table __oe_core_ecalls_table -#define __oe_ecalls_table_size __oe_core_ecalls_table_size - -/* Override oe_call_host_function() calls with _call_host_function(). */ -#define oe_call_host_function _call_host_function - -/* Use this function below instead of oe_call_host_function(). */ -static oe_result_t _call_host_function( - size_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_call_host_function_by_table_id( - OE_CORE_OCALL_FUNCTION_TABLE_ID, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written, - false /* non-switchless */); -} - -/* Include the oeedger8r generated C file. The macros defined above customize - * the generated code for internal use. */ -#include "core_t.c" - -/* Registers the core ECALL function table. */ -oe_result_t oe_register_core_ecall_function_table(void) -{ - const uint64_t table_id = OE_CORE_ECALL_FUNCTION_TABLE_ID; - const oe_ecall_func_t* ecalls = __oe_core_ecalls_table; - const size_t num_ecalls = __oe_core_ecalls_table_size; - - return oe_register_ecall_function_table(table_id, ecalls, num_ecalls); -} diff --git a/enclave/core/hostcalls.c b/enclave/core/hostcalls.c index d7aacb7b9b..1bd08a8420 100644 --- a/enclave/core/hostcalls.c +++ b/enclave/core/hostcalls.c @@ -13,7 +13,6 @@ #include "core_t.h" -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototypes of the following functions to avoid the * missing-prototypes warning. @@ -51,7 +50,6 @@ oe_result_t _oe_write_ocall(int device, const char* str, size_t maxlen) return OE_UNSUPPORTED; } OE_WEAK_ALIAS(_oe_write_ocall, oe_write_ocall); -#endif void* oe_host_malloc(size_t size) { diff --git a/enclave/core/malloc.c b/enclave/core/malloc.c index 8a0f42b4c8..8c7f7aaeaa 100644 --- a/enclave/core/malloc.c +++ b/enclave/core/malloc.c @@ -32,6 +32,9 @@ #endif +/* If true, disable the debug malloc checking */ +bool oe_disable_debug_malloc_check; + static oe_allocation_failure_callback_t _failure_callback; void oe_set_allocation_failure_callback( diff --git a/enclave/core/optee/calls.c b/enclave/core/optee/calls.c index 62364d4220..1a27bf158c 100644 --- a/enclave/core/optee/calls.c +++ b/enclave/core/optee/calls.c @@ -7,8 +7,7 @@ #include #include -oe_result_t oe_call_host_function_by_table_id( - uint64_t table_id, +oe_result_t oe_call_host_function_internal( uint64_t function_id, const void* input_buffer, size_t input_buffer_size, @@ -26,7 +25,6 @@ oe_result_t oe_call_host_function_by_table_id( /* Initialize the arguments */ { - args.table_id = table_id; args.function_id = function_id; args.input_buffer = input_buffer; args.input_buffer_size = input_buffer_size; @@ -64,8 +62,7 @@ oe_result_t oe_call_host_function( size_t output_buffer_size, size_t* output_bytes_written) { - return oe_call_host_function_by_table_id( - OE_UINT64_MAX, + return oe_call_host_function_internal( function_id, input_buffer, input_buffer_size, diff --git a/enclave/core/optee/gp.c b/enclave/core/optee/gp.c index 1dd0d74c0a..3291acf184 100644 --- a/enclave/core/optee/gp.c +++ b/enclave/core/optee/gp.c @@ -184,23 +184,9 @@ static TEE_Result _handle_call_enclave_function( u_output_buffer_size = params[3].memref.size; } - /* Resolve which ECALL table to use. */ - if (args.table_id == OE_UINT64_MAX) - { - ecall_table.ecalls = __oe_ecalls_table; - ecall_table.num_ecalls = __oe_ecalls_table_size; - } - else - { - if (args.table_id >= OE_MAX_ECALL_TABLES) - return TEE_ERROR_ITEM_NOT_FOUND; - - ecall_table.ecalls = _ecall_tables[args.table_id].ecalls; - ecall_table.num_ecalls = _ecall_tables[args.table_id].num_ecalls; - - if (!ecall_table.ecalls) - return TEE_ERROR_ITEM_NOT_FOUND; - } + /* __oe_calls_table is defined in the oeedger8r-generated code. */ + ecall_table.ecalls = __oe_ecalls_table; + ecall_table.num_ecalls = __oe_ecalls_table_size; /* Fetch matching function */ if (args.function_id >= ecall_table.num_ecalls) @@ -415,12 +401,6 @@ TEE_Result TA_CreateEntryPoint(void) /* Call compiler-generated initialization functions */ oe_call_init_functions(); -#ifdef OE_USE_BUILTIN_EDL - /* Install the common TEE ECALL function table. */ - if (oe_register_core_ecall_function_table() != OE_OK) - return TEE_ERROR_GENERIC; -#endif - /* Done */ __oe_initialized = 1; diff --git a/enclave/core/sgx/backtrace.c b/enclave/core/sgx/backtrace.c index 81e953e7d6..b9d64b1b4c 100644 --- a/enclave/core/sgx/backtrace.c +++ b/enclave/core/sgx/backtrace.c @@ -19,7 +19,6 @@ #error "optimized __builtin_return_address() not supported by Intel compiler" #endif -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototype of the following function to avoid the * missing-prototypes warning. @@ -63,8 +62,6 @@ oe_result_t _oe_sgx_backtrace_symbols_ocall( } OE_WEAK_ALIAS(_oe_sgx_backtrace_symbols_ocall, oe_sgx_backtrace_symbols_ocall); -#endif - /* Return null if address is outside of the enclave; else return ptr. */ const void* _check_address(const void* ptr) { diff --git a/enclave/core/sgx/calls.c b/enclave/core/sgx/calls.c index 86d4935633..fff58179e3 100644 --- a/enclave/core/sgx/calls.c +++ b/enclave/core/sgx/calls.c @@ -163,14 +163,6 @@ static oe_result_t _handle_init_enclave(uint64_t arg_in) { oe_enclave_t* enclave = (oe_enclave_t*)arg_in; -#ifdef OE_USE_BUILTIN_EDL - /* Install the common TEE ECALL function table. */ - OE_CHECK(oe_register_core_ecall_function_table()); - - /* Install the SGX ECALL function table. */ - OE_CHECK(oe_register_platform_ecall_function_table()); -#endif // OE_USE_BUILTIN_EDL - if (!oe_is_outside_enclave(enclave, 1)) OE_RAISE(OE_INVALID_PARAMETER); @@ -244,23 +236,10 @@ oe_result_t oe_handle_call_enclave_function(uint64_t arg_in) OE_CHECK(oe_safe_add_u64( args.input_buffer_size, args.output_buffer_size, &buffer_size)); - // Resolve which ecall table to use. - if (args_ptr->table_id == OE_UINT64_MAX) - { - ecall_table.ecalls = __oe_ecalls_table; - ecall_table.num_ecalls = __oe_ecalls_table_size; - } - else - { - if (args_ptr->table_id >= OE_MAX_ECALL_TABLES) - OE_RAISE(OE_NOT_FOUND); - - ecall_table.ecalls = _ecall_tables[args_ptr->table_id].ecalls; - ecall_table.num_ecalls = _ecall_tables[args_ptr->table_id].num_ecalls; - - if (!ecall_table.ecalls) - OE_RAISE(OE_NOT_FOUND); - } + // The __oe_ecall_table is defined in the oeedger8r-generated + // code. + ecall_table.ecalls = __oe_ecalls_table; + ecall_table.num_ecalls = __oe_ecalls_table_size; // Fetch matching function. if (args.function_id >= ecall_table.num_ecalls) @@ -700,8 +679,7 @@ oe_result_t oe_ocall(uint16_t func, uint64_t arg_in, uint64_t* arg_out) **============================================================================== */ -oe_result_t oe_call_host_function_by_table_id( - uint64_t table_id, +oe_result_t oe_call_host_function_internal( uint64_t function_id, const void* input_buffer, size_t input_buffer_size, @@ -733,7 +711,6 @@ oe_result_t oe_call_host_function_by_table_id( OE_RAISE(OE_UNEXPECTED); } - args->table_id = table_id; args->function_id = function_id; args->input_buffer = input_buffer; args->input_buffer_size = input_buffer_size; @@ -799,8 +776,7 @@ oe_result_t oe_call_host_function( size_t output_buffer_size, size_t* output_bytes_written) { - return oe_call_host_function_by_table_id( - OE_UINT64_MAX, + return oe_call_host_function_internal( function_id, input_buffer, input_buffer_size, diff --git a/enclave/core/sgx/platform_t_wrapper.c b/enclave/core/sgx/platform_t_wrapper.c deleted file mode 100644 index 87fb056150..0000000000 --- a/enclave/core/sgx/platform_t_wrapper.c +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Open Enclave SDK contributors. -// Licensed under the MIT License. - -#include - -#include -#include -#include -#include -#include - -/* Rename the global ecalls table. */ -#define __oe_ecalls_table __oe_platform_ecalls_table -#define __oe_ecalls_table_size __oe_platform_ecalls_table_size - -/* Override oe_call_host_function() calls with _call_host_function(). */ -#define oe_call_host_function _call_host_function - -/* Use this function below instead of oe_call_host_function(). */ -static oe_result_t _call_host_function( - size_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_call_host_function_by_table_id( - OE_SGX_OCALL_FUNCTION_TABLE_ID, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written, - false /* non-switchless */); -} - -/* Include the oeedger8r generated C file. The macros defined above customize - * the generated code for internal use. */ -#include "platform_t.c" - -/* Registers the sgx ECALL function table. */ -oe_result_t oe_register_platform_ecall_function_table(void) -{ - const uint64_t table_id = OE_SGX_ECALL_FUNCTION_TABLE_ID; - const oe_ecall_func_t* ecalls = __oe_platform_ecalls_table; - const size_t num_ecalls = __oe_platform_ecalls_table_size; - - return oe_register_ecall_function_table(table_id, ecalls, num_ecalls); -} diff --git a/enclave/core/sgx/report.c b/enclave/core/sgx/report.c index aa17fe04ce..9121f14865 100644 --- a/enclave/core/sgx/report.c +++ b/enclave/core/sgx/report.c @@ -16,7 +16,6 @@ #include #include "platform_t.h" -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototypes of the following functions to avoid the * missing-prototypes warning. @@ -88,8 +87,6 @@ oe_result_t _oe_get_quote_ocall( } OE_WEAK_ALIAS(_oe_get_quote_ocall, oe_get_quote_ocall); -#endif - OE_STATIC_ASSERT(OE_REPORT_DATA_SIZE == sizeof(sgx_report_data_t)); OE_STATIC_ASSERT(sizeof(oe_identity_t) == 96); diff --git a/enclave/core/sgx/switchlesscalls.c b/enclave/core/sgx/switchlesscalls.c index f12ffca8dc..faa005160d 100644 --- a/enclave/core/sgx/switchlesscalls.c +++ b/enclave/core/sgx/switchlesscalls.c @@ -31,7 +31,6 @@ static bool _is_switchless_initialized = false; * */ static int64_t _switchless_init_in_progress = 0; -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototypes of the following functions to avoid the * missing-prototypes warning. @@ -68,8 +67,6 @@ OE_WEAK_ALIAS( _oe_sgx_sleep_switchless_worker_ocall, oe_sgx_sleep_switchless_worker_ocall); -#endif - /* **============================================================================== ** @@ -238,8 +235,7 @@ oe_result_t oe_switchless_call_host_function( size_t output_buffer_size, size_t* output_bytes_written) { - return oe_call_host_function_by_table_id( - OE_UINT64_MAX, + return oe_call_host_function_internal( function_id, input_buffer, input_buffer_size, diff --git a/enclave/sgx/attester.c b/enclave/sgx/attester.c index 0919b2c497..18553b68ee 100644 --- a/enclave/sgx/attester.c +++ b/enclave/sgx/attester.c @@ -23,7 +23,6 @@ #include "../core/sgx/report.h" #include "platform_t.h" -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototype of the following function to avoid the * missing-prototypes warning. @@ -60,8 +59,6 @@ OE_WEAK_ALIAS( _oe_get_supported_attester_format_ids_ocall, oe_get_supported_attester_format_ids_ocall); -#endif - static const oe_uuid_t _local_uuid = {OE_FORMAT_UUID_SGX_LOCAL_ATTESTATION}; static const oe_uuid_t _ecdsa_uuid = {OE_FORMAT_UUID_SGX_ECDSA_P256}; static const oe_uuid_t _ecdsa_report_uuid = { diff --git a/enclave/sgx/collateralinfo.c b/enclave/sgx/collateralinfo.c index ce733cbc4a..d8a1a50414 100644 --- a/enclave/sgx/collateralinfo.c +++ b/enclave/sgx/collateralinfo.c @@ -12,7 +12,6 @@ #include "../common/sgx/collateral.h" #include "platform_t.h" -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototype of the following function to avoid the * missing-prototypes warning. @@ -110,8 +109,6 @@ OE_WEAK_ALIAS( _oe_get_quote_verification_collateral_ocall, oe_get_quote_verification_collateral_ocall); -#endif - /** * Update these default size values as needed. * These represent the default buffer sizes that can store their diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index ed3eaec2f8..f592ad7e50 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -12,26 +12,14 @@ set(EDL_DIR ${PROJECT_SOURCE_DIR}/include/openenclave/edl) ##============================================================================== set(CORE_EDL_FILE ${EDL_DIR}/core.edl) -if (COMPILE_SYSTEM_EDL) - add_custom_command( - OUTPUT core_u.h core_u.c core_args.h - DEPENDS ${CORE_EDL_FILE} edger8r - COMMAND edger8r --search-path ${OE_INCLUDE_DIR} --untrusted - ${CORE_EDL_FILE}) - - add_custom_target(core_untrusted_edl DEPENDS core_u.h core_u.c core_args.h) +# Only generate headers +add_custom_command( + OUTPUT core_u.h core_args.h + DEPENDS ${CORE_EDL_FILE} edger8r + COMMAND edger8r --header-only --search-path ${OE_INCLUDE_DIR} --untrusted + ${CORE_EDL_FILE}) - list(APPEND PLATFORM_SDK_ONLY_SRC core_u_wrapper.c) -else () - # Only generate headers - add_custom_command( - OUTPUT core_u.h core_args.h - DEPENDS ${CORE_EDL_FILE} edger8r - COMMAND edger8r --header-only --search-path ${OE_INCLUDE_DIR} --untrusted - ${CORE_EDL_FILE}) - - add_custom_target(core_untrusted_edl DEPENDS core_u.h core_args.h) -endif () +add_custom_target(core_untrusted_edl DEPENDS core_u.h core_args.h) ##============================================================================== ## @@ -95,17 +83,7 @@ install(DIRECTORY ${OE_EDL_INCLUDE_DIR} ##============================================================================== set(SGX_EDL_FILE ${EDL_DIR}/sgx/platform.edl) -if (OE_SGX AND COMPILE_SYSTEM_EDL) - add_custom_command( - OUTPUT platform_u.h platform_u.c platform_args.h - DEPENDS ${SGX_EDL_FILE} edger8r - COMMAND edger8r --search-path ${OE_INCLUDE_DIR} --untrusted ${SGX_EDL_FILE}) - - add_custom_target(platform_untrusted_edl DEPENDS platform_u.h platform_u.c - platform_args.h) - - list(APPEND PLATFORM_SDK_ONLY_SRC sgx/platform_u_wrapper.c) -elseif (OE_SGX) +if (OE_SGX) add_custom_command( OUTPUT platform_u.h platform_args.h DEPENDS ${SGX_EDL_FILE} edger8r @@ -123,25 +101,13 @@ endif () ##============================================================================== set(SYSCALL_EDL ${EDL_DIR}/syscall.edl) -if (COMPILE_SYSTEM_EDL) - add_custom_command( - OUTPUT syscall_u.h syscall_u.c syscall_args.h - DEPENDS ${SYSCALL_EDL} edger8r - COMMAND edger8r --search-path ${OE_INCLUDE_DIR} --untrusted ${SYSCALL_EDL}) - - add_custom_target(syscall_untrusted_edl DEPENDS syscall_u.h syscall_u.c - syscall_args.h) - - list(APPEND PLATFORM_SDK_ONLY_SRC syscall_u_wrapper.c) -else () - add_custom_command( - OUTPUT syscall_u.h syscall_args.h - DEPENDS ${SYSCALL_EDL} edger8r - COMMAND edger8r --header-only --search-path ${OE_INCLUDE_DIR} --untrusted - ${SYSCALL_EDL}) +add_custom_command( + OUTPUT syscall_u.h syscall_args.h + DEPENDS ${SYSCALL_EDL} edger8r + COMMAND edger8r --header-only --search-path ${OE_INCLUDE_DIR} --untrusted + ${SYSCALL_EDL}) - add_custom_target(syscall_untrusted_edl DEPENDS syscall_u.h syscall_args.h) -endif () +add_custom_target(syscall_untrusted_edl DEPENDS syscall_u.h syscall_args.h) ##============================================================================== ## @@ -468,10 +434,6 @@ if (USE_DEBUG_MALLOC) target_compile_definitions(oehost PRIVATE OE_USE_DEBUG_MALLOC) endif () -if (COMPILE_SYSTEM_EDL) - target_compile_definitions(oehost PRIVATE OE_USE_BUILTIN_EDL) -endif () - if (WITH_EEID) target_compile_definitions(oehost PRIVATE OE_WITH_EXPERIMENTAL_EEID) endif () diff --git a/host/calls.c b/host/calls.c index 92501ab410..65abb4503f 100644 --- a/host/calls.c +++ b/host/calls.c @@ -9,51 +9,17 @@ /* **============================================================================== ** -** oe_register_ocall_function_table() -** -** Register an ocall table with the given table_id. -** -**============================================================================== -*/ - -ocall_table_t _ocall_tables[OE_MAX_OCALL_TABLES]; -static oe_mutex _ocall_tables_lock = OE_H_MUTEX_INITIALIZER; - -oe_result_t oe_register_ocall_function_table( - uint64_t table_id, - const oe_ocall_func_t* ocalls, - size_t num_ocalls) -{ - oe_result_t result = OE_UNEXPECTED; - - if (table_id >= OE_MAX_OCALL_TABLES || !ocalls) - OE_RAISE(OE_INVALID_PARAMETER); - - oe_mutex_lock(&_ocall_tables_lock); - _ocall_tables[table_id].ocalls = ocalls; - _ocall_tables[table_id].num_ocalls = num_ocalls; - oe_mutex_unlock(&_ocall_tables_lock); - - result = OE_OK; - -done: - return result; -} - -/* -**============================================================================== -** -** oe_call_enclave_function_by_table_id() +** oe_call_enclave_function() ** -** Call the enclave function specified by the given table-id and function-id. +** Call the enclave function specified by the given function-id in the +** function table. ** **============================================================================== */ -oe_result_t oe_call_enclave_function_by_table_id( +oe_result_t oe_call_enclave_function( oe_enclave_t* enclave, - uint64_t table_id, - uint64_t function_id, + uint32_t function_id, const void* input_buffer, size_t input_buffer_size, void* output_buffer, @@ -69,7 +35,6 @@ oe_result_t oe_call_enclave_function_by_table_id( /* Initialize the call_enclave_args structure */ { - args.table_id = table_id; args.function_id = function_id; args.input_buffer = input_buffer; args.input_buffer_size = input_buffer_size; @@ -100,34 +65,3 @@ oe_result_t oe_call_enclave_function_by_table_id( done: return result; } - -/* -**============================================================================== -** -** oe_call_enclave_function() -** -** Call the enclave function specified by the given function-id in the default -** function table. -** -**============================================================================== -*/ - -oe_result_t oe_call_enclave_function( - oe_enclave_t* enclave, - uint32_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_call_enclave_function_by_table_id( - enclave, - OE_UINT64_MAX, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written); -} diff --git a/host/calls.h b/host/calls.h index d4a276a8f1..d5e53bb288 100644 --- a/host/calls.h +++ b/host/calls.h @@ -15,8 +15,6 @@ typedef struct _ocall_table size_t num_ocalls; } ocall_table_t; -extern ocall_table_t _ocall_tables[]; - oe_result_t oe_handle_call_host_function(uint64_t arg, oe_enclave_t* enclave); #endif /* OE_HOST_CALLS_H */ diff --git a/host/core_u_wrapper.c b/host/core_u_wrapper.c deleted file mode 100644 index 2db200dee1..0000000000 --- a/host/core_u_wrapper.c +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Open Enclave SDK contributors. -// Licensed under the MIT License. - -#include - -#include -#include -#include - -/* Override oe_call_enclave_function() with _call_core_enclave_function(). */ -#define oe_call_enclave_function _call_core_enclave_function - -/* Obscure the generated creation function by renaming it. */ -#define oe_create_tee_enclave __unused_oe_create_core_enclave - -/* The ocall edge routines will use this function to route ecalls. */ -static oe_result_t _call_core_enclave_function( - oe_enclave_t* enclave, - uint32_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_call_enclave_function_by_table_id( - enclave, - OE_CORE_ECALL_FUNCTION_TABLE_ID, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written); -} - -/* Include the oeedger8r generated C file. The macros defined above customize - * the generated code for internal use. */ -#include "core_u.c" - -/* Registers the tee OCALL function table. */ -oe_result_t oe_register_core_ocall_function_table(void) -{ - const uint64_t table_id = OE_CORE_OCALL_FUNCTION_TABLE_ID; - const oe_ocall_func_t* ocalls = __core_ocall_function_table; - const size_t num_ocalls = OE_COUNTOF(__core_ocall_function_table); - - return oe_register_ocall_function_table(table_id, ocalls, num_ocalls); -} diff --git a/host/optee/linux/enclave.c b/host/optee/linux/enclave.c index 187ad9da8b..f5538429be 100644 --- a/host/optee/linux/enclave.c +++ b/host/optee/linux/enclave.c @@ -80,14 +80,6 @@ * the value is indeed at least as large as we assume it to be. */ OE_STATIC_ASSERT(TEEC_CONFIG_PAYLOAD_REF_COUNT >= 4); -static void _initialize_enclave_host() -{ -#ifdef OE_USE_BUILTIN_EDL - oe_register_core_ocall_function_table(); - oe_register_syscall_ocall_function_table(); -#endif // OE_USE_BUILTIN_EDL -} - static oe_result_t _handle_call_host_function( void* inout_buffer, size_t inout_buffer_size, @@ -116,23 +108,8 @@ static oe_result_t _handle_call_host_function( if (args_ptr == NULL) OE_RAISE(OE_INVALID_PARAMETER); - /* Resolve which OCALL table to use. */ - if (args_ptr->table_id == OE_UINT64_MAX) - { - ocall_table.ocalls = enclave->ocalls; - ocall_table.num_ocalls = enclave->num_ocalls; - } - else - { - if (args_ptr->table_id >= OE_MAX_OCALL_TABLES) - OE_RAISE(OE_NOT_FOUND); - - ocall_table.ocalls = _ocall_tables[args_ptr->table_id].ocalls; - ocall_table.num_ocalls = _ocall_tables[args_ptr->table_id].num_ocalls; - - if (!ocall_table.ocalls) - OE_RAISE(OE_NOT_FOUND); - } + ocall_table.ocalls = enclave->ocalls; + ocall_table.num_ocalls = enclave->num_ocalls; /* Fetch matching function */ if (args_ptr->function_id >= ocall_table.num_ocalls) @@ -414,8 +391,6 @@ oe_result_t oe_create_enclave( bool have_context = false; bool have_session = false; - _initialize_enclave_host(); - if (enclave_out) *enclave_out = NULL; diff --git a/host/sgx/calls.c b/host/sgx/calls.c index f04657a614..ebbfd51ef1 100644 --- a/host/sgx/calls.c +++ b/host/sgx/calls.c @@ -231,23 +231,8 @@ oe_result_t oe_handle_call_host_function(uint64_t arg, oe_enclave_t* enclave) if (args_ptr->input_buffer == NULL || args_ptr->output_buffer == NULL) OE_RAISE(OE_INVALID_PARAMETER); - // Resolve which ocall table to use. - if (args_ptr->table_id == OE_UINT64_MAX) - { - ocall_table.ocalls = enclave->ocalls; - ocall_table.num_ocalls = enclave->num_ocalls; - } - else - { - if (args_ptr->table_id >= OE_MAX_OCALL_TABLES) - OE_RAISE(OE_NOT_FOUND); - - ocall_table.ocalls = _ocall_tables[args_ptr->table_id].ocalls; - ocall_table.num_ocalls = _ocall_tables[args_ptr->table_id].num_ocalls; - - if (!ocall_table.ocalls) - OE_RAISE(OE_NOT_FOUND); - } + ocall_table.ocalls = enclave->ocalls; + ocall_table.num_ocalls = enclave->num_ocalls; // Fetch matching function. if (args_ptr->function_id >= ocall_table.num_ocalls) diff --git a/host/sgx/create.c b/host/sgx/create.c index 3be96bbcb8..afdf6bc105 100644 --- a/host/sgx/create.c +++ b/host/sgx/create.c @@ -80,12 +80,6 @@ static void _initialize_exception_handling(void) static void _initialize_enclave_host() { oe_once(&_enclave_init_once, _initialize_exception_handling); - -#ifdef OE_USE_BUILTIN_EDL - oe_register_core_ocall_function_table(); - oe_register_platform_ocall_function_table(); - oe_register_syscall_ocall_function_table(); -#endif // OE_USE_BUILTIN_EDL } #endif // OEHOSTMR diff --git a/host/sgx/platform_u_wrapper.c b/host/sgx/platform_u_wrapper.c deleted file mode 100644 index dd48138a73..0000000000 --- a/host/sgx/platform_u_wrapper.c +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Open Enclave SDK contributors. -// Licensed under the MIT License. - -#include - -#include -#include -#include - -/* Override oe_call_enclave_function() with _call_platform_enclave_function(). - */ -#define oe_call_enclave_function _call_platform_enclave_function - -/* The ocall edge routines will use this function to route ecalls. */ -static oe_result_t _call_platform_enclave_function( - oe_enclave_t* enclave, - uint32_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_call_enclave_function_by_table_id( - enclave, - OE_SGX_ECALL_FUNCTION_TABLE_ID, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written); -} - -/* Include the oeedger8r generated C file. The macros defined above customize - * the generated code for internal use. */ -#include "platform_u.c" - -/* Registers the sgx OCALL function table. */ -oe_result_t oe_register_platform_ocall_function_table(void) -{ - const uint64_t table_id = OE_SGX_OCALL_FUNCTION_TABLE_ID; - const oe_ocall_func_t* ocalls = __platform_ocall_function_table; - const size_t num_ocalls = OE_COUNTOF(__platform_ocall_function_table); - - return oe_register_ocall_function_table(table_id, ocalls, num_ocalls); -} diff --git a/host/sgx/report.c b/host/sgx/report.c index 7d014efff9..3fee03b622 100644 --- a/host/sgx/report.c +++ b/host/sgx/report.c @@ -20,7 +20,6 @@ #include "sgxquoteprovider.h" -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototypes of the following functions to avoid the * missing-prototypes warning. @@ -112,8 +111,6 @@ oe_result_t _oe_verify_report_ecall( } OE_WEAK_ALIAS(_oe_verify_report_ecall, oe_verify_report_ecall); -#endif - OE_STATIC_ASSERT(OE_REPORT_DATA_SIZE == sizeof(sgx_report_data_t)); static const oe_uuid_t _ecdsa_uuid = {OE_FORMAT_UUID_SGX_ECDSA_P256}; diff --git a/host/sgx/switchless.c b/host/sgx/switchless.c index 1066dea57b..66aee01ffb 100644 --- a/host/sgx/switchless.c +++ b/host/sgx/switchless.c @@ -24,7 +24,6 @@ */ #define OE_ENCLAVE_WORKER_SPIN_COUNT_THRESHOLD (4096U) -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototypes of the following functions to avoid missing-prototypes * warning. @@ -77,8 +76,6 @@ OE_WEAK_ALIAS( _oe_sgx_switchless_enclave_worker_thread_ecall, oe_sgx_switchless_enclave_worker_thread_ecall); -#endif - /* ** The thread function that handles switchless ocalls ** @@ -354,10 +351,19 @@ void oe_sgx_wake_switchless_worker_ocall(oe_host_worker_context_t* context) oe_host_worker_wake(context); } -static oe_result_t oe_switchless_call_enclave_function_by_table_id( +/* +**============================================================================== +** +** oe_switchless_call_enclave_function() +** +** Switchlessly call the enclave function specified by the given function-id in +** the function table. +** +**============================================================================== +*/ +oe_result_t oe_switchless_call_enclave_function( oe_enclave_t* enclave, - uint64_t table_id, - uint64_t function_id, + uint32_t function_id, const void* input_buffer, size_t input_buffer_size, void* output_buffer, @@ -377,7 +383,6 @@ static oe_result_t oe_switchless_call_enclave_function_by_table_id( /* Initialize the call_enclave_args structure */ { - args.table_id = table_id; args.function_id = function_id; args.input_buffer = input_buffer; args.input_buffer_size = input_buffer_size; @@ -466,33 +471,3 @@ static oe_result_t oe_switchless_call_enclave_function_by_table_id( done: return result; } - -/* -**============================================================================== -** -** oe_switchless_call_enclave_function() -** -** Switchlessly call the enclave function specified by the given function-id in -** the default function table. -** -**============================================================================== -*/ -oe_result_t oe_switchless_call_enclave_function( - oe_enclave_t* enclave, - uint32_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_switchless_call_enclave_function_by_table_id( - enclave, - OE_UINT64_MAX, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written); -} diff --git a/host/syscall_u_wrapper.c b/host/syscall_u_wrapper.c deleted file mode 100644 index ba0e75981d..0000000000 --- a/host/syscall_u_wrapper.c +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Open Enclave SDK contributors. -// Licensed under the MIT License. - -#include - -#include -#include -#include "hostthread.h" - -#if defined(_MSC_VER) -#define st_atime st_atime -#define st_mtime st_mtime -#define st_ctime st_ctime -#endif - -/* Override oe_call_enclave_function() calls with _call_enclave_function(). */ -#define oe_call_enclave_function _call_enclave_function - -/* Obscure the generated creation function by renaming it. */ -#define oe_create_syscall_enclave __unused_oe_create_syscall_enclave - -/* The ocall edge routines will use this function to route ecalls. */ -static oe_result_t _call_enclave_function( - oe_enclave_t* enclave, - uint32_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_call_enclave_function_by_table_id( - enclave, - OE_SYSCALL_ECALL_FUNCTION_TABLE_ID, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written); -} - -/* Include the oeedger8r generated C file. The macros defined above customize - * the generated code for internal use. */ -#include "syscall_u.c" - -static oe_once_type _once = OE_H_ONCE_INITIALIZER; - -static void _once_function(void) -{ - if (oe_register_ocall_function_table( - OE_SYSCALL_OCALL_FUNCTION_TABLE_ID, - __syscall_ocall_function_table, - OE_COUNTOF(__syscall_ocall_function_table)) != OE_OK) - { - const char func[] = "oe_register_syscall_ocall_function_table()"; - - fprintf(stderr, "%s(%u): %s(): failed\n", __FILE__, __LINE__, func); - abort(); - } -} - -void oe_register_syscall_ocall_function_table(void) -{ - oe_once(&_once, _once_function); -} diff --git a/host/traceh_enclave.c b/host/traceh_enclave.c index f98d1553e2..b77fd5cf1e 100644 --- a/host/traceh_enclave.c +++ b/host/traceh_enclave.c @@ -18,7 +18,6 @@ #include "core_u.h" -#if !defined(OE_USE_BUILTIN_EDL) /** * Declare the prototype of the following function to avoid the * missing-prototypes warning. @@ -48,8 +47,6 @@ oe_result_t _oe_log_init_ecall( } OE_WEAK_ALIAS(_oe_log_init_ecall, oe_log_init_ecall); -#endif - /* * This file is separated from traceh.c since the host verification library * should not depend on ECALLS. diff --git a/include/openenclave/internal/calls.h b/include/openenclave/internal/calls.h index 4ce6ce3f7a..1c94c8c4a1 100644 --- a/include/openenclave/internal/calls.h +++ b/include/openenclave/internal/calls.h @@ -181,10 +181,6 @@ OE_INLINE uint16_t oe_get_result_from_call_arg1(uint64_t arg) typedef struct _oe_call_enclave_function_args { - // OE_UINT64_MAX refers to default function table. Other values are - // reserved for alternative function tables. - uint64_t table_id; - uint64_t function_id; const void* input_buffer; size_t input_buffer_size; @@ -194,24 +190,6 @@ typedef struct _oe_call_enclave_function_args oe_result_t result; } oe_call_enclave_function_args_t; -/* -**============================================================================== -** -** oe_call_enclave_function_by_table_id() -** -**============================================================================== -*/ - -oe_result_t oe_call_enclave_function_by_table_id( - oe_enclave_t* enclave, - uint64_t table_id, - uint64_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written); - /* **============================================================================== ** @@ -222,12 +200,7 @@ oe_result_t oe_call_enclave_function_by_table_id( typedef struct _oe_call_host_function_args { - // OE_UINT64_MAX refers to default function table. Other values are - // reserved for alternative function tables. - uint64_t table_id; - uint64_t function_id; - const void* input_buffer; size_t input_buffer_size; void* output_buffer; @@ -239,13 +212,12 @@ typedef struct _oe_call_host_function_args /* **============================================================================== ** -** oe_call_host_function_by_table_id() +** oe_call_host_function_internal() ** **============================================================================== */ -oe_result_t oe_call_host_function_by_table_id( - size_t table_id, +oe_result_t oe_call_host_function_internal( size_t function_id, const void* input_buffer, size_t input_buffer_size, @@ -254,54 +226,6 @@ oe_result_t oe_call_host_function_by_table_id( size_t* output_bytes_written, bool switchless); -/* -**============================================================================== -** -** oe_register_ocall_function_table() -** -** Register an ocall table with the given table id. -** -**============================================================================== -*/ - -#define OE_MAX_OCALL_TABLES 64 - -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); - -oe_result_t oe_register_ocall_function_table( - uint64_t table_id, - const oe_ocall_func_t* ocalls, - size_t num_ocalls); - -/* -**============================================================================== -** -** oe_register_ecall_function_table() -** -** Register an ecall table with the given table id. -** -**============================================================================== -*/ - -#define OE_MAX_ECALL_TABLES 64 - -typedef void (*oe_ecall_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); - -oe_result_t oe_register_ecall_function_table( - uint64_t table_id, - const oe_ecall_func_t* ecalls, - size_t num_ecalls); - /** * Perform a low-level enclave function call (ECALL). * @@ -389,47 +313,6 @@ oe_result_t oe_ecall( */ oe_result_t oe_ocall(uint16_t func, uint64_t arg_in, uint64_t* arg_out); -/* -**============================================================================== -** -** The SYSCALL function tables. -** -**============================================================================== -*/ - -#ifdef OE_USE_BUILTIN_EDL - -#define OE_CORE_OCALL_FUNCTION_TABLE_ID 0 -#define OE_CORE_ECALL_FUNCTION_TABLE_ID 0 - -#define OE_SGX_OCALL_FUNCTION_TABLE_ID 1 -#define OE_SGX_ECALL_FUNCTION_TABLE_ID 1 - -#define OE_SYSCALL_OCALL_FUNCTION_TABLE_ID 2 -#define OE_SYSCALL_ECALL_FUNCTION_TABLE_ID 2 - -/* Register the OCALL table needed by the common TEE interface (host side). */ -oe_result_t oe_register_core_ocall_function_table(void); - -/* Register the ECALL table needed by the common TEE interface (enclave side). - */ -oe_result_t oe_register_core_ecall_function_table(void); - -/* Register the OCALL table needed by the SGX-specific interface (host side). */ -oe_result_t oe_register_platform_ocall_function_table(void); - -/* Register the ECALL table needed by the SGX-specific interface (enclave side). - */ -oe_result_t oe_register_platform_ecall_function_table(void); - -/* Register the OCALL table needed by the SYSCALL interface (host side). */ -void oe_register_syscall_ocall_function_table(void); - -/* Register the ECALL table needed by the SYSCALL interface (enclave side). */ -void oe_register_syscall_ecall_function_table(void); - -#endif // OE_USE_BUILTIN_EDL - OE_EXTERNC_END #endif /* _OE_CALLS_H */ diff --git a/syscall/CMakeLists.txt b/syscall/CMakeLists.txt index 5897ff3aa4..94c6e5745c 100644 --- a/syscall/CMakeLists.txt +++ b/syscall/CMakeLists.txt @@ -11,26 +11,15 @@ set(OE_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include) set(EDL_DIR ${PROJECT_SOURCE_DIR}/include/openenclave/edl) set(EDL_FILE ${EDL_DIR}/syscall.edl) -if (COMPILE_SYSTEM_EDL) - add_custom_command( - OUTPUT syscall_t.h syscall_t.c syscall_args.h - DEPENDS ${EDL_FILE} edger8r - COMMAND edger8r --search-path ${OE_INCLUDE_DIR} --trusted ${EDL_FILE}) - add_custom_target(syscall_trusted_edl DEPENDS syscall_t.h syscall_t.c - syscall_args.h) +# Generate headers only +add_custom_command( + OUTPUT syscall_t.h syscall_args.h + DEPENDS ${EDL_FILE} edger8r + COMMAND edger8r --header-only --search-path ${OE_INCLUDE_DIR} --trusted + ${EDL_FILE}) - list(APPEND SOURCES syscall_t_wrapper.c) -else () - # Generate headers only - add_custom_command( - OUTPUT syscall_t.h syscall_args.h - DEPENDS ${EDL_FILE} edger8r - COMMAND edger8r --header-only --search-path ${OE_INCLUDE_DIR} --trusted - ${EDL_FILE}) - - add_custom_target(syscall_trusted_edl DEPENDS syscall_t.h syscall_args.h) -endif () +add_custom_target(syscall_trusted_edl DEPENDS syscall_t.h syscall_args.h) ##============================================================================== ## @@ -76,10 +65,6 @@ enclave_include_directories( enclave_link_libraries(oesyscall PUBLIC oecore) enclave_compile_options(oesyscall PRIVATE -ffunction-sections) -if (COMPILE_SYSTEM_EDL) - enclave_compile_definitions(oesyscall PRIVATE OE_USE_BUILTIN_EDL) -endif () - set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/syscall_t.c PROPERTIES COMPILE_FLAGS -DOE_NEED_STDC_NAMES) diff --git a/syscall/hostcalls.c b/syscall/hostcalls.c index 60fbaec6cc..9b2147f726 100644 --- a/syscall/hostcalls.c +++ b/syscall/hostcalls.c @@ -26,8 +26,6 @@ * error. */ -#if !defined(OE_USE_BUILTIN_EDL) - /* **============================================================================== ** @@ -1391,5 +1389,3 @@ oe_result_t _oe_syscall_uname_ocall(int* _retval, struct oe_utsname* buf) return OE_UNSUPPORTED; } OE_WEAK_ALIAS(_oe_syscall_uname_ocall, oe_syscall_uname_ocall); - -#endif diff --git a/syscall/syscall_t_wrapper.c b/syscall/syscall_t_wrapper.c deleted file mode 100644 index 5742133e1a..0000000000 --- a/syscall/syscall_t_wrapper.c +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) Open Enclave SDK contributors. -// Licensed under the MIT License. - -#include - -#include -#include -#include -#include -#include - -/* Rename the ecalls table. */ -#define __oe_ecalls_table __oe_syscall_ecalls_table -#define __oe_ecalls_table_size __oe_syscall_ecalls_table_size - -/* Override oe_call_host_function() calls with _call_host_function(). */ -#define oe_call_host_function _call_host_function - -/* Use this function below instead of oe_call_host_function(). */ -static oe_result_t _call_host_function( - size_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_call_host_function_by_table_id( - OE_SYSCALL_OCALL_FUNCTION_TABLE_ID, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written, - false /* non-switchless */); -} - -/* Include the oeedger8r generated C file. The macros defined above customize - * the generated code for internal use. */ -#include "syscall_t.c" - -static oe_once_t _once = OE_ONCE_INITIALIZER; - -static void _once_function(void) -{ - if (oe_register_ecall_function_table( - OE_SYSCALL_ECALL_FUNCTION_TABLE_ID, - __oe_syscall_ecalls_table, - __oe_syscall_ecalls_table_size) != OE_OK) - { - oe_printf( - "%s(%u): failed to register syscall function table\n", - __FILE__, - __LINE__); - oe_abort(); - } -} - -void oe_register_syscall_ecall_function_table(void) -{ - oe_once(&_once, _once_function); -}