Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
95ed80c
Add detection for EDMM support in kernel
haitaohuang Oct 13, 2021
9da656c
EDMM support using kernel interfaces
haitaohuang Aug 24, 2021
6074214
emm: fix typos
haitaohuang Dec 2, 2021
e6b2ff7
update IOCTL definitions for EDMM
haitaohuang Dec 2, 2021
5afb5c5
emm: update kernel branch in README
haitaohuang Dec 5, 2021
5cb4cf7
urts and enclave_common: update for edmm kernel patches v2
haitaohuang Feb 8, 2022
60fda39
sgx_mm_ocalls: add more robust error handling for ioctl() calls
haitaohuang Feb 10, 2022
022a663
EMM: Update README for the kernel patches V2
haitaohuang Feb 11, 2022
1398ae3
urts: check if /dev is mounted with noexec
haitaohuang Mar 7, 2022
3dda98b
emm: add design doc and update README
haitaohuang Mar 8, 2022
151a3bb
TRTS: use a separate spinlock implementation for EMM
haitaohuang Mar 9, 2022
fbe7e62
Revert "urts: check if /dev is mounted with noexec"
haitaohuang Mar 22, 2022
0e57da8
enclave_common and urts: update for EDMM kernel patch V3
haitaohuang Apr 5, 2022
ac72298
emm: update README for edmm V3
haitaohuang Apr 5, 2022
1c664ee
PSW: update for kernel EDMM patch V4
haitaohuang Apr 15, 2022
6f18470
enclave_common: update for kernel patch V5
haitaohuang May 8, 2022
07ba234
sdk/emm: merge ocalls for continuous pages
haitaohuang May 8, 2022
6ca2ce7
trts: fix an overflow
haitaohuang May 8, 2022
0e2de0a
ema: remove unused lock
haitaohuang May 12, 2022
bda6b29
sdk/ema: misc stability fixes
haitaohuang May 15, 2022
c4c1b3d
emm: add custom allocator for internal use
haitaohuang May 13, 2022
139aabb
Update SGX_EMM.md to include sgx_mm_init API
haitaohuang May 27, 2022
ec544fe
enclave_common: simplfy permissions change
haitaohuang May 29, 2022
a6af9b5
emalloc: misc fixes
haitaohuang May 29, 2022
ca27dd4
urts/user_handler: allow OCalls/Exception callback without OCall tables
haitaohuang Jun 6, 2022
5d778d8
sdk/emm: update design doc
haitaohuang Jun 8, 2022
68048bd
psw/enclave_common: remove some unneeded wording from enclave_alloc a…
haitaohuang Jun 15, 2022
e3865c6
EMM: update driver interface for upstream kernel
haitaohuang Jun 28, 2022
a2a4b48
Enclave Common API for EDMM
haitaohuang Jun 28, 2022
8da2132
emm: handle potential spurious #PF
haitaohuang Jul 8, 2022
be1417a
EMM: update design doc
haitaohuang Jul 12, 2022
33718ab
Add sgx-emm submodule
haitaohuang Jul 14, 2022
ee88ac2
EMM: restructure to use sgx-emm submodule
haitaohuang Jul 14, 2022
d9f70c2
Revert "enclave_common: simplfy permissions change"
haitaohuang Aug 17, 2022
fc6f8f6
sgx-emm/api_tests: add a case to change permissions to PT_NONE
haitaohuang Aug 17, 2022
3cdca12
EDMM support with configurable User Region Size
xxu36 Jun 6, 2022
1cbcb2d
Added signtool checking for EDMM related configurations
xxu36 Jul 3, 2022
6b68f96
Support for compatibility
xxu36 Jul 10, 2022
a0b0ff3
Metadata and sdk version selection for compatibility
xxu36 Jul 18, 2022
92a08a3
Fix bookkeeping overhead
xxu36 Aug 23, 2022
5a8e3f1
update API test to use UserRegionSize in config
haitaohuang Jul 19, 2022
4f4d1f1
Update enclave common loader interface
xxu36 Aug 5, 2022
1604f39
Fix build error after adapting enclave common loader changes
xxu36 Aug 11, 2022
6ad7ab1
update for sgx_mm_init returning error.
haitaohuang Aug 18, 2022
a3254d9
sgx-emm: update commit to point to dev
haitaohuang Aug 29, 2022
e2fce97
enclave_common: fix build error in sgx_mm_ocalls.cpp
haitaohuang Aug 29, 2022
b817ce3
update commit for sgx-emm
haitaohuang Aug 30, 2022
3c082a7
sgx-emm/api_tests: add case for longjmp from exception handler
haitaohuang Sep 8, 2022
2b4dcf8
sgx-emm/api_tests: add a case with nested handler
haitaohuang Sep 9, 2022
c9f757f
sgx-emm/api_tests: add random allocation and stack expansion cases
haitaohuang Sep 9, 2022
ec216f7
sgx-emm/api_tests: move random tests to unsafe
haitaohuang Sep 10, 2022
0cb086d
sdk/trts: remove init_rts_ema_root
haitaohuang Sep 11, 2022
720b1c1
urts: add a null pointer check for acquire_thread
haitaohuang Sep 19, 2022
bfeded4
update sgx-emm commit
haitaohuang Sep 19, 2022
0e68258
Add two helper scripts to compile and install
tatetian Dec 24, 2018
020c837
Enable Intel MPX for enclaves by default
tatetian Dec 28, 2018
dfea91f
Add sgx_thread_get_self API
tatetian Jan 4, 2019
dfdabfe
Add integrity-only mode for SGX protected files
Aug 6, 2019
10b7fb3
Refactor scripts that compiles and installs SGX SDK
liqinggd Jan 13, 2020
0a88815
Add --no-start-aesm parameter to psw installation
Feb 12, 2020
a18698f
Add sgx-gdb support for apps running on Occlum
liqinggd Feb 4, 2020
2c68a3e
Support handling exceptions in Occlum's user space
Mar 6, 2020
f359f3c
Add sgx_thread_wait_untrusted_event_timeout_ocall API
liqinggd Mar 15, 2020
2c7dcb0
Support user code manage stack
Apr 29, 2020
572ac00
Add no_mitigation option to compile sdk
liqinggd May 19, 2020
c4c69fb
Add macro to get rid of rdrand for non-supported platforms
jessehui Apr 29, 2020
a7520f1
Create uRTS static library
Jun 8, 2020
9c7875d
Fix urts not found by sgx debugger when statically linked by libocclu…
Jun 28, 2020
d03fcc3
Add optional timeout to the OCall for waiting events
tatetian Jul 3, 2020
ad73520
Add new EDL file for occlum specific usage
jessehui Jul 16, 2020
64c0421
Improve support for urts_sim static library building
jessehui Aug 4, 2020
c15d8f7
Support no-return customer exception handlers
Sep 23, 2020
617d0df
Support to wait event with an absolute timeout
liqinggd Nov 17, 2020
af62b2f
Compile and install DCAP package
Dec 10, 2020
e08e421
Support SGX-GDB to load library's symbol for Glibc
liqinggd Jan 13, 2021
73fc25c
Fix aesm build failure in docker buildx enviroment
Jan 25, 2021
f92b1c1
Enable exception support under simulation mode
Jan 26, 2021
e0546fc
Fix some simulation mode AEX bugs and add SIG64 support
Feb 4, 2021
861a7b6
Remove PSW and DCAP build process
Feb 8, 2021
05b64e2
Fix create enclave failed due to ENOMEM in simulation mode
jessehui Aug 11, 2021
7dafa4a
Solve the simulation mode register signal handler twice issue.
Aug 13, 2021
069f920
Update the simulation mode to align the Occlum implementation
Dec 3, 2021
7ab0aa5
Workaround the Occlum interrupt mode
Dec 7, 2021
ffaa5fa
Update the installation script
Dec 28, 2021
38fdd14
Add one more check in simualtion mode signal hander to confirm the
Dec 30, 2021
968d0f5
Fix se_event_timeout_wait to handle relative and absolute timeout
jessehui Feb 23, 2022
b819fa5
Support parameterized cache size of SGX PFS (apply intel's patch)
lucassong-mh Sep 2, 2022
d786b38
Add fsync to sgx_fflush and sgx_fclose to ensure persistency
lucassong-mh Sep 2, 2022
f1c5425
Fix bug in get_first_executable_segment_info()
Bonjourz Sep 9, 2022
6715a60
Revert "Add fsync to sgx_fflush and sgx_fclose to ensure persistency"…
lucassong-mh Oct 31, 2022
32383ef
Add the interrupt mechanism for dynamically-loaded workloads
tatetian Jun 27, 2020
d01ec4f
Fix the interrupt mode issue by restore the FS and the RFlags
Dec 28, 2021
92ae3ec
Add PKU support: isolating LibOS from userspace apps
Bonjourz Apr 1, 2022
faf8dea
Enlarge the stack size for non-standard exception handler
jessehui Nov 22, 2022
01180a9
Fix edmm compilation in simulation mode
jessehui Nov 22, 2022
5f6ed53
Enable vdso and support interrupt mechanism
jessehui Nov 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
path = external/protobuf/protobuf_code
url = https://github.com/protocolbuffers/protobuf.git
branch = 3.14.x
[submodule "external/sgx-emm/emm_src"]
path = external/sgx-emm/emm_src
url = https://github.com/intel/sgx-emm
branch = dev
19 changes: 15 additions & 4 deletions SampleCode/SampleEnclave/Enclave/Enclave.config.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
<EnclaveConfiguration>
<ProdID>0</ProdID>
<ISVSVN>0</ISVSVN>
<StackMaxSize>0x40000</StackMaxSize>
<HeapMaxSize>0x100000</HeapMaxSize>
<TCSNum>10</TCSNum>
<TCSNum>1</TCSNum>
<TCSMinPool>5</TCSMinPool>
<TCSPolicy>1</TCSPolicy>
<TCSMaxNum>13</TCSMaxNum>

<!-- For a static thread, total available stack is 0x40000 -->
<!-- For a dynamic thread, once it is creted, available stack is
0x2000, the gap, that is 0x40000 - 0x2000, can be dynamically
expanded as necessary.
-->
<StackMaxSize>0x4000</StackMaxSize>
<StackMinSize>0x2000</StackMinSize>
<HeapMaxSize>0x5000</HeapMaxSize>
<UserRegionSize>0x50000</UserRegionSize>

<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscSelect>1</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
2 changes: 1 addition & 1 deletion SampleCode/SampleEnclave/Enclave/config.01.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@

<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscSelect>1</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
2 changes: 1 addition & 1 deletion SampleCode/SampleEnclave/Enclave/config.02.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<TCSPolicy>1</TCSPolicy>
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscSelect>1</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
2 changes: 1 addition & 1 deletion SampleCode/SampleEnclave/Enclave/config.03.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@

<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscSelect>1</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
2 changes: 1 addition & 1 deletion SampleCode/SampleEnclave/Enclave/config.04.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscSelect>1</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
11 changes: 11 additions & 0 deletions common/inc/internal/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ typedef struct _exit_info_t
#define SE_VECTOR_BP 3
#define SE_VECTOR_BR 5
#define SE_VECTOR_UD 6
#define SE_VECTOR_GP 13
#define SE_VECTOR_PF 14
#define SE_VECTOR_MF 16
#define SE_VECTOR_AC 17
#define SE_VECTOR_XM 19
Expand Down Expand Up @@ -156,6 +158,15 @@ typedef struct _ssa_gpr_t
uint64_t gs; /* (176) GS register */
} ssa_gpr_t;

