Skip to content

Commit

Permalink
Rename edl umberella files to make more sense for public-facing imports
Browse files Browse the repository at this point in the history
Now that OE EDL files will need to be imported by application EDL, there
should be a clear path to enabling the same behavior of icluding all
system EDL. This path is to include just the three uberella EDL files.

Rename tee.edl -> oecore.edl and sgx/sgx.edl -> sgx/platform.edl. All
the ecalls/ocalls included by sgx/platform.edl are needed for all SGX
applications. Also add optee/platform.edl which contains no functions so
that an application can blindly support both optee and SGX.

A normal SGX application which wants to maintin parity with the old
build system will now just add the following 3 lines to their edl file:

from "sgx/platform.edl" import *
from "core.edl" import *
from "syscall.edl" import *

Signed-off-by: Jordan Hand <[email protected]>
  • Loading branch information
jhand2 committed Apr 10, 2020
1 parent 6bed4b5 commit e5e8b8e
Show file tree
Hide file tree
Showing 52 changed files with 147 additions and 127 deletions.
4 changes: 2 additions & 2 deletions docs/DesignDocs/SGX_QuoteEx_Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The SGX ECDSA-p256 attester plugin is implemented in code file
`enclave/sgx/attester.c` and other relevant enclave-side and host-side code files,
called enclave-side and host-side plugin libraries in this document.
he enclave-side plugin library interacts with the host-side plugin library
via OCALLs defined in interface definition file `common/sgx/sgx.edl`.
via OCALLs defined in interface definition file `edl/sgx/platform.edl`.
For SGX ECDSA-p256 evidence generation, there are 2 OCALLs:

- `oe_get_qetarget_info_ocall(sgx_target_info_t* target_info)`
Expand Down Expand Up @@ -206,7 +206,7 @@ creates a list of attester plugins for them, and returns the created list
to the caller.

For SGX evidence formats enumeration, a new OCALL is added to interface
definition file `common/sgx/sgx.edl` and implemented in the host-side
definition file `edl/sgx/platform.edl` and implemented in the host-side
SGX plugin library:

