Author: mjw
Date: Fri May 9 11:41:46 2014
New Revision: 13948
Log:
Add test for MPX instructions and bnd prefix. Bug #333666.
Added:
trunk/none/tests/amd64/mpx.c
trunk/none/tests/amd64/mpx.stderr.exp
trunk/none/tests/amd64/mpx.stdout.exp
trunk/none/tests/amd64/mpx.vgtest
Modified:
trunk/NEWS
trunk/configure.ac
trunk/none/tests/amd64/Makefile.am
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Fri May 9 11:41:46 2014
@@ -98,6 +98,7 @@
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
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri May 9 11:41:46 2014
@@ -2322,6 +2322,27 @@
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
Modified: trunk/none/tests/amd64/Makefile.am
==============================================================================
--- trunk/none/tests/amd64/Makefile.am (original)
+++ trunk/none/tests/amd64/Makefile.am Fri May 9 11:41:46 2014
@@ -56,6 +56,7 @@
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 @@
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
Added: trunk/none/tests/amd64/mpx.c
==============================================================================
--- trunk/none/tests/amd64/mpx.c (added)
+++ trunk/none/tests/amd64/mpx.c Fri May 9 11:41:46 2014
@@ -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;
+}
Added: trunk/none/tests/amd64/mpx.stderr.exp
==============================================================================
(empty)
Added: trunk/none/tests/amd64/mpx.stdout.exp
==============================================================================
(empty)
Added: trunk/none/tests/amd64/mpx.vgtest
==============================================================================
--- trunk/none/tests/amd64/mpx.vgtest (added)
+++ trunk/none/tests/amd64/mpx.vgtest Fri May 9 11:41:46 2014
@@ -0,0 +1,3 @@
+prog: mpx
+prereq: test -x mpx
+vgopts: -q
|