-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EDMM: Add support for dynamic thread creation #1223
Comments
@vijaydhanraj: IMO it would be good to start the continuation of EDMM work with this feature, as it's the most user-facing one - a lot of users hit errors with their apps because of the thread limit, and the apps often handle the failure badly (i.e. it's not clear why they failed without debugging). |
Sure @mkow, currently working on a design. Once ready, will present it in our community meeting. |
I can work out the design and implement it if @vijaydhanraj doesn't have time for it. |
Design proposalCurrent Pal-SGX host prepares Here proposed that Pal-SGX enclave prepares and manages dynamic thread data: TCS, SSA, stack, sig_stack, TCB(same as TLS). At new thread creation, if no available dynamic thread data, Pal-SGX enclave allocates a dynamic thread data and pass the TCS address to Pal-SGX host. Pal-SGX host adds this dynamic TCS to Changes:
Note that there is a rare condition: This proposal doesn't alter control of static TCS, or thread creation flow. If EDMM is not enabled, everything stays the same. Impacts:manifest: No changes. Debugger: It has a Attached a flow chart of the proposal. |
I'm unclear about the following aspects:
The rest looks good to me. If I understand correctly, we will never free dynamically created threads, but instead we will reuse them. This is the same as we do with in-enclave thread stacks on the Linux PAL, see: gramine/pal/src/host/linux/pal_threading.c Lines 23 to 73 in a01265b
Feel free to reuse some parts of that logic in your implementation for Linux-SGX. |
TCS is really released after host calls EEXIT and then
The reason is similar to your second question, enclave doesn't know whether a TCS is released accurately. |
@llly presented the diagram above during today's Gramine meeting, and (at least to me) the design sounded correct. |
Description of the feature
Each executing thread in the enclave is associated with a
Thread Control Structure (TCS)
. TheTCS
contains meta-data used by the hardware to save and restore thread specific information when entering/exiting the enclave.The SGX2 extensions allow dynamically adding TCS page to an enclave there by providing capability to add/remove threads during enclave runtime and removes the hard limit of max threads that can be used in an enclave.
Why Gramine should implement it?
Gramine could get away with this (https://gramine.readthedocs.io/en/stable/manifest-syntax.html#number-of-threads) hard limit on the number of threads that can run within an enclave
The text was updated successfully, but these errors were encountered: