From: Florian Krohm Date: Sun, 26 Aug 2012 18:58:13 +0000 (+0000) Subject: s390: Add support for the ecag insn. Patch from Divya Vyas X-Git-Tag: svn/VALGRIND_3_9_0^2~273 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2a11205fe2b86a113f539d25d4e502ed8dd1e4a;p=thirdparty%2Fvalgrind.git s390: Add support for the ecag insn. Patch from Divya Vyas (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 --- diff --git a/VEX/priv/guest_s390_defs.h b/VEX/priv/guest_s390_defs.h index 1d771af96f..1c99e502ca 100644 --- a/VEX/priv/guest_s390_defs.h +++ b/VEX/priv/guest_s390_defs.h @@ -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 { diff --git a/VEX/priv/guest_s390_helpers.c b/VEX/priv/guest_s390_helpers.c index 09ee1581b7..81d6727daa 100644 --- a/VEX/priv/guest_s390_helpers.c +++ b/VEX/priv/guest_s390_helpers.c @@ -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. ---*/ diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index 3612f05671..da1c92f448 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -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; diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index 26f259efb4..58e166b03c 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -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"); } diff --git a/VEX/pub/libvex_emnote.h b/VEX/pub/libvex_emnote.h index 5f02bba1fe..f5cf943918 100644 --- a/VEX/pub/libvex_emnote.h +++ b/VEX/pub/libvex_emnote.h @@ -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;