From c06a5ebf830fde54c7c9d6722c2e528f455305a4 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 11 Sep 2012 11:23:49 +0200 Subject: [PATCH] Add valgrind-3.8.0-lzcnt-tzcnt-bugfix.patch (KDE#295808) --- valgrind-3.8.0-lzcnt-tzcnt-bugfix.patch | 66 +++++++++++++++++++++++++ valgrind.spec | 5 ++ 2 files changed, 71 insertions(+) create mode 100644 valgrind-3.8.0-lzcnt-tzcnt-bugfix.patch diff --git a/valgrind-3.8.0-lzcnt-tzcnt-bugfix.patch b/valgrind-3.8.0-lzcnt-tzcnt-bugfix.patch new file mode 100644 index 0000000..00d8bf3 --- /dev/null +++ b/valgrind-3.8.0-lzcnt-tzcnt-bugfix.patch @@ -0,0 +1,66 @@ +------------------------------------------------------------------------ +r2478 | sewardj | 2012-08-23 22:14:51 +0200 (Thu, 23 Aug 2012) | 4 lines + +Fix LZCNT and TZCNT properly. Fixes #295808. (Jakub Jelinek, +jakub@redhat.com) + + +------------------------------------------------------------------------ +Index: priv/guest_amd64_toIR.c +=================================================================== +--- valgrind-3.8.0/VEX/priv/guest_amd64_toIR.c (revision 2477) ++++ valgrind-3.8.0/VEX/priv/guest_amd64_toIR.c (revision 2478) +@@ -20084,13 +20084,16 @@ + return delta; + + case 0xBC: /* BSF Gv,Ev */ +- if (haveF2orF3(pfx)) goto decode_failure; ++ if (haveF2(pfx)) goto decode_failure; + delta = dis_bs_E_G ( vbi, pfx, sz, delta, True ); + return delta; + + case 0xBD: /* BSR Gv,Ev */ +- if (!haveF2orF3(pfx)) { +- /* no-F2 no-F3 0F BD = BSR */ ++ if (!haveF2orF3(pfx) ++ || (haveF3noF2(pfx) ++ && 0 == (archinfo->hwcaps & VEX_HWCAPS_AMD64_LZCNT))) { ++ /* no-F2 no-F3 0F BD = BSR ++ or F3 0F BD = REP; BSR on older CPUs. */ + delta = dis_bs_E_G ( vbi, pfx, sz, delta, False ); + return delta; + } +Index: priv/guest_x86_toIR.c +=================================================================== +--- valgrind-3.8.0/VEX/priv/guest_x86_toIR.c (revision 2477) ++++ valgrind-3.8.0/VEX/priv/guest_x86_toIR.c (revision 2478) +@@ -14021,12 +14021,28 @@ + for the rest, it means REP) */ + case 0xF3: { + Addr32 eip_orig = guest_EIP_bbstart + delta_start; +- if (sorb != 0) goto decode_failure; + abyte = getIByte(delta); delta++; + + if (abyte == 0x66) { sz = 2; abyte = getIByte(delta); delta++; } + ++ if (sorb != 0 && abyte != 0x0F) goto decode_failure; ++ + switch (abyte) { ++ case 0x0F: ++ switch (getIByte(delta)) { ++ /* On older CPUs, TZCNT behaves the same as BSF. */ ++ case 0xBC: /* REP BSF Gv,Ev */ ++ delta = dis_bs_E_G ( sorb, sz, delta + 1, True ); ++ break; ++ /* On older CPUs, LZCNT behaves the same as BSR. */ ++ case 0xBD: /* REP BSR Gv,Ev */ ++ delta = dis_bs_E_G ( sorb, sz, delta + 1, False ); ++ break; ++ default: ++ goto decode_failure; ++ } ++ break; ++ + case 0xA4: sz = 1; /* REP MOVS */ + case 0xA5: + dis_REP_op ( &dres, X86CondAlways, dis_MOVS, sz, eip_orig, diff --git a/valgrind.spec b/valgrind.spec index e7a9051..47a87a4 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -21,6 +21,7 @@ Patch10: valgrind-3.8.0-ldso-supp.patch Patch11: valgrind-3.8.0-x86-backtrace.patch Patch12: valgrind-3.8.0-find-buildid.patch Patch13: valgrind-3.8.0-abbrev-parsing.patch +Patch14: valgrind-3.8.0-lzcnt-tzcnt-bugfix.patch Obsoletes: valgrind-callgrind %ifarch x86_64 ppc64 @@ -113,6 +114,7 @@ for details. %patch11 -p1 %patch12 -p1 %patch13 -p1 +%patch14 -p1 %build CC=gcc @@ -223,6 +225,9 @@ echo ===============END TESTING=============== %endif %changelog +* Tue Sep 11 2012 Mark Wielaard +- Add valgrind-3.8.0-lzcnt-tzcnt-bugfix.patch (KDE#295808) + * Mon Aug 27 2012 Mark Wielaard 3.8.0-5 - Add valgrind-3.8.0-abbrev-parsing.patch for #849783 (KDE#305513).