about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-05-31 20:13:41 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-05-31 20:13:41 +0200
commite028a67f4f0f2d4f8c423d0eef9c10223e7922f9 (patch)
tree5c71a98b793d711a0a7456ff27ba171eb23f34a9
parentc5e8aaff4a73665ad9ee0231713a7b6068bf2547 (diff)
downloadbox64-e028a67f4f0f2d4f8c423d0eef9c10223e7922f9.tar.gz
box64-e028a67f4f0f2d4f8c423d0eef9c10223e7922f9.zip
Do not try to preserve high memory (unless BOX64_RESERVE_HIGH=1 is used), as currently, it seems buggy and making more harm then good
-rwxr-xr-xdocs/USAGE.md4
-rw-r--r--src/custommem.c6
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;