Support Occlum statically-linked mode #295
kailun-qin
started this conversation in
Ideas
Replies: 1 comment
-
We could continue to evaluate ROI of the static mode. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Motivation
Comparing to Occlum LibOS mode, this statically-linked mode is targeting:
-- for users who do not wish to include the whole LibOS
-- achieved by linking only to the used functions
-- eliminate unnecessary overhead (register switches) for some syscalls
-- LibOS grpc uds
Drafted Design
High Level Design
Work flow
i. init log_level
ii. register_exception_handlers
iii. init interrupt
i. prepare environment
-- fake/dummy task
-- prepare syscall stack
-- save & set task (%gs)
ii. app: main
-- sgx_tcxx/sgx_tstdc
-- musl libc
-- syscall
-- Occlum syscall handler
-- do_syscall
-- (ocalls/hostcalls)
-- do_sysret
iii. restore environment
-- restore %gs
PoC
Changes Possibly Required
i. main/func as normal
ii. built to .a
i. link order (-Wl,--start-group ...-lsgx_tcxx -lsgx_tstdc -lmusl_c... -Wl,--end-group)
i. weak for all funcs
ii. set __occlum_entry
-- weak extern hidden size_t __occlum_syscall_linux_abi(void) {}
-- __occlum_entry = (size_t)__occlum_syscall_linux_abi
-- init enclave -> special ecall, construct function
i. fake dummy task
-- prepare syscall stack
-- set and restore %gs
ii. no need for __exec_task (save kernel fsbase, user user fsbase & stack, jmp to user code)
i. no need for wrfsbase
i. used to bond w/ process
ii. skip searching from the file table
iii. use fd directly from syscalls
i. from_user::check_array, from_user::check_mut_ptr etc.
Reference Implementation
Occlum PR
musl PR
TODO / Open for Discussions
Beta Was this translation helpful? Give feedback.
All reactions