]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 487439 - SIGILL in JDK11, JDK17
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 16 Jun 2024 07:25:51 +0000 (09:25 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 16 Jun 2024 07:25:51 +0000 (09:25 +0200)
.gitignore
NEWS
VEX/priv/guest_amd64_toIR.c
none/tests/amd64/Makefile.am
none/tests/amd64/bug487439.cpp [new file with mode: 0644]
none/tests/amd64/bug487439.stderr.exp [new file with mode: 0644]
none/tests/amd64/bug487439.stdout.exp [new file with mode: 0644]
none/tests/amd64/bug487439.vgtest [new file with mode: 0644]

index e80b1dda8973f6cf8ef9a4d1ca8a72012f56542e..1473e9a7391542d94f4a8b8348238f3860b21008 100644 (file)
 /none/tests/amd64/bug137714-amd64
 /none/tests/amd64/bug156404-amd64
 /none/tests/amd64/bug485148
+/none/tests/amd64/bug487439
 /none/tests/amd64/cet_nops
 /none/tests/amd64/clc
 /none/tests/amd64/cmpxchg
diff --git a/NEWS b/NEWS
index 990e2238a898ea891f838818ecd86692ba59a8cc..7a8505cb503d96e49b153e29a2e23ba05749dd73 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
         'guest_IP_AT_SYSCALL'
 486293  memccpy false positives
 486569  linux inotify_init syscall wrapper missing POST entry in syscall_table
+487439  SIGILL in JDK11, JDK17
 487993  Alignment error when using Eigen with Valgrind and -m32
 488026  Use of `sizeof` instead of `strlen
 488441  Add tests for --track-fds=yes --xml=yes and fd suppression tests
index f0b1c55162677546a73f5a967f090b561dcac4f6..28c37f09221194ef4607d11224c50d33886bb03f 100644 (file)
@@ -14138,7 +14138,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK,
          goto decode_success;
       }
       /* 66 0F 73 /6 ib = PSLLQ by immediate */
-      if (have66noF2noF3(pfx) && sz == 2 
+      if (have66noF2noF3(pfx) && (sz == 2 || /* ignore redundant REX.W */ sz == 8)
           && epartIsReg(getUChar(delta))
           && gregLO3ofRM(getUChar(delta)) == 6) {
          delta = dis_SSE_shiftE_imm( pfx, delta, "psllq", Iop_ShlN64x2 );
index dc0498018209ac479a40072557196a225bcdb8b5..83029c15590cc18a5e9970f452ba72aa48b83e18 100644 (file)
@@ -44,6 +44,7 @@ EXTRA_DIST = \
        bug156404-amd64.vgtest bug156404-amd64.stdout.exp \
        bug156404-amd64.stderr.exp \
        bug485148.vgtest bug485148.stdout.exp bug485148.stderr.exp \
+       bug487439.vgtest bug487439.stdout.exp bug487439.stderr.exp \
        cet_nops.vgtest cet_nops.stdout.exp cet_nops.stderr.exp \
        clc.vgtest clc.stdout.exp clc.stderr.exp \
        crc32.vgtest crc32.stdout.exp crc32.stderr.exp \
@@ -107,6 +108,7 @@ check_PROGRAMS = \
        amd64locked \
        bt_flags \
        bug127521-64 bug132813-amd64 bug132918 bug137714-amd64 \
+       bug487439 \
        cet_nops \
        clc \
        cmpxchg \
@@ -204,6 +206,7 @@ amd64locked_CFLAGS  = $(AM_CFLAGS) -O
 bug132918_LDADD                = -lm
 bug485148_CXXFLAGS      = ${AM_CXXFLAGS} -mfma
 bug485148_SOURCES       = bug485148.cpp
+bug487439_SOURCES      = bug487439.cpp
 cmpxchg_CFLAGS         = $(AM_CFLAGS) @FLAG_NO_PIE@
 fb_test_amd64_CFLAGS   = $(AM_CFLAGS) -O -fno-strict-aliasing
 fb_test_amd64_LDADD    = -lm
diff --git a/none/tests/amd64/bug487439.cpp b/none/tests/amd64/bug487439.cpp
new file mode 100644 (file)
index 0000000..f86bb65
--- /dev/null
@@ -0,0 +1,83 @@
+// This is more or less a copy/paste from the generated insn_sse2.c
+// I didn't want to mess with the perl generator because
+// GCC and clang don't agree on the asm syntax
+// Using the rex prefix looks like a bug or misfeature in OpenJDK
+// so I'm assuming that this is a one-off and not a general issue
+
+#include <iostream>
+#include <csetjmp>
+#include <csignal>
+
+union reg128_t {
+  char sb[16];
+  unsigned char ub[16];
+  short sw[8];
+  unsigned short uw[8];
+  int sd[4];
+  unsigned int ud[4];
+  long long int sq[2];
+  unsigned long long int uq[2];
+  float ps[4];
+  double pd[2];
+} __attribute__ ((aligned (16)));
+
+static sigjmp_buf catchpoint;
+
+static void handle_sigill(int signum)
+{
+   siglongjmp(catchpoint, 1);
+}
+
+/* with redundant rex.W */
+static void psllq_4(void)
+{
+   reg128_t arg1 = { .uq = { 0x0123456789abcdefULL, 0x0123456789abcdefULL } };
+   reg128_t result0;
+   char state[108];
+
+   if (sigsetjmp(catchpoint, 1) == 0)
+   {
+      asm(
+         "ffree %%st(7)\n"
+         "ffree %%st(6)\n"
+         "ffree %%st(5)\n"
+         "ffree %%st(4)\n"
+         "movlps %2, %%xmm1\n"
+         "movhps %3, %%xmm1\n"
+         // only GCC
+         //".rex.W psllq $12, %%xmm1\n"
+         // only clang
+         //"data16 rex64 psllq $12, %mm1\n"
+         ".byte 0x66,0x48,0x0f,0x73,0xf1,0x0c\n"
+         "movlps %%xmm1, %0\n"
+         "movhps %%xmm1, %1\n"
+         "cld\n"
+         : "=m" (result0.uq[0]), "=m" (result0.uq[1])
+         : "m" (arg1.uq[0]), "m" (arg1.uq[1]), "m" (state[0])
+         : "xmm1"
+      );
+
+      if (result0.uq[0] == 0x3456789abcdef000ULL && result0.uq[1] == 0x3456789abcdef000ULL )
+      {
+         std::cout << "psllq_4 ... ok\n";
+      }
+      else
+      {
+         std::cout << "psllq_4 ... not ok\n";
+         std::cout << "  result0.uq[0] = " << result0.uq[0] << " (expected " << 0x3456789abcdef000ULL << ")\n";
+         std::cout << "  result0.uq[1] = " << result0.uq[1] << " (expected " << 0x3456789abcdef000ULL << ")\n";
+      }
+   }
+   else
+   {
+      std::cout << "psllq_4 ... failed\n";
+   }
+
+   return;
+}
+
+int main()
+{
+   signal(SIGILL, handle_sigill);
+   psllq_4();
+}
diff --git a/none/tests/amd64/bug487439.stderr.exp b/none/tests/amd64/bug487439.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/amd64/bug487439.stdout.exp b/none/tests/amd64/bug487439.stdout.exp
new file mode 100644 (file)
index 0000000..065b518
--- /dev/null
@@ -0,0 +1 @@
+psllq_4 ... ok
diff --git a/none/tests/amd64/bug487439.vgtest b/none/tests/amd64/bug487439.vgtest
new file mode 100644 (file)
index 0000000..3faa1ed
--- /dev/null
@@ -0,0 +1,2 @@
+prog: bug487439
+vgopts: -q