diff options
author | ed <ed@FreeBSD.org> | 2016-04-06 11:11:31 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2016-04-06 11:11:31 +0000 |
commit | e55c02e6f81af885baabf454832a1908013331f5 (patch) | |
tree | b34a51eca356eac838df8dddb88435653105bae9 /sys/contrib/cloudabi | |
parent | f5a4347e1c8f2e48ca0d0185b8c27fb25c428c27 (diff) | |
download | FreeBSD-src-e55c02e6f81af885baabf454832a1908013331f5.zip FreeBSD-src-e55c02e6f81af885baabf454832a1908013331f5.tar.gz |
Make CloudABI's way of doing TLS more friendly to userspace emulators.
We're currently seeing how hard it would be to run CloudABI binaries on
operating systems cannot be modified easily (Windows, Mac OS X). The
idea is that we want to just run them without any sandboxing. Now
that CloudABI executables are PIE, this is already a bit easier, but TLS
is still problematic:
- CloudABI executables want to write to the %fs, which typically
requires extra system calls by the emulator every time it needs to
switch between CloudABI's and its own TLS.
- If CloudABI executables overwrite the %fs base unconditionally, it
also becomes harder for the emulator to store a backup of the old
value of %fs. To solve this, let's no longer overwrite %fs, but just
%fs:0.
As CloudABI's C library does not use a TCB, this space can now be used
by an emulator to keep track of its internal state. The executable can
now safely overwrite %fs:0, as long as it makes sure that the TCB is
copied over to the new TLS area.
Ensure that there is an initial TLS area set up when the process starts,
only containing a bogus TCB. We don't really care about its contents on
FreeBSD.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D5836
Diffstat (limited to 'sys/contrib/cloudabi')
-rw-r--r-- | sys/contrib/cloudabi/cloudabi64_types.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/contrib/cloudabi/cloudabi64_types.h b/sys/contrib/cloudabi/cloudabi64_types.h index 88babaa..cb354d4 100644 --- a/sys/contrib/cloudabi/cloudabi64_types.h +++ b/sys/contrib/cloudabi/cloudabi64_types.h @@ -192,6 +192,13 @@ _Static_assert(offsetof(cloudabi64_subscription_t, proc_terminate.fd) == 16, "In _Static_assert(sizeof(cloudabi64_subscription_t) == 56, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_subscription_t) == 8, "Incorrect layout"); +typedef struct { + _Alignas(8) uint64_t parent; +} cloudabi64_tcb_t; +_Static_assert(offsetof(cloudabi64_tcb_t, parent) == 0, "Incorrect layout"); +_Static_assert(sizeof(cloudabi64_tcb_t) == 8, "Incorrect layout"); +_Static_assert(_Alignof(cloudabi64_tcb_t) == 8, "Incorrect layout"); + typedef void cloudabi64_threadentry_t(cloudabi_tid_t tid, uint64_t aux); typedef struct { |