]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Run x86 host with FPU in 53-bit precision mode (non default).
authorJulian Seward <jseward@acm.org>
Mon, 10 Jan 2005 16:51:14 +0000 (16:51 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 10 Jan 2005 16:51:14 +0000 (16:51 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3218

coregrind/core_asm.h
coregrind/vg_scheduler.c
coregrind/x86/dispatch.S

index 4b49b50fd5a3f7a04e69d2e522104611542bd504..6b78520f075baca91490d6df4d92e520051ad118 100644 (file)
@@ -52,6 +52,7 @@
 #define VG_TRC_INNER_FASTMISS     37 /* TRC only; means fast-cache miss. */
 #define VG_TRC_INNER_COUNTERZERO  41 /* TRC only; means bb ctr == 0 */
 #define VG_TRC_UNRESUMABLE_SIGNAL 43 /* TRC only; got sigsegv/sigbus */
+#define VG_TRC_INVARIANT_FAILED   47 /* TRC only; invariant violation */
 
 
 /* Constants for the fast translation lookup cache. */
index 6ba20c08c5ca495ce2ad76c01a4e80dff05832fb..9ec067fba85928aef730e0047be6361b60ff5053 100644 (file)
@@ -287,6 +287,7 @@ UInt run_thread_for_a_while ( ThreadId tid )
    volatile UInt sz_vex   = (UInt) sizeof VG_(threads)[tid].arch.vex;
    volatile UInt sz_vexsh = (UInt) sizeof VG_(threads)[tid].arch.vex_shadow;
    volatile UInt sz_spill = (UInt) sizeof VG_(threads)[tid].arch.vex_spill;
+   /* volatile UInt zz = VG_(threads)[tid].arch.vex.guest_EIP; */
 
    /* Paranoia */
    vg_assert(VG_(is_valid_tid)(tid));
@@ -340,6 +341,14 @@ UInt run_thread_for_a_while ( ThreadId tid )
 
    vg_assert(!scheduler_jmpbuf_valid);
 
+   if (trc == VG_TRC_INVARIANT_FAILED) {
+      /* To see the bb causing this to fail, set VG_SCHEDULING_QUANTUM to 1, 
+         and make zz be the program counter at entry to this fn. */
+      /* VG_(translate)(tid,zz,True); */
+      VG_(core_panic)
+         ("host invariant state failure in VEX-generated code");
+   }
+
    done_this_time = (Int)dispatch_ctr_SAVED - (Int)VG_(dispatch_ctr) - 0;
 
    vg_assert(done_this_time >= 0);
index 7505f8c459b233fa65a23d49054a5fe6f43d7c68..50405344980bb8920898c1d1d0ed3d125710b012 100644 (file)
@@ -68,9 +68,10 @@ VG_(run_innerloop):
        movl    (%ebp, %esi, 1), %eax
 
        /* set host FPU control word to the default mode expected 
-          by VEX-generated code. */
+           by VEX-generated code.  See comments in libvex.h for
+           more info. */
        finit
-       pushl   $0x037F
+       pushl   $0x027F
        fldcw   (%esp)
        addl    $4, %esp
        
@@ -123,19 +124,33 @@ dispatch_boring:
        jmp     dispatch_exceptional
 
        
-fast_lookup_failed:
-       /* %EIP is up to date here since dispatch_boring dominates */
-       addl    $1, VG_(dispatch_ctr)
-       movl    $VG_TRC_INNER_FASTMISS, %eax
-       jmp     run_innerloop_exit
 
-counter_is_zero:
-       /* %EIP is up to date here since dispatch_boring dominates */
-       addl    $1, VG_(dispatch_ctr)
-       movl    $VG_TRC_INNER_COUNTERZERO, %eax
-       jmp     run_innerloop_exit
-       
-run_innerloop_exit:
+/* All exits from the dispatcher go through here.  %eax holds
+   the return value. 
+*/
+run_innerloop_exit: 
+       /* We're leaving.  Check that nobody messed with
+           %mxcsr or %fpucw.  We can't mess with %eax here as it
+          holds the tentative return value, but any other is OK. */
+       pushl   $0
+       fstcw   (%esp)
+       cmpl    $0x027F, (%esp)
+       popl    %esi /* get rid of the word without trashing %eflags */
+       jnz     invariant_violation
+       pushl   $0
+       stmxcsr (%esp)
+       andl    $0xFFFFFFC0, (%esp)  /* mask out status flags */
+       cmpl    $0x1F80, (%esp)
+       popl    %esi
+       jnz     invariant_violation
+       /* otherwise we're OK */
+       jmp     run_innerloop_exit_REALLY
+
+invariant_violation:
+       movl    $VG_TRC_INVARIANT_FAILED, %eax
+       jmp     run_innerloop_exit_REALLY
+
+run_innerloop_exit_REALLY:
        popl    %ebp
        popl    %edi
        popl    %esi
@@ -161,6 +176,18 @@ dispatch_exceptional:
        movl    %ebp, %eax
        jmp     run_innerloop_exit
 
+fast_lookup_failed:
+       /* %EIP is up to date here since dispatch_boring dominates */
+       addl    $1, VG_(dispatch_ctr)
+       movl    $VG_TRC_INNER_FASTMISS, %eax
+       jmp     run_innerloop_exit
+
+counter_is_zero:
+       /* %EIP is up to date here since dispatch_boring dominates */
+       addl    $1, VG_(dispatch_ctr)
+       movl    $VG_TRC_INNER_COUNTERZERO, %eax
+       jmp     run_innerloop_exit
+
        
 /* Let the linker know we don't need an executable stack */
 .section .note.GNU-stack,"",@progbits