From: Julian Seward Date: Thu, 23 Sep 2010 11:01:15 +0000 (+0000) Subject: LibVEX_GuestARM_get_cpsr: set CPSR.Q, .GE, .T and .M X-Git-Tag: svn/VALGRIND_3_6_1^2~41 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5be2c2e8527dca9efe02015c12cb445e92b43b77;p=thirdparty%2Fvalgrind.git LibVEX_GuestARM_get_cpsr: set CPSR.Q, .GE, .T and .M in the resulting value. Fixes #251362. git-svn-id: svn://svn.valgrind.org/vex/trunk@2041 --- diff --git a/VEX/priv/guest_arm_helpers.c b/VEX/priv/guest_arm_helpers.c index 3b3eb30355..e90d44e2c6 100644 --- a/VEX/priv/guest_arm_helpers.c +++ b/VEX/priv/guest_arm_helpers.c @@ -478,14 +478,39 @@ void LibVEX_GuestARM_put_flags ( UInt flags_native, /* VISIBLE TO LIBVEX CLIENT */ UInt LibVEX_GuestARM_get_cpsr ( /*IN*/VexGuestARMState* vex_state ) { - UInt nzcv; - nzcv = armg_calculate_flags_nzcv( - vex_state->guest_CC_OP, - vex_state->guest_CC_DEP1, - vex_state->guest_CC_DEP2, - vex_state->guest_CC_NDEP - ); - return nzcv; + UInt cpsr = 0; + // NZCV + cpsr |= armg_calculate_flags_nzcv( + vex_state->guest_CC_OP, + vex_state->guest_CC_DEP1, + vex_state->guest_CC_DEP2, + vex_state->guest_CC_NDEP + ); + vassert(0 == (cpsr & 0x0FFFFFFF)); + // Q + if (vex_state->guest_QFLAG32 > 0) + cpsr |= (1 << 27); + // GE + if (vex_state->guest_GEFLAG0 > 0) + cpsr |= (1 << 16); + if (vex_state->guest_GEFLAG1 > 0) + cpsr |= (1 << 17); + if (vex_state->guest_GEFLAG2 > 0) + cpsr |= (1 << 18); + if (vex_state->guest_GEFLAG3 > 0) + cpsr |= (1 << 19); + // M + cpsr |= (1 << 4); // 0b10000 means user-mode + // J,T J (bit 24) is zero by initialisation above + // T we copy from R15T[0] + if (vex_state->guest_R15T & 1) + cpsr |= (1 << 5); + // ITSTATE we punt on for the time being. Could compute it + // if needed though. + // E, endianness, 0 (littleendian) from initialisation above + // A,I,F disable some async exceptions. Not sure about these. + // Leave as zero for the time being. + return cpsr; } /* VISIBLE TO LIBVEX CLIENT */