Discussion:
vex: r3368 - in /trunk/priv: guest_arm64_defs.h guest_arm64_helpers.c guest_arm64_toIR.c
Add Reply
s***@valgrind.org
2017-05-14 13:00:10 UTC
Reply
Permalink
Raw Message
Author: sewardj
Date: Sun May 14 14:00:07 2017
New Revision: 3368

Log:
Implement "mrs <reg>, cntfrq_el0". Fixes #368868.

Modified:
trunk/priv/guest_arm64_defs.h
trunk/priv/guest_arm64_helpers.c
trunk/priv/guest_arm64_toIR.c

Modified: trunk/priv/guest_arm64_defs.h
==============================================================================
--- trunk/priv/guest_arm64_defs.h (original)
+++ trunk/priv/guest_arm64_defs.h Sun May 14 14:00:07 2017
@@ -124,6 +124,8 @@

extern ULong arm64g_dirtyhelper_MRS_CNTVCT_EL0 ( void );

+extern ULong arm64g_dirtyhelper_MRS_CNTFRQ_EL0 ( void );
+
extern void arm64g_dirtyhelper_PMULLQ ( /*OUT*/V128* res,
ULong arg1, ULong arg2 );


Modified: trunk/priv/guest_arm64_helpers.c
==============================================================================
--- trunk/priv/guest_arm64_helpers.c (original)
+++ trunk/priv/guest_arm64_helpers.c Sun May 14 14:00:07 2017
@@ -774,6 +774,21 @@
}


+/* CALLED FROM GENERATED CODE */
+/* DIRTY HELPER (non-referentially-transparent) */
+/* Horrible hack. On non-arm64 platforms, return 0. */
+ULong arm64g_dirtyhelper_MRS_CNTFRQ_EL0 ( void )
+{
+# if defined(__aarch64__) && !defined(__arm__)
+ ULong w = 0x5555555555555555ULL; /* overwritten */
+ __asm__ __volatile__("mrs %0, cntfrq_el0" : "=r"(w));
+ return w;
+# else
+ return 0ULL;
+# endif
+}
+
+
void arm64g_dirtyhelper_PMULLQ ( /*OUT*/V128* res, ULong arg1, ULong arg2 )
{
/* This doesn't need to be a dirty helper, except for the fact that

Modified: trunk/priv/guest_arm64_toIR.c
==============================================================================
--- trunk/priv/guest_arm64_toIR.c (original)
+++ trunk/priv/guest_arm64_toIR.c Sun May 14 14:00:07 2017
@@ -7008,6 +7008,27 @@
DIP("mrs %s, cntvct_el0\n", nameIReg64orZR(tt));
return True;
}
+ /* ---- Cases for CNTFRQ_EL0 ----
+ This is always RO at EL0, so it's safe to pass through to the host.
+ D5 3B E0 000 Rt MRS Xt, cntfrq_el0
+ */
+ if ((INSN(31,0) & 0xFFFFFFE0) == 0xD53BE000) {
+ UInt tt = INSN(4,0);
+ IRTemp val = newTemp(Ity_I64);
+ IRExpr** args = mkIRExprVec_0();
+ IRDirty* d = unsafeIRDirty_1_N (
+ val,
+ 0/*regparms*/,
+ "arm64g_dirtyhelper_MRS_CNTFRQ_EL0",
+ &arm64g_dirtyhelper_MRS_CNTFRQ_EL0,
+ args
+ );
+ /* execute the dirty call, dumping the result in val. */
+ stmt( IRStmt_Dirty(d) );
+ putIReg64orZR(tt, mkexpr(val));
+ DIP("mrs %s, cntfrq_el0\n", nameIReg64orZR(tt));
+ return True;
+ }

/* ------------------ IC_IVAU ------------------ */
/* D5 0B 75 001 Rt ic ivau, rT

Loading...