12 Commits
Author SHA1 Message Date
borysp 989dac6fc8 [Pal] Fix semantics of DkSegmentRegister
On x64 DkSegmentRegister had weird semantics which also disabled some
usages like `0` as fsbase.
2020-12-17 16:18:26 +01:00
Michał Kowalczyk 61a9534921 [Pal] Fix broken Thread test
Almost everything in this test was wrong:
  - race on `count = 100` in the main thread and `count++` in the
    worker thread
  - using volatile as atomic
  - dead code after `DkThreadExit`, which is `noreturn`
  - checking if noreturn function didn't actually return
  - doing the above with 500 loop iterations
2020-06-16 16:18:30 +00:00
Stefan Berger fff09c00af Add -Wmissing-prototypes to CFLAGS and deal with the fallout 2020-06-04 17:22:19 +02:00
Stefan Berger 679dcb134e [Pal] Merge Pal/test directory into Pal/regression
Move and clean up all testcases from the Pal/test directory into the
Pal/regression and add them to CI. Some of them were redundant and thus
got removed.
2020-04-08 00:58:19 +02:00
Dmitrii Kuvaiskii 40c08ff75a [LibOS, Pal/{Linux,Linux-SGX}] Remove DkObjectsWaitAny()
Now Graphene supports an improved version of DkObjectsWaitAny() with
correct polling semantics -- DkObjectsWaitEvents(). This makes
DkObjectsWaitAny() obsolete. This commit removes DkObjectsWaitAny()
and replaces it with:
- DkSynchronizationObjectWait() to wait on a single synchronization
  object like mutex or event.
- DkStreamsWaitEvents() to wait on stream-like objects (this is the
  renamed DkObjectsWaitEvents()).

The corresponding tests are fixed to use the new PAL interfaces.
Also, IPC helper and Async helper threads are significantly refactored
to make better use of DkStreamsWaitEvents().
2020-01-14 20:31:40 -08:00
Dmitrii Kuvaiskii b194aa17fb [LibOS,Pal] Correctly emulate CLONE_CHILD_CLEARTID
When child thread exits, it wakes up its parent if CLONE_CHILD_CLEARTID was set
during clone() call. Previously, this was done by the child thread itself as
part of its own clean-up in release_clear_child_id(). But this child thread is
still alive at this point and uses some resources, most notably the stack (that
might have been provided by the parent) and the SGX TCS slot. Upon waking up,
the parent might decide to free that stack (as Pthreads do) or re-use the TCS
slot, causing data races.

This commit introduces a correct emulation of CLONE_CHILD_CLEARTID:
- A new argument `PAL_PTR clear_child_tid` is added to DkThreadExit();
  it points to internal Graphene memory that is erased on child exit to notify
  Async Helper thread.
- At PAL layer, when thread finally exits, it sets PAL-level *clear_child_tid = 0
  (corresponds to &clear_child_tid_val_pal at LibOS level);  this signals to LibOS
  layer that the thread stopped using resources.
- At LibOS layer, Async Helper thread is set up to wait for the signal from
  PAL; it is now the responsibility of Async Helper thread to call
  release_clear_child_id() to wake up the parent thread.
- Async Helper thread waits for clear_child_tid_val_pal == 0 and then sets
  the actual clear_child_tid to 0 and wakes up the waiting parent.

Note that for Linux-SGX PAL, clear_child_tid is set to 0 not immediately
but as part of handle_thread_reset, otherwise the TCS slot could be still
occupied when LibOS wakes up the parent.

As a side effect, the LibOS code for threads/process exit is cleaned up.

This commit also fixes all regression tests to use the new signature of
DkThreadExit() and increases the number of SGX threads slightly (to
accommodate the newly used Async Helper thread).
2019-12-03 21:19:07 -08:00
Michał Kowalczyk de42ebabe1 Reformat repository to our clang-format rules 2019-09-09 22:11:23 +02:00
Chia-Che Tsai be9852784f [All components] Remove all modelines from all source files 2019-06-07 15:30:43 -05:00
Isaku Yamahata 8dd311a353 [Pal/Linux-SGX] Add format check to pal_printf
Add __attribute__((format(printf))) check to pal_printf and
fix corresponding format errors.
2019-05-01 15:50:12 -07:00
Li Lei 195c2b1f7b [PAL] Enable Wunsed-parameter warning as part of Wextra 2019-04-03 14:27:43 +02:00
Chia-Che Tsai 48f330c88b [Linux/SGX PAL] Use the C11 standard instead of GNU99
Signed-off-by: Chia-Che Tsai <chiache@tamu.edu>
2019-02-10 13:52:18 -06:00
Chia-Che Tsai 7f19f62f31 beta version 0.2
Plenty of bugfixes for Linux kernel later than 3.5 and Ubuntu later than 10.10.
More organized code to improve portability.
Regression tests for Pal to test completeness of implementation.
2015-05-20 14:15:52 -04:00