diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-02-23 16:41:44 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-02-23 16:41:44 +0100 |
| commit | ffda782c3d88d977acc12a3c2c2738719f9304ed (patch) | |
| tree | a0e1893fb28090c4f0f2a26c7a67bb40ae71f6b5 /src/tools/rcfile.c | |
| parent | 3a6df996dc85257a5496ecb28a72579df225a176 (diff) | |
| download | box64-ffda782c3d88d977acc12a3c2c2738719f9304ed.tar.gz box64-ffda782c3d88d977acc12a3c2c2738719f9304ed.zip | |
Better handling of Hardware counter for rdtsc emulation (ARM64 only for now), more cpuid leafs, and introduce BOX64_RDTSC env.var. with a profile that use it
Diffstat (limited to 'src/tools/rcfile.c')
| -rw-r--r-- | src/tools/rcfile.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c index b628fb6b..9c44336c 100644 --- a/src/tools/rcfile.c +++ b/src/tools/rcfile.c @@ -10,6 +10,7 @@ #include "box64context.h" #include "fileutils.h" #include "pathcoll.h" +#include "x64emu.h" #ifdef HAVE_TRACE #include "x64trace.h" #endif @@ -88,6 +89,7 @@ ENTRYBOOL(BOX64_SHOWSEGV, box64_showsegv) \ ENTRYBOOL(BOX64_SHOWBT, box64_showbt) \ ENTRYBOOL(BOX64_MMAP32, box64_mmap32) \ ENTRYBOOL(BOX64_IGNOREINT3, box64_ignoreint3) \ +ENTRYINT(BOX64_RDTSC, box64_rdtsc, 0, 2, 2) \ ENTRYBOOL(BOX64_X11THREADS, box64_x11threads) \ ENTRYBOOL(BOX64_X11GLX, box64_x11glx) \ ENTRYDSTRING(BOX64_LIBGL, box64_libGL) \ @@ -574,6 +576,22 @@ void ApplyParams(const char* name) my_context->bashpath = strdup(param->bash); printf_log(LOG_INFO, "Applying %s=%s\n", "BOX64_BASH", param->bash); } + if(param->is_box64_rdtsc_present && (box64_rdtsc==2)) { + #if defined(ARM64) + box64_rdtsc = 0; // allow hardxware counter + uint64_t freq = ReadTSCFrequency(NULL); + printf_log(LOG_INFO, "Applying RDTSC: Hardware counter measured at %d Mhz, ", freq/1000); + if(freq>1000000000) { + printf_log(LOG_INFO, "keeping it\n"); + } else { + box64_rdtsc = 1; + printf_log(LOG_INFO, "not using it\n"); + } + #else + box64_rdtsc = 1; + printf_log(LOG_INFO, "Applying RDTSC: Will use time-based emulation for rdtsc, even if hardware counter are available\n"); + #endif + } #ifdef HAVE_TRACE int old_x64trace = my_context->x64trace; if(param->is_trace_present) { |