- `oe_get_supported_attester_format_ids_ocall(void* format_ids, size_t format_ids_size, size_t* format_ids_size_out)`
Expand Down
37 changes: 19 additions & 18 deletions docs/DesignDocs/system_ocall_opt_in.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enclave
}
```

2. Import all OCalls from `tee.edl`
2. Import all OCalls from `core.edl`

```
// sample.edl
Expand All @@ -66,8 +66,8 @@ enclave
```

In example (1), linking would fail if the enclave made a call to `oe_realloc_ocall()`
(also part of tee.edl) unless the developer modified the import line to
`from "openenclave/edl/tee.edl" import oe_log_ocall, oe_realloc_ocall;`. In this scenario,
(also part of core.edl) unless the developer modified the import line to
`from "openenclave/edl/core.edl" import oe_log_ocall, oe_realloc_ocall;`. In this scenario,
example (2) will work without modification.

## EDL local structures
Expand Down Expand Up @@ -122,18 +122,19 @@ The following 4 OCalls can be implemented in EDL, they just aren't today. Issue
All system OCalls (other than the previously mentioned exceptions) are found
in one of the following EDL files

* `common/logging.edl`
* `common/memory.edl`
* `common/epoll.edl`
* `common/fcntl.edl`
* `common/ioctl.edl`
* `common/poll.edl`
* `common/signal.edl`
* `common/socket.edl`
* `common/time.edl`
* `common/unistd.edl`
* `common/utsname.edl`
* `common/syscall.edl`
* `common/syscall.edl`
* `common/sgx/sgx.edl`
* `common/sgx/switchless.edl`
* `edl/logging.edl`
* `edl/memory.edl`
* `edl/epoll.edl`
* `edl/fcntl.edl`
* `edl/ioctl.edl`
* `edl/poll.edl`
* `edl/signal.edl`
* `edl/socket.edl`
* `edl/time.edl`
* `edl/unistd.edl`
* `edl/utsname.edl`
* `edl/sgx/cpu.edl`
* `edl/sgx/debug.edl`
* `edl/sgx/sgx_attestation.edl`
* `edl/sgx/switchless.edl`
* `edl/sgx/thread.edl`
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion common/edl/tee.edl → edl/core.edl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
**==============================================================================
**
** tee.edl:
** core.edl:
**
** This file declares internal ECALLs/OCALLs used by liboehost/liboecore
** for usage with any TEE technology.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions edl/optee/platform.edl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Open Enclave SDK contributors.
// Licensed under the MIT License.

/*
**==============================================================================
**
** optee/platform.edl:
**
** This is a temporary wrapper for aggregating all OPTEE-specific ECALLs and
** OCALLs for convenient use by oecore.
**
**==============================================================================
*/

enclave
{
// There are currently no OP-TEE specific ocalls/ecalls which must be
// included. This file exists to allow an application to blindly include
// platform.edl and be compiled for any TEE.
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions common/sgx/edl/sgx.edl → edl/sgx/platform.edl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
**==============================================================================
**
** sgx/sgx.edl:
** sgx/platform.edl:
**
** This is a temporary wrapper for aggregating all SGX-specific ECALLs and
** OCALLs for convenient use by oecore.
Expand All @@ -14,7 +14,7 @@

enclave
{
from "attestation.edl" import *;
from "sgx_attestation.edl" import *;
from "cpu.edl" import *;
from "debug.edl" import *;
from "thread.edl" import *;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
**==============================================================================
**
** sgx/attestation.edl:
** sgx/sgx_attestation.edl:
**
** Internal ECALLs/OCALLs to be used by liboehost/liboecore for SGX-specific
** attestation.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 15 additions & 16 deletions enclave/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) Open Enclave SDK contributors.
# Licensed under the MIT License.

set(EDL_DIR ${CMAKE_SOURCE_DIR}/common/edl)
set(EDL_DIR ${CMAKE_SOURCE_DIR}/edl)
if (OE_SGX)
set(SGX_EDL_DIR ${CMAKE_SOURCE_DIR}/common/sgx/edl)
set(SGX_EDL_DIR ${EDL_DIR}/sgx)
endif()

##==============================================================================
Expand All @@ -13,15 +13,15 @@ endif()
##
##==============================================================================

set(TEE_EDL_FILE ${EDL_DIR}/tee.edl)
set(OECORE_EDL_FILE ${EDL_DIR}/core.edl)

add_custom_command(
OUTPUT tee_t.h tee_t.c tee_args.h
DEPENDS ${TEE_EDL_FILE} edger8r
COMMAND edger8r --search-path ${EDL_DIR} --trusted ${TEE_EDL_FILE})
OUTPUT core_t.h core_t.c core_args.h
DEPENDS ${OECORE_EDL_FILE} edger8r
COMMAND edger8r --search-path ${EDL_DIR} --trusted ${OECORE_EDL_FILE})

add_custom_target(tee_trusted_edl
DEPENDS tee_t.h tee_t.c tee_args.h)
add_custom_target(core_trusted_edl
DEPENDS core_t.h core_t.c core_args.h)

##==============================================================================
##
Expand Down Expand Up @@ -49,15 +49,14 @@ endif()
##==============================================================================

if(OE_SGX)
set(SGX_EDL_FILE ${SGX_EDL_DIR}/sgx.edl)
set(SGX_EDL_FILE ${SGX_EDL_DIR}/platform.edl)

add_custom_command(
OUTPUT sgx_t.h sgx_t.c sgx_args.h
OUTPUT platform_t.h platform_t.c platform_args.c
DEPENDS ${SGX_EDL_FILE} edger8r
COMMAND edger8r --search-path ${SGX_EDL_DIR} --trusted ${SGX_EDL_FILE})

add_custom_target(sgx_trusted_edl
DEPENDS sgx_t.h sgx_t.c sgx_args.h)
add_custom_target(platform_trusted_edl DEPENDS platform_t.h platform_t.c platform_args.c)
endif()

##==============================================================================
Expand Down Expand Up @@ -106,7 +105,7 @@ if (OE_SGX)
sgx/report.c
sgx/sched_yield.c
sgx/setjmp.S
sgx/sgx_t_wrapper.c
sgx/platform_t_wrapper.c
sgx/spinlock.c
sgx/switchless_t_wrapper.c
sgx/switchlesscalls.c
Expand Down Expand Up @@ -199,7 +198,7 @@ add_enclave_library(oecore STATIC
string.c
strtok_r.c
strtoul.c
tee_t_wrapper.c
core_t_wrapper.c
time.c
tracee.c
wchar.c
Expand Down Expand Up @@ -236,9 +235,9 @@ set_property(SOURCE ${NEEDS_STDC_NAMES} APPEND PROPERTY

maybe_build_using_clangw(oecore)

add_enclave_dependencies(oecore tee_trusted_edl)
add_enclave_dependencies(oecore core_trusted_edl)
if(OE_SGX)
add_enclave_dependencies(oecore sgx_trusted_edl switchless_trusted_edl)
add_enclave_dependencies(oecore platform_trusted_edl switchless_trusted_edl)
endif()
enclave_include_directories(oecore PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

Expand Down
18 changes: 9 additions & 9 deletions enclave/core/tee_t_wrapper.c → enclave/core/core_t_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <openenclave/internal/thread.h>

/* Rename the global ecalls table. */
#define __oe_ecalls_table __oe_tee_ecalls_table
#define __oe_ecalls_table_size __oe_tee_ecalls_table_size
#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
Expand All @@ -26,7 +26,7 @@ static oe_result_t _call_host_function(
size_t* output_bytes_written)
{
return oe_call_host_function_by_table_id(
OE_TEE_OCALL_FUNCTION_TABLE_ID,
OE_CORE_OCALL_FUNCTION_TABLE_ID,
function_id,
input_buffer,
input_buffer_size,
Expand All @@ -38,14 +38,14 @@ static oe_result_t _call_host_function(

/* Include the oeedger8r generated C file. The macros defined above customize
* the generated code for internal use. */
#include "tee_t.c"
#include "core_t.c"

/* Registers the tee ECALL function table. */
oe_result_t oe_register_tee_ecall_function_table(void)
/* Registers the core ECALL function table. */
oe_result_t oe_register_core_ecall_function_table(void)
{
const uint64_t table_id = OE_TEE_ECALL_FUNCTION_TABLE_ID;
const oe_ecall_func_t* ecalls = __oe_tee_ecalls_table;
const size_t num_ecalls = __oe_tee_ecalls_table_size;
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);
}
2 changes: 1 addition & 1 deletion enclave/core/hostcalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <openenclave/internal/stack_alloc.h>

#include "arena.h"
#include "tee_t.h"
#include "core_t.h"

void* oe_host_malloc(size_t size)
{
Expand Down
4 changes: 2 additions & 2 deletions enclave/core/optee/gp.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "../atexit.h"
#include "../calls.h"
#include "../init_fini.h"
#include "tee_t.h"
#include "core_t.h"

#include <tee_internal_api.h>

Expand Down Expand Up @@ -410,7 +410,7 @@ TEE_Result TA_CreateEntryPoint(void)
oe_call_init_functions();

/* Install the common TEE ECALL function table. */
if (oe_register_tee_ecall_function_table() != OE_OK)
if (oe_register_core_ecall_function_table() != OE_OK)
return TEE_ERROR_GENERIC;

/* Done */
Expand Down
4 changes: 2 additions & 2 deletions enclave/core/sgx/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <openenclave/internal/raise.h>
#include <openenclave/internal/safecrt.h>
#include "../oe_nodebug_alloc.h"
#include "sgx_t.h"
#include "tee_t.h"
#include "core_t.h"
#include "platform_t.h"

#if defined(__INTEL_COMPILER)
#error "optimized __builtin_return_address() not supported by Intel compiler"
Expand Down
8 changes: 4 additions & 4 deletions enclave/core/sgx/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
#include "../atexit.h"
#include "../tracee.h"
#include "asmdefs.h"
#include "core_t.h"
#include "cpuid.h"
#include "handle_ecall.h"
#include "init.h"
#include "platform_t.h"
#include "report.h"
#include "sgx_t.h"
#include "switchlesscalls.h"
#include "td.h"
#include "tee_t.h"

oe_result_t __oe_enclave_status = OE_OK;
uint8_t __oe_initialized = 0;
Expand Down Expand Up @@ -160,10 +160,10 @@ static oe_result_t _handle_init_enclave(uint64_t arg_in)
OE_CHECK(oe_register_switchless_ecall_function_table());

/* Install the common TEE ECALL function table. */
OE_CHECK(oe_register_tee_ecall_function_table());
OE_CHECK(oe_register_core_ecall_function_table());

/* Install the SGX ECALL function table. */
OE_CHECK(oe_register_sgx_ecall_function_table());
OE_CHECK(oe_register_platform_ecall_function_table());

if (!oe_is_outside_enclave(enclave, 1))
OE_RAISE(OE_INVALID_PARAMETER);
Expand Down
2 changes: 1 addition & 1 deletion enclave/core/sgx/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <openenclave/internal/cpuid.h>
#include <openenclave/internal/raise.h>
#include <openenclave/internal/safecrt.h>
#include "sgx_t.h"
#include "platform_t.h"

static uint32_t _cpuid_table[OE_CPUID_LEAF_COUNT][OE_CPUID_REG_COUNT];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <openenclave/internal/thread.h>

/* Rename the global ecalls table. */
#define __oe_ecalls_table __oe_sgx_ecalls_table
#define __oe_ecalls_table_size __oe_sgx_ecalls_table_size
#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
Expand All @@ -38,14 +38,14 @@ static oe_result_t _call_host_function(

/* Include the oeedger8r generated C file. The macros defined above customize
* the generated code for internal use. */
#include "sgx_t.c"
#include "platform_t.c"

/* Registers the sgx ECALL function table. */
oe_result_t oe_register_sgx_ecall_function_table(void)
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_sgx_ecalls_table;
const size_t num_ecalls = __oe_sgx_ecalls_table_size;
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);
}
2 changes: 1 addition & 1 deletion enclave/core/sgx/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <openenclave/internal/safecrt.h>
#include <openenclave/internal/safemath.h>
#include <openenclave/internal/utils.h>
#include "sgx_t.h"
#include "platform_t.h"

OE_STATIC_ASSERT(OE_REPORT_DATA_SIZE == sizeof(sgx_report_data_t));

Expand Down
2 changes: 1 addition & 1 deletion enclave/core/sgx/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <openenclave/internal/raise.h>
#include <openenclave/internal/safecrt.h>
#include <openenclave/internal/thread.h>
#include "sgx_t.h"
#include "platform_t.h"
#include "td.h"

/*
Expand Down
2 changes: 1 addition & 1 deletion enclave/core/tracee.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <openenclave/internal/safemath.h>
#include <openenclave/internal/trace.h>
#include <openenclave/internal/utils.h>
#include "tee_t.h"
#include "core_t.h"

static oe_log_level_t _active_log_level = OE_LOG_LEVEL_ERROR;
static char _enclave_filename[OE_MAX_FILENAME_LEN];
Expand Down
2 changes: 1 addition & 1 deletion enclave/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <openenclave/enclave.h>
#include <openenclave/internal/malloc.h>
#include "tee_t.h"
#include "core_t.h"

//
// start.S (the compilation unit containing the entry point) contains a
Expand Down
Loading

0 comments on commit e5e8b8e

Please sign in to comment.