From: Julian Seward Date: Mon, 10 Jan 2005 16:51:14 +0000 (+0000) Subject: Run x86 host with FPU in 53-bit precision mode (non default). X-Git-Tag: svn/VALGRIND_3_0_0~1100 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=41029893963032d2f03a67230ca60a1cf0e33ef8;p=thirdparty%2Fvalgrind.git Run x86 host with FPU in 53-bit precision mode (non default). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3218 --- diff --git a/coregrind/core_asm.h b/coregrind/core_asm.h index 4b49b50fd5..6b78520f07 100644 --- a/coregrind/core_asm.h +++ b/coregrind/core_asm.h @@ -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. */ diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 6ba20c08c5..9ec067fba8 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -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); diff --git a/coregrind/x86/dispatch.S b/coregrind/x86/dispatch.S index 7505f8c459..5040534498 100644 --- a/coregrind/x86/dispatch.S +++ b/coregrind/x86/dispatch.S @@ -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