From: Florian Krohm Date: Tue, 11 Feb 2014 09:23:01 +0000 (+0000) Subject: s390: Fix s390_amode_for_guest_state. In general the offset relative X-Git-Tag: svn/VALGRIND_3_10_1^2~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97eadc3221530eb91b842d20c72fbd813da7eed9;p=thirdparty%2Fvalgrind.git s390: Fix s390_amode_for_guest_state. In general the offset relative to the guest state pointer may be more than the B12 addressing mode can handle. Fall back and use a B20 addressing mode in those cases. git-svn-id: svn://svn.valgrind.org/vex/trunk@2817 --- diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index ce76285d43..a7e3928e67 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -273,13 +273,20 @@ s390_amode_bx20(Int d, HReg b, HReg x) } -/* Construct an AMODE for accessing the guest state at OFFSET */ +/* Construct an AMODE for accessing the guest state at OFFSET. + OFFSET can be at most 3 * sizeof(VexGuestS390XState) + LibVEX_N_SPILL_BYTES + which may be too large for a B12 addressing mode. + Use a B20 amode as a fallback which will be safe for any offset. +*/ s390_amode * s390_amode_for_guest_state(Int offset) { if (fits_unsigned_12bit(offset)) return s390_amode_b12(offset, s390_hreg_guest_state_pointer()); + if (fits_signed_20bit(offset)) + return s390_amode_b20(offset, s390_hreg_guest_state_pointer()); + vpanic("invalid guest state offset"); } @@ -458,7 +465,6 @@ genSpill_S390(HInstr **i1, HInstr **i2, HReg rreg, Int offsetB, Bool mode64) s390_amode *am; vassert(offsetB >= 0); - vassert(offsetB <= (1 << 12)); /* because we use b12 amode */ vassert(!hregIsVirtual(rreg)); *i1 = *i2 = NULL; @@ -485,7 +491,6 @@ genReload_S390(HInstr **i1, HInstr **i2, HReg rreg, Int offsetB, Bool mode64) s390_amode *am; vassert(offsetB >= 0); - vassert(offsetB <= (1 << 12)); /* because we use b12 amode */ vassert(!hregIsVirtual(rreg)); *i1 = *i2 = NULL;