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

Side by Side Diff: src/trusted/service_runtime/arch/x86_32/sel_addrspace_x86_32.c

Issue 7648002: Modify the NaCl_page_alloc_hint function to use VirtualQuery to check (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The Native Client Authors. All rights reserved. 2 * Copyright 2009 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/include/nacl_platform.h" 7 #include "native_client/src/include/nacl_platform.h"
8 #include "native_client/src/shared/platform/nacl_check.h" 8 #include "native_client/src/shared/platform/nacl_check.h"
9 #include "native_client/src/trusted/service_runtime/sel_memory.h" 9 #include "native_client/src/trusted/service_runtime/sel_memory.h"
10 #include "native_client/src/trusted/service_runtime/sel_ldr.h" 10 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
11 11
12
13 NaClErrorCode NaClAllocateSpace(void **mem, size_t addrsp_size) { 12 NaClErrorCode NaClAllocateSpace(void **mem, size_t addrsp_size) {
14 int result; 13 int result;
14 const size_t kOneGb = 0x40000000;
Brad Chen 2011/08/16 01:21:49 I'm used to 'b' meaning 'bit'. I'd rather see kOne
bbudge 2011/08/16 19:46:22 Done.
15 15
16 CHECK(NULL != mem); 16 CHECK(NULL != mem);
17 17
18 #ifdef NACL_SANDBOX_FIXED_AT_ZERO 18 #ifdef NACL_SANDBOX_FIXED_AT_ZERO
19 /* 19 /*
20 * When creating a zero-based sandbox, we do not allocate the first 64K of 20 * When creating a zero-based sandbox, we do not allocate the first 64K of
21 * pages beneath the trampolines, because -- on Linux at least -- we cannot. 21 * pages beneath the trampolines, because -- on Linux at least -- we cannot.
22 * Instead, we allocate starting at the trampolines, and then coerce the 22 * Instead, we allocate starting at the trampolines, and then coerce the
23 * out parameter. 23 * out parameter.
24 */ 24 */
25 addrsp_size -= NACL_TRAMPOLINE_START; 25 addrsp_size -= NACL_TRAMPOLINE_START;
26 *mem = (void *) NACL_TRAMPOLINE_START; 26 *mem = (void *) NACL_TRAMPOLINE_START;
27 result = NaCl_page_alloc_at_addr(mem, addrsp_size); 27 result = NaCl_page_alloc_at_addr(mem, addrsp_size);
28 *mem = 0; 28 *mem = 0;
29 #elif NACL_WINDOWS && NACL_ARCH_CPU_32_BITS
Mark Seaborn 2011/08/16 17:34:10 Can you use "NACL_BUILD_SUBARCH == 64" rather than
bbudge 2011/08/16 19:46:22 Done.
30 /*
31 * On 32 bit Windows XP, a 1Gb region of address space is reserved before
32 * starting up this process to make sure we can get a contiguous block. Look
33 * for it now.
34 */
35 if (0 == NaCl_find_sandbox_memory(mem, kOneGb))
Mark Seaborn 2011/08/16 17:34:10 Nit: I'd use curly brackets for this 'if'.
bbudge 2011/08/16 19:46:22 Done.
36 result = NaCl_page_alloc_at_addr(mem, addrsp_size);
Brad Chen 2011/08/16 01:21:49 I don't understand how mem gets initialized in thi
bbudge 2011/08/16 17:21:02 It's obscure, but the 'mem' parameter gets filled
Brad Chen 2011/08/16 17:28:38 Nit: A brief comment before the call to NaCl_page_
bbudge 2011/08/16 19:46:22 Done. (I expanded the comment for the whole case)
37 else
38 result = NaCl_page_alloc(mem, addrsp_size);
29 #else 39 #else
30 result = NaCl_page_alloc(mem, addrsp_size); 40 result = NaCl_page_alloc(mem, addrsp_size);
31 #endif 41 #endif
32 42
33 if (0 != result) { 43 if (0 != result) {
34 NaClLog(2, 44 NaClLog(2,
35 "NaClAllocateSpace: NaCl_page_alloc 0x%08"NACL_PRIxPTR 45 "NaClAllocateSpace: NaCl_page_alloc 0x%08"NACL_PRIxPTR
36 " failed\n", 46 " failed\n",
37 (uintptr_t) *mem); 47 (uintptr_t) *mem);
38 return LOAD_NO_MEMORY; 48 return LOAD_NO_MEMORY;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 NACL_SYSCALL_START_ADDR >> NACL_PAGESHIFT, 82 NACL_SYSCALL_START_ADDR >> NACL_PAGESHIFT,
73 PROT_NONE, 83 PROT_NONE,
74 (struct NaClMemObj *) NULL)) { 84 (struct NaClMemObj *) NULL)) {
75 NaClLog(LOG_ERROR, ("NaClMemoryProtection: NaClVmmapAdd failed" 85 NaClLog(LOG_ERROR, ("NaClMemoryProtection: NaClVmmapAdd failed"
76 " (NULL pointer guard page)\n")); 86 " (NULL pointer guard page)\n"));
77 return LOAD_MPROTECT_FAIL; 87 return LOAD_MPROTECT_FAIL;
78 } 88 }
79 89
80 return LOAD_OK; 90 return LOAD_OK;
81 } 91 }
OLDNEW
« no previous file with comments | « no previous file | src/trusted/service_runtime/sel_memory.h » ('j') | src/trusted/service_runtime/sel_memory.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698