There are two types of stacks: the kernel ones and the user ones. The kernel stacks are used by Occlum and managed by Intel SGX SDK itself, while the user stacks are used by the threads created and managed by Occlum. These user stacks are transparent to Intel SGX SDK so far. The problem is that Intel SGX SDK needs to be aware of the user stacks. SGX exception handlers will check whether the rsp value---when the exception happened---is within the stack of the current SGX thread. If the check fails, the registered exception handler will not be triggered. But when exceptions are triggered by the threads running upon Occlum, the rsp value points to the user stacks, which Intel SGX SDK are completely unware of. So the check always fails. Therefore, we extend Intel SGX SDK with two new APIs: int sgx_enable_user_stack(size_t stack_base, size_t stack_limit); void sgx_disable_user_stack(void); And this commit uses the two APIs to inform Intel SGX SDK about the Occlum-managed stacks. And the rsp checks in SGX exception handlers will check whether rsp is within the user stacks. |
||
---|---|---|
.. | ||
main.c | ||
Makefile |