]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390: Add support for the ecag insn. Patch from Divya Vyas
authorFlorian Krohm <florian@eich-krohm.de>
Sun, 26 Aug 2012 18:58:13 +0000 (18:58 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sun, 26 Aug 2012 18:58:13 +0000 (18:58 +0000)
(divyvyas@linux.vnet.ibm.com) with mods to terminate the super block
with EmFail in case the insn is not available on the host.
Part of fixing bugzilla #275800.

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

VEX/priv/guest_s390_defs.h
VEX/priv/guest_s390_helpers.c
VEX/priv/guest_s390_toIR.c
VEX/priv/main_main.c
VEX/pub/libvex_emnote.h

index 1d771af96fff4c7e80ee374bd75408a29bf5130d..1c99e502ca6851ea323146abb75633eb514ab50d 100644 (file)
@@ -92,6 +92,7 @@ ULong s390_do_cu41(UInt srcvalue);
 ULong s390_do_cu42(UInt srcvalue);
 UInt  s390_do_cvb(ULong decimal);
 ULong s390_do_cvd(ULong binary);
+ULong s390_do_ecag(ULong op2addr);
 
 /* The various ways to compute the condition code. */
 enum {
index 09ee1581b79e1d25daf5ea555d1ea39eb5bdc0b5..81d6727daab31c520a90db575bd1d2a7660a25b8 100644 (file)
@@ -848,6 +848,24 @@ s390_do_cvd(ULong binary_in)
 ULong s390_do_cvd(ULong binary) { return 0; }
 #endif
 
+/*------------------------------------------------------------*/
+/*--- Clean helper for "Extract cache attribute".          ---*/
+/*------------------------------------------------------------*/
+#if defined(VGA_s390x)
+ULong
+s390_do_ecag(ULong op2addr)
+{
+   ULong result;
+
+   __asm__ volatile(".insn rsy,0xEB000000004C,%[out],0,0(%[in])\n\t"
+                    : [out] "=d"(result)
+                    : [in] "d"(op2addr));
+   return result;
+}
+
+#else
+ULong s390_do_ecag(ULong op2addr) { return 0; }
+#endif
 
 /*------------------------------------------------------------*/
 /*--- Helper for condition code.                           ---*/
index 3612f0567109322808d3b383356140db8cf32ba3..da1c92f4488b5b885b2fb11f5ba1de30282d7bd4 100644 (file)
@@ -11766,6 +11766,38 @@ s390_irgen_CU14(UChar m3, UChar r1, UChar r2)
    return "cu14";
 }
 
+static IRExpr *
+s390_call_ecag(IRExpr *op2addr)
+{
+   IRExpr **args, *call;
+
+   args = mkIRExprVec_1(op2addr);
+   call = mkIRExprCCall(Ity_I64, 0 /*regparm*/,
+                        "s390_do_ecag", &s390_do_ecag, args);
+
+   /* Nothing is excluded from definedness checking. */
+   call->Iex.CCall.cee->mcx_mask = 0;
+
+   return call;
+}
+
+static HChar *
+s390_irgen_ECAG(UChar r1, UChar r3, IRTemp op2addr)
+{
+   if (! s390_host_has_gie) {
+      stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_EMNOTE),
+           mkU32(EmFail_S390X_ecag)));
+      put_IA(mkaddr_expr(guest_IA_next_instr));
+      dis_res->whatNext = Dis_StopHere;
+      dis_res->jk_StopHere = Ijk_EmFail;
+   } else {
+      put_gpr_dw0(r1, s390_call_ecag(mkexpr(op2addr)));
+   }
+
+   return "ecag";
+}
+
+
 /*------------------------------------------------------------*/
 /*--- Build IR for special instructions                    ---*/
 /*------------------------------------------------------------*/
@@ -13488,7 +13520,10 @@ s390_decode_6byte_and_irgen(UChar *bytes)
                                                 ovl.fmt.RSY.r1, ovl.fmt.RSY.r3,
                                                 ovl.fmt.RSY.b2, ovl.fmt.RSY.dl2,
                                                 ovl.fmt.RSY.dh2);  goto ok;
-   case 0xeb000000004cULL: /* ECAG */ goto unimplemented;
+   case 0xeb000000004cULL: s390_format_RSY_RRRD(s390_irgen_ECAG, ovl.fmt.RSY.r1,
+                                                ovl.fmt.RSY.r3, ovl.fmt.RSY.b2,
+                                                ovl.fmt.RSY.dl2, 
+                                                ovl.fmt.RSY.dh2);  goto ok;
    case 0xeb0000000051ULL: s390_format_SIY_URD(s390_irgen_TMY, ovl.fmt.SIY.i2,
                                                ovl.fmt.SIY.b1, ovl.fmt.SIY.dl1,
                                                ovl.fmt.SIY.dh1);  goto ok;
index 26f259efb4197bd572baa5c9922c04e954c63639..58e166b03c947ad9c6ad70c82ea4ea8578cd3571 100644 (file)
@@ -1030,6 +1030,8 @@ HChar* LibVEX_EmNote_string ( VexEmNote ew )
         return "Instruction stfle is not supported on this host";
    case EmFail_S390X_stckf:
         return "Instruction stckf is not supported on this host";
+   case EmFail_S390X_ecag:
+        return "Instruction ecag is not supported on this host";
      default: 
         vpanic("LibVEX_EmNote_string: unknown warning");
    }
index 5f02bba1fe7f79f6e6b81dff0febdece42cf3a48..f5cf943918fe8e2551b0a28374bcd3f5cfc400ad 100644 (file)
@@ -91,6 +91,9 @@ typedef
       /* stckf insn is not supported on this host */
       EmFail_S390X_stckf,
 
+      /* ecag insn is not supported on this host */
+      EmFail_S390X_ecag,
+
       EmNote_NUMBER
    }
    VexEmNote;