typedef struct _misc_exinfo
{
uint64_t maddr; // address for #PF, #GP.
uint32_t errcd;
uint32_t reserved;
} misc_exinfo_t;

#define MISC_BYTE_SIZE sizeof(misc_exinfo_t)

typedef uint64_t si_flags_t;

#define SI_FLAG_NONE 0x0
Expand Down
1 change: 1 addition & 0 deletions common/inc/internal/bit_array.h
1 change: 1 addition & 0 deletions common/inc/internal/bit_array_imp.h
1 change: 1 addition & 0 deletions common/inc/internal/ema.h
1 change: 1 addition & 0 deletions common/inc/internal/ema_imp.h
1 change: 1 addition & 0 deletions common/inc/internal/emm_private.h
2 changes: 1 addition & 1 deletion common/inc/internal/enclave_creator.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class EnclaveCreator : private Uncopyable
virtual uint32_t handle_page_fault(uint64_t pf_address) { UNUSED(pf_address); return (uint32_t)SGX_ERROR_UNEXPECTED; }
#endif
virtual int emodpr(uint64_t addr, uint64_t size, uint64_t flag) = 0;
virtual int alloc(uint64_t addr, uint64_t size, int flag) = 0;
virtual int mktcs(uint64_t tcs_addr) = 0;
virtual int trim_range(uint64_t fromaddr, uint64_t toaddr) = 0;
virtual int trim_accept(uint64_t addr) = 0;
virtual int remove_range(uint64_t fromaddr, uint64_t numpages) = 0;

