From: Julian Seward Date: Fri, 7 Jan 2005 14:14:50 +0000 (+0000) Subject: Fix some minor things to do with memory fences and the Elan3 drivers. X-Git-Tag: svn/VALGRIND_3_0_1^2~634 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eae818a4d4988671ed54cb88d12c772954d5eb68;p=thirdparty%2Fvalgrind.git Fix some minor things to do with memory fences and the Elan3 drivers. Also recognise "lock addl $0,0(%esp)" as a memory fence. git-svn-id: svn://svn.valgrind.org/vex/trunk@700 --- diff --git a/VEX/priv/guest-x86/toIR.c b/VEX/priv/guest-x86/toIR.c index 81fc2fa0ea..3f9768ff38 100644 --- a/VEX/priv/guest-x86/toIR.c +++ b/VEX/priv/guest-x86/toIR.c @@ -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++; } diff --git a/VEX/priv/host-x86/hdefs.c b/VEX/priv/host-x86/hdefs.c index 90d647bbaa..c24b082aae 100644 --- a/VEX/priv/host-x86/hdefs.c +++ b/VEX/priv/host-x86/hdefs.c @@ -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 */ diff --git a/VEX/priv/ir/iropt.c b/VEX/priv/ir/iropt.c index 50dd02dcae..14c4789055 100644 --- a/VEX/priv/ir/iropt.c +++ b/VEX/priv/ir/iropt.c @@ -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. */