about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-04-29 10:57:19 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-04-29 10:57:19 +0200
commit71c5447b8ad534f2507c0405a348d902e9374517 (patch)
treea6f9bc80d6206d488b01ac0871cc18a1aa99efb6 /src
parenta9a338ff428c0a30ffbc0cb0a26a96ed7e4aa9a0 (diff)
downloadbox64-71c5447b8ad534f2507c0405a348d902e9374517.tar.gz
box64-71c5447b8ad534f2507c0405a348d902e9374517.zip
Added a way to hide SSE 4.2, as it might slow down things using the string opcodes. Also, looks like some java program have issue with current implementation of pcmp[ei]str[im] somehow, so diabling automaticaly when detecting libjvm.so (for SlayTheSpire in particular)
Diffstat (limited to 'src')
-rw-r--r--src/core.c10
-rw-r--r--src/include/debug.h1
-rw-r--r--src/librarian/library.c15
-rw-r--r--src/tools/my_cpuid.c2
-rw-r--r--src/tools/rcfile.c1
5 files changed, 23 insertions, 6 deletions
diff --git a/src/core.c b/src/core.c
index 25fa9f14..6b96d37d 100644
--- a/src/core.c
+++ b/src/core.c
@@ -147,6 +147,7 @@ int box64_prefer_wrapped = 0;
 int box64_sse_flushto0 = 0;
 int box64_x87_no80bits = 0;
 int box64_sync_rounding = 0;
+int box64_sse42 = 1;
 int fix_64bit_inodes = 0;
 int box64_dummy_crashhandler = 1;
 int box64_mapclean = 0;
@@ -970,6 +971,15 @@ void LoadLogEnv()
             printf_log(LOG_INFO, "Disable the use of futex waitv syscall\n");
         #endif
     }
+    p = getenv("BOX64_SSE42");
+    if(p) {
+        if(strlen(p)==1) {
+            if(p[0]>='0' && p[0]<='0'+1)
+                box64_sse42 = p[0]-'0';
+        }
+        if(!box64_sse42)
+            printf_log(LOG_INFO, "Do not expose SSE 4.2 capabilities\n");
+    }
     p = getenv("BOX64_FIX_64BIT_INODES");
     if(p) {
         if(strlen(p)==1) {
diff --git a/src/include/debug.h b/src/include/debug.h
index f7719991..8d75a5c5 100644
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -92,6 +92,7 @@ extern int box64_dummy_crashhandler;
 extern int box64_sse_flushto0;
 extern int box64_x87_no80bits;
 extern int box64_sync_rounding;
+extern int box64_sse42;
 extern int allow_missing_libs;
 extern int box64_mapclean;
 extern int box64_prefer_wrapped;
diff --git a/src/librarian/library.c b/src/librarian/library.c
index f8c64c58..3466e017 100644
--- a/src/librarian/library.c
+++ b/src/librarian/library.c
@@ -334,16 +334,21 @@ static int loadEmulatedLib(const char* libname, library_t *lib, box64context_t*
             box64_dynarec_bigblock = 0;
             box64_dynarec_strongmem = 1;
         }
-        if(libname && box64_dynarec_jvm && strstr(libname, "libjvm.so")) {
-            printf_dump(LOG_INFO, "libjvm detected, disable Dynarec BigBlock and enable Dynarec StrongMem\n");
-            box64_dynarec_bigblock = 0;
-            box64_dynarec_strongmem = 1;
-        }
         if(libname && box64_dynarec_tbb && strstr(libname, "libtbb.so")) {
             printf_dump(LOG_INFO, "libtbb detected, enable Dynarec StrongMem\n");
             box64_dynarec_strongmem = 3;
         }
         #endif
+        if(libname && box64_dynarec_jvm && strstr(libname, "libjvm.so")) {
+            #ifdef DYNAREC
+            printf_dump(LOG_INFO, "libjvm detected, disable Dynarec BigBlock and enable Dynarec StrongMem, hide SSE 4.2\n");
+            box64_dynarec_bigblock = 0;
+            box64_dynarec_strongmem = 1;
+            #else
+            printf_dump(LOG_INFO, "libjvm detected, hide SSE 4.2\n");
+            #endif
+            box64_sse42 = 0;
+        }
         if(libname && box64_libcef && strstr(libname, "libcef.so")) {
             printf_dump(LOG_INFO, "libcef detected, using malloc_hack_2\n");
             box64_malloc_hack = 2;
diff --git a/src/tools/my_cpuid.c b/src/tools/my_cpuid.c
index 46dbab76..a6909570 100644
--- a/src/tools/my_cpuid.c
+++ b/src/tools/my_cpuid.c
@@ -257,7 +257,7 @@ void my_cpuid(x64emu_t* emu, uint32_t tmp32u)
                     //| 1<<12     // fma    // some games treat FMA as AVX
                     | 1<<13     // cx16 (cmpxchg16)
                     | 1<<19     // SSE4_1
-                    | 1<<20     // SSE4_2
+                    | (box64_sse42?(1<<20):0)     // SSE4_2 can be hiden
                     | 1<<22     // MOVBE
                     | 1<<23     // POPCOUNT
                     | 1<<25     // aesni
diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c
index 3ee749e3..9098f9dc 100644
--- a/src/tools/rcfile.c
+++ b/src/tools/rcfile.c
@@ -96,6 +96,7 @@ ENTRYBOOL(BOX64_CRASHHANDLER, box64_dummy_crashhandler) \
 ENTRYBOOL(BOX64_NOPULSE, box64_nopulse)                 \
 ENTRYBOOL(BOX64_NOGTK, box64_nogtk)                     \
 ENTRYBOOL(BOX64_NOVULKAN, box64_novulkan)               \
+ENTRYBOOL(BOX64_SSE42, box64_sse42)                     \
 ENTRYBOOL(BOX64_FUTEX_WAITV, box64_futex_waitv)         \
 ENTRYSTRING_(BOX64_BASH, bash)                          \
 ENTRYINT(BOX64_JITGDB, jit_gdb, 0, 3, 2)                \