valgrind/SOURCES/0018-Implement-VMOVQ-xmm1-xmm2-m64.patch

319 lines
14 KiB
Diff

From 0ddeadb018a19f4033dbf63aa336561c07074688 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Sun, 30 Jun 2024 20:17:32 +0200
Subject: [PATCH 18/21] Implement VMOVQ xmm1, xmm2/m64
We implemented the memory variant already, but not the reg variant.
Add a separate avx-vmovq testcase, because avx-1 is already really big.
https://bugs.kde.org/show_bug.cgi?id=391148
https://bugs.kde.org/show_bug.cgi?id=417572
https://bugs.kde.org/show_bug.cgi?id=489088
(cherry picked from commit 10a22445d747817932692b1c1ee3faa726121cb4)
---
.gitignore | 1 +
NEWS | 3 +
VEX/priv/guest_amd64_toIR.c | 10 +-
none/tests/amd64/Makefile.am | 6 +-
none/tests/amd64/avx-vmovq.c | 19 +++
none/tests/amd64/avx-vmovq.stderr.exp | 0
none/tests/amd64/avx-vmovq.stdout.exp | 162 ++++++++++++++++++++++++++
none/tests/amd64/avx-vmovq.vgtest | 3 +
8 files changed, 200 insertions(+), 4 deletions(-)
create mode 100644 none/tests/amd64/avx-vmovq.c
create mode 100644 none/tests/amd64/avx-vmovq.stderr.exp
create mode 100644 none/tests/amd64/avx-vmovq.stdout.exp
create mode 100644 none/tests/amd64/avx-vmovq.vgtest
diff --git a/NEWS b/NEWS
index 9f4f69744086..cd89e50829bd 100644
--- a/NEWS
+++ b/NEWS
@@ -8,7 +8,9 @@ The following bugs have been fixed or resolved on this branch.
202770 open fd at exit --log-socket=127.0.0.1:1500 with --track-fds=yes
311655 --log-file=FILE leads to apparent fd leak
337388 fcntl works on Valgrind's own file descriptors
+391148 Unhandled AVX instruction vmovq %xmm9,%xmm1
444781 MIPS: wrong syscall numbers used
+417572 vex amd64->IR: unhandled instruction bytes: 0xC5 0x79 0xD6 0xED 0xC5
453044 gbserver_tests failures in aarch64
479661 Valgrind leaks file descriptors
486180 [MIPS] 'VexGuestArchState' has no member named 'guest_IP_AT_SYSCALL'
@@ -16,6 +18,7 @@ The following bugs have been fixed or resolved on this branch.
486569 linux inotify_init syscall wrapper missing POST entry in syscall_table
487439 SIGILL in JDK11, JDK17
488379 --track-fds=yes errors that cannot be suppressed with --xml-file=
+489088 Valgrind throws unhandled instruction bytes: 0xC5 0x79 0xD6 0xE0 0xC5
n-i-bz aarch64 frinta and frinta vector instructions
To see details of a given bug, visit
diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c
index 28c37f092211..57a8a434b845 100644
--- a/VEX/priv/guest_amd64_toIR.c
+++ b/VEX/priv/guest_amd64_toIR.c
@@ -27015,7 +27015,6 @@ Long dis_ESC_0F__VEX (
break;
case 0xD6:
- /* I can't even find any Intel docs for this one. */
/* Basically: 66 0F D6 = MOVQ -- move 64 bits from G (lo half
xmm) to E (mem or lo half xmm). Looks like L==0(128), W==0
(WIG, maybe?) */
@@ -27024,8 +27023,15 @@ Long dis_ESC_0F__VEX (
UChar modrm = getUChar(delta);
UInt rG = gregOfRexRM(pfx,modrm);
if (epartIsReg(modrm)) {
- /* fall through, awaiting test case */
/* dst: lo half copied, hi half zeroed */
+ UInt rE = eregOfRexRM(pfx,modrm);
+ putXMMRegLane64( rE, 0, getXMMRegLane64( rG, 0 ));
+ /* zero bits 255:64 */
+ putXMMRegLane64( rE, 1, mkU64(0) );
+ putYMMRegLane128( rE, 1, mkV128(0) );
+ DIP("vmovq %s,%s\n", nameXMMReg(rG), nameXMMReg(rE));
+ delta += 1;
+ goto decode_success;
} else {
addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 );
storeLE( mkexpr(addr), getXMMRegLane64( rG, 0 ));
diff --git a/none/tests/amd64/Makefile.am b/none/tests/amd64/Makefile.am
index 83029c15590c..e4d907c3dd54 100644
--- a/none/tests/amd64/Makefile.am
+++ b/none/tests/amd64/Makefile.am
@@ -3,7 +3,7 @@ include $(top_srcdir)/Makefile.tool-tests.am
dist_noinst_SCRIPTS = filter_cpuid filter_inf_nan filter_stderr gen_insn_test.pl
-# Used by avx-1.c and avx_estimate_insn.c
+# Used by avx-1.c, avx-vmovq and avx_estimate_insn.c
noinst_HEADERS = avx_tests.h
CLEANFILES = $(addsuffix .c,$(INSN_TESTS))
@@ -29,6 +29,7 @@ EXTRA_DIST = \
avx-1.vgtest avx-1.stdout.exp avx-1.stderr.exp \
avx_estimate_insn.vgtest avx_estimate_insn.stderr.exp \
avx_estimate_insn.stdout.exp avx_estimate_insn.stdout.exp-amd \
+ avx-vmovq.vgtest avx-vmovq.stdout.exp avx-vmovq.stderr.exp \
avx2-1.vgtest avx2-1.stdout.exp avx2-1.stderr.exp \
asorep.stderr.exp asorep.stdout.exp asorep.vgtest \
bmi.stderr.exp bmi.stdout.exp bmi.vgtest \
@@ -131,7 +132,8 @@ endif
if BUILD_AVX_TESTS
if BUILD_VPCLMULQDQ_TESTS
check_PROGRAMS += avx-1 \
- avx_estimate_insn
+ avx_estimate_insn \
+ avx-vmovq
endif
if BUILD_FMA4_TESTS
check_PROGRAMS += fma4
diff --git a/none/tests/amd64/avx-vmovq.c b/none/tests/amd64/avx-vmovq.c
new file mode 100644
index 000000000000..da8a1959b34f
--- /dev/null
+++ b/none/tests/amd64/avx-vmovq.c
@@ -0,0 +1,19 @@
+#include"avx_tests.h"
+
+GEN_test_RandM(VMOVQ_XMM_to_XMM_LOW_HIGH,
+ "vmovq %%xmm9, %%xmm7",
+ "vmovq %%xmm8, (%%rsi)")
+
+// xmm0 is scratch
+GEN_test_RandM(VMOVQ_XMM_to_XMM_LOW_LOW_HIGH,
+ "vmovq %%xmm0, %%xmm7; vmovq %%xmm8, %%xmm0",
+ "vmovq %%xmm0, (%%rsi); vmovq %%xmm9, %%xmm0")
+
+int main ( void )
+{
+ DO_D( VMOVQ_XMM_to_XMM_LOW_HIGH );
+ DO_D( VMOVQ_XMM_to_XMM_LOW_LOW_HIGH );
+
+ return 0;
+}
+
diff --git a/none/tests/amd64/avx-vmovq.stderr.exp b/none/tests/amd64/avx-vmovq.stderr.exp
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/none/tests/amd64/avx-vmovq.stdout.exp b/none/tests/amd64/avx-vmovq.stdout.exp
new file mode 100644
index 000000000000..f5b45e54de79
--- /dev/null
+++ b/none/tests/amd64/avx-vmovq.stdout.exp
@@ -0,0 +1,162 @@
+VMOVQ_XMM_to_XMM_LOW_HIGH(reg)
+ before
+ 7d6528c5fa956a0d.69c3e9a6af27d13b.5175e39d19c9ca1e.98f24a4984175700
+ b6d2fb5aa7bc5127.fe9915e556a044b2.60b160857d45c484.47b8d8c0eeef1e50
+ 065d77195d623e6b.842adc6450659e17.19a348215c3a67fd.399182c2dbcc2d38
+ cb509970b8136c85.d740b80eb7839b97.d89998df5035ed36.4a4bc43968bc40e5
+ 56b01a12b0ca1583
+ after
+ 0000000000000000.0000000000000000.0000000000000000.4a4bc43968bc40e5
+ b6d2fb5aa7bc5127.fe9915e556a044b2.60b160857d45c484.47b8d8c0eeef1e50
+ 065d77195d623e6b.842adc6450659e17.19a348215c3a67fd.399182c2dbcc2d38
+ cb509970b8136c85.d740b80eb7839b97.d89998df5035ed36.4a4bc43968bc40e5
+ 56b01a12b0ca1583
+VMOVQ_XMM_to_XMM_LOW_HIGH(mem)
+ before
+ 398e0039cf03663d.5ff85bc9535c191f.d3a727d1a705f65d.f9dd4a29f8c093db
+ cfaff39be272ef40.20a1bb92cbc97fe8.542da4983df76c96.d8bc5c6dee699597
+ f4e06e2205236eb7.6897b536bbe4da8a.369dab4f9465b86e.d182c916cebc2e17
+ 84ededbc53239dcf.95264321bf3b68b2.55c2b9e2c95c9810.407b8d9035449b06
+ 81f2a547be8d1811
+ after
+ 398e0039cf03663d.5ff85bc9535c191f.d3a727d1a705f65d.d8bc5c6dee699597
+ cfaff39be272ef40.20a1bb92cbc97fe8.542da4983df76c96.d8bc5c6dee699597
+ f4e06e2205236eb7.6897b536bbe4da8a.369dab4f9465b86e.d182c916cebc2e17
+ 84ededbc53239dcf.95264321bf3b68b2.55c2b9e2c95c9810.407b8d9035449b06
+ 81f2a547be8d1811
+
+VMOVQ_XMM_to_XMM_LOW_HIGH(reg)
+ before
+ f0350ca70523e0e4.5ba1ec54e87d39b3.019963bf7459630b.8d69483df7e8c6a9
+ e98ebd1ca893312a.54cae7d5e13dfe91.0a3e0f7c75cb0842.b95ed64d3b13ff64
+ c84ab71340684590.4d325b2d5a70a792.0a5f45c55f1c9202.b76ddefcb0ebfe6e
+ e9b5f3f66b2e58c1.21a6c3476d21f1e5.5f490104ced83ff8.6262dd37727c80f3
+ 96084deb9ed0411e
+ after
+ 0000000000000000.0000000000000000.0000000000000000.6262dd37727c80f3
+ e98ebd1ca893312a.54cae7d5e13dfe91.0a3e0f7c75cb0842.b95ed64d3b13ff64
+ c84ab71340684590.4d325b2d5a70a792.0a5f45c55f1c9202.b76ddefcb0ebfe6e
+ e9b5f3f66b2e58c1.21a6c3476d21f1e5.5f490104ced83ff8.6262dd37727c80f3
+ 96084deb9ed0411e
+VMOVQ_XMM_to_XMM_LOW_HIGH(mem)
+ before
+ 2e2dac0350f6fd1c.a81b6e33c572a86a.acf29b0f395c98b4.63483da65c8c49d0
+ 089b756aa3f77018.61c82534e9bf6f37.c9e25f72d82e582b.73a8f718a8c3ec35
+ ff1f240eb3e1553f.6f07136773a2ead3.56428c5a66a2ec77.ecb42ac54b0966d4
+ ee8536da9dbf68bc.3026343700a654eb.2ddd9db4ffc411c4.28bad218e4ebf159
+ 8404eb7f0cf4ca6f
+ after
+ 2e2dac0350f6fd1c.a81b6e33c572a86a.acf29b0f395c98b4.73a8f718a8c3ec35
+ 089b756aa3f77018.61c82534e9bf6f37.c9e25f72d82e582b.73a8f718a8c3ec35
+ ff1f240eb3e1553f.6f07136773a2ead3.56428c5a66a2ec77.ecb42ac54b0966d4
+ ee8536da9dbf68bc.3026343700a654eb.2ddd9db4ffc411c4.28bad218e4ebf159
+ 8404eb7f0cf4ca6f
+
+VMOVQ_XMM_to_XMM_LOW_HIGH(reg)
+ before
+ 5cdf726562b02dc2.b39925ba7d9d67bc.ff6f850f2c57ea2a.2c810e6dc1a1833d
+ 0c9761367fac55ff.28276f9a6e880c6b.372f015d9242e83d.2ef85b6fc544fd0f
+ f078b65e01737fd2.2bfa8f668c8b14f4.36b2a38dcef18acf.0e0f01a829ba3c66
+ 65ce6d498492e7e7.96df010bf4b23b84.57436a097df30b8d.aa927a03090dfc6d
+ dc4c446c804bf950
+ after
+ 0000000000000000.0000000000000000.0000000000000000.aa927a03090dfc6d
+ 0c9761367fac55ff.28276f9a6e880c6b.372f015d9242e83d.2ef85b6fc544fd0f
+ f078b65e01737fd2.2bfa8f668c8b14f4.36b2a38dcef18acf.0e0f01a829ba3c66
+ 65ce6d498492e7e7.96df010bf4b23b84.57436a097df30b8d.aa927a03090dfc6d
+ dc4c446c804bf950
+VMOVQ_XMM_to_XMM_LOW_HIGH(mem)
+ before
+ 810bdacfab80ee3d.c5e48064a393c8e9.47a34273c10a3c47.f5304f3e3ad1a923
+ 769ab818a5b7985e.6d08ed19fa045f84.1810cd8c109ed568.6ec34f98a2199d3c
+ 95c45b338afcb3df.b984aed62671e865.e6f21d40fc7bc013.1c4a678450562685
+ bc563e0c775bfaed.05a5c205c3659f38.8e17b17da2acb976.5d0f926ce1157eaa
+ 8b5fccbef0e1e256
+ after
+ 810bdacfab80ee3d.c5e48064a393c8e9.47a34273c10a3c47.6ec34f98a2199d3c
+ 769ab818a5b7985e.6d08ed19fa045f84.1810cd8c109ed568.6ec34f98a2199d3c
+ 95c45b338afcb3df.b984aed62671e865.e6f21d40fc7bc013.1c4a678450562685
+ bc563e0c775bfaed.05a5c205c3659f38.8e17b17da2acb976.5d0f926ce1157eaa
+ 8b5fccbef0e1e256
+
+VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(reg)
+ before
+ 048612e51a468e36.c51cdd8f87e12ab4.acb722146c6cbfa9.ea4a022e1d3d7dbb
+ 22cf5e4cfad1bdf5.8de2b4a9d799ff5f.0c05cb6ebd128663.d7568e3e8a3ac80e
+ 4288ae612c0dad40.f0733f448390351b.80ddba7e53e42d12.3208cf9b04b0569c
+ c1fbfd8f4d8698c2.cb9dfb4ea5d18713.6489eab2c96df363.d52c4330a7aae391
+ 9d8e66ea90352a18
+ after
+ 0000000000000000.0000000000000000.0000000000000000.2525252525252525
+ 22cf5e4cfad1bdf5.8de2b4a9d799ff5f.0c05cb6ebd128663.d7568e3e8a3ac80e
+ 4288ae612c0dad40.f0733f448390351b.80ddba7e53e42d12.3208cf9b04b0569c
+ c1fbfd8f4d8698c2.cb9dfb4ea5d18713.6489eab2c96df363.d52c4330a7aae391
+ 9d8e66ea90352a18
+VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(mem)
+ before
+ 66fab2b3db5ce85e.f9754842f9c9ba28.f82a63b15c68b274.14575775bc3a1202
+ 0c3ca578a32bd88e.474289e7cb61501e.54e7f35bc162726a.ec91fe34c7d6c79a
+ 6b1fba2604afb8d5.08aebee85fda964f.bba02737f3c98220.4784d95987cd4ed8
+ 5f706da71bf2425f.9605e2b252c1c868.09217c310baca0c3.837be65197abe268
+ fbc4208894fdc0f5
+ after
+ 66fab2b3db5ce85e.f9754842f9c9ba28.f82a63b15c68b274.2525252525252525
+ 0c3ca578a32bd88e.474289e7cb61501e.54e7f35bc162726a.ec91fe34c7d6c79a
+ 6b1fba2604afb8d5.08aebee85fda964f.bba02737f3c98220.4784d95987cd4ed8
+ 5f706da71bf2425f.9605e2b252c1c868.09217c310baca0c3.837be65197abe268
+ fbc4208894fdc0f5
+
+VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(reg)
+ before
+ 0aaa836b194e242c.c5fc3ae904033357.4e92f1b240a12214.1a366d352714867e
+ 0e780c65c22b4ab8.778d9ed6d9eb46ea.8ca3e752c306df00.caab752f630ff07e
+ 627bb6e12d1f6d46.51ef145cb9b83843.ac82c1007a7d3cd8.f54b130cdaa89cef
+ 61ff7d4df3b6ca81.31f01866bd76c58f.0a7c7a27fe917447.77e3c0b6a9ec44fc
+ 2c3ffa1aebe6a4d2
+ after
+ 0000000000000000.0000000000000000.0000000000000000.2525252525252525
+ 0e780c65c22b4ab8.778d9ed6d9eb46ea.8ca3e752c306df00.caab752f630ff07e
+ 627bb6e12d1f6d46.51ef145cb9b83843.ac82c1007a7d3cd8.f54b130cdaa89cef
+ 61ff7d4df3b6ca81.31f01866bd76c58f.0a7c7a27fe917447.77e3c0b6a9ec44fc
+ 2c3ffa1aebe6a4d2
+VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(mem)
+ before
+ f02b3b25bca27a9c.69505d14b27d9d16.f25b26e0042fa9fa.02dd0e32eecfc5fa
+ 9f7301c1392d8087.d4ba52a206ff21b1.70fbbab6a7f19faf.f0f1798fe3c1699c
+ 15e3c8dc7e9273bf.0088596389c893fd.879d51d4c5c764db.3004b7a97cf69dda
+ 2d460a61a5dd0f6f.47086cc3da642fa7.130d662777beb4a9.1e61c5ec52f79c60
+ 16559ec50352a3d9
+ after
+ f02b3b25bca27a9c.69505d14b27d9d16.f25b26e0042fa9fa.2525252525252525
+ 9f7301c1392d8087.d4ba52a206ff21b1.70fbbab6a7f19faf.f0f1798fe3c1699c
+ 15e3c8dc7e9273bf.0088596389c893fd.879d51d4c5c764db.3004b7a97cf69dda
+ 2d460a61a5dd0f6f.47086cc3da642fa7.130d662777beb4a9.1e61c5ec52f79c60
+ 16559ec50352a3d9
+
+VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(reg)
+ before
+ 742c3e9e2b92eef2.c569453ccd1b0fc4.0784892e9360315b.f0177599dbe14b46
+ 9432a2e46543b956.b819f459105730e9.9a49ac115048d4c4.f987fa170d3ce4dd
+ d2b3c4044ef23fb2.e22093a48a9d2e0b.5da3cfd6aea6558e.0c28728e28dc3c9c
+ 89fba268812abdb2.1e4a9e0958fac555.adddf0eb4808f067.04c857e949cc0fac
+ bc3127138b19183c
+ after
+ 0000000000000000.0000000000000000.0000000000000000.2525252525252525
+ 9432a2e46543b956.b819f459105730e9.9a49ac115048d4c4.f987fa170d3ce4dd
+ d2b3c4044ef23fb2.e22093a48a9d2e0b.5da3cfd6aea6558e.0c28728e28dc3c9c
+ 89fba268812abdb2.1e4a9e0958fac555.adddf0eb4808f067.04c857e949cc0fac
+ bc3127138b19183c
+VMOVQ_XMM_to_XMM_LOW_LOW_HIGH(mem)
+ before
+ 12305efa0acd1475.1755377e9a786f01.4a6592749579b0f4.e4450ababbfae0f9
+ e1917689e3f6bf86.d70f7fb13667914c.413cead25e27ac14.5f2619b1a20662f0
+ 0420edac31a0d599.2573776df1835e3e.de9a220dce0e75e0.7acb193b9abab2f9
+ 59a93d4f11d611db.5cce191e65591384.ff4cb613013cc685.918107c43ea20cc0
+ 0194ddb82b49abf0
+ after
+ 12305efa0acd1475.1755377e9a786f01.4a6592749579b0f4.2525252525252525
+ e1917689e3f6bf86.d70f7fb13667914c.413cead25e27ac14.5f2619b1a20662f0
+ 0420edac31a0d599.2573776df1835e3e.de9a220dce0e75e0.7acb193b9abab2f9
+ 59a93d4f11d611db.5cce191e65591384.ff4cb613013cc685.918107c43ea20cc0
+ 0194ddb82b49abf0
+
diff --git a/none/tests/amd64/avx-vmovq.vgtest b/none/tests/amd64/avx-vmovq.vgtest
new file mode 100644
index 000000000000..ba4f5caaf2ad
--- /dev/null
+++ b/none/tests/amd64/avx-vmovq.vgtest
@@ -0,0 +1,3 @@
+prog: avx-vmovq
+prereq: test -x avx-vmovq && ../../../tests/x86_amd64_features amd64-avx
+vgopts: -q
--
2.45.2