63 Commits

Author SHA1 Message Date
Paweł Marczewski 6ea8e951f0 [LibOS] Use GS register for syscalls
Instead of depending on dynamic linking for LibOS entry point
(syscalldb), we pass a pointer in the shim_tcb structure, so that
the patched code can enter syscall using 'jmp *%gs:<offset>'.

The same applies to the vDSO syscall code that previously needed
an up-to-date pointer to syscalldb function. Now, there is no
need to adjust the values inside the vDSO page.

In addition, this change removes the other two instances where we
import a symbol directly from LibOS: register_library (can be also
done through GS register) and glibc_version (not important because
we build Graphene and glibc together).

This simplifies things because the dynamic linking necessary to
make the syscalldb function available had to be performed by LibOS
itself (in many cases, effectively doing a second pass of dynamic
linking after ld.so). After this change, there will be no need for
LibOS to perform dynamic linking, and the ELF loading code can be
simplified.

Signed-off-by: Paweł Marczewski <pawel@invisiblethingslab.com>
2021-02-15 22:19:28 +01:00
Paweł Marczewski a06b93d8dc [LibOS] Drop support for glibc 2.23
Signed-off-by: Paweł Marczewski <pawel@invisiblethingslab.com>
2021-02-09 16:34:22 +01:00
Stefan Berger c1ea3d9321 [LibOS] Build glibc with the stack protector enabled 2021-01-12 08:23:43 -05:00
Dmitrii Kuvaiskii 73b774f5eb [LibOS] Makefile: Revert commit 'Make sure to build GCC with GCC'
Unfortunately, specifying environment variables like CC, CXX, AS
during GCC build leads to strange errors. The official GCC docs
simply state "defining certain environment variables such as CC
can interfere with the functioning of make". So we unset them
explicitly for the GCC build.
2020-10-02 01:17:51 -07:00
Paweł Marczewski 2a18591848 [LibOS] Make sure to build GCC with GCC 2020-09-07 17:12:16 +00:00
Paweł Marczewski dbb734ada6 [LibOS] Make sure to build glibc with GCC 2020-09-07 17:12:16 +00:00
Dmitrii Kuvaiskii a440d54536 [LibOS] Build GCC with patched libgomp.so (OpenMP runtime library)
Many multi-threaded applications rely on OpenMP for efficient
parallelism. Such applications link against the libgomp.so lib.
Unfortunately, the native libgomp.so uses a raw SYSCALL instruction
to issues futex() syscalls instead of syscall() Glibc wrapper (for
performance reasons). SYSCALL instructions are executed on hot paths
of OpenMP, but they are forbidden inside SGX enclaves, so Graphene
traps-and-emulates them. This is very expensive, so this commit
introduces an optional `make -C LibOS gcc` to build libgomp.so where
SYSCALL is replaced by direct call into Graphene, similar to how we
patch Glibc. See `openmp` LibOS regression manifest for example.
This patched libgomp.so improves SGX performance of e.g. PyTorch:
from 25% perf overhead over native to 8% on some workloads.

Note that libgomp.so is built as part of GCC, and the build takes
30 min to 2 hours. That's why we make it optional and do not build
in Jenkins.
2020-08-24 11:00:50 -07:00
Dmitrii Kuvaiskii 9e0f361de4 [LibOS] Remove unused IPC parts, Graphene syscalls and liblibos
This commit removes a lot of unused code in LibOS:
- Graphene-introduced syscalls msgpersist(), benchmark_rpc(),
  send_rpc(), recv_rpc() are removed completely. We decided to
  introduce new Graphene-specific functionality through pseudo-
  files and maybe IOCTLs, but not new syscalls.
- Because of the removed syscalls, there is no need for liblibos
  library and corresponding Glibc patches.
- Complex and useless features of the IPC subsystem are removed:
  - Moving SYS-V resources to "appropriate" nodes based on scores.
  - All code under USE_SHARED_SEMAPHORE macro.
  - All code under MIGRATE_SYSV_MSG and MIGRATE_SYSV_SEM macros.
  - NOP, arbitrary RPC messages in IPC.
- Useless tests are removed: rpc_latency{2} under benchmark and
  msg_{create,send}_libos under native.
2020-08-10 09:50:11 -07:00
borysp 420a56b402 Make symlinks in Runtime directory relative 2020-07-29 20:45:01 +02:00
Michał Kowalczyk 2552cf0f35 [LibOS] glibc: Overwrite instead of appending to build.log 2020-07-13 14:28:36 +02:00
Dmitrii Kuvaiskii 8ae949b478 [LibOS] Improve Glibc patches to contain complete index hashes
Previously, Glibc patches were generated with shortened index hashes.
This commit re-generates all Glibc patches with complete index
hashes using `--full-index` option.

