Added BOX64_RESERVE_HIGH in rcfile handling

This commit is contained in:
ptitSeb 2024-06-18 17:25:32 +02:00
parent 865ef2ff6e
commit 4eebf25f1c
4 changed files with 27 additions and 9 deletions

View File

@ -335,7 +335,7 @@ Define x86_64 bash to launch script
* XXX=yyyy
will add XXX=yyyy env. var. and continue with BOX86_ENV2 ... until var doesn't exist
#### BOX64_RESERVE_HIGH
#### 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)

View File

@ -1499,15 +1499,12 @@ static void atfork_child_custommem(void)
init_mutexes();
}
void reserveHighMem()
void my_reserveHighMem()
{
char* p = getenv("BOX64_RESERVE_HIGH");
#if 0//def ADLINK
if(p && p[0]=='0')
#else
if(!p || p[0]=='0')
#endif
return; // don't reserve by default
static int reserved = 0;
if(reserved || !have48bits)
return;
reserved = 1;
uintptr_t cur = 1ULL<<47;
uintptr_t bend = 0;
uint32_t prot;
@ -1522,6 +1519,19 @@ void reserveHighMem()
}
cur = bend;
}
}
void reserveHighMem()
{
char* p = getenv("BOX64_RESERVE_HIGH");
#if 0//def ADLINK
if(p && p[0]=='0')
#else
if(!p || p[0]=='0')
#endif
return; // don't reserve by default
my_reserveHighMem();
}
void init_custommem_helper(box64context_t* ctx)

View File

@ -121,6 +121,7 @@ ENTRYSTRING_(BOX64_ENV1, new_env1) \
ENTRYSTRING_(BOX64_ENV2, new_env2) \
ENTRYSTRING_(BOX64_ENV3, new_env3) \
ENTRYSTRING_(BOX64_ENV4, new_env4) \
ENTRYBOOL(BOX64_RESERVE_HIGH, new_reserve_high) \
#ifdef HAVE_TRACE
#define SUPER2() \
@ -491,6 +492,7 @@ void openFTrace(const char* newtrace);
void addNewEnvVar(const char* s);
void AddNewLibs(const char* libs);
void computeRDTSC();
void my_reserveHighMem();
#ifdef DYNAREC
void GatherDynarecExtensions();
#endif
@ -511,6 +513,7 @@ void ApplyParams(const char* name)
int new_maxcpu = box64_maxcpu;
int new_avx = box64_avx2?2:box64_avx;
int box64_dynarec_jvm = box64_jvm;
int new_reserve_high = 0;
if(!strcmp(name, old_name)) {
return;
}
@ -558,6 +561,8 @@ void ApplyParams(const char* name)
cycle_log = new_cycle_log;
initCycleLog(my_context);
}
if(new_reserve_high)
my_reserveHighMem();
if(param->is_new_avx_present) {
if(!new_avx) {
printf_log(LOG_INFO, "Hidding AVX extension");

View File

@ -76,6 +76,7 @@ BOX64_DYNAREC_ALIGNED_ATOMICS=1
[geekbench6]
BOX64_ENV=BOX64_DYNAREC_STRONGMEM=3
BOX64_ENV1=BOX64_RESERVE_HIGH=1
[geekbench5]
BOX64_ENV=BOX64_DYNAREC_BIGBLOCK=2
@ -88,6 +89,8 @@ BOX64_NOSANDBOX=1
BOX64_DYNAREC_ALIGNED_ATOMICS=1
BOX64_MAXCPU=16
[Kingdom Rush Origins]
BOX64_RESERVE_HIGH=1
[heroic]
BOX64_NOSANDBOX=1