]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
VEX/priv/guest_riscv64_toIR.c: Recognize both fence and fence.tso
authorMark Wielaard <mark@klomp.org>
Sat, 14 Dec 2024 22:11:57 +0000 (22:11 +0000)
committerMark Wielaard <mark@klomp.org>
Tue, 25 Feb 2025 20:36:49 +0000 (21:36 +0100)
fence.tso is used for __atomic_thread_fence (__ATOMIC_ACQ_REL)

There are 3 fence variants.

fence.tso  fm set to 1000 and pred and succ both set to 0011.
fence with fm set to 0000 and pred and succ both set to 1111.
fence with fm set to 0000 and pred and succ with some iorw flags set.

https://bugs.kde.org/show_bug.cgi?id=468575#c42

VEX/priv/guest_riscv64_toIR.c

index 93ea5a173ddbe5833e568b6f8907da7500f31524..e76a602a0d78a232d3e5f48757d329b09019ee9e 100644 (file)
@@ -1610,19 +1610,26 @@ static Bool dis_RV64I(/*MB_OUT*/ DisResult* dres,
    }
 
    /* ------------------------ fence ------------------------ */
-   if (INSN(19, 0) == 0b00000000000000001111 && INSN(31, 28) == 0b0000) {
+   if (INSN(19, 0) == 0b00000000000000001111) {
+      UInt   fm = INSN(31, 28);
       UInt succ = INSN(23, 20);
       UInt pred = INSN(27, 24);
-      stmt(irsb, IRStmt_MBE(Imbe_Fence));
-      if (pred == 0b1111 && succ == 0b1111)
-         DIP("fence\n");
-      else
-         DIP("fence %s%s%s%s,%s%s%s%s\n", (pred & 0x8) ? "i" : "",
-             (pred & 0x4) ? "o" : "", (pred & 0x2) ? "r" : "",
-             (pred & 0x1) ? "w" : "", (succ & 0x8) ? "i" : "",
-             (succ & 0x4) ? "o" : "", (succ & 0x2) ? "r" : "",
-             (succ & 0x1) ? "w" : "");
-      return True;
+      if ((fm == 0b1000 && pred == 0b0011 && succ == 0b0011)
+          || fm == 0b0000)
+      {
+         if (fm == 0b1000)
+            DIP("fence.tso\n");
+         else if (pred == 0b1111 && succ == 0b1111)
+            DIP("fence\n");
+         else
+            DIP("fence %s%s%s%s,%s%s%s%s\n", (pred & 0x8) ? "i" : "",
+                (pred & 0x4) ? "o" : "", (pred & 0x2) ? "r" : "",
+                (pred & 0x1) ? "w" : "", (succ & 0x8) ? "i" : "",
+                (succ & 0x4) ? "o" : "", (succ & 0x2) ? "r" : "",
+                (succ & 0x1) ? "w" : "");
+         stmt(irsb, IRStmt_MBE(Imbe_Fence));
+         return True;
+      }
    }
 
    /* ------------------------ ecall ------------------------ */