// destructor
virtual ~EnclaveCreator() {};
Expand Down
4 changes: 3 additions & 1 deletion common/inc/internal/inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ typedef enum {
SE_ERESUME,
SE_EEXIT,
SE_EACCEPT,
SE_EVERIFYREPORT2 = 0x8,
SE_EMODPE,
SE_EACCEPTCOPY,
SE_EVERIFYREPORT2,
SE_LAST_RING3,

SE_ECREATE = 0x0,
Expand Down
1 change: 1 addition & 0 deletions common/inc/internal/linux/linux-regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#define SE_EEXIT 4
#define SE_EACCEPT 5
#define SE_EMODPE 6
#define SE_EACCEPTCOPY 7
#define SE_EVERIFYREPORT2 8


Expand Down
8 changes: 5 additions & 3 deletions common/inc/internal/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
#pragma pack(1)

/* version of metadata */
#define MAJOR_VERSION 2 //MAJOR_VERSION should not larger than 0ffffffff
#define MINOR_VERSION 4 //MINOR_VERSION should not larger than 0ffffffff
#define MAJOR_VERSION 3 //MAJOR_VERSION should not larger than 0ffffffff
#define MINOR_VERSION 0 //MINOR_VERSION should not larger than 0ffffffff

#define SGX_2_ELRANGE_MAJOR_VERSION 12
#define SGX_2_ELRANGE_MAJOR_VERSION 13
#define SGX_1_ELRANGE_MAJOR_VERSION 11

#define SGX_MAJOR_VERSION_GAP 10
Expand Down Expand Up @@ -84,6 +84,7 @@
#define HEAP_SIZE_MAX 0x1000000 /* 16 MB */
#define RSRV_SIZE_MIN 0x0000000 /* 0 KB */
#define RSRV_SIZE_MAX 0x0000000 /* 0 KB */
#define USER_REGION_SIZE 0x0000000 /* 0 KB */
#define DEFAULT_MISC_SELECT 0
#define DEFAULT_MISC_MASK 0xFFFFFFFF
#define ISVFAMILYID_MAX 0xFFFFFFFFFFFFFFFFULL
Expand Down Expand Up @@ -128,6 +129,7 @@ typedef enum
#define LAYOUT_ID_RSRV_MIN (20)
#define LAYOUT_ID_RSRV_INIT (21)
#define LAYOUT_ID_RSRV_MAX (22)
#define LAYOUT_ID_USER_REGION (23)

extern const char * layout_id_str[];

Expand Down
9 changes: 7 additions & 2 deletions common/inc/internal/rts.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ typedef enum
SDK_VERSION_2_0,
SDK_VERSION_2_1,
SDK_VERSION_2_2,
SDK_VERSION_2_3
SDK_VERSION_2_3,
SDK_VERSION_3_0,
} sdk_version_t;

typedef struct _system_features
Expand Down Expand Up @@ -95,17 +96,21 @@ typedef struct _system_features
#define BUILTIN_OCALL_2 -3
#define BUILTIN_OCALL_3 -4
#define BUILTIN_OCALL_4 -5
#define BUILTIN_OCALL_5 -6
#define BUILTIN_OCALL_6 -7

typedef enum
{
EDMM_TRIM = BUILTIN_OCALL_1,
EDMM_TRIM_COMMIT = BUILTIN_OCALL_2,
EDMM_MODPR = BUILTIN_OCALL_3,
EDMM_MPROTECT = BUILTIN_OCALL_4,
EDMM_ALLOC = BUILTIN_OCALL_5,
EDMM_MODIFY = BUILTIN_OCALL_6,
}edmm_ocall_t;


#define is_builtin_ocall(ocall_val) (((int)ocall_val >= BUILTIN_OCALL_4) && ((int)ocall_val <= BUILTIN_OCALL_1))
#define is_builtin_ocall(ocall_val) (((int)ocall_val >= BUILTIN_OCALL_6) && ((int)ocall_val <= BUILTIN_OCALL_1))

#pragma pack(pop)

Expand Down
2 changes: 2 additions & 0 deletions common/inc/internal/rts_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

#define ECMD_ECALL_PTHREAD (-6)

#define ECMD_INTERRUPT (-32)

/* Reserved for 3rd party usage */
#define RESERVED_FOR_3RD_PARTY_START -100
#define RESERVED_FOR_3RD_PARTY_END -1000
Expand Down
3 changes: 3 additions & 0 deletions common/inc/internal/se_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

# include <stdlib.h>
# include <unistd.h>
# include <errno.h>
# include <time.h>
# include <sys/syscall.h>
typedef void * se_handle_t;

Expand All @@ -53,6 +55,7 @@ se_handle_t SGXAPI se_event_init(void);
void SGXAPI se_event_destroy(se_handle_t);

int SGXAPI se_event_wait(se_handle_t);
int SGXAPI se_event_timeout_wait(se_handle_t, int, const struct timespec *, int, int *);
int SGXAPI se_event_wait_timeout(se_handle_t se_event, uint64_t timeout);
int SGXAPI se_event_wake(se_handle_t);

Expand Down
59 changes: 59 additions & 0 deletions common/inc/internal/sethread_spinlock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

/*
* Copyright (C) 2022 Intel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

#ifndef _SE_THREAD_SPINLOCK_H_
#define _SE_THREAD_SPINLOCK_H_
#include "sgx_thread.h"
/** a recursive spin lock */
typedef struct _sgx_thread_spinlock_t
{
size_t m_refcount; /* number of recursive calls */
volatile uint32_t m_lock; /* use sgx_spinlock_t */
sgx_thread_t m_owner;
} sgx_thread_spinlock_t;

#define SGX_THREAD_RECURSIVE_SPINLOCK_INITIALIZER \
{0, 0, SGX_THREAD_T_NULL}
#ifdef __cplusplus
extern "C" {
#endif

int sgx_thread_spin_init(sgx_thread_spinlock_t *mutex);
int sgx_thread_spin_destroy(sgx_thread_spinlock_t *mutex);

int sgx_thread_spin_trylock(sgx_thread_spinlock_t *mutex);
int sgx_thread_spin_unlock(sgx_thread_spinlock_t *mutex);
#ifdef __cplusplus
}
#endif

