Dirk Mueller
a32108fd69
OBS-URL: https://build.opensuse.org/package/show/devel:tools/valgrind?expand=0&rev=110
116 lines
4.0 KiB
Diff
116 lines
4.0 KiB
Diff
------------------------------------------------------------------------
|
|
r13948 | mjw | 2014-05-09 13:41:46 +0200 (Fr, 09 Mai 2014) | 1 line
|
|
|
|
Add test for MPX instructions and bnd prefix. Bug #333666.
|
|
------------------------------------------------------------------------
|
|
Index: none/tests/amd64/mpx.stderr.exp
|
|
===================================================================
|
|
Index: none/tests/amd64/mpx.c
|
|
===================================================================
|
|
--- none/tests/amd64/mpx.c (revision 0)
|
|
+++ none/tests/amd64/mpx.c (revision 13948)
|
|
@@ -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;
|
|
+}
|
|
Index: none/tests/amd64/mpx.stdout.exp
|
|
===================================================================
|
|
Index: none/tests/amd64/mpx.vgtest
|
|
===================================================================
|
|
--- none/tests/amd64/mpx.vgtest (revision 0)
|
|
+++ none/tests/amd64/mpx.vgtest (revision 13948)
|
|
@@ -0,0 +1,3 @@
|
|
+prog: mpx
|
|
+prereq: test -x mpx
|
|
+vgopts: -q
|
|
Index: none/tests/amd64/Makefile.am
|
|
===================================================================
|
|
--- none/tests/amd64/Makefile.am (revision 13947)
|
|
+++ none/tests/amd64/Makefile.am (revision 13948)
|
|
@@ -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
|
|
Index: configure.ac
|
|
===================================================================
|
|
--- configure.ac (revision 13947)
|
|
+++ configure.ac (revision 13948)
|
|
@@ -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
|