]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Handle the invalid opcode 0000.
authorFlorian Krohm <florian@eich-krohm.de>
Mon, 8 Aug 2011 18:22:58 +0000 (18:22 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Mon, 8 Aug 2011 18:22:58 +0000 (18:22 +0000)
This is sometimes used by applications on purpose.
Although never executed, we might still decode it because
of chasing unconditional goto/calls.

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

VEX/priv/guest_s390_defs.h
VEX/priv/guest_s390_helpers.c
VEX/priv/guest_s390_toIR.c

index 733902481c845623eff6a9989a55c2da17137e23..3c389551b633fc4c2b1d9cc3fda01ebcedac8f64 100644 (file)
@@ -74,6 +74,7 @@ extern VexGuestLayout s390xGuest_layout;
 /*------------------------------------------------------------*/
 /*--- Dirty Helper functions.                              ---*/
 /*------------------------------------------------------------*/
+void s390x_dirtyhelper_00(VexGuestS390XState *guest_state);
 void s390x_dirtyhelper_EX(ULong torun);
 ULong s390x_dirtyhelper_STCK(ULong *addr);
 ULong s390x_dirtyhelper_STCKF(ULong *addr);
index ff48771d2d2934d01ffdf03694ff7df3d1edebb6..b95810cb498a4fb8b5c60eccf4d30573a56348de 100644 (file)
@@ -226,6 +226,21 @@ VexGuestLayout s390xGuest_layout = {
    }
 };
 
+/*------------------------------------------------------------*/
+/*--- Dirty helper for invalid opcode 00                   ---*/
+/*------------------------------------------------------------*/
+#if defined(VGA_s390x)
+void
+s390x_dirtyhelper_00(VexGuestS390XState *guest_state)
+{
+   /* Avoid infinite loop in case SIGILL is caught. See also
+      none/tests/s390x/op_exception.c */
+   guest_state->guest_IA += 2;
+
+   asm volatile(".hword 0\n");
+}
+#endif
+
 /*------------------------------------------------------------*/
 /*--- Dirty helper for EXecute                             ---*/
 /*------------------------------------------------------------*/
index ce0722c708665f63e5c8569616a45e5a2abf5c2a..79f13d4ea45524da0ea4b8cd481397507991a57d 100644 (file)
@@ -2063,6 +2063,26 @@ s390_format_SIL_RDU(HChar *(*irgen)(UShort i2, IRTemp op1addr),
 /*--- Build IR for opcodes                                 ---*/
 /*------------------------------------------------------------*/
 
+static HChar *
+s390_irgen_00(UChar r1 __attribute__((unused)),
+              UChar r2 __attribute__((unused)))
+{
+   IRDirty *d;
+
+   d = unsafeIRDirty_0_N (0, "s390x_dirtyhelper_00", &s390x_dirtyhelper_00,
+                          mkIRExprVec_0());
+   d->needsBBP = 1;  /* Need to pass pointer to guest state to helper */
+
+   d->fxState[0].fx     = Ifx_Modify;  /* read then write */
+   d->fxState[0].offset = S390X_GUEST_OFFSET(guest_IA);
+   d->fxState[0].size   = sizeof(ULong);
+   d->nFxState = 1;
+
+   stmt(IRStmt_Dirty(d));
+
+   return "00";
+}
+
 static HChar *
 s390_irgen_AR(UChar r1, UChar r2)
 {
@@ -10688,6 +10708,8 @@ s390_decode_2byte_and_irgen(UChar *bytes)
    ((char *)(&ovl.value))[1] = bytes[1];
 
    switch (ovl.value & 0xffff) {
+   case 0x0000: /* invalid opcode */
+      s390_format_RR_RR(s390_irgen_00, 0, 0); goto ok;
    case 0x0101: /* PR */ goto unimplemented;
    case 0x0102: /* UPT */ goto unimplemented;
    case 0x0104: /* PTFF */ goto unimplemented;