Skip to content

Commit

Permalink
Remove COMPILE_SYSTEM_EDL cmake option
Browse files Browse the repository at this point in the history
Signed-off-by: Ming-Wei Shih <[email protected]>
  • Loading branch information
mingweishih committed Aug 18, 2020
1 parent 5d0ce69 commit 0af1073
Show file tree
Hide file tree
Showing 32 changed files with 73 additions and 864 deletions.
23 changes: 7 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
40 changes: 7 additions & 33 deletions enclave/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

##==============================================================================
##
Expand All @@ -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
Expand Down Expand Up @@ -180,7 +159,6 @@ add_enclave_library(
assert.c
atexit.c
backtrace.c
calls.c
ctype.c
debugmalloc.c
hexdump.c
Expand Down Expand Up @@ -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 ()
Expand Down
46 changes: 0 additions & 46 deletions enclave/core/calls.c

This file was deleted.

2 changes: 0 additions & 2 deletions enclave/core/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
51 changes: 0 additions & 51 deletions enclave/core/core_t_wrapper.c

This file was deleted.

2 changes: 0 additions & 2 deletions enclave/core/hostcalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions enclave/core/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 2 additions & 5 deletions enclave/core/optee/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#include <openenclave/internal/calls.h>
#include <openenclave/internal/raise.h>

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,
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 3 additions & 23 deletions enclave/core/optee/gp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 0 additions & 3 deletions enclave/core/sgx/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
{
Expand Down
36 changes: 6 additions & 30 deletions enclave/core/sgx/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 0af1073

Please sign in to comment.