]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Track (but ignore) the state of %RFLAGS.ACFLAG, since that is
authorJulian Seward <jseward@acm.org>
Tue, 28 Sep 2010 15:59:04 +0000 (15:59 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 28 Sep 2010 15:59:04 +0000 (15:59 +0000)
necessary for proper CPUID checking.  (pepp, pelloux+kde@gmail.com)
Fixes #249943.

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

VEX/priv/guest_amd64_helpers.c
VEX/priv/guest_amd64_toIR.c
VEX/pub/libvex_guest_amd64.h

index c24cba37b91f18d4b2a910a238e517b81517566d..80feeb125607a15864467d9afd424d8925b7ebb6 100644 (file)
@@ -824,6 +824,9 @@ ULong LibVEX_GuestAMD64_get_rflags ( /*IN*/VexGuestAMD64State* vex_state )
       rflags |= (1<<10);
    if (vex_state->guest_IDFLAG == 1)
       rflags |= (1<<21);
+   if (vex_state->guest_ACFLAG == 1)
+      rflags |= (1<<18);
+
    return rflags;
 }
 
index bdd56cf79a66e24617f33ebcdb3fea9713f18f69..82c2ebab44e7a50ee102669127ff0500e46a0d86 100644 (file)
@@ -411,6 +411,7 @@ static void unimplemented ( HChar* str )
 #define OFFB_FPREGS    offsetof(VexGuestAMD64State,guest_FPREG[0])
 #define OFFB_FPTAGS    offsetof(VexGuestAMD64State,guest_FPTAG[0])
 #define OFFB_DFLAG     offsetof(VexGuestAMD64State,guest_DFLAG)
+#define OFFB_ACFLAG    offsetof(VexGuestAMD64State,guest_ACFLAG)
 #define OFFB_IDFLAG    offsetof(VexGuestAMD64State,guest_IDFLAG)
 #define OFFB_FTOP      offsetof(VexGuestAMD64State,guest_FTOP)
 #define OFFB_FC3210    offsetof(VexGuestAMD64State,guest_FC3210)
@@ -16427,6 +16428,19 @@ DisResult disInstr_AMD64_WRK (
                   mkU64(1))) 
           );
 
+      /* And set the AC flag too */
+      stmt( IRStmt_Put( 
+               OFFB_ACFLAG,
+               IRExpr_Mux0X( 
+                  unop(Iop_32to8,
+                  unop(Iop_64to32,
+                       binop(Iop_And64, 
+                             binop(Iop_Shr64, mkexpr(t1), mkU8(18)), 
+                             mkU64(1)))),
+                  mkU64(0), 
+                  mkU64(1))) 
+          );
+
       DIP("popf%c\n", nameISize(sz));
       break;
 
@@ -16591,12 +16605,22 @@ DisResult disInstr_AMD64_WRK (
                               mkU64(1<<21)))
             );
 
+      /* And patch in the AC flag too. */
+      t5 = newTemp(Ity_I64);
+      assign( t5, binop(Iop_Or64,
+                        mkexpr(t4),
+                        binop(Iop_And64,
+                              binop(Iop_Shl64, IRExpr_Get(OFFB_ACFLAG,Ity_I64), 
+                                               mkU8(18)),
+                              mkU64(1<<18)))
+            );
+
       /* if sz==2, the stored value needs to be narrowed. */
       if (sz == 2)
         storeLE( mkexpr(t1), unop(Iop_32to16,
-                             unop(Iop_64to32,mkexpr(t4))) );
+                             unop(Iop_64to32,mkexpr(t5))) );
       else 
-        storeLE( mkexpr(t1), mkexpr(t4) );
+        storeLE( mkexpr(t1), mkexpr(t5) );
 
       DIP("pushf%c\n", nameISize(sz));
       break;
index eb9e19eb1cda977c48f921853350be080ef5d29b..c37e6c8ce0795f5d09cea3f9d3ddab74d8379d04 100644 (file)
@@ -76,15 +76,15 @@ typedef
       /* The D flag is stored here, encoded as either -1 or +1 */
       /* 160 */ ULong  guest_DFLAG;
       /* 168 */ ULong  guest_RIP;
+      /* Bit 18 (AC) of eflags stored here, as either 0 or 1. */
+      /* ... */ ULong  guest_ACFLAG;
+      /* Bit 21 (ID) of eflags stored here, as either 0 or 1. */
+      /* 176 */ ULong guest_IDFLAG;
       /* Probably a lot more stuff too. 
          D,ID flags
          16  128-bit SSE registers
          all the old x87 FPU gunk
-         segment registers
-      */
-
-      /* Bit 21 (ID) of eflags stored here, as either 0 or 1. */
-      /* 176 */ ULong guest_IDFLAG;
+         segment registers */
 
       /* HACK to make tls on amd64-linux work.  %fs only ever seems to
          hold zero, and so guest_FS_ZERO holds the 64-bit offset
@@ -161,7 +161,7 @@ typedef
       ULong guest_IP_AT_SYSCALL;
 
       /* Padding to make it have an 16-aligned size */
-      /* ULong padding; */
+      ULong padding;
    }
    VexGuestAMD64State;