From: Julian Seward Date: Sat, 14 Dec 2002 23:59:09 +0000 (+0000) Subject: Merge patch from JeremyF: X-Git-Tag: svn/VALGRIND_1_9_4~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8c2b4c7de61d089b1f1da99a4cbec64549ec8cb;p=thirdparty%2Fvalgrind.git Merge patch from JeremyF: 66-illegal-instr When translation encounters an illegal instruction, emit a call to an illegal instruction rather than giving up altogether. Some programs check for CPU capabilities by actually trying them out, so we want to match a dumb Pentium's behaviour a little better. It still prints the message, so it won't hide actual illegal or mis-parsed instructions. I was hoping this might make the Nvidia drivers realize they're running on a pre-MMX P5, but apparently they just won't take that as an answer. It does make the virtual CPU behave a little more like a real CPU though. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1370 --- diff --git a/coregrind/vg_helpers.S b/coregrind/vg_helpers.S index 3861abecd3..b2af7d79a8 100644 --- a/coregrind/vg_helpers.S +++ b/coregrind/vg_helpers.S @@ -536,7 +536,13 @@ VG_(helper_idiv_16_8): popl %eax ret - + +/* Undefined instruction (generates SIGILL) */ +.globl VG_(helper_undefined_instruction) +VG_(helper_undefined_instruction): +1: ud2 + jmp 1b + ##--------------------------------------------------------------------## ##--- end vg_helpers.S ---## ##--------------------------------------------------------------------## diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h index 6b8b32a752..67943acf3d 100644 --- a/coregrind/vg_include.h +++ b/coregrind/vg_include.h @@ -1547,6 +1547,8 @@ extern void VG_(helper_SAHF); extern void VG_(helper_DAS); extern void VG_(helper_DAA); +extern void VG_(helper_undefined_instruction); + /* NOT A FUNCTION; this is a bogus RETURN ADDRESS. */ extern void VG_(signalreturn_bogusRA)( void ); @@ -1671,6 +1673,8 @@ extern Int VGOFF_(helper_SAHF); extern Int VGOFF_(helper_DAS); extern Int VGOFF_(helper_DAA); +extern Int VGOFF_(helper_undefined_instruction); + extern Int VGOFF_(handle_esp_assignment); /* :: Addr -> void */ /* For storing extension-specific helpers, determined at runtime. The addr diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 825f045f66..e2d97135ad 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -100,6 +100,7 @@ Int VGOFF_(helper_SAHF) = INVALID_OFFSET; Int VGOFF_(helper_DAS) = INVALID_OFFSET; Int VGOFF_(helper_DAA) = INVALID_OFFSET; Int VGOFF_(handle_esp_assignment) = INVALID_OFFSET; +Int VGOFF_(helper_undefined_instruction) = INVALID_OFFSET; /* MAX_NONCOMPACT_HELPERS can be increased easily. If MAX_COMPACT_HELPERS is * increased too much, they won't really be compact any more... */ @@ -318,6 +319,9 @@ static void vg_init_baseBlock ( void ) VGOFF_(helper_DAA) = alloc_BaB_1_set( (Addr) & VG_(helper_DAA) ); + VGOFF_(helper_undefined_instruction) + = alloc_BaB_1_set( (Addr) & VG_(helper_undefined_instruction) ); + /* Allocate slots for noncompact helpers */ assign_helpers_in_baseBlock(VG_(n_noncompact_helpers), VG_(noncompact_helper_offsets), diff --git a/coregrind/vg_to_ucode.c b/coregrind/vg_to_ucode.c index 601b2ee4a9..b60f8aaf6e 100644 --- a/coregrind/vg_to_ucode.c +++ b/coregrind/vg_to_ucode.c @@ -4679,7 +4679,16 @@ static Addr disInstr ( UCodeBlock* cb, Addr eip, Bool* isEnd ) "MMX, SSE, SSE2 or 3DNow!\n" ); VG_(printf)("instruction. Valgrind does not currently " "support such instructions. Sorry.\n" ); - VG_(unimplemented)("unhandled x86 0x0F 2-byte opcode"); + uInstr0(cb, CALLM_S, 0); + uInstr1(cb, CALLM, 0, Lit16, VGOFF_(helper_undefined_instruction)); + uInstr0(cb, CALLM_E, 0); + + /* just because everything else insists the last instruction + of a BB is a jmp */ + uInstr1(cb, JMP, 0, Literal, 0); + uCond(cb, CondAlways); + uLiteral(cb, eip); + *isEnd = True; } break;