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

Side by Side Diff: src/trusted/service_runtime/sel_ldr_standard.c

Issue 7108031: this patch adds the manifest proxy server to sel_ldr and the manifest (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 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 /* 7 /*
8 * NaCl Simple/secure ELF loader (NaCl SEL). 8 * NaCl Simple/secure ELF loader (NaCl SEL).
9 */ 9 */
10 10
11 #include "native_client/src/include/portability.h" 11 #include "native_client/src/include/portability.h"
12 12
13 #include <stdio.h> 13 #include <stdio.h>
14 #include <stdlib.h> 14 #include <stdlib.h>
15 #include <string.h> 15 #include <string.h>
16 16
17 #include "native_client/src/include/elf_constants.h" 17 #include "native_client/src/include/elf_constants.h"
18 #include "native_client/src/include/nacl_elf.h" 18 #include "native_client/src/include/nacl_elf.h"
19 #include "native_client/src/include/nacl_macros.h" 19 #include "native_client/src/include/nacl_macros.h"
20 #include "native_client/src/include/win/mman.h" 20 #include "native_client/src/include/win/mman.h"
21 #include "native_client/src/shared/platform/nacl_check.h" 21 #include "native_client/src/shared/platform/nacl_check.h"
22 #include "native_client/src/shared/platform/nacl_log.h" 22 #include "native_client/src/shared/platform/nacl_log.h"
23 #include "native_client/src/shared/platform/nacl_sync_checked.h" 23 #include "native_client/src/shared/platform/nacl_sync_checked.h"
24 #include "native_client/src/shared/platform/nacl_time.h" 24 #include "native_client/src/shared/platform/nacl_time.h"
25 #include "native_client/src/trusted/perf_counter/nacl_perf_counter.h" 25 #include "native_client/src/trusted/perf_counter/nacl_perf_counter.h"
26 26
27 #include "native_client/src/trusted/manifest_name_service_proxy/manifest_proxy.h "
noelallen_use_chromium 2011/06/14 02:25:45 include order?
bsy 2011/06/14 20:30:03 Done.
28
27 #include "native_client/src/trusted/service_runtime/include/sys/errno.h" 29 #include "native_client/src/trusted/service_runtime/include/sys/errno.h"
30 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
28 31
29 #include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h" 32 #include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h"
30 #include "native_client/src/trusted/service_runtime/elf_util.h" 33 #include "native_client/src/trusted/service_runtime/elf_util.h"
31 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h" 34 #include "native_client/src/trusted/service_runtime/nacl_app_thread.h"
32 #include "native_client/src/trusted/service_runtime/nacl_closure.h" 35 #include "native_client/src/trusted/service_runtime/nacl_closure.h"
33 #include "native_client/src/trusted/service_runtime/nacl_debug_init.h" 36 #include "native_client/src/trusted/service_runtime/nacl_debug_init.h"
34 #include "native_client/src/trusted/service_runtime/nacl_sync_queue.h" 37 #include "native_client/src/trusted/service_runtime/nacl_sync_queue.h"
35 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" 38 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h"
36 #include "native_client/src/trusted/service_runtime/nacl_text.h" 39 #include "native_client/src/trusted/service_runtime/nacl_text.h"
37 #include "native_client/src/trusted/service_runtime/outer_sandbox.h" 40 #include "native_client/src/trusted/service_runtime/outer_sandbox.h"
38 #include "native_client/src/trusted/service_runtime/sel_memory.h" 41 #include "native_client/src/trusted/service_runtime/sel_memory.h"
39 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 42 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
43 #include "native_client/src/trusted/service_runtime/sel_ldr_thread_interface.h"
40 #include "native_client/src/trusted/service_runtime/sel_util.h" 44 #include "native_client/src/trusted/service_runtime/sel_util.h"
41 #include "native_client/src/trusted/service_runtime/sel_addrspace.h" 45 #include "native_client/src/trusted/service_runtime/sel_addrspace.h"
42 46
43 #if !defined(SIZE_T_MAX) 47 #if !defined(SIZE_T_MAX)
44 # define SIZE_T_MAX (~(size_t) 0) 48 # define SIZE_T_MAX (~(size_t) 0)
45 #endif 49 #endif
46 50
47 51
48 /* 52 /*
49 * Fill from static_text_end to end of that page with halt 53 * Fill from static_text_end to end of that page with halt
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 int NaClAddrIsValidEntryPt(struct NaClApp *nap, 519 int NaClAddrIsValidEntryPt(struct NaClApp *nap,
516 uintptr_t addr) { 520 uintptr_t addr) {
517 if (0 != (addr & (nap->bundle_size - 1))) { 521 if (0 != (addr & (nap->bundle_size - 1))) {
518 return 0; 522 return 0;
519 } 523 }
520 524
521 return addr < nap->static_text_end; 525 return addr < nap->static_text_end;
522 } 526 }
523 527
524 int NaClAppLaunchServiceThreads(struct NaClApp *nap) { 528 int NaClAppLaunchServiceThreads(struct NaClApp *nap) {
529 struct NaClManifestProxy *manifest_proxy = NULL;
530 int rv;
531
525 NaClNameServiceLaunch(nap->name_service); 532 NaClNameServiceLaunch(nap->name_service);
526 return 1; 533
534 NaClXMutexLock(&nap->mu);
noelallen_use_chromium 2011/06/14 02:25:45 Comment? As is, this code appears racy... The var
bsy 2011/06/14 20:30:03 reverse_channel_initialized is set in the RPC hand
535 rv = !nap->reverse_channel_initialized;
536 NaClXMutexUnlock(&nap->mu);
537 if (rv) {
538 NaClLog(3,
539 ("NaClAppLaunchServiceThreads: no reverse channel;"
540 " NOT launching manifest proxy\n"));
541 goto done;
542 }
543
544 rv = 0;
545 /*
546 * Allocate/construct the manifest proxy without grabbing global
547 * locks.
548 */
549 NaClLog(3, "NaClAppLaunchServiceThreads: launching manifest proxy\n");
550
551 /*
552 * ReverseClientSetup RPC should be done via the command channel
553 * prior to the load_module / start_module RPCs, and
554 * occurs after that, so checking
555 * nap->reverse_client suffices for determining whether the proxy is
556 * exporting reverse services.
557 */
558 manifest_proxy = (struct NaClManifestProxy *) malloc(sizeof *manifest_proxy);
559 if (NULL == manifest_proxy) {
560 NaClLog(LOG_ERROR, "No memory for manifest proxy\n");
561 goto manifest_proxy_alloc_failure;
562 }
563 if (!NaClManifestProxyCtor(manifest_proxy,
564 NaClAddrSpSquattingThreadIfFactoryFunction,
565 (void *) nap,
566 nap)) {
567 NaClLog(LOG_ERROR, "ManifestProxyCtor failed\n");
568 goto manifest_proxy_ctor_failure;
569 }
570
571 /*
572 * StartThread requires lock.
noelallen_use_chromium 2011/06/14 02:25:45 Where is the lock this comment mentions?
bsy 2011/06/14 20:30:03 clarified.
573 */
574 if (!NaClSimpleServiceStartServiceThread((struct NaClSimpleService *)
575 manifest_proxy)) {
576 NaClLog(LOG_ERROR, "ManifestProxy start service failed\n");
577 NaClRefCountUnref((struct NaClRefCount *) manifest_proxy);
noelallen_use_chromium 2011/06/14 02:25:45 This is counter-intuitive. Internally NaClSimpleS
bsy 2011/06/14 20:30:03 any object of a NaClRefCount subclass, after it's
578 manifest_proxy = NULL;
579 goto manifest_proxy_start_failed;
580 }
581
582 NaClXMutexLock(&nap->mu);
583 CHECK(NULL == nap->manifest_proxy);
584
585 nap->manifest_proxy = manifest_proxy;
586 manifest_proxy = NULL;
587
588 NaClLog(3,
589 ("NaClAppLaunchServiceThreads: adding manifest proxy to"
590 " name service\n"));
591 (*NACL_VTBL(NaClNameService, nap->name_service)->
592 CreateDescEntry)(nap->name_service,
593 "manifest_proxy", NACL_ABI_O_RDWR,
594 NaClDescRef(nap->manifest_proxy->base.bound_and_cap[1]));
595
596 rv = 1;
597 NaClXMutexUnlock(&nap->mu);
598
599 manifest_proxy_start_failed:
600 manifest_proxy_ctor_failure:
601 free(manifest_proxy);
602 manifest_proxy_alloc_failure:
603 done:
604 return rv;
527 } 605 }
528 606
529 /* 607 /*
530 * preconditions: 608 * preconditions:
531 * argc > 0, argc and argv table is consistent 609 * argc > 0, argc and argv table is consistent
532 * envv may be NULL (this happens on MacOS/Cocoa 610 * envv may be NULL (this happens on MacOS/Cocoa
533 * if envv is non-NULL it is 'consistent', null terminated etc. 611 * if envv is non-NULL it is 'consistent', null terminated etc.
534 */ 612 */
535 int NaClCreateMainThread(struct NaClApp *nap, 613 int NaClCreateMainThread(struct NaClApp *nap,
536 int argc, 614 int argc,
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 sys_tdb, 883 sys_tdb,
806 tdb_size)) { 884 tdb_size)) {
807 NaClLog(LOG_WARNING, 885 NaClLog(LOG_WARNING,
808 ("NaClCreateAdditionalThread: could not allocate thread index." 886 ("NaClCreateAdditionalThread: could not allocate thread index."
809 " Returning EAGAIN per POSIX specs.\n")); 887 " Returning EAGAIN per POSIX specs.\n"));
810 free(natp); 888 free(natp);
811 return -NACL_ABI_EAGAIN; 889 return -NACL_ABI_EAGAIN;
812 } 890 }
813 return 0; 891 return 0;
814 } 892 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698