]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add test for MPX instructions and bnd prefix. Bug #333666.
authorMark Wielaard <mark@klomp.org>
Fri, 9 May 2014 11:41:46 +0000 (11:41 +0000)
committerMark Wielaard <mark@klomp.org>
Fri, 9 May 2014 11:41:46 +0000 (11:41 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13948

NEWS
configure.ac
none/tests/amd64/Makefile.am
none/tests/amd64/mpx.c [new file with mode: 0644]
none/tests/amd64/mpx.stderr.exp [new file with mode: 0644]
none/tests/amd64/mpx.stdout.exp [new file with mode: 0644]
none/tests/amd64/mpx.vgtest [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index ac02d09d2e4f0339f076a42a769b6c8957f0c138..b0b9e90fa51dc34c5a49469e1977105efaa62bfc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -98,6 +98,7 @@ where XXXXXX is the bug number as listed below.
         consistency checks enabled
 333230  AAarch64 missing instruction encodings: dc, ic, dsb.
 333228  AAarch64 Missing instruction encoding: mrs %[reg], ctr_el0
+333666  Recognize MPX instructions and bnd prefix.
 n-i-bz  Fix KVM_CREATE_IRQCHIP ioctl handling
 n-i-bz  s390x: Fix memory corruption for multithreaded applications
 n-i-bz  vex arm->IR: allow PC as basereg in some LDRD cases
index b1e567a54136f40666fc8f2171ad620d6cb61b92..af4228915a105d4b29b97caec2a6916330346be7 100644 (file)
@@ -2322,6 +2322,27 @@ AC_MSG_RESULT([no])
 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
 
 
+# does the amd64 assembler understand MPX instructions?
+# Note, this doesn't generate a C-level symbol.  It generates a
+# automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
+AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+  asm ("bndmov %bnd0,(%rsp)")
+]])], [
+ac_have_as_mpx=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_as_mpx=no
+AC_MSG_RESULT([no])
+])
+
+AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
+
+
+# Does the C compiler support the "ifunc" attribute
+# Note, this doesn't generate a C-level symbol.  It generates a
+# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
 # does the x86/amd64 assembler understand MOVBE?
 # Note, this doesn't generate a C-level symbol.  It generates a
 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
index d7ec56abfb58583ce4b250845066d1023217364d..d5f9e48a4a267bc779872b8a7bee3c8375eb5537 100644 (file)
@@ -56,6 +56,7 @@ EXTRA_DIST = \
        loopnel.stderr.exp loopnel.stdout.exp loopnel.vgtest \
        lzcnt64.stderr.exp lzcnt64.stdout.exp lzcnt64.vgtest \
        movbe.stderr.exp movbe.stdout.exp movbe.vgtest \
+       mpx.stderr.exp mpx.stdout.exp mpx.vgtest \
        nan80and64.stderr.exp nan80and64.stdout.exp nan80and64.vgtest \
        nibz_bennee_mmap.stderr.exp nibz_bennee_mmap.stdout.exp \
        nibz_bennee_mmap.vgtest \
@@ -133,6 +134,10 @@ endif
 if BUILD_MOVBE_TESTS
  check_PROGRAMS += movbe
 endif
+if BUILD_MPX_TESTS
+ check_PROGRAMS += mpx
+endif
+
 
 # DDD: these need to be made to work on Darwin like the x86/ ones were.
 if ! VGCONF_OS_IS_DARWIN
diff --git a/none/tests/amd64/mpx.c b/none/tests/amd64/mpx.c
new file mode 100644 (file)
index 0000000..ae713d6
--- /dev/null
@@ -0,0 +1,38 @@
+int
+main (int argc, char **argv)
+{
+  // Since MPX is disabled all these are just NOPS.
+  // Some of these instructions are just random.
+  // Once the GCC support is merged creating real test cases will be easier.
+  // http://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler
+
+  // This is what ld.so does in _dl_runtime_resolve to save the bnds.
+  asm ("bndmov %bnd0, (%rsp)");
+  asm ("bndmov %bnd1, 16(%rsp)");
+  asm ("bndmov %bnd2, 32(%rsp)");
+  asm ("bndmov %bnd3, 48(%rsp)");
+
+  // Create a bnd, check lower and upper...
+  asm ("bndmk (%rax,%rdx), %bnd0");
+  asm ("bndcl (%rax,%rdi,4), %bnd0");
+  asm ("bndcu 3(%rax,%rdi,4), %bnd0");
+  asm ("bndcn 3(%rax,%rdi,4), %bnd0");
+
+  // Load bnd pointer and update...
+  asm ("bndldx 3(%rbx,%rdx), %bnd2");
+  asm ("bndstx %bnd2, 3(,%r12,1)");
+
+  // "bnd" prefixed call, return and jmp...
+  asm ("bnd call foo\n\
+        bnd jmp  end\n\
+        foo: bnd ret\n\
+        end: nop");
+
+  // And set the bnds back...
+  asm ("bndmov 48(%rsp), %bnd3");
+  asm ("bndmov 32(%rsp), %bnd2");
+  asm ("bndmov 16(%rsp), %bnd1");
+  asm ("bndmov (%rsp), %bnd0");
+
+  return 0;
+}
diff --git a/none/tests/amd64/mpx.stderr.exp b/none/tests/amd64/mpx.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/amd64/mpx.stdout.exp b/none/tests/amd64/mpx.stdout.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/amd64/mpx.vgtest b/none/tests/amd64/mpx.vgtest
new file mode 100644 (file)
index 0000000..ab96355
--- /dev/null
@@ -0,0 +1,3 @@
+prog: mpx
+prereq: test -x mpx
+vgopts: -q