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

Unified Diff: src/minsfi/trusted/state.c

Issue 539683002: MinSFI: Add loader (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Fixed nits 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/minsfi/trusted/loader.c ('k') | tests/minsfi/nacl.scons » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/minsfi/trusted/state.c
diff --git a/src/minsfi/trusted/state.c b/src/minsfi/trusted/state.c
new file mode 100644
index 0000000000000000000000000000000000000000..122429001087798d5a680c4a4edd23c47a03fe7a
--- /dev/null
+++ b/src/minsfi/trusted/state.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include <string.h>
+
+#include "native_client/src/include/minsfi_priv.h"
+
+/*
+ * This is the memory base variable which the SFI-sandboxed pointers are
+ * treated relative to. It is defined in the trusted runtime, exported and then
+ * imported by the untrusted code via the compiler transforms. It is a 64-bit
+ * unsigned integer on both 32-bit and 64-bit platforms. See comments in the
+ * SandboxMemoryAccesses MinSFI LLVM pass for more details.
+ */
+uint64_t __sfi_memory_base = 0;
+
+static MinsfiSandbox ActiveSandbox = { .mem_base = NULL };
+
+const MinsfiSandbox *MinsfiGetActiveSandbox(void) {
+ if (ActiveSandbox.mem_base != NULL)
+ return &ActiveSandbox;
+ else
+ return NULL;
+}
+
+void MinsfiSetActiveSandbox(const MinsfiSandbox *sb) {
+ if (sb != NULL)
+ memcpy(&ActiveSandbox, sb, sizeof(MinsfiSandbox));
+ else
+ ActiveSandbox.mem_base = NULL;
+
+ __sfi_memory_base = (uintptr_t) ActiveSandbox.mem_base;
+}
« no previous file with comments | « src/minsfi/trusted/loader.c ('k') | tests/minsfi/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698