|
From: Florian K. <br...@ac...> - 2011-08-08 18:25:53
|
On 08/07/2011 03:50 PM, Christian Borntraeger wrote:
> On 30/07/11 17:44, Florian Krohm wrote:
>> On 07/30/2011 11:02 AM, Christian Borntraeger wrote:
>>>>
>
> I found some time to look at the ex_clone testcase. The error comes from
> decoding libcs abort function coming from base_from_cb_data
> (which was not done before we had resteer)
>
>
> the code in question is
> [...]
> if (stage == 7)
> {
> ++stage;
> _exit (127);
> }
> [...]
> while (1)
> /* Try for ever and ever. */
> ABORT_INSTRUCTION;
>
>
>
> and ABORT_INSTRUCTION is defined as
> "asm (".word 0")"
>
>
> Florian, looks like we should treat 0000 special.
>
Thanks for investigating this. So we're decoding 0000 although we're
never executing this because we leave the superblock earlier via a
conditional branch. Makes sense.
I'm going to tentatively apply this here (because I can't reproduce
the DRD failures on my box):
Index: VEX/priv/guest_s390_toIR.c
===================================================================
--- VEX/priv/guest_s390_toIR.c (revision 2187)
+++ VEX/priv/guest_s390_toIR.c (working copy)
@@ -2064,6 +2064,26 @@
/*------------------------------------------------------------*/
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)
{
IRTemp op1 = newTemp(Ity_I32);
@@ -10688,6 +10708,8 @@
((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;
Index: VEX/priv/guest_s390_defs.h
===================================================================
--- VEX/priv/guest_s390_defs.h (revision 2186)
+++ VEX/priv/guest_s390_defs.h (working copy)
@@ -74,6 +74,7 @@
/*------------------------------------------------------------*/
/*--- 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: VEX/priv/guest_s390_helpers.c
===================================================================
--- VEX/priv/guest_s390_helpers.c (revision 2186)
+++ VEX/priv/guest_s390_helpers.c (working copy)
@@ -227,6 +227,21 @@
};
/*------------------------------------------------------------*/
+/*--- 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 ---*/
/*------------------------------------------------------------*/
void
and we'll see how this helps.
It'll make op_exception fail. I'll fix that later should this patch
become permanent.
Florian
|