]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
emit_ARM64Instr: fix assertion failures associated with chaining patching (ARM64in_XD...
authorJulian Seward <jseward@acm.org>
Sat, 5 May 2018 08:03:26 +0000 (10:03 +0200)
committerJulian Seward <jseward@acm.org>
Sat, 5 May 2018 08:03:26 +0000 (10:03 +0200)
This has happened because (I think!) this has never before been tested with
guest code addresses >= 2^48.  This in turn means that this is the first
time that

  p = imm64_to_ireg(p, /*x*/9, i->ARM64in.XDirect.dstGA);

has been called upon to emit a constant which is non-zero in all four 16-bit
chunks, so it generates 4 instructions rather than (at most, in all previous
runs) 3, and so the "how many insns at max" assertions failed.  This commit
fixes the assertions.

VEX/priv/host_arm64_defs.c

index 4d088c77b4822575b3e9be1cd0d268ae9e91178b..a1328ff8fe5ae6f07df5696fecd1462b82c1188d 100644 (file)
@@ -3572,7 +3572,7 @@ Int emit_ARM64Instr ( /*MB_MOD*/Bool* is_profInc,
          /* Fix up the conditional jump, if there was one. */
          if (i->ARM64in.XDirect.cond != ARM64cc_AL) {
             Int delta = (UChar*)p - (UChar*)ptmp; /* must be signed */
-            vassert(delta > 0 && delta < 40);
+            vassert(delta > 0 && delta <= 40);
             vassert((delta & 3) == 0);
             UInt notCond = 1 ^ (UInt)i->ARM64in.XDirect.cond;
             vassert(notCond <= 13); /* Neither AL nor NV */
@@ -5481,7 +5481,7 @@ Int emit_ARM64Instr ( /*MB_MOD*/Bool* is_profInc,
    /*NOTREACHED*/
 
   done:
-   vassert(((UChar*)p) - &buf[0] <= 36);
+   vassert(((UChar*)p) - &buf[0] <= 40);
    return ((UChar*)p) - &buf[0];
 }