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