OLD | NEW |
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) memory protection abstractions. | 8 * NaCl Simple/secure ELF loader (NaCl SEL) memory protection abstractions. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_MEMORY_H_ | 11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_MEMORY_H_ |
12 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_MEMORY_H_ 1 | 12 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_MEMORY_H_ 1 |
13 | 13 |
14 #ifdef __cplusplus | 14 #ifdef __cplusplus |
15 extern "C" { | 15 extern "C" { |
16 #endif /* __cplusplus */ | 16 #endif /* __cplusplus */ |
17 | 17 |
18 /* | 18 /* |
19 * We do not use posix_memalign but instead directly attempt to mmap | 19 * We do not use posix_memalign but instead directly attempt to mmap |
20 * (or VirtualAlloc) memory into aligned addresses, since we want to be | 20 * (or VirtualAlloc) memory into aligned addresses, since we want to be |
21 * able to munmap pages to map in shared memory pages for the NaCl | 21 * able to munmap pages to map in shared memory pages for the NaCl |
22 * versions of shmat or mmap, esp if SHM_REMAP is used. Note that the | 22 * versions of shmat or mmap, esp if SHM_REMAP is used. Note that the |
23 * Windows ABI has 4KB pages for operations like page protection, but | 23 * Windows ABI has 4KB pages for operations like page protection, but |
24 * 64KB allocation granularity (see nacl_config.h), and since we want | 24 * 64KB allocation granularity (see nacl_config.h), and since we want |
25 * host-OS indistinguishability, this means we inherit this restriction | 25 * host-OS indistinguishability, this means we inherit this restriction |
26 * into our least-common-denominator design. | 26 * into our least-common-denominator design. |
27 */ | 27 */ |
28 #define MAX_RETRIES 1024 | 28 #define MAX_RETRIES 1024 |
29 | 29 |
| 30 int NaCl_find_prereserved_sandbox_memory(void **p, |
| 31 size_t num_bytes); |
| 32 |
30 int NaCl_page_alloc(void **p, | 33 int NaCl_page_alloc(void **p, |
31 size_t num_bytes) NACL_WUR; | 34 size_t num_bytes) NACL_WUR; |
32 | 35 |
33 int NaCl_page_alloc_randomized(void **p, | 36 int NaCl_page_alloc_randomized(void **p, |
34 size_t num_bytes) NACL_WUR; | 37 size_t num_bytes) NACL_WUR; |
35 | 38 |
36 int NaCl_page_alloc_at_addr(void **p, | 39 int NaCl_page_alloc_at_addr(void **p, |
37 size_t size) NACL_WUR; | 40 size_t size) NACL_WUR; |
38 | 41 |
39 void NaCl_page_free(void *p, | 42 void NaCl_page_free(void *p, |
40 size_t num_bytes); | 43 size_t num_bytes); |
41 | 44 |
42 int NaCl_mprotect(void *addr, | 45 int NaCl_mprotect(void *addr, |
43 size_t len, | 46 size_t len, |
44 int prot) NACL_WUR; | 47 int prot) NACL_WUR; |
45 | 48 |
46 int NaCl_madvise(void *start, | 49 int NaCl_madvise(void *start, |
47 size_t length, | 50 size_t length, |
48 int advice) NACL_WUR; | 51 int advice) NACL_WUR; |
49 | 52 |
50 | 53 |
51 #ifdef __cplusplus | 54 #ifdef __cplusplus |
52 } | 55 } |
53 #endif /* __cplusplus */ | 56 #endif /* __cplusplus */ |
54 | 57 |
55 #endif /* NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_MEMORY_H_ */ | 58 #endif /* NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_MEMORY_H_ */ |
OLD | NEW |