This commit also removes mentions of removed old Glibc 2.19 and the
unused Gold ld patch.
2020-07-07 20:42:51 +00:00
Stefan Berger fe772752f1 [LibOS] Use elf/ld-linux-x86_64.so.2 only on x86_64
GLIBC_LIBS needs to have a per-architecture dynamic linker library.
2020-05-21 07:08:47 +00:00
Dmitrii Kuvaiskii b79940aada [Makefiles] Make Graphene build on Clear Linux
Clear Linux ships with Glibc built with `-Wp,-DFORTIFY_SOURCE=2`.
This overwrites Graphene's `-UFORTIFY_SOURCE` because of the quirk
in how GCC applies arguments (first without Wp, then with Wp).
This commit updates Makefiles to use `-Wp,-UFORTIFY_SOURCE`.
2020-05-01 23:35:49 +00:00
Dmitrii Kuvaiskii 997d84c40e [LibOS] Add Glibc 2.31 (used in Ubuntu 20.04) 2020-03-17 21:57:11 +01:00
Dmitrii Kuvaiskii d0aef30b8c [LibOS] Remove malloc-arena-size patch; consolidate liblibos patch 2020-03-17 21:57:11 +01:00
Isaku Yamahata df358b8ba8 [Make] Consistently use $(RM) instead of rm -f 2020-02-12 01:09:21 +01:00
Isaku Yamahata 50bdec8a23 [LibOS,Pal] Move Makefile.Host under Scripts/ 2020-02-05 23:21:05 -08:00
Isaku Yamahata 35dd8c9423 [LibOS,Pal] Consolidate export DEBUG in Makefile.configs 2020-02-05 23:21:05 -08:00
Isaku Yamahata 0912f20ccf [LibOS,Pal] Unify the setting of CC and remove raw gcc invocations 2020-02-05 23:21:05 -08:00
Isaku Yamahata 732712e23e [LibOS,Pal] Move makefile libraries under Scripts/
This commit moves Makefile.configs, Makefile.rules, and Makefile.Test
under Scripts/ and adjusts their includes.
2020-02-05 23:21:04 -08:00
Simon Gaiser 9052837dfc [Make] Improve download handling
Instead of implementing downloading of external resources in every
Makefile again, use one script. This script adds the following
features:

 - Always check the download against a known SHA-256 hash.

 - Support caching of downloaded resources (set DL_CACHE=/some/dir).

 - Allow offline builds if all files are cached. If DL_OFFLINE=true the
   build will never attempt to download anything.
2020-02-05 00:41:10 +01:00
Simon Gaiser 7377a787bc [Makefile] Add distclean target
Before, there was no target that cleaned up downloaded sources. This
commit adds a distclean target to match the 'apps' Makefiles.
2020-02-04 01:15:08 +01:00
Wojtek Porczyk 101371683a [LibOS] Sanitize glibc build script
The academic-quality build script was supplanted by industry-grade
Makefile rule.

Also, glibc 2.19 is not supported, because it is not present in any
supported distro.
2019-12-02 18:50:13 +01:00
Isaku Yamahata 2cb174cd8e [LibOS] Eliminate GLIBC_DISABLE_VDSO and remove vdso-related patch to Glibc 2019-11-25 17:29:58 -08:00
Simon Gaiser 2d29f7aaeb [Makefile] Drop SGX_RUN
For detection of SGX/non-SGX (for example in regression tests) always
use the SGX environment variable. To generate launch/EINIT tokens use
the new 'sgx-tokens' Make target.
2019-09-27 12:38:14 +02:00
Simon Gaiser 13cac1df92 [Makefile] Fix missing cleans 2019-09-27 03:45:21 +02:00
Isaku Yamahata b82d838b7e [LibOS] Remove setting PARALELLMFLAGS for Glibc build
Previously, PARALLELMFLAGS variable caused warnings during Glibc build:
"-jN forced in submake: disabling jobserver mode". Since make supports
the jobserver such that passing -jN to parent make automatically allows
its child make to parallelize its jobs, we do not have to pass -j flags
to the child make.
2019-08-16 13:36:30 -07:00
Chia-Che Tsai dc8b63ce62 [Glibc] Update Glibc version to 2.23 and 2.27
Previously, Graphene supported Glibc version 2.19 only. This commit
adds support for Glibc v2.23 (default in Ubuntu 16.04) and Glibc
v2.27 (default in Ubuntu 18.04). The exact version can be chosen by
specifying GLIBC_VERSION during Graphene build. The default version
to be built is v2.27.

