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

Side by Side Diff: src/trusted/service_runtime/posix/nacl_signal.c

Issue 10392005: Thread suspension: Implement for Linux (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Comment about docs Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/trusted/service_runtime/nacl_syscall_hook.c ('k') | src/trusted/service_runtime/sel_ldr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 28 matching lines...) Expand all
39 * into architecture specific files. Bug #955 39 * into architecture specific files. Bug #955
40 */ 40 */
41 41
42 /* Use 4K more than the minimum to allow breakpad to run. */ 42 /* Use 4K more than the minimum to allow breakpad to run. */
43 #define SIGNAL_STACK_SIZE (SIGSTKSZ + 4096) 43 #define SIGNAL_STACK_SIZE (SIGSTKSZ + 4096)
44 #define STACK_GUARD_SIZE NACL_PAGESIZE 44 #define STACK_GUARD_SIZE NACL_PAGESIZE
45 45
46 static int s_Signals[] = { 46 static int s_Signals[] = {
47 #if NACL_LINUX 47 #if NACL_LINUX
48 SIGSTKFLT, 48 SIGSTKFLT,
49 NACL_THREAD_SUSPEND_SIGNAL,
49 #endif 50 #endif
50 SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV 51 SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV
51 }; 52 };
52 53
53 static struct sigaction s_OldActions[NACL_ARRAY_SIZE_UNSAFE(s_Signals)]; 54 static struct sigaction s_OldActions[NACL_ARRAY_SIZE_UNSAFE(s_Signals)];
54 55
55 int NaClSignalStackAllocate(void **result) { 56 int NaClSignalStackAllocate(void **result) {
56 /* 57 /*
57 * We use mmap() to allocate the signal stack for two reasons: 58 * We use mmap() to allocate the signal stack for two reasons:
58 * 59 *
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 * Note that we check natp (which is based on %gs) rather than 310 * Note that we check natp (which is based on %gs) rather than
310 * is_untrusted (which is based on %cs) because we need to handle 311 * is_untrusted (which is based on %cs) because we need to handle
311 * the case where %gs is set to the untrusted-code value but %cs is 312 * the case where %gs is set to the untrusted-code value but %cs is
312 * not. 313 * not.
313 */ 314 */
314 if (natp != NULL) { 315 if (natp != NULL) {
315 NaClSetGs(natp->sys.gs); 316 NaClSetGs(natp->sys.gs);
316 } 317 }
317 #endif 318 #endif
318 319
320 #if NACL_LINUX
321 if (sig == NACL_THREAD_SUSPEND_SIGNAL) {
322 NaClSuspendSignalHandler();
323 return;
324 }
325 #endif
326
319 if (is_untrusted && sig == SIGSEGV) { 327 if (is_untrusted && sig == SIGSEGV) {
320 if (DispatchToUntrustedHandler(natp, &sigCtx)) { 328 if (DispatchToUntrustedHandler(natp, &sigCtx)) {
321 NaClSignalContextToHandler(uc, &sigCtx); 329 NaClSignalContextToHandler(uc, &sigCtx);
322 /* Resume untrusted code using the modified register state. */ 330 /* Resume untrusted code using the modified register state. */
323 return; 331 return;
324 } 332 }
325 } 333 }
326 334
327 FindAndRunHandler(sig, info, uc); 335 FindAndRunHandler(sig, info, uc);
328 } 336 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 389 }
382 if ((sa.sa_flags & SA_SIGINFO) != 0 390 if ((sa.sa_flags & SA_SIGINFO) != 0
383 ? sa.sa_sigaction != NULL 391 ? sa.sa_sigaction != NULL
384 : (sa.sa_handler != SIG_DFL && sa.sa_handler != SIG_IGN)) { 392 : (sa.sa_handler != SIG_DFL && sa.sa_handler != SIG_IGN)) {
385 NaClLog(LOG_FATAL, "NaClSignalAssertNoHandlers: " 393 NaClLog(LOG_FATAL, "NaClSignalAssertNoHandlers: "
386 "A signal handler is registered for signal %d. " 394 "A signal handler is registered for signal %d. "
387 "Did Breakpad register this?\n", signum); 395 "Did Breakpad register this?\n", signum);
388 } 396 }
389 } 397 }
390 } 398 }
OLDNEW
« no previous file with comments | « src/trusted/service_runtime/nacl_syscall_hook.c ('k') | src/trusted/service_runtime/sel_ldr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698