Skip to content

Conversation

@jessehui
Copy link
Contributor

Currently based on https://github.com/intel/linux-sgx/tree/edmm_v5 and apply patches from Occlum. This is a workable version.

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Add a runtime agnostic enclave memory manager implementation in sdk/emm.
The EMM APIs are based on design proposed in this PR: openenclave/openenclave#3991

Enclave common loader changes are in psw/enclave_common/sgx_mm_ocalls.cpp, which are basically
OCall support needed for EMM.

Intel SDK runtime specific support are implemented as runtime abstraction layer: sdk/trts/ema_rt.c

Current limitations, steps to build and test are documented in sdk/emm/README.md

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Xiaofeng Xu <20158212+xxu36@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
The ioctl numbers for EDMM functions are shifted in upstream patches:
https://patchwork.kernel.org/project/intel-sgx/cover/cover.1638381245.git.reinette.chatre@intel.com/
Change those definitions accordingly in isgx_user.h

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Add error checking for remove ioctl()
Do emodt for multiple pages in on call

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
This is to avoid unneeded ocall references in regular mutex implementation,
which requires every enclave to import those ocalls in its EDL even if it
does not need the mutex for synchronization.

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
This reverts commit 435c34b3afeca1e4590e1ba98291159d76a403a3.
It does not work for DCAP driver
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
To minimize number of VMAs created by kernel

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Kernel(V5) allows emodpr to PROT_NONE directly

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
commit EPC of reserves before first use
fix compile error for gcc 7.5
style and typo fixes
Signed-off-by: Xiaofeng Xu <20158212+xxu36@users.noreply.github.com>
Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
This is necessary to enable builtin OCALL and commit-on-demand
for emalloc reserves

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Added a figure for overall arch
Restructure the introduction section

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
…pi docs

Signed-off-by:  Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Signed-off-by:  Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Adjust Enclave Common API compatible with existing style and definitions:
1) split flags in enclave_alloc to page type and alloc flags
2) return non-OS specific error code
3) add new API enclave_get_features

Update EMM ocall definition:
1) Return EFAULT for all ocall failures
2) align sgx_mm_alloc with enclave_alloc to use separate parameters for page
type and alloc_flags

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
Also EXEC always require READ

Signed-off-by: Haitao Huang <4699115+haitaohuang@users.noreply.github.com>
He Sun and others added 29 commits November 22, 2022 05:51
1. Fix urts_sim static library lack of symbols
2. Add new urts_sim static library needed by Occlum tools
In simulation mode, previously, ECREATE will commit all the pages which
will cause ENOMEM if the size is very big.
This patch fixed this by only reserving the pages (with PROT_NONE) in
ECREATE but committing the pages in EADD.
This solution just works for us. Need an official solution form Intel.
The first executable segment (contains code section) should have PF_X flag.
Workloads in an enclave can be classified into two categories:
statically-loaded and dynamically-loaded workloads. Statically-loaded
workloads are application code that are built into the enclave; that is,
they are part of the enclave since enclave initialization.
Dynamically-loaded workloads, as the name suggests, are application code
loaded after the enclave gets running.

One typical example of dynamically-loaded workloads is user programs
loaded by a SGX LibOS. The user programs could be arbitrary code. As a
result, once the user program gets executed, the LibOS may never have
the opportunity to take control of the CPU. Without the ability to
regain the control, it is impossible for the LibOS to implement features
like interruptible signal handler or preemptive in-enclave thread
scheduling.

To address the issue above, we implement the signal-based interrupt
mechanism for dynamically-loaded workloads. With the provided APIs, the
users can now interrupt the dynamically-loaded workloads executed in a
SGX thread by simply sending a real-time POSIX signal (whose number is
64, the max value of signal numbers on Linux) to the SGX thread. The
signal will be captured and (if the timing is good) a pre-registered
interrupt handler will get executed inside the enclave.
Also add edmm api test in the install script. Simulation mode is not test heavily.
When official EDMM support is released, this patch should be removed.
@jessehui jessehui marked this pull request as draft November 23, 2022 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants