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

Unified Diff: src/trusted/service_runtime/win/sel_memory.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 side-by-side diff with in-line comments
Download patch
Index: src/trusted/service_runtime/win/sel_memory.c
===================================================================
--- src/trusted/service_runtime/win/sel_memory.c (revision 6420)
+++ src/trusted/service_runtime/win/sel_memory.c (working copy)
@@ -24,6 +24,31 @@
#define MSGWIDTH "25"
+#if NACL_ARCH_CPU_32_BITS
Mark Seaborn 2011/08/16 17:34:10 As before.
bbudge 2011/08/16 19:46:22 Done.
+
+int NaCl_find_sandbox_memory(void **p,
Mark Seaborn 2011/08/16 17:34:10 Can you put a comment in to say that the purpose o
bbudge 2011/08/16 19:46:22 Done.
+ size_t num_bytes) {
+ SYSTEM_INFO sys_info;
+ MEMORY_BASIC_INFORMATION mem;
+ char* start;
Mark Seaborn 2011/08/16 17:34:10 Nit: " *" rather than "* "
bbudge 2011/08/16 19:46:22 Done.
+
+ GetSystemInfo(&sys_info);
+ start = sys_info.lpMinimumApplicationAddress;
+ while (VirtualQuery((LPCVOID)start, &mem, sizeof(mem))) {
Mark Seaborn 2011/08/16 17:34:10 I'd suggest checking that the return value is eith
bbudge 2011/08/16 19:46:22 Done.
+ if (mem.State == MEM_RESERVE && mem.RegionSize == num_bytes) {
+ VirtualFree(start, 0, MEM_RELEASE);
Mark Seaborn 2011/08/16 17:34:10 Please check return value. You can use LOG_FATAL
bbudge 2011/08/16 19:46:22 Done.
+ *p = start;
+ return 0;
+ }
+ start += mem.RegionSize;
+ if ((LPVOID)start > sys_info.lpMaximumApplicationAddress)
Mark Seaborn 2011/08/16 17:34:10 Minor nit: maybe '>='?
bbudge 2011/08/16 19:46:22 Done.
+ break;
+ }
+ return -ENOMEM;
+}
+
+#endif /* NACL_ARCH_CPU_32_BITS */
+
/*
* NaCl_page_free: free pages allocated with NaCl_page_alloc.
* Must start at allocation granularity (NACL_MAP_PAGESIZE) and
@@ -48,8 +73,7 @@
}
-static
-int NaCl_page_alloc_hint(void **p,
+int NaCl_page_alloc_at_addr(void **p,
size_t num_bytes) {
SYSTEM_INFO sys_info;
@@ -151,7 +175,7 @@
*p = addr;
return 0;
retry:
- NaClLog(2, "NaCl_page_alloc_hint: retrying w/o hint\n");
+ NaClLog(2, "NaCl_page_alloc_at_addr: retrying w/o hint\n");
hint = NULL;
}
@@ -161,7 +185,7 @@
int NaCl_page_alloc(void **p,
size_t num_bytes) {
*p = NULL;
- return NaCl_page_alloc_hint(p, num_bytes);
+ return NaCl_page_alloc_at_addr(p, num_bytes);
}
/*
@@ -203,7 +227,7 @@
NaClLog(LOG_INFO, "NaCl_page_alloc_randomized: hint 0x%"NACL_PRIxPTR"\n",
(uintptr_t) *p);
- neg_errno = NaCl_page_alloc_hint(p, size);
+ neg_errno = NaCl_page_alloc_at_addr(p, size);
if (0 == neg_errno) {
break;
}
@@ -213,7 +237,7 @@
"NaCl_page_alloc_randomized: failed (%d), dropping hints\n",
-neg_errno);
*p = 0;
- neg_errno = NaCl_page_alloc_hint(p, size);
+ neg_errno = NaCl_page_alloc_at_addr(p, size);
}
return neg_errno;
}
« src/trusted/service_runtime/sel_memory.h ('K') | « src/trusted/service_runtime/sel_memory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698