Commit Graph

299 Commits

Author SHA1 Message Date
Tate, Hongliang Tian
a7400ca6dc Fix thread exiting but not being freed 2020-03-31 14:47:31 +00:00
LI Qing
23329efe14 Fix the broken dependency on SEFS
SEFS depends on version 0.9 of bitvec crate, which has been yanked on crates.io
by the crate author for some reasons. To fix this, we upgrade to the latest
version of bitvec crate.
2020-03-30 08:58:57 +00:00
Tate, Hongliang Tian
1eefa0a123 Fix poll when given negative fds 2020-03-27 18:00:49 +08:00
Tate, Hongliang Tian
6dbdbfdcf0 Fix potential deadlocks caused by epoll/poll/select 2020-03-27 05:42:20 +00:00
Tate, Hongliang Tian
1a35188212 Simplify the frequent code of getting a file reference 2020-03-26 10:34:14 +00:00
Tate, Hongliang Tian
5933499f9b Refactor LibOS to conform with logging strategy
This commit introduces a unified logging strategy, summarized as below:

1. Use `error!` to mark errors or unexpected conditions, e.g., a
 `Result::Err` returned from a system call.
2. Use `warn!` to warn about potentially problematic issues, e.g.,
 executing a workaround or fake implementation.
3. Use `info!` to show important events (from users' perspective) in
 normal execution, e.g., creating/exiting a process/thread.
4. Use `debug!` to track major events in normal execution, e.g., the
 high-level arguments of a system call.
5. Use `trace!` to record the most detailed info, e.g., when a system
 call enters and exits the LibOS.
2020-03-25 02:53:31 +00:00
Tate, Hongliang Tian
9713e74ed9 Add the support for setting log level at runtime
Now one can specify the log level of the LibOS by setting `OCCLUM_LOG_LEVEL`
environment variable. The possible values are "off", "error", "warn",
"info", and "trace".

However, for the sake of security, the log level of a release enclave
(DisableDebug = 1 in Enclave.xml) is always "off" (i.e., no log) regardless of
the log level specified by the untrusted environment.
2020-03-25 01:40:47 +00:00
Tate, Hongliang Tian
6d7cf7b9f6 Add more info to log messages (e.g., timestamp, thread, and round) 2020-03-25 01:34:41 +00:00
Tate, Hongliang Tian
dddcb89f7e Refactor the LibOS entry point by introducing system call table
This commit introduces a system call table, which brings several benefits:

1. The table is a centralized info hub that one can find an answer for every
question about system calls, e.g., what is the number and arguments of a
system call, is it implemented or supported, and if so, what is the
function that actual implements it.

2. System call-related code can be automatically derived from the system call
table through a clever use of macros. In this way, the code avoids repeating
itself.
2020-03-25 01:15:18 +00:00
LI Qing
c1669791f6 Update the SEFS submodule 2020-03-24 14:49:21 +00:00
He Sun
65694815a4 Add eventfd file type and system call 2020-03-24 22:16:41 +08:00
LI Qing
f7ce60e764 Fix the emulation of RDTSC instruction with ocall 2020-03-24 22:06:14 +08:00
He Sun
e2edaa49c0 Change the flags used in sendmsg/recvmsg from raw int to memory-safe type 2020-03-24 21:51:04 +08:00
LI Qing
eff91daac9 Add timeout support for futex wait 2020-03-24 20:05:06 +08:00
LI Qing
96876b2935 Add rename for hostfs 2020-03-23 02:45:47 +00:00
He Sun
8842af88f3 Fix incompatibility between OpenVino with musl libc 2020-03-21 08:52:37 +00:00
LI Qing
23817fc659 Add fstatat and openat system calls 2020-03-09 16:20:51 +00:00
Tate, Hongliang Tian
66dec604e4 Update the version number to 0.10.0 2020-03-09 04:17:48 +00:00
Hui, Chunyang
95ef2819db Add local attestation demo 2020-03-09 04:17:41 +00:00
Hui,Chunyang
83dfdc4f0f Add explanation for usage of SGX simulation mode 2020-03-07 09:46:31 +00:00
Hui, Chunyang
15ce6efdc0 Add simulation support for Occlum embedded mode demo 2020-03-07 09:45:50 +00:00
Hui,Chunyang
4ebedd9bf5 Improve simulation mode user experience
Simulation mode and hardware mode can both work without rebuild Occlum.
2020-03-07 09:44:49 +00:00
He Sun
06f7763d55 Fix a bug in poll that modifies input fds 2020-03-07 17:37:52 +08:00
He Sun
74fad28938 Add performance profiler for threads and system calls 2020-03-07 17:35:39 +08:00
zongmin.gu
a1e003ebdb Fix two bugs by updating SDK's stack ranges on user/kernel switch
Before this commit, there are two strange bugs:
1. No backtraces are displayed on panic by Rust; and,
2. Thread local storage in Rust sometimes causes panics.

It turns out that the the root cause of the two bugs are the same: Occlum's
patch to Intel SGX SDK that informs SDK about the stack range of the currnet
LibOS user-level thread. The problem about this patch is that it modifies some
fundamental data structures and Rust SGX SDK does not know the modification.
This causes Rust SGX SDK to panic in certain conditions.

To resolve the conflict for good, this commit gets rid of the patch to Intel
SGX SDK by updating SDK's stack ranges upon user/kernel switch.
2020-03-07 08:17:40 +00:00
LI Qing
6f986855e9 Fix the issue that process resource cannot be freed in some cases
If untrusted app calls "occlum_pal_exec" sequentially or concurrently,
Occlum cannot free the resource of the enclave process correctly.
2020-03-02 14:42:19 +00:00
sanqian.hcy
b08f5b9ceb Add support for SGX simulation mode
1. Use arch_prctl to replace RDFSBASE/WRFSBASE
Ptrace can't get right value if WRFSBASE is called which
will make debugger fail in simulation mode. Use arch_prctl
to replace these instructions in simulation mode.

2. Disable the busy thread in exit_group test
exit_group doesn't have a real implementation yet but test
under SGX simulation mode give core dump for exit_group test.
Disable the busy loop thread and the core dump disappear.

3. Add SDK lib path to LD_LIBRARY_PATH
Linker sometims can't find urts_sim and uae_service_sim when
running. Explicitly add path to LD_LIBRARY_PATH when running
occlum command.

Signed-off-by: sanqian.hcy <sanqian.hcy@antfin.com>
2020-03-01 06:42:33 +00:00
LI Qing
045ea46e9f Extend CPUID emulation for Intel Celeron and newer Intel CPUs 2020-02-28 10:53:38 +00:00
LI Qing
bbd4cd9be2 Add fstat() and poll() for the random device 2020-02-27 03:41:05 +00:00
LI Qing
9f1fa883df Fix GDB cannot work in release build 2020-02-26 06:58:18 +00:00
LI Qing
3e81b42912 Add SQLite demo 2020-02-25 11:14:48 +00:00
LI Qing
551fb8f9d8 Add a dummy implementation for file advisory locks
This commits is a dummy implementation of file advisory locks.
Specifically, for regular files, fcntl `F_SETLK` (i.e., acquiring
or releasing locks) always succeeds and fcntl `F_GETLK` (i.e., testing locks)
always returns no locks.
2020-02-25 17:31:02 +08:00
Tate, Hongliang Tian
a6e55881b9 Add ioctls for SGX local attestation 2020-02-19 14:48:12 +00:00
LI Qing
76b90efa8f Fix read_at() in SEFS if offset beyond the end of the file 2020-02-14 08:05:29 +00:00
LI Qing
bd56504b20 Add GDB support for apps running upon Occlum
Please see the "gdb_support" in demos to find out how to
use GDB to debug your apps running upon Occlum.
2020-02-14 07:52:45 +00:00
LI Qing
de904bf628 Refactor the structure of FS subsystem
1. Move the system call handling functions into the "syscalls.rs"
2. Split syscall memory safe implementations into small sub-modules
3. Move the unix_socket and io_multiplexing into "net"
4. Remove some unnecessary code
2020-02-14 06:19:49 +00:00
He Sun
cfa6532768 Fix bugs that fail CentOS Dockerfile 2020-02-14 06:19:48 +00:00
LI Qing
2372ef0d4e Fix make submodule command error 2020-02-10 12:02:23 +00:00
Tate, Hongliang Tian
e96892d348 Update version number to 0.9.0 2020-01-23 10:04:38 +00:00
He Sun
e352a190ea Optimize the perf of sendmsg/recvmsg by allocating untrusted buffers directly
It is slow to allocate big buffers using SGX SDK's malloc. Even worse, it
consumes a large amount of precious trusted memory inside enclaves. This
commit avoids using trusted buffers and allocates untrusted buffers for
sendmsg/recvmsg directly via OCall, thus improving the performance of
sendmsg/recvmsg. Note that this optimization does not affect the security of
network data as it has to be sent/received via OCalls.
2020-01-23 06:58:51 +00:00
Tate, Hongliang Tian
c3d042dcd0 Refactor EDL for adding custom C types easily
Before this commit, using custom C types in ECalls/OCalls defined in Occlum's
EDL is cumbersme. Now this issue is resolved by providing `occlum_edl_types.h`
header file. There are two versions of this file: one is under
`src/libos/include/edl/` for LibOS, the other is under
`src/pal/include/edl/` for PAL. So now to define a new custom C type, just
edit the two versions of `occlum_edl_types.h` to define the type.
2020-01-23 06:58:46 +00:00
Tate, Hongliang Tian
986d1d2e44 Fix ioctl SGX_IOC_GET_EPID_GROUP_ID for EBUSY error
SGX SDK's sgx_init_quote may return SGX_ERROR_BUSY, which is previously not
handled. The implementation of ioctl for /dev/sgx is now fixed to handle this
error.
2020-01-23 04:40:54 +00:00
Tate, Hongliang Tian
c6bcbaf442 Fix some typos 2020-01-23 04:40:54 +00:00
Tate, Hongliang Tian
671da280d8 Add support for compiling C code as well as Rust in release mode
We can now build all source code (.S, .c, and .rs) under `src/` in release
mode with `OCCLUM_RELEASE_BUILD=1 make` command.
2020-01-23 04:40:54 +00:00
LI Qing
d825351f02 Fix potential overflow or underflow of offset in INodeFile's seek 2020-01-23 04:40:54 +00:00
LI Qing
449ba1d5d9 Add Dockerfile for Ubuntu 18.04 2020-01-23 04:40:54 +00:00
He Sun
295d52fbe8 Add pipe support for fcntl's F_GETFL and F_SETFL commands 2020-01-23 04:40:54 +00:00
LI Qing
343c19391a Add Python demo 2020-01-23 04:40:54 +00:00
LI Qing
488ec48fe7 Upgrade Rust SGX SDK and its deps to the latest
1. Upgrade Rust SGX SDK to v1.1.0
2. Upgrade Intel SGX SDK to v2.7.1
3. Upgrade Rust to nightly-2019-11-25
2020-01-23 04:40:54 +00:00
Tate, Hongliang Tian
f2b4e96ed0 Add a demo for the embedded mode 2020-01-23 04:40:54 +00:00