#endif
1 change: 1 addition & 0 deletions common/inc/internal/sgx_mm_rt_abstraction.h
6 changes: 1 addition & 5 deletions common/inc/internal/trts_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,13 @@ struct ms_tcs
extern "C" {
#endif

int sgx_accept_forward(si_flags_t sfl, size_t lo, size_t hi);
int do_ereport(const sgx_target_info_t *target_info, const sgx_report_data_t *report_data, sgx_report_t *report);
int do_everifyreport2(const sgx_report2_mac_struct_t *report2_mac_struct);
int do_egetkey(const sgx_key_request_t *key_request, sgx_key_128bit_t *key);
uint32_t do_rdrand(uint32_t *rand);
int do_eaccept(const sec_info_t *, size_t);
int do_eacceptcopy(const sec_info_t *, size_t, size_t);
int do_emodpe(const sec_info_t*, size_t);
int apply_EPC_pages(void *start_address, size_t page_number);
int apply_pages_within_exception(void *start_address, size_t page_count);
int trim_EPC_pages(void *start_address, size_t page_number);
sgx_status_t SGXAPI trts_mprotect(size_t start, size_t size, uint64_t perms);
sgx_status_t do_add_thread(void *ms);
int is_dynamic_thread(void *tcs);
int is_dynamic_thread_exist(void);
Expand Down
2 changes: 1 addition & 1 deletion common/inc/sgx_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#define SGX_XFRM_MPX 0x0000000000000018ULL /* MPX XFRM - not supported */
#define SGX_XFRM_PKRU 0x0000000000000200ULL /* PKRU state */

#define SGX_XFRM_RESERVED (~(SGX_XFRM_LEGACY | SGX_XFRM_AVX | SGX_XFRM_AVX512 | SGX_XFRM_PKRU))
#define SGX_XFRM_RESERVED (~(SGX_XFRM_LEGACY | SGX_XFRM_AVX | SGX_XFRM_AVX512 | SGX_XFRM_MPX | SGX_XFRM_PKRU))

typedef struct _attributes_t
{
Expand Down
65 changes: 65 additions & 0 deletions common/inc/sgx_interrupt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef _SGX_INTERRUPT_H_
#define _SGX_INTERRUPT_H_

// An interrupt mechanism for dynamically-loaded workloads in enclaves.
//
// Workloads in an enclave can be classified into two categories: statically-loaded and
// dynamically-loaded workloads. Statically-loaded workloads are application code that
// are built into the enclave; that is, they are part of the enclave since enclave initialization.
// Dynamically-loaded workloads, as the name suggests, are application code loaded after
// the enclave gets running.
//
// One typical example of dynamically-loaded workloads is user programs loaded by a SGX
// LibOS. The user programs could be arbitrary code. As a result, once the user program
// gets executed, the LibOS may never have the opportunity to take control of the CPU.
// Without the ability to regain the control, it is impossible for the LibOS to implement
// features like interruptible signal handler or preemptive in-enclave thread scheduling.
//
// To address the issue above, we implement the signal-based interrupt mechanism for
// dynamically-loaded workloads. With the provided APIs, the users can now interrupt the
// dynamically-loaded workloads executed in a SGX thread by simply sending a real-time
// POSIX signal (whosenumber is 64, the max value of signal numbers on Linux) to the SGX
// thread. The signal will be captured and (if the timing is good) a pre-registered
// interrupt handler will get executed inside the enclave.
//
// Note that the interrupt mechanism only performs the signal-to-interrupt conversion
// described above is in a best-effort manner. That is, sending a signal may not
// result in the interrupt handler getting called. For example, if the target SGX thread is
// executing some code outside the enclave, then the signal received will be simply
// ignored, thus not triggering the interrupt handler to be executed. So the users of
// the interrupt mechanism should find other means to determine if an interrupt has been
// delivered, and if not, whether and when to resend the interrupt (via POSIX signal).

#include "sgx_error.h"
#include "sgx_trts_exception.h"

// A data structure that represents an interrupt
typedef struct _sgx_interrupt_info_t {
sgx_cpu_context_t cpu_context;
} sgx_interrupt_info_t;

// A handler function that processes an interrupt
typedef void (*sgx_interrupt_handler_t)(sgx_interrupt_info_t*);

#ifdef __cplusplus
extern "C" {
#endif

// Initialize the interrupt mechanism for SGX threads.
sgx_status_t SGXAPI sgx_interrupt_init(sgx_interrupt_handler_t handler);

// Make the current thread interruptible when executing in the given code region.
//
// By default, a SGX thread is not interruptible. It is the responsibility of the
// caller of this API to ensure that the given code region is ok to be interrupted,
// e.g., not causing deadlocks.
sgx_status_t SGXAPI sgx_interrupt_enable(size_t code_addr, size_t code_size);

// Make the current thread uninterruptible.
sgx_status_t SGXAPI sgx_interrupt_disable(void);

#ifdef __cplusplus
}
#endif

#endif /* _SGX_INTERRUPT_H_ */
1 change: 1 addition & 0 deletions common/inc/sgx_mm.h
1 change: 1 addition & 0 deletions common/inc/sgx_mm_primitives.h
1 change: 1 addition & 0 deletions common/inc/sgx_mm_rt_abstraction.h
Loading