]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix some minor things to do with memory fences and the Elan3 drivers.
authorJulian Seward <jseward@acm.org>
Fri, 7 Jan 2005 14:14:50 +0000 (14:14 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 7 Jan 2005 14:14:50 +0000 (14:14 +0000)
Also recognise "lock addl $0,0(%esp)" as a memory fence.

git-svn-id: svn://svn.valgrind.org/vex/trunk@700

VEX/priv/guest-x86/toIR.c
VEX/priv/host-x86/hdefs.c
VEX/priv/ir/iropt.c

index 81fc2fa0ea138b9e058dc32cb40bdc6ec6179eff..3f9768ff384ebdbeb60d914426a4e632c3163c08 100644 (file)
@@ -6880,11 +6880,25 @@ DisResult disInstr ( /*IN*/  Bool       resteerOK,
       a memory barrier, for example  lock addl $0,0(%esp)
       and emit an IR MFence construct.
    */
-   if (getIByte(delta) == 0xF0) { 
-      if (1) {
+   if (getIByte(delta) == 0xF0) {
+
+      UChar* code = (UChar*)(guest_code + delta);
+
+      /* Various bits of kernel headers use the following as a memory
+         barrier.  Hence, first emit an MFence and then let the insn
+         go through as usual. */
+      /* F08344240000:  lock addl $0, 0(%esp) */
+      if (code[0] == 0xF0 && code[1] == 0x83 && code[2] == 0x44 && 
+          code[3] == 0x24 && code[4] == 0x00 && code[5] == 0x00) {
+         stmt( IRStmt_MFence() );
+      }
+      else
+      if (0) {
          vex_printf("vex x86->IR: ignoring LOCK prefix on: ");
          insn_verbose = True;
       }
+
+      /* In any case, skip the prefix. */
       delta++;
    }
 
index 90d647bbaab62004878afda43af5af64d4e01ee3..c24b082aae84114249f7e51500b03f9198f76dc5 100644 (file)
@@ -2338,7 +2338,7 @@ Int emit_X86Instr ( UChar* buf, Int nbuf, X86Instr* i )
 
    case Xin_MFence:
       /* see comment in hdefs.h re this insn */
-vex_printf("EMIT FENCE\n");
+      if (0) vex_printf("EMIT FENCE\n");
       switch (i->Xin.MFence.subarch) {
          case VexSubArchX86_sse0:
             vassert(0); /* awaiting test case */
index 50dd02dcaef8fc587317db9854e42d144c16a818..14c478905552bc05847650b21db38a6659916fba 100644 (file)
@@ -2333,6 +2333,10 @@ Bool guestAccessWhichMightOverlapPutI (
    getArrayBounds(pi->Ist.PutI.descr, &minoffP, &maxoffP);
    switch (s2->tag) {
 
+      case Ist_MFence:
+         /* just be paranoid ... this should be rare. */
+         return True;
+
       case Ist_Dirty:
          /* If the dirty call has any guest effects at all, give up.
             Probably could do better. */