Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Issue 10392005: Thread suspension: Implement for Linux (Closed)

Created:
8 years, 7 months ago by Mark Seaborn
Modified:
8 years, 7 months ago
Reviewers:
bradn
CC:
native-client-reviews_googlegroups.com, halyavin, eaeltsin
Visibility:
Public.

Description

Thread suspension: Implement for Linux Linux doesn't have an equivalent of Windows's SuspendThread() call for suspending individual threads (except for ptrace(), which we can't readily use inside Chromium's outer sandbox), so we use an asynchronous signal to interrupt and suspend a thread. For speed and simplicity, and to avoid deadlocks in the signal handler, we use Linux futexes for the synchronisation. Since NaClAppThreadSetSuspendState() now has multiple implementations, it moves into the OS-specific files. Add a "generic" directory for the non-OS-specific no-op implementation. Add an implementation of NaClTlsGetIdx() for x86-32 Linux that mirrors the x86-64 equivalent so that we can get the interrupted thread's identity inside the signal handler. This is intended for use by the debug stub. However, it does not save registers yet. This just implements for Linux what we already have for Windows. BUG=http://code.google.com/p/nativeclient/issues/detail?id=2758 TEST=run_thread_suspension_test Committed: https://src.chromium.org/viewvc/native_client?view=rev&revision=8670

Patch Set 1 #

Patch Set 2 : Switch to using futexes #

Patch Set 3 : Fix build #

Patch Set 4 : Fix tests #

Patch Set 5 : Cleanup #

Patch Set 6 : Fix #if #

Patch Set 7 : Rebase; comment; fix QEMU disabling #

Patch Set 8 : Use %d #

Total comments: 20

Patch Set 9 : Comments #

Patch Set 10 : Tweaks #

Patch Set 11 : Use private futexes #

Total comments: 1

Patch Set 12 : Comment about docs #

Unified diffs Side-by-side diffs Delta from patch set Stats (+340 lines, -70 lines) Patch
M SConstruct View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M src/trusted/service_runtime/arch/x86_32/nacl_tls_32.c View 1 2 3 4 2 chunks +26 lines, -0 lines 0 comments Download
M src/trusted/service_runtime/build.scons View 1 2 4 chunks +4 lines, -16 lines 0 comments Download
A src/trusted/service_runtime/generic/thread_suspension.c View 1 2 3 4 1 chunk +29 lines, -0 lines 0 comments Download
A src/trusted/service_runtime/linux/thread_suspension.c View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +223 lines, -0 lines 0 comments Download
M src/trusted/service_runtime/nacl_app_thread.h View 1 2 3 4 5 6 3 chunks +15 lines, -9 lines 0 comments Download
M src/trusted/service_runtime/nacl_app_thread.c View 1 2 chunks +0 lines, -24 lines 0 comments Download
M src/trusted/service_runtime/nacl_signal.h View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M src/trusted/service_runtime/nacl_syscall_hook.c View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M src/trusted/service_runtime/posix/nacl_signal.c View 1 2 3 4 5 6 2 chunks +8 lines, -0 lines 0 comments Download
M src/trusted/service_runtime/sel_ldr.h View 1 2 3 4 1 chunk +3 lines, -15 lines 0 comments Download
M src/trusted/service_runtime/service_runtime.gyp View 1 2 chunks +2 lines, -0 lines 0 comments Download
M src/trusted/service_runtime/win/thread_suspension.c View 1 2 3 4 1 chunk +15 lines, -0 lines 0 comments Download
M tests/thread_suspension/nacl.scons View 1 2 3 4 5 6 1 chunk +5 lines, -5 lines 0 comments Download
M tests/thread_suspension/suspend_test_host.c View 1 2 3 4 5 6 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
halyavin
Imagine this scenario. Thread 1 in transitioning from untrusted code to trusted code. natp->suspend_state is ...
8 years, 7 months ago (2012-05-11 11:47:28 UTC) #1
Mark Seaborn
On 11 May 2012 04:47, <halyavin@google.com> wrote: > Imagine this scenario. > Thread 1 in ...
8 years, 7 months ago (2012-05-15 00:39:31 UTC) #2
Mark Seaborn
I haven't finished checking this with my model checker (the one in https://github.com/mseaborn/nacl-model-check) and I ...
8 years, 7 months ago (2012-05-16 21:02:19 UTC) #3
bradn
http://codereview.chromium.org/10392005/diff/2012/SConstruct File SConstruct (right): http://codereview.chromium.org/10392005/diff/2012/SConstruct#newcode767 SConstruct:767: 'run_thread_suspension_test', ? doesn't work on qemu? http://codereview.chromium.org/10392005/diff/2012/src/trusted/service_runtime/arch/x86_32/nacl_tls_32.c File src/trusted/service_runtime/arch/x86_32/nacl_tls_32.c ...
8 years, 7 months ago (2012-05-18 19:56:35 UTC) #4
Mark Seaborn
Please take a look. http://codereview.chromium.org/10392005/diff/2012/SConstruct File SConstruct (right): http://codereview.chromium.org/10392005/diff/2012/SConstruct#newcode767 SConstruct:767: 'run_thread_suspension_test', On 2012/05/18 19:56:35, bradn ...
8 years, 7 months ago (2012-05-21 15:03:56 UTC) #5
bradn
lgtm http://codereview.chromium.org/10392005/diff/17006/src/trusted/service_runtime/linux/thread_suspension.c File src/trusted/service_runtime/linux/thread_suspension.c (right): http://codereview.chromium.org/10392005/diff/17006/src/trusted/service_runtime/linux/thread_suspension.c#newcode30 src/trusted/service_runtime/linux/thread_suspension.c:30: * We use the *_PRIVATE variant to use ...
8 years, 7 months ago (2012-05-21 17:42:57 UTC) #6
Mark Seaborn
8 years, 7 months ago (2012-05-22 04:28:10 UTC) #7
On 21 May 2012 10:42, <bradnelson@google.com> wrote:

>
>
http://codereview.chromium.org/10392005/diff/17006/src/trusted/service_runtim...
> File src/trusted/service_runtime/**linux/thread_suspension.c (right):
>
> http://codereview.chromium.**org/10392005/diff/17006/src/**
>
trusted/service_runtime/linux/**thread_suspension.c#newcode30<http://codereview.chromium.org/10392005/diff/17006/src/trusted/service_runtime/linux/thread_suspension.c#newcode30>
> src/trusted/service_runtime/**linux/thread_suspension.c:30: * We use the
> *_PRIVATE variant to use process-local futexes which are
> Mention that these are well know but undocumented (as the docs are
> stale).
>

Done, and committed.  Thanks!

Mark

-- 
You received this message because you are subscribed to the Google Groups
"Native-Client-Reviews" group.
To post to this group, send email to native-client-reviews@googlegroups.com.
To unsubscribe from this group, send email to
native-client-reviews+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/native-client-reviews?hl=en.

Powered by Google App Engine
This is Rietveld 408576698