diff options
| -rwxr-xr-x | docs/USAGE.md | 4 | ||||
| -rw-r--r-- | src/custommem.c | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/docs/USAGE.md b/docs/USAGE.md index ced076a9..5c67f0f8 100755 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -321,3 +321,7 @@ Those variables are only valid inside a rcfile: #### BOX64_EXIT * 0 : Nothing special * 1 : Just exit, don't try to run the program + +#### BOX64_RESERVE_HIGH +* 0 : Don't try to pe-reserve high memory (beyond 47bits) (Default) +* 1 : Try to reserve (without allocating it) memory beyond 47bits (seems unstable) diff --git a/src/custommem.c b/src/custommem.c index 6cb7cedb..dfeb6bbc 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -1425,6 +1425,9 @@ static void atfork_child_custommem(void) void reserveHighMem() { + char* p = getenv("BOX64_RESERVE_HIGH"); + if(!p || p[0]=='0') + return; // don't reserve by default intptr_t cur = 1LL<<47; mapmem_t* m = mapmem; while(m && (m->end<cur)) { @@ -1434,7 +1437,8 @@ void reserveHighMem() uintptr_t addr = 0, end = 0; if(m->begin>cur) { void* ret = mmap64((void*)cur, m->begin-cur, 0, MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE|MAP_NORESERVE, -1, 0); - printf_log(LOG_DEBUG, "Reserve %p(0x%zx) => %p (%s)\n", (void*)cur, m->begin-cur, ret, strerror(errno)); + printf_log(LOG_DEBUG, "Reserve %p-%p => %p (%s)\n", (void*)cur, m->begin, ret, strerror(errno)); + printf_log(LOG_DEBUG, "mmap %p-%p\n", m->begin, m->end); if(ret!=(void*)-1) { addr = cur; end = m->begin; |