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

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: 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
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..6433b18ea0f7e7ce998c2a439f7d38a197afa54f
--- /dev/null
+++ b/src/include/minsfi_priv.h
@@ -0,0 +1,56 @@
+/*
+ * 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 MINSFI_PRIV_H
+#define MINSFI_PRIV_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.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;
+} manifest;
jvoung (off chromium) 2014/09/05 00:31:59 If we're following NaCl style, I think most of the
dbrazdil 2014/09/05 19:41:37 Done.
+
+typedef struct {
+ uint32_t offset;
+ uint32_t length;
+} region;
+
+typedef struct {
+ region dataseg;
+ region heap;
+ region stack;
+} layout;
+
+/*
+ * 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 generate_layout(manifest *sb, uint32_t page_size, layout *mem);
jvoung (off chromium) 2014/09/05 00:31:59 Could this be "const manifest *sb" ? Similar belo
dbrazdil 2014/09/05 19:41:37 Done.
+
+/*
+ * 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 the base address of the address subspace if successful
+ * and NULL otherwise.
+ */
+char *init_sandbox(manifest *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 destroy_sandbox(char *base, manifest *sb);
+
+#endif // MINSFI_PRIV_H

Powered by Google App Engine
This is Rietveld 408576698