DescriptionCommit log for first patchset:
---------------
i#2089 TLS init: use a magic field to indicate init
Puts in a new scheme for is_thread_tls_initialized(): rather than reading
thread id fields and comparing to expensive syscalls, and trying to
distinguish different fork and clone children, we instead use a very simple
approach. We add a magic number field to our TLS and
is_thread_tls_initialized() simply does a safe read of that field: if it
equals our magic number, it's initialized.
On a clone, the parent swaps to a separate private TLS with an invalid
magic field. The child inherits this and thus starts out correctly
uninitialized, while the parent's syscall gencode still works as it ignores
the magic field. The parent's TLS is restored first thing in dispatch().
On a fork, nothing is done, and thus the magic number remains and the child
is correctly initialized.
We avoid safe read faults on thread exit by pointing the exiting thread's
TLS at a fake TLS with an invalid magic number. This is efficient for regular
threads and required for threads missing CLONE_SIGHAND, for which we must
also skip the segment zeroing at thread exit.
On swapping to native, we also put in the private TLS. On re-take-over, we
add new queries (including using a special "invalid" magic number to
distinguish from a completely unknown thread) and TLS swaps to several
attach points to avoid thinking that a NULL dcontext or
!is_thread_tls_initialized() means an unknown thread.
Generalizes the segment swapping code to correctly swap DR's segment too
instead of what it did before where it took in a segment parameter but then
hardcoded the register to use.
The app using the aux segment is not yet supported: that's i#2088/i#107.
The new scheme is under the -safe_read_tls_init option, which is now on by
default. Once we're sure it's stable we'll remove the option and the old
code.
Adds a new test linux.clone-pie, a PIE build of linux.clone, which forces
the use of the MSR for TLS instead of the GDT and results in a crash with
-no_safe_read_tls_init.
Expands the linux.clone* tests to also test a thread without CLONE_SIGHAND.
Fixes #2089
---------------
Patch Set 1 #Patch Set 2 : Committed #
MessagesTotal messages: 2
|