]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge patch from JeremyF:
authorJulian Seward <jseward@acm.org>
Sat, 14 Dec 2002 23:59:09 +0000 (23:59 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 14 Dec 2002 23:59:09 +0000 (23:59 +0000)
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

coregrind/vg_helpers.S
coregrind/vg_include.h
coregrind/vg_main.c
coregrind/vg_to_ucode.c

index 3861abecd34ff2311cd40f25d9c0b45771364252..b2af7d79a8bf60ff896fe1ee9ca230986f741fb8 100644 (file)
@@ -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 ---##
 ##--------------------------------------------------------------------##
index 6b8b32a752db49eedb18662b160ceded7d5c4f07..67943acf3d66c3bdba77f1f2aea6278f5f9c2197 100644 (file)
@@ -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 
index 825f045f66a3c83ac50c29a48c82f84dab8e5b78..e2d97135adfb76984d268415d175025c5b5a21c3 100644 (file)
@@ -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), 
index 601b2ee4a986f89e68d0403a6567422e94fb5288..b60f8aaf6eae07b4267f3fd4c1d13236b39dda6e 100644 (file)
@@ -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;