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

Side by Side Diff: src/minsfi/trusted/entry.c

Issue 539683002: MinSFI: Add loader (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7 #include "native_client/src/include/minsfi.h"
8 #include "native_client/src/include/minsfi_priv.h"
9
10 /*
11 * Fixed offset of the data segment. This must be kept in sync with the
12 * AllocateDataSegment compiler pass.
13 */
14 #define DATASEG_OFFSET 0x10000
15
16 /* Globals exported by the sandbox, aka the manifest. */
17 extern uint32_t __sfi_pointer_size;
18 extern const char __sfi_data_segment[];
19 extern uint32_t __sfi_data_segment_size;
20
21 /* Entry point of the sandbox */
22 extern int _start_minsfi(void);
23
24 /*
25 * This is the global memory base variable used by the SFI sandboxing. It is
26 * a 64-bit unsigned integer on both 32-bit and 64-bit platforms.
27 */
28 uint64_t __sfi_memory_base = 0;
jvoung (off chromium) 2014/09/05 00:31:59 Could add some emphasis that this is exported, but
dbrazdil 2014/09/05 19:41:37 Done.
29
30 static inline void get_manifest(manifest *sb) {
31 sb->ptr_size = __sfi_pointer_size;
32 sb->dataseg_offset = DATASEG_OFFSET;
33 sb->dataseg_size = __sfi_data_segment_size;
34 sb->dataseg_template = __sfi_data_segment;
35 }
36
37 int minsfi_exec(void) {
38 if (__sfi_memory_base == 0) {
39 char *base;
40 manifest sb;
41
42 get_manifest(&sb);
43 base = init_sandbox(&sb);
44 if (base == NULL)
45 return EXIT_FAILURE;
46
47 __sfi_memory_base = (uint64_t) ((uintptr_t) base);
48 }
49
50 return _start_minsfi();
51 }
52
53 bool minsfi_destroy(void) {
54 manifest sb;
55
56 if (__sfi_memory_base == 0)
57 return true;
58
59 get_manifest(&sb);
60 return destroy_sandbox((char*) ((uintptr_t) __sfi_memory_base), &sb);
jvoung (off chromium) 2014/09/05 00:31:59 Should this modify __sfi_memory_base back to 0 bef
dbrazdil 2014/09/05 19:41:37 Done. Added tests which check that the base has be
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698