about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorYang Liu <numbksco@gmail.com>2024-04-27 01:34:14 +0800
committerGitHub <noreply@github.com>2024-04-26 19:34:14 +0200
commit1c7e620a86178b2597408586e4f0e4b3b3f246a8 (patch)
tree2076cedcfd96219d5fdbe7ac892d0c3f3a67a781 /src
parentc40096e128b9d03f56baae98f0ad6d3e85258c26 (diff)
downloadbox64-1c7e620a86178b2597408586e4f0e4b3b3f246a8.tar.gz
box64-1c7e620a86178b2597408586e4f0e4b3b3f246a8.zip
[LA64_DYNAREC] Added more useful extensions detection (#1469)
Diffstat (limited to 'src')
-rw-r--r--src/core.c20
-rw-r--r--src/dynarec/la64/dynarec_la64_00.c13
-rw-r--r--src/include/debug.h3
3 files changed, 29 insertions, 7 deletions
diff --git a/src/core.c b/src/core.c
index f2ed9dcb..7b94fbd6 100644
--- a/src/core.c
+++ b/src/core.c
@@ -115,6 +115,9 @@ int rv64_xtheadmac = 0;
 int rv64_xtheadfmv = 0;
 #elif defined(LA64)
 int la64_lbt = 0;
+int la64_lam_bh = 0;
+int la64_lamcas = 0;
+int la64_scq = 0;
 #endif
 #else   //DYNAREC
 int box64_dynarec = 0;
@@ -456,10 +459,23 @@ HWCAP2_ECV
     char* p = getenv("BOX64_DYNAREC_LA64NOEXT");
     if(p == NULL || p[0] == '0') {
         uint32_t cpucfg2 = 0, idx = 2;
-        // there are other extensions, but we don't care.
         asm volatile("cpucfg %0, %1" : "=r"(cpucfg2) : "r"(idx));
+        if ((cpucfg2 >> 6) & 0b1) {
+            printf_log(LOG_INFO, "with extension LSX");
+        } else {
+            printf_log(LOG_INFO, "\nMissing LSX extension support, disabling Dynarec\n");
+            box64_dynarec = 0;
+            return;
+        }
+
         if (la64_lbt = (cpucfg2 >> 18) & 0b1)
-            printf_log(LOG_INFO, "with extension LBT_X86");
+            printf_log(LOG_INFO, " LBT_X86");
+        if (la64_lam_bh = (cpucfg2 >> 27) & 0b1)
+            printf_log(LOG_INFO, " LAM_BT");
+        if (la64_lamcas = (cpucfg2 >> 28) & 0b1)
+            printf_log(LOG_INFO, " LAMCAS");
+        if (la64_scq = (cpucfg2 >> 30) & 0b1)
+            printf_log(LOG_INFO, " SCQ");
     }
 #elif defined(RV64)
     void RV64_Detect_Function();
diff --git a/src/dynarec/la64/dynarec_la64_00.c b/src/dynarec/la64/dynarec_la64_00.c
index 3390c6ca..38a7abdd 100644
--- a/src/dynarec/la64/dynarec_la64_00.c
+++ b/src/dynarec/la64/dynarec_la64_00.c
@@ -738,11 +738,14 @@ uintptr_t dynarec64_00(dynarec_la64_t* dyn, uintptr_t addr, uintptr_t ip, int ni
             } else {
                 GETGB(x3);
                 addr = geted(dyn, addr, ninst, nextop, &ed, x2, x1, &fixedaddress, rex, LOCK_LOCK, 0, 0);
-                // AMSWAP_DB_B(x1, gd, ed);
-                SMDMB();
-                LD_BU(x1, ed, 0);
-                ST_B(gd, ed, 0);
-                SMDMB();
+                if (la64_lam_bh)
+                    AMSWAP_DB_B(x1, gd, ed);
+                else {
+                    SMDMB();
+                    LD_BU(x1, ed, 0);
+                    ST_B(gd, ed, 0);
+                    SMDMB();
+                }
                 BSTRINS_D(gb1, x1, gb2 + 7, gb2);
             }
             break;
diff --git a/src/include/debug.h b/src/include/debug.h
index 422a8f6e..f7719991 100644
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -63,6 +63,9 @@ extern int rv64_xtheadmac;
 extern int rv64_xtheadfmv;
 #elif defined(LA64)
 extern int la64_lbt;
+extern int la64_lam_bh;
+extern int la64_lamcas;
+extern int la64_scq;
 #endif
 #endif
 extern int box64_libcef;