06ef44f
From d10cd86ee32bf76495f79c02df62fc242adbcbe3 Mon Sep 17 00:00:00 2001
06ef44f
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
06ef44f
Date: Thu, 26 Jul 2018 16:35:24 +0200
06ef44f
Subject: [PATCH] s390x: More fixes for z13 support
06ef44f
06ef44f
This patch addresses the following:
06ef44f
06ef44f
* Fix the implementation of LOCGHI.  Previously Valgrind performed 32-bit
06ef44f
  sign extension instead of 64-bit sign extension on the immediate value.
06ef44f
06ef44f
* Advertise VXRS in HWCAP.  If no VXRS are advertised, but the program
06ef44f
  uses vector registers, this could cause problems with a glibc built with
06ef44f
  "-march=z13".
06ef44f
---
06ef44f
 VEX/priv/guest_s390_toIR.c          | 2 +-
06ef44f
 coregrind/m_initimg/initimg-linux.c | 6 +++---
06ef44f
 2 files changed, 4 insertions(+), 4 deletions(-)
06ef44f
06ef44f
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
06ef44f
index 9c4d79b87..50a5a4177 100644
06ef44f
--- a/VEX/priv/guest_s390_toIR.c
06ef44f
+++ b/VEX/priv/guest_s390_toIR.c
06ef44f
@@ -16325,7 +16325,7 @@ static const HChar *
06ef44f
 s390_irgen_LOCGHI(UChar r1, UChar m3, UShort i2, UChar unused)
06ef44f
 {
06ef44f
    next_insn_if(binop(Iop_CmpEQ32, s390_call_calculate_cond(m3), mkU32(0)));
06ef44f
-   put_gpr_dw0(r1, mkU64((UInt)(Int)(Short)i2));
06ef44f
+   put_gpr_dw0(r1, mkU64((ULong)(Long)(Short)i2));
06ef44f
 
06ef44f
    return "locghi";
06ef44f
 }
06ef44f
diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c
06ef44f
index 61cc458bc..8a7f0d024 100644
06ef44f
--- a/coregrind/m_initimg/initimg-linux.c
06ef44f
+++ b/coregrind/m_initimg/initimg-linux.c
06ef44f
@@ -699,9 +699,9 @@ Addr setup_client_stack( void*  init_sp,
06ef44f
             }
06ef44f
 #           elif defined(VGP_s390x_linux)
06ef44f
             {
06ef44f
-               /* Advertise hardware features "below" TE only.  TE and VXRS
06ef44f
-                  (and anything above) are not supported by Valgrind. */
06ef44f
-               auxv->u.a_val &= VKI_HWCAP_S390_TE - 1;
06ef44f
+               /* Advertise hardware features "below" TE and VXRS.  TE itself
06ef44f
+                  and anything above VXRS is not supported by Valgrind. */
06ef44f
+               auxv->u.a_val &= (VKI_HWCAP_S390_TE - 1) | VKI_HWCAP_S390_VXRS;
06ef44f
             }
06ef44f
 #           elif defined(VGP_arm64_linux)
06ef44f
             {
06ef44f
-- 
06ef44f
2.17.0
06ef44f