diff --git a/valgrind-3.10.1-s390x-fiebra.patch b/valgrind-3.10.1-s390x-fiebra.patch new file mode 100644 index 0000000..f200e1b --- /dev/null +++ b/valgrind-3.10.1-s390x-fiebra.patch @@ -0,0 +1,309 @@ +Subject: [PATCH] s390x: Fix unrecognized instruction fiebra + +Add support for the z/Architecture instructions FIEBRA and FIDBRA. +Also add a suitable test case. + +GCC may emit FIEBRA since the following GCC patch: + + S/390: Add support for the "load fp integer" instructions: + https://gcc.gnu.org/ml/gcc-patches/2013-09/msg00112.html + +Index: valgrind/none/tests/s390x/rounding-6.c +=================================================================== +--- valgrind.orig/none/tests/s390x/rounding-6.c 2015-07-08 10:53:04.000000000 +0200 ++++ valgrind/none/tests/s390x/rounding-6.c 2015-07-08 12:53:31.000000000 +0200 +@@ -44,6 +44,20 @@ do { \ + opcode, src, dst, cc, rtext(round)); \ + } while (0) + ++#define round_to_int(mnem,opcode,type,round,value) \ ++do { \ ++ type src = value; \ ++ type dst; \ ++ \ ++ __asm__ volatile (".insn rrf,0x" opcode "0000, %[dst],%[src]," #round ",4\n\t" \ ++ : [dst] "=f"(dst) \ ++ : [src] "f"(src) \ ++ : ); \ ++ \ ++ printf("%s %.5f\t-> %g %s\n", \ ++ mnem, src, dst, rtext(round)); \ ++} while (0) ++ + + #define cfebr(value, round) \ + convert_to_int("cfebr",float,int32_t,PRId32,round,value) +@@ -54,6 +68,11 @@ do { \ + #define cgdbr(value, round) \ + convert_to_int("cgdbr",double,int64_t,PRId64,round,value) + ++#define fiebra(value, round) \ ++ round_to_int("fiebra","b357",float,round,value) ++#define fidbra(value, round) \ ++ round_to_int("fidbra","b35f",double,round,value) ++ + void + set_rounding_mode(unsigned mode) + { +@@ -117,5 +136,25 @@ int main(void) + cgdbr(dval[j], M3_BFP_ROUND_NEGINF); + } + ++ /* f32 -> f32, round to int */ ++ for (j = 0; j < sizeof dval / sizeof dval[0]; ++j) { ++ set_rounding_mode(FPC_BFP_ROUND_ZERO); ++ fiebra(dval[j], M3_BFP_ROUND_NEAREST_EVEN); ++ set_rounding_mode(FPC_BFP_ROUND_NEAREST_EVEN); ++ fiebra(dval[j], M3_BFP_ROUND_ZERO); ++ fiebra(dval[j], M3_BFP_ROUND_POSINF); ++ fiebra(dval[j], M3_BFP_ROUND_NEGINF); ++ } ++ ++ /* f64 -> f64, round to int */ ++ for (j = 0; j < sizeof dval / sizeof dval[0]; ++j) { ++ set_rounding_mode(FPC_BFP_ROUND_ZERO); ++ fidbra(dval[j], M3_BFP_ROUND_NEAREST_EVEN); ++ set_rounding_mode(FPC_BFP_ROUND_NEAREST_EVEN); ++ fidbra(dval[j], M3_BFP_ROUND_ZERO); ++ fidbra(dval[j], M3_BFP_ROUND_POSINF); ++ fidbra(dval[j], M3_BFP_ROUND_NEGINF); ++ } ++ + return 0; + } +Index: valgrind/none/tests/s390x/rounding-6.stdout.exp +=================================================================== +--- valgrind.orig/none/tests/s390x/rounding-6.stdout.exp 2015-07-08 10:53:04.000000000 +0200 ++++ valgrind/none/tests/s390x/rounding-6.stdout.exp 2015-07-08 12:53:31.000000000 +0200 +@@ -142,3 +142,75 @@ cgdbr 0.000000 -> 0 cc = 0 [-> nearest + cgdbr 0.000000 -> 0 cc = 0 [-> 0] + cgdbr 0.000000 -> 0 cc = 0 [-> +inf] + cgdbr 0.000000 -> 0 cc = 0 [-> -inf] ++fiebra 1.25000 -> 1 [-> nearest even] ++fiebra 1.25000 -> 1 [-> 0] ++fiebra 1.25000 -> 2 [-> +inf] ++fiebra 1.25000 -> 1 [-> -inf] ++fiebra 1.50000 -> 2 [-> nearest even] ++fiebra 1.50000 -> 1 [-> 0] ++fiebra 1.50000 -> 2 [-> +inf] ++fiebra 1.50000 -> 1 [-> -inf] ++fiebra 2.50000 -> 2 [-> nearest even] ++fiebra 2.50000 -> 2 [-> 0] ++fiebra 2.50000 -> 3 [-> +inf] ++fiebra 2.50000 -> 2 [-> -inf] ++fiebra 1.75000 -> 2 [-> nearest even] ++fiebra 1.75000 -> 1 [-> 0] ++fiebra 1.75000 -> 2 [-> +inf] ++fiebra 1.75000 -> 1 [-> -inf] ++fiebra -1.25000 -> -1 [-> nearest even] ++fiebra -1.25000 -> -1 [-> 0] ++fiebra -1.25000 -> -1 [-> +inf] ++fiebra -1.25000 -> -2 [-> -inf] ++fiebra -1.50000 -> -2 [-> nearest even] ++fiebra -1.50000 -> -1 [-> 0] ++fiebra -1.50000 -> -1 [-> +inf] ++fiebra -1.50000 -> -2 [-> -inf] ++fiebra -2.50000 -> -2 [-> nearest even] ++fiebra -2.50000 -> -2 [-> 0] ++fiebra -2.50000 -> -2 [-> +inf] ++fiebra -2.50000 -> -3 [-> -inf] ++fiebra -1.75000 -> -2 [-> nearest even] ++fiebra -1.75000 -> -1 [-> 0] ++fiebra -1.75000 -> -1 [-> +inf] ++fiebra -1.75000 -> -2 [-> -inf] ++fiebra 0.00000 -> 0 [-> nearest even] ++fiebra 0.00000 -> 0 [-> 0] ++fiebra 0.00000 -> 0 [-> +inf] ++fiebra 0.00000 -> 0 [-> -inf] ++fidbra 1.25000 -> 1 [-> nearest even] ++fidbra 1.25000 -> 1 [-> 0] ++fidbra 1.25000 -> 2 [-> +inf] ++fidbra 1.25000 -> 1 [-> -inf] ++fidbra 1.50000 -> 2 [-> nearest even] ++fidbra 1.50000 -> 1 [-> 0] ++fidbra 1.50000 -> 2 [-> +inf] ++fidbra 1.50000 -> 1 [-> -inf] ++fidbra 2.50000 -> 2 [-> nearest even] ++fidbra 2.50000 -> 2 [-> 0] ++fidbra 2.50000 -> 3 [-> +inf] ++fidbra 2.50000 -> 2 [-> -inf] ++fidbra 1.75000 -> 2 [-> nearest even] ++fidbra 1.75000 -> 1 [-> 0] ++fidbra 1.75000 -> 2 [-> +inf] ++fidbra 1.75000 -> 1 [-> -inf] ++fidbra -1.25000 -> -1 [-> nearest even] ++fidbra -1.25000 -> -1 [-> 0] ++fidbra -1.25000 -> -1 [-> +inf] ++fidbra -1.25000 -> -2 [-> -inf] ++fidbra -1.50000 -> -2 [-> nearest even] ++fidbra -1.50000 -> -1 [-> 0] ++fidbra -1.50000 -> -1 [-> +inf] ++fidbra -1.50000 -> -2 [-> -inf] ++fidbra -2.50000 -> -2 [-> nearest even] ++fidbra -2.50000 -> -2 [-> 0] ++fidbra -2.50000 -> -2 [-> +inf] ++fidbra -2.50000 -> -3 [-> -inf] ++fidbra -1.75000 -> -2 [-> nearest even] ++fidbra -1.75000 -> -1 [-> 0] ++fidbra -1.75000 -> -1 [-> +inf] ++fidbra -1.75000 -> -2 [-> -inf] ++fidbra 0.00000 -> 0 [-> nearest even] ++fidbra 0.00000 -> 0 [-> 0] ++fidbra 0.00000 -> 0 [-> +inf] ++fidbra 0.00000 -> 0 [-> -inf] +Index: valgrind/VEX/priv/guest_s390_toIR.c +=================================================================== +--- valgrind.orig/VEX/priv/guest_s390_toIR.c 2015-07-08 10:53:23.000000000 +0200 ++++ valgrind/VEX/priv/guest_s390_toIR.c 2015-07-08 12:53:31.000000000 +0200 +@@ -12384,6 +12384,40 @@ s390_irgen_LXEB(UChar r1, IRTemp op2addr + } + + static const HChar * ++s390_irgen_FIEBRA(UChar m3, UChar m4 __attribute__((unused)), ++ UChar r1, UChar r2) ++{ ++ if (! s390_host_has_fpext && m3 != S390_BFP_ROUND_PER_FPC) { ++ emulation_warning(EmWarn_S390X_fpext_rounding); ++ m3 = S390_BFP_ROUND_PER_FPC; ++ } ++ IRTemp result = newTemp(Ity_F32); ++ ++ assign(result, binop(Iop_RoundF32toInt, mkexpr(encode_bfp_rounding_mode(m3)), ++ get_fpr_w0(r2))); ++ put_fpr_w0(r1, mkexpr(result)); ++ ++ return "fiebra"; ++} ++ ++static const HChar * ++s390_irgen_FIDBRA(UChar m3, UChar m4 __attribute__((unused)), ++ UChar r1, UChar r2) ++{ ++ if (! s390_host_has_fpext && m3 != S390_BFP_ROUND_PER_FPC) { ++ emulation_warning(EmWarn_S390X_fpext_rounding); ++ m3 = S390_BFP_ROUND_PER_FPC; ++ } ++ IRTemp result = newTemp(Ity_F64); ++ ++ assign(result, binop(Iop_RoundF64toInt, mkexpr(encode_bfp_rounding_mode(m3)), ++ get_fpr_dw0(r2))); ++ put_fpr_dw0(r1, mkexpr(result)); ++ ++ return "fidbra"; ++} ++ ++static const HChar * + s390_irgen_LNEBR(UChar r1, UChar r2) + { + IRTemp result = newTemp(Ity_F32); +@@ -14520,11 +14554,15 @@ s390_decode_4byte_and_irgen(const UChar + case 0xb350: /* TBEDR */ goto unimplemented; + case 0xb351: /* TBDR */ goto unimplemented; + case 0xb353: /* DIEBR */ goto unimplemented; +- case 0xb357: /* FIEBR */ goto unimplemented; ++ case 0xb357: s390_format_RRF_UUFF(s390_irgen_FIEBRA, ovl.fmt.RRF2.m3, ++ ovl.fmt.RRF2.m4, ovl.fmt.RRF2.r1, ++ ovl.fmt.RRF2.r2); goto ok; + case 0xb358: /* THDER */ goto unimplemented; + case 0xb359: /* THDR */ goto unimplemented; + case 0xb35b: /* DIDBR */ goto unimplemented; +- case 0xb35f: /* FIDBR */ goto unimplemented; ++ case 0xb35f: s390_format_RRF_UUFF(s390_irgen_FIDBRA, ovl.fmt.RRF2.m3, ++ ovl.fmt.RRF2.m4, ovl.fmt.RRF2.r1, ++ ovl.fmt.RRF2.r2); goto ok; + case 0xb360: /* LPXR */ goto unimplemented; + case 0xb361: /* LNXR */ goto unimplemented; + case 0xb362: /* LTXR */ goto unimplemented; +Index: valgrind/VEX/priv/host_s390_defs.c +=================================================================== +--- valgrind.orig/VEX/priv/host_s390_defs.c 2015-07-08 10:53:23.000000000 +0200 ++++ valgrind/VEX/priv/host_s390_defs.c 2015-07-08 12:53:31.000000000 +0200 +@@ -3939,6 +3939,40 @@ s390_emit_LEXBRA(UChar *p, UChar m3, UCh + + + static UChar * ++s390_emit_FIEBRA(UChar *p, UChar m3, UChar m4, UChar r1, UChar r2) ++{ ++ vassert(m3 == 0 || s390_host_has_fpext); ++ ++ if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) { ++ if (m4 == 0) ++ s390_disasm(ENC3(MNM, FPR, FPR), "fiebr", r1, r2); ++ else ++ s390_disasm(ENC5(MNM, FPR, UINT, FPR, UINT), ++ "fiebra", r1, m3, r2, m4); ++ } ++ ++ return emit_RRF2(p, 0xb3570000, m3, m4, r1, r2); ++} ++ ++ ++static UChar * ++s390_emit_FIDBRA(UChar *p, UChar m3, UChar m4, UChar r1, UChar r2) ++{ ++ vassert(m3 == 0 || s390_host_has_fpext); ++ ++ if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) { ++ if (m4 == 0) ++ s390_disasm(ENC3(MNM, FPR, FPR), "fidbr", r1, r2); ++ else ++ s390_disasm(ENC5(MNM, FPR, UINT, FPR, UINT), ++ "fidbra", r1, m3, r2, m4); ++ } ++ ++ return emit_RRF2(p, 0xb35f0000, m3, m4, r1, r2); ++} ++ ++ ++static UChar * + s390_emit_MEEBR(UChar *p, UChar r1, UChar r2) + { + if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) +@@ -6693,6 +6727,8 @@ s390_insn_as_string(const s390_insn *ins + case S390_BFP_F64_TO_F128: + case S390_BFP_F128_TO_F32: + case S390_BFP_F128_TO_F64: op = "v-f2f"; break; ++ case S390_BFP_F32_TO_F32I: ++ case S390_BFP_F64_TO_F64I: op = "v-f2fi"; break; + default: goto fail; + } + s390_sprintf(buf, "%M %R,%R", op, insn->variant.bfp_convert.dst_hi, +@@ -8964,6 +9000,10 @@ s390_insn_bfp_convert_emit(UChar *buf, c + case S390_BFP_F128_TO_F32: return s390_emit_LEXBRA(buf, m3, m4, r1, r2); + case S390_BFP_F128_TO_F64: return s390_emit_LDXBRA(buf, m3, m4, r1, r2); + ++ /* Load FP integer */ ++ case S390_BFP_F32_TO_F32I: return s390_emit_FIEBRA(buf, m3, m4, r1, r2); ++ case S390_BFP_F64_TO_F64I: return s390_emit_FIDBRA(buf, m3, m4, r1, r2); ++ + default: goto fail; + } + +Index: valgrind/VEX/priv/host_s390_defs.h +=================================================================== +--- valgrind.orig/VEX/priv/host_s390_defs.h 2015-07-08 10:53:23.000000000 +0200 ++++ valgrind/VEX/priv/host_s390_defs.h 2015-07-08 12:53:31.000000000 +0200 +@@ -242,7 +242,9 @@ typedef enum { + S390_BFP_F128_TO_U32, + S390_BFP_F128_TO_U64, + S390_BFP_F128_TO_F32, +- S390_BFP_F128_TO_F64 ++ S390_BFP_F128_TO_F64, ++ S390_BFP_F32_TO_F32I, ++ S390_BFP_F64_TO_F64I + } s390_bfp_conv_t; + + /* Type conversion operations: to and/or from decimal floating point */ +Index: valgrind/VEX/priv/host_s390_isel.c +=================================================================== +--- valgrind.orig/VEX/priv/host_s390_isel.c 2015-07-08 10:53:23.000000000 +0200 ++++ valgrind/VEX/priv/host_s390_isel.c 2015-07-08 12:53:31.000000000 +0200 +@@ -2378,6 +2378,8 @@ s390_isel_float_expr_wrk(ISelEnv *env, I + return dst; + + case Iop_F64toF32: conv = S390_BFP_F64_TO_F32; goto convert_float; ++ case Iop_RoundF32toInt: conv = S390_BFP_F32_TO_F32I; goto convert_float; ++ case Iop_RoundF64toInt: conv = S390_BFP_F64_TO_F64I; goto convert_float; + case Iop_I32StoF32: conv = S390_BFP_I32_TO_F32; goto convert_int; + case Iop_I32UtoF32: conv = S390_BFP_U32_TO_F32; goto convert_int; + case Iop_I64StoF32: conv = S390_BFP_I64_TO_F32; goto convert_int; diff --git a/valgrind.spec b/valgrind.spec index 6788f4e..ca3b67f 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -3,7 +3,7 @@ Summary: Tool for finding memory management bugs in programs Name: %{?scl_prefix}valgrind Version: 3.10.1 -Release: 13%{?dist} +Release: 14%{?dist} Epoch: 1 License: GPLv2+ URL: http://www.valgrind.org/ @@ -110,6 +110,9 @@ Patch19: valgrind-3.10.1-di_notify_mmap.patch # KDE#349828 memcpy intercepts memmove causing src/dst overlap error Patch20: valgrind-3.10.1-memmove-ld_so-ppc64.patch +# KDE#342841 s390x unrecognized instruction fiebra +Patch21: valgrind-3.10.1-s390x-fiebra.patch + %if %{build_multilib} # Ensure glibc{,-devel} is installed for both multilib arches BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.so @@ -228,6 +231,7 @@ Valgrind User Manual for details. %patch18 -p1 %patch19 -p1 %patch20 -p1 +%patch21 -p1 %build # We need to use the software collection compiler and binutils if available. @@ -383,6 +387,9 @@ echo ===============END TESTING=============== %endif %changelog +* Wed Jul 08 2015 Mark Wielaard - 3.10.1-14 +- Add valgrind-3.10.1-s390x-fiebra.patch + * Tue Jul 07 2015 Mark Wielaard - 3.10.1-13 - Add valgrind-3.10.1-di_notify_mmap.patch - Add valgrind-3.10.1-memmove-ld_so-ppc64.patch