Skip to content

Commit 7eb4370

Browse files
rchatrehansendc
authored andcommitted
selftests/sgx: Introduce dynamic entry point
The test enclave (test_encl.elf) is built with two initialized Thread Control Structures (TCS) included in the binary. Both TCS are initialized with the same entry point, encl_entry, that correctly computes the absolute address of the stack based on the stack of each TCS that is also built into the binary. A new TCS can be added dynamically to the enclave and requires to be initialized with an entry point used to enter the enclave. Since the existing entry point, encl_entry, assumes that the TCS and its stack exists at particular offsets within the binary it is not able to handle a dynamically added TCS and its stack. Introduce a new entry point, encl_dyn_entry, that initializes the absolute address of that thread's stack to the address immediately preceding the TCS itself. It is now possible to dynamically add a contiguous memory region to the enclave with the new stack preceding the new TCS. With the new TCS initialized with encl_dyn_entry as entry point the absolute address of the stack is computed correctly on entry. Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Acked-by: Jarkko Sakkinen <jarkko@kernel.org> Link: https://lkml.kernel.org/r/93e9c420dedf5f773ba6965c18245bc7d62aca83.1652137848.git.reinette.chatre@intel.com
1 parent 67f1f70 commit 7eb4370

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/testing/selftests/sgx/test_encl_bootstrap.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ encl_entry:
4545
# TCS #2. By adding the value of encl_stack to it, we get
4646
# the absolute address for the stack.
4747
lea (encl_stack)(%rbx), %rax
48+
jmp encl_entry_core
49+
encl_dyn_entry:
50+
# Entry point for dynamically created TCS page expected to follow
51+
# its stack directly.
52+
lea -1(%rbx), %rax
53+
encl_entry_core:
4854
xchg %rsp, %rax
4955
push %rax
5056

0 commit comments

Comments
 (0)