mystikos
mystikos copied to clipboard
Implement multi-threading in kernel with M:N mapping
We should support M:N mapping from target threads to user threads in the kernel. Target threads are from underlying platforms, in the case of SGX, it would be ethreads. In the case of OP-TEE or UEFI, it's the main thread that the platform started. In any case, the kernel needs to create a mapping so that the user space still sees possibly unlimited number of threads when it calls pthread_create.
Alongside the M:N mapping, the kernel becomes the thread manager, which removes potential security risk from the host on SGX platform. The in-enclave thread manager also makes possible trust-worthy handling of syscalls related to thread priorities and affinities, such as SYS_sched_getaffinity, SYS_sched_setaffinity, SYS_sched_setparam, SYS_sched_getparam, etc.