Note that for the best GDB experience it is advised to build Graphene
with the same Glibc version as installed on the host OS.
2019-08-15 13:30:53 -07:00
Isaku Yamahata 350b522263 [LibOS/Glibc] Remove Glibc modification which disabled vDSO
vDSO is supported by Graphene now, so this commit removes the
modification of Glibc which disabled vDSO in Graphene. Currently,
compile-time option GLIBC_DISABLE_VDSO is introduced to be able
to revert to the old behaviour (disabled by default).
2019-08-14 18:51:59 -07:00
Simon Gaiser 1ff85d10a3 [Makefile] Move building of tests to a separate target
Fixes #204.
2019-08-14 00:44:17 +02:00
Isaku Yamahata 2a54d1915b [LibOS] Remove PARALLELMFLAGS hack from buildglibc.py
Remove PARALLELMFLAGS replacing logic from buildglibc.py and instead use
$(MAKE) PARALLELMFLAGS="-j `nproc`"
2019-08-13 19:03:47 +02:00
Don Porter a0c208f71e [Makefiles] Enable parallel make in Jenkins, fix parallel make for SGX 2019-06-20 19:16:10 -07:00
Chia-Che Tsai 2f39783a33 [GLIBC] Fix the Makefile 2019-06-01 03:33:13 +02:00
Isaku Yamahata c2da06e3ed [LibOS] Remove USE_clone_FOR_fork and glibc patch for fork 2019-05-29 01:44:49 +02:00
Chia-Che Tsai 05a65c6188 [GLIBC] Move syscalldb implementation to a separate patch 2019-05-28 13:09:22 -04:00
Chia-Che Tsai c0c45bc679 [LibOS] Separate glibc patch and source files for liblibos 2019-05-24 20:42:22 +02:00
Chia-Che Tsai 1df0204555 [LibOS/Glibc] Separate Glibc patch for supporting ld.gold 2019-05-23 17:19:29 -07:00
Isaku Yamahata c806e5b437 [LibOS/glibc] Make fork-instead-of-clone patch optional
Previously, in-LibOS Glibc was patched to prefer fork()
over clone(!CLONE_VM) to spawn a new process. Now that
clone(!CLONE_VM) works correctly, this patch is not needed.
Thus, this Glibc patch is made optional.
2019-05-22 03:51:40 -07:00
Isaku Yamahata 10994e1b69 [Makefile] Use symlinks instead of cp to populate Runtime dir
Currently cp to Runtime dir is used. Sometimes it is confusing when
binaries are re-built under Pal or LibOS. Symlink is better, so use
it instead.
  - It's easy to understand where a file under Runtime dir comes from
  - It's easy to understand in which directory to run `make`
  - If cp is used, it's quite easy to test old binary under Runtime.

This patch create ln_sf rule and use it instead of cp and applies to
other recipe with cp.
In this context, creating symlink of glibc libraries is mess. This
patch also cleans it up to use Makefile instead of embedding the logic
into python script.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-26 02:47:38 +02:00
Isaku Yamahata 7ffe9ffe65 [LibOS/glibc] Add glibc dependencies to Makefile
Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-02-18 10:30:38 -05:00
Isaku Yamahata 36d243a045 [LibOS/shim/Makefile] Don't build glibc unnecessarily
Keep Success.build file by .SECONDARY instead of .INTERMEDIATE.
2019-02-11 19:50:27 +01:00
Isaku Yamahata 5a26186ed8 LibOS/Makefile: imporove handling of glibc patches
When glibc patches are updated, glibc won't be re-build.
This patch adds patches and Makefile as dependencies of glibc so that
when patches or Makefile are updated, glibc will be re-build.
2019-01-30 10:26:39 -05:00
Chia-Che Tsai 056ff6bfa9 [LibOS] Adding multiple mirrors for downloading glibc
Signed-off-by: Chia-Che Tsai <chiache@tamu.edu>
2018-12-03 20:54:39 -08:00
Michał Kowalczyk f14049316a [Build] Add make format target 2018-12-04 00:17:52 +01:00
Jat 6a1faf7874 gcc -dumpmachine returns x86_64-xxx-linux-gnu (#242)
This change normalizes the behavior of the Makefile in checking for the host system time, building across a wider range of systems.
2018-10-10 11:35:30 -07:00
Chia-Che Tsai 58e608793e Addressing GLIBC building issue with GCC 5/6/7/8 (#241) 2018-08-25 08:02:02 -07:00
Chia-Che Tsai 76cd8ed917 suppressing some glibc compilation warnings (#226) 2018-07-09 10:16:28 -07:00
Chia-Che Tsai 6e3c5aea56 deprecating .packed directories (#149)
.packed directories are originally created for testing on non-Linux platforms. The usage is mostly obsolete right now, and the binaries are completely out-dated. A better strategy would be to create a hook in the github to release binary packages.
2017-12-21 11:13:53 -05:00
Don Porter c844d24199 CI Improvements (#141)
Run CI in a Docker image

* Wait a second for lighttp and apache to fully initialize the socket

* Try to add a timeout for lmbench, which is prone to hanging (vfork)

* Set a timeout on gcc; one of the PRs is causing gcc hello to hang.  Also, to avoid interference, run apache test on 8001 by default.

* Update lmbench to ignore bin dir

* Do the faster tests first; fail earlier

* Get the IP addr properly for web server tests

* Some notes on flaky LTP tests to debug later.  Move a few that tend to heisenbugs off of the required list for now 

* Try to detect vma list corruption during the debug dump, lest it be infinite.

* Temporarily disable the lmbench vfork test (Issue #142).

* Catch some failures faster.

* Catch failures in apachebench

* Take apache out of the Linux host/Debug build CI for now, as it hangs consistently.  Filed issue #144 to track.
2017-12-09 16:34:56 -08:00
Michał Kowalczyk 3a24ad56d4 Add lacking .PHONY to Makefiles (#118) 2017-11-25 08:56:36 +00:00