|
From: <sv...@va...> - 2012-08-26 18:58:22
|
florian 2012-08-26 19:58:13 +0100 (Sun, 26 Aug 2012)
New Revision: 2488
Log:
s390: Add support for the ecag insn. Patch from Divya Vyas
(div...@li...) with mods to terminate the super block
with EmFail in case the insn is not available on the host.
Part of fixing bugzilla #275800.
Modified files:
trunk/priv/guest_s390_defs.h
trunk/priv/guest_s390_helpers.c
trunk/priv/guest_s390_toIR.c
trunk/priv/main_main.c
trunk/pub/libvex_emnote.h
Modified: trunk/priv/guest_s390_helpers.c (+18 -0)
===================================================================
--- trunk/priv/guest_s390_helpers.c 2012-08-26 15:32:28 +01:00 (rev 2487)
+++ trunk/priv/guest_s390_helpers.c 2012-08-26 19:58:13 +01:00 (rev 2488)
@@ -848,7 +848,25 @@
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. ---*/
/*------------------------------------------------------------*/
Modified: trunk/priv/guest_s390_defs.h (+1 -0)
===================================================================
--- trunk/priv/guest_s390_defs.h 2012-08-26 15:32:28 +01:00 (rev 2487)
+++ trunk/priv/guest_s390_defs.h 2012-08-26 19:58:13 +01:00 (rev 2488)
@@ -92,6 +92,7 @@
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 {
Modified: trunk/priv/guest_s390_toIR.c (+36 -1)
===================================================================
--- trunk/priv/guest_s390_toIR.c 2012-08-26 15:32:28 +01:00 (rev 2487)
+++ trunk/priv/guest_s390_toIR.c 2012-08-26 19:58:13 +01:00 (rev 2488)
@@ -11766,6 +11766,38 @@
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 @@
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;
Modified: trunk/pub/libvex_emnote.h (+3 -0)
===================================================================
--- trunk/pub/libvex_emnote.h 2012-08-26 15:32:28 +01:00 (rev 2487)
+++ trunk/pub/libvex_emnote.h 2012-08-26 19:58:13 +01:00 (rev 2488)
@@ -91,6 +91,9 @@
/* 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;
Modified: trunk/priv/main_main.c (+2 -0)
===================================================================
--- trunk/priv/main_main.c 2012-08-26 15:32:28 +01:00 (rev 2487)
+++ trunk/priv/main_main.c 2012-08-26 19:58:13 +01:00 (rev 2488)
@@ -1030,6 +1030,8 @@
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");
}
|