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

Unified Diff: src/include/minsfi_priv.h

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/include/minsfi.h ('k') | src/minsfi/trusted/build.scons » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/include/minsfi_priv.h
diff --git a/src/include/minsfi_priv.h b/src/include/minsfi_priv.h
new file mode 100644
index 0000000000000000000000000000000000000000..5702e823eb65a32b48877e8e042908fc376df3d7
--- /dev/null
+++ b/src/include/minsfi_priv.h
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+#ifndef NATIVE_CLIENT_SRC_INCLUDE_MINSFI_PRIV_H_
+#define NATIVE_CLIENT_SRC_INCLUDE_MINSFI_PRIV_H_
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+
+typedef struct {
+ uint32_t ptr_size; /* size of sandboxed pointers in bits */
+ uint32_t dataseg_offset;
+ uint32_t dataseg_size;
+ const char *dataseg_template;
+} MinsfiManifest;
+
+typedef struct {
+ uint32_t offset;
+ uint32_t length;
+} MinsfiMemoryRegion;
+
+typedef struct {
+ MinsfiMemoryRegion dataseg;
+ MinsfiMemoryRegion heap;
+ MinsfiMemoryRegion stack;
+} MinsfiMemoryLayout;
+
+typedef struct {
+ char *mem_base;
+ uint64_t mem_alloc_size;
+ uint32_t ptr_mask;
+ MinsfiMemoryLayout mem_layout;
+} MinsfiSandbox;
+
+/*
+ * Computes the boundaries of the individual regions of the sandbox's address
+ * subspace and stores them into the given minsfi_layout data structure.
+ * Returns FALSE if a layout cannot be created for the given parameters.
+ */
+bool MinsfiGenerateMemoryLayout(const MinsfiManifest *manifest,
+ uint32_t page_size, MinsfiMemoryLayout *layout);
+
+/*
+ * This function initializes the address subspace of the sandbox. Protection of
+ * the pages allocated to the data segment, heap and stack is set to read/write,
+ * the rest is no-access. The data segment template is copied into the sandbox.
+ *
+ * The function returns TRUE if the initialization was successful, and stores
+ * information about the sandbox into the given MinsfiSandbox struct.
+ */
+bool MinsfiInitSandbox(const MinsfiManifest *manifest, MinsfiSandbox *sb);
+
+/*
+ * Unmaps a memory region given by the provided base and the declared pointer
+ * size of the sandbox. The function returns FALSE if munmap() fails.
+ */
+bool MinsfiUnmapSandbox(const MinsfiSandbox *sb);
+
+/*
+ * Returns information about the active sandbox, or NULL if there is no
+ * initialized sandbox at the moment.
+ */
+const MinsfiSandbox *MinsfiGetActiveSandbox(void);
+
+/*
+ * Sets the sandbox which all trampolines will refer to. Internally copies the
+ * data structure to its own storage.
+ */
+void MinsfiSetActiveSandbox(const MinsfiSandbox *sb);
+
+#endif // NATIVE_CLIENT_SRC_INCLUDE_MINSFI_PRIV_H_
« no previous file with comments | « src/include/minsfi.h ('k') | src/minsfi/trusted/build.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698