]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 253436 - vex amd64->IR: unhandled instruction bytes: 0xF2 0xA6 (repne cmps) users/paulf/try-bug253436
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 24 Jan 2026 07:20:29 +0000 (08:20 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 24 Jan 2026 07:20:29 +0000 (08:20 +0100)
Patch submitted by jacobly.alt@gmail.com
Regtest update submitted by Lukas Dullinger <itislu.git@gmail.com>

NEWS
VEX/priv/guest_amd64_toIR.c
VEX/test/test-amd64.c

diff --git a/NEWS b/NEWS
index 9091f0a390ad7c3ec549de673d10336b4cf5b7fa..d907a32e484efeed3797311165e3acc44b3a1bfe 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 
 126256  (fnop) vex x86->IR: unhandled instruction bytes: 0xD9 0xD0 0x31 0xC0
 228343  none/tests/darwin/bug228343 fails on OS X
+253436  vex amd64->IR: unhandled instruction bytes: 0xF2 0xA6 (repne cmps)
 258140  Valgrind on OS X always reports some memory "still reachable"
 413369  unhandled amd64-darwin syscall: unix:151 (getpgid)
 487055  memcheck/tests/x86-linux/scalar fails running in Docker
index 5faf9c07c04e28363f664ac7143ff14b71517ac3..39a88b4e680f37918464ceb4487b7feda2e17b0e 100644 (file)
@@ -20768,8 +20768,8 @@ Long dis_ESC_NONE (
          dis_REP_op ( dres, AMD64CondAlways, dis_MOVS, sz,
                       guest_RIP_curr_instr,
                       guest_RIP_bbstart+delta, "rep movs", pfx );
-        dres->whatNext = Dis_StopHere;
-        return delta;
+         vassert(dres->whatNext == Dis_StopHere);
+         return delta;
       }
       /* A4: movsb */
       if (!haveF3(pfx) && !haveF2(pfx)) {
@@ -20782,14 +20782,31 @@ Long dis_ESC_NONE (
 
    case 0xA6:
    case 0xA7:
-      /* F3 A6/A7: repe cmps/rep cmps{w,l,q} */
-      if (haveF3(pfx) && !haveF2(pfx)) {
+      /* F2 A6/A7: repne cmpsb/repne cmps{w,l,q} */
+      if (haveF2(pfx) && !haveF3(pfx)) {
+         if (opc == 0xA6)
+            sz = 1;
+         dis_REP_op ( dres, AMD64CondNZ, dis_CMPS, sz, 
+                      guest_RIP_curr_instr,
+                      guest_RIP_bbstart+delta, "repne cmps", pfx );
+         vassert(dres->whatNext == Dis_StopHere);
+         return delta;
+      }
+      /* F3 A6/A7: repe cmpsb/repe cmps{w,l,q} */
+      if (!haveF2(pfx) && haveF3(pfx)) {
          if (opc == 0xA6)
             sz = 1;
          dis_REP_op ( dres, AMD64CondZ, dis_CMPS, sz, 
                       guest_RIP_curr_instr,
                       guest_RIP_bbstart+delta, "repe cmps", pfx );
-         dres->whatNext = Dis_StopHere;
+         vassert(dres->whatNext == Dis_StopHere);
+         return delta;
+      }
+      /* A6/A7: cmpsb/cmps{w,l,q} */
+      if (!haveF2(pfx) && !haveF3(pfx)) {
+         if (opc == 0xA6)
+            sz = 1;
+         dis_string_op ( dis_CMPS, sz, "cmps", pfx );
          return delta;
       }
       goto decode_failure;
index bedc99e98f4ce6f13e3b4d674ad66c36d566d8d3..981aa3ea030b0ce79cc20e0c106e4cfc323b706d 100644 (file)
@@ -1207,9 +1207,9 @@ void test_string(void)
    TEST_STRING(scas, "");
    // REINSTATE: TEST_STRING(scas, "repz ");
    TEST_STRING(scas, "repnz ");
-   // REINSTATE: TEST_STRING(cmps, "");
+   TEST_STRING(cmps, "");
    TEST_STRING(cmps, "repz ");
-   // REINSTATE: TEST_STRING(cmps, "repnz ");
+   TEST_STRING(cmps, "repnz ");
 }
 
 /* VM86 test */