Add valgrind-3.21.0-vgm.patch and valgrind-3.21.0-vgm-tests.patch
Resolves: #2216963 [RHEL9.3][valgrind][s390x] valgrind cannot work as expected on qemu-kvm
This commit is contained in:
parent
c29dbe6c21
commit
c8ea80be5f
105
valgrind-3.21.0-vgm-tests.patch
Normal file
105
valgrind-3.21.0-vgm-tests.patch
Normal file
@ -0,0 +1,105 @@
|
||||
From 21f7a2af2805a02a144c81f12895c134f4a171a3 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Arnez <arnez@linux.ibm.com>
|
||||
Date: Mon, 22 May 2023 19:49:08 +0200
|
||||
Subject: [PATCH 2/2] Bug 470132 - s390x: Increase test coverage for VGM
|
||||
|
||||
Add more tests for the VGM instruction, to verify the fix for the VGM
|
||||
wrap-around case. Also test setting unused bits in the I2 and I3 fields,
|
||||
to check that Valgrind ignores them as it should.
|
||||
---
|
||||
none/tests/s390x/vec2.c | 44 ++++++++++++++++++++++++++++++++
|
||||
none/tests/s390x/vec2.stdout.exp | 20 +++++++++++++++
|
||||
2 files changed, 64 insertions(+)
|
||||
|
||||
diff --git a/none/tests/s390x/vec2.c b/none/tests/s390x/vec2.c
|
||||
index 73b04dee4..c473a2a9a 100644
|
||||
--- a/none/tests/s390x/vec2.c
|
||||
+++ b/none/tests/s390x/vec2.c
|
||||
@@ -301,6 +301,49 @@ static void test_all_fp_int_conversions()
|
||||
#undef TEST_EXEC
|
||||
#undef TEST_GENERATE
|
||||
|
||||
+/* -- Vector generate mask -- */
|
||||
+
|
||||
+#define TEST_GENERATE(insn, i2, i3, m4) \
|
||||
+ static void test_vgm_##i2##_##i3##_##m4(void) \
|
||||
+ { \
|
||||
+ ulong_v out = vec_ini; \
|
||||
+ __asm__("vgm %[out]," #i2 "," #i3 "," #m4 : [out] "+v"(out) : :); \
|
||||
+ printf("\t%016lx %016lx\n", out[0], out[1]); \
|
||||
+ }
|
||||
+
|
||||
+#define TEST_EXEC(insn, i2, i3, m4) \
|
||||
+ do { \
|
||||
+ puts(#insn " " #i2 "," #i3 "," #m4); \
|
||||
+ test_vgm_##i2##_##i3##_##m4(); \
|
||||
+ } while (0)
|
||||
+
|
||||
+#define INSNS \
|
||||
+ XTEST(vgmb, 2, 1, 0); \
|
||||
+ XTEST(vgmb, 0xf7, 0x30, 0); \
|
||||
+ XTEST(vgmb, 0, 0, 0); \
|
||||
+ XTEST(vgmh, 3, 2, 1); \
|
||||
+ XTEST(vgmh, 15, 15, 1); \
|
||||
+ XTEST(vgmf, 4, 3, 2); \
|
||||
+ XTEST(vgmf, 16, 17, 2); \
|
||||
+ XTEST(vgmg, 55, 63, 3); \
|
||||
+ XTEST(vgmg, 43, 55, 3); \
|
||||
+ XTEST(vgmg, 63, 2, 3);
|
||||
+
|
||||
+#define XTEST TEST_GENERATE
|
||||
+INSNS
|
||||
+#undef XTEST
|
||||
+
|
||||
+static void test_all_generate_mask()
|
||||
+{
|
||||
+#define XTEST TEST_EXEC
|
||||
+ INSNS
|
||||
+#undef XTEST
|
||||
+}
|
||||
+
|
||||
+#undef INSNS
|
||||
+#undef TEST_EXEC
|
||||
+#undef TEST_GENERATE
|
||||
+
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -310,5 +353,6 @@ int main()
|
||||
test_all_double_bitshifts();
|
||||
test_all_int_fp_conversions();
|
||||
test_all_fp_int_conversions();
|
||||
+ test_all_generate_mask();
|
||||
return 0;
|
||||
}
|
||||
diff --git a/none/tests/s390x/vec2.stdout.exp b/none/tests/s390x/vec2.stdout.exp
|
||||
index b32cbe1bc..2c9ac21c1 100644
|
||||
--- a/none/tests/s390x/vec2.stdout.exp
|
||||
+++ b/none/tests/s390x/vec2.stdout.exp
|
||||
@@ -166,3 +166,23 @@ vcsfp 0
|
||||
vcsfp 8
|
||||
00ffffff - - -
|
||||
00000004 - - -
|
||||
+vgmb 2,1,0
|
||||
+ ffffffffffffffff ffffffffffffffff
|
||||
+vgmb 0xf7,0x30,0
|
||||
+ 8181818181818181 8181818181818181
|
||||
+vgmb 0,0,0
|
||||
+ 8080808080808080 8080808080808080
|
||||
+vgmh 3,2,1
|
||||
+ ffffffffffffffff ffffffffffffffff
|
||||
+vgmh 15,15,1
|
||||
+ 0001000100010001 0001000100010001
|
||||
+vgmf 4,3,2
|
||||
+ ffffffffffffffff ffffffffffffffff
|
||||
+vgmf 16,17,2
|
||||
+ 0000c0000000c000 0000c0000000c000
|
||||
+vgmg 55,63,3
|
||||
+ 00000000000001ff 00000000000001ff
|
||||
+vgmg 43,55,3
|
||||
+ 00000000001fff00 00000000001fff00
|
||||
+vgmg 63,2,3
|
||||
+ e000000000000001 e000000000000001
|
||||
--
|
||||
2.40.1
|
||||
|
99
valgrind-3.21.0-vgm.patch
Normal file
99
valgrind-3.21.0-vgm.patch
Normal file
@ -0,0 +1,99 @@
|
||||
From 70ef4417837b690755feede0088331a28b102c65 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Arnez <arnez@linux.ibm.com>
|
||||
Date: Mon, 22 May 2023 18:57:35 +0200
|
||||
Subject: [PATCH 1/2] Bug 470132 - s390x: Fix the wrap-around case in VGM
|
||||
|
||||
Valgrind's implementation of VGM is incomplete:
|
||||
|
||||
* It doesn't support generating a wrap-around bit mask. Such a mask
|
||||
should result when the ending bit position is smaller than the starting
|
||||
bit position. Valgrind runs into an assertion failure instead.
|
||||
|
||||
* It doesn't ignore unused bits in the I2 and I3 fields of the
|
||||
instruction, as it should.
|
||||
|
||||
Fix this by re-implementing the main logic in s390_irgen_VGM().
|
||||
---
|
||||
VEX/priv/guest_s390_toIR.c | 57 +++++++++++++++-----------------------
|
||||
1 file changed, 22 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c
|
||||
index 11dda41ef..d9d746c38 100644
|
||||
--- a/VEX/priv/guest_s390_toIR.c
|
||||
+++ b/VEX/priv/guest_s390_toIR.c
|
||||
@@ -16388,50 +16388,37 @@ s390_irgen_VGBM(UChar v1, UShort i2, UChar m3 __attribute__((unused)))
|
||||
static const HChar *
|
||||
s390_irgen_VGM(UChar v1, UShort i2, UChar m3)
|
||||
{
|
||||
- UChar from = (i2 & 0xff00) >> 8;
|
||||
- UChar to = (i2 & 0x00ff);
|
||||
- ULong value = 0UL;
|
||||
- IRType type = s390_vr_get_type(m3);
|
||||
- vassert(from <= to);
|
||||
-
|
||||
- UChar maxIndex = 0;
|
||||
- switch (type) {
|
||||
- case Ity_I8:
|
||||
- maxIndex = 7;
|
||||
- break;
|
||||
- case Ity_I16:
|
||||
- maxIndex = 15;
|
||||
- break;
|
||||
- case Ity_I32:
|
||||
- maxIndex = 31;
|
||||
- break;
|
||||
- case Ity_I64:
|
||||
- maxIndex = 63;
|
||||
- break;
|
||||
- default:
|
||||
- vpanic("s390_irgen_VGM: unknown type");
|
||||
- }
|
||||
-
|
||||
- for(UChar index = from; index <= to; index++) {
|
||||
- value |= (1ULL << (maxIndex - index));
|
||||
- }
|
||||
-
|
||||
- IRExpr *fillValue;
|
||||
- switch (type) {
|
||||
- case Ity_I8:
|
||||
+ s390_insn_assert("vgm", m3 <= 3);
|
||||
+
|
||||
+ UChar max_idx = (8 << m3) - 1;
|
||||
+ UChar from = max_idx & (i2 >> 8);
|
||||
+ UChar to = max_idx & i2;
|
||||
+ ULong all_one = (1ULL << max_idx << 1) - 1;
|
||||
+ ULong value = (all_one >> from) ^ (all_one >> to >> 1);
|
||||
+
|
||||
+ /* In case of wrap-around we now have a value that needs inverting:
|
||||
+ to from
|
||||
+ V V
|
||||
+ 00000111111111110000000000000000 */
|
||||
+ if (to < from)
|
||||
+ value ^= all_one;
|
||||
+
|
||||
+ IRExpr* fillValue;
|
||||
+ switch (m3) {
|
||||
+ case 0:
|
||||
fillValue = mkU8(value);
|
||||
break;
|
||||
- case Ity_I16:
|
||||
+ case 1:
|
||||
fillValue = mkU16(value);
|
||||
break;
|
||||
- case Ity_I32:
|
||||
+ case 2:
|
||||
fillValue = mkU32(value);
|
||||
break;
|
||||
- case Ity_I64:
|
||||
+ case 3:
|
||||
fillValue = mkU64(value);
|
||||
break;
|
||||
default:
|
||||
- vpanic("s390_irgen_VGM: unknown type");
|
||||
+ vpanic("s390_irgen_VGM: unknown element size");
|
||||
}
|
||||
|
||||
s390_vr_fill(v1, fillValue);
|
||||
--
|
||||
2.40.1
|
||||
|
@ -100,6 +100,11 @@ Patch8: valgrind-3.21.0-callgrind_control-no-strict.patch
|
||||
# https://bugs.kde.org/show_bug.cgi?id=470520
|
||||
Patch9: valgrind-3.21.0-realloc-again.patch
|
||||
|
||||
# s390x: Assertion failure on VGM instruction
|
||||
# https://bugs.kde.org/show_bug.cgi?id=470132
|
||||
Patch10: valgrind-3.21.0-vgm.patch
|
||||
Patch11: valgrind-3.21.0-vgm-tests.patch
|
||||
|
||||
BuildRequires: make
|
||||
BuildRequires: glibc-devel
|
||||
|
||||
@ -245,6 +250,8 @@ Valgrind User Manual for details.
|
||||
|
||||
%patch8 -p1
|
||||
%patch9 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
|
||||
|
||||
%build
|
||||
@ -476,6 +483,7 @@ fi
|
||||
- Add valgrind-3.21.0-callgrind_control-no-strict.patch
|
||||
- Add valgrind-3.21.0-realloc-again.patch
|
||||
- Update valgrind-3.21.0-no-memcpy-replace-check.patch (memcpy_chk)
|
||||
- Add valgrind-3.21.0-vgm.patch and valgrind-3.21.0-vgm-tests.patch
|
||||
|
||||
* Tue May 16 2023 Alexandra Hájková <ahajkova@redhat.com> - 3.21.0-3
|
||||
- Add valgrind-3.21.0-Add-with-gdbscripts-dir.patch
|
||||
|
Loading…
Reference in New Issue
Block a user