|
|
ce426f |
# MPX Support for glibc:
|
|
|
ce426f |
#
|
|
|
ce426f |
# Note: Renamed configure.ac changes to configure.in changes.
|
|
|
ce426f |
#
|
|
|
ce426f |
# commit ea8ba7cd14d0f479bae8365ae5c4ef177bdd0aad
|
|
|
ce426f |
# Author: Igor Zamyatin <igor.zamyatin@intel.com>
|
|
|
ce426f |
# Date: Wed Apr 16 14:43:16 2014 -0700
|
|
|
ce426f |
#
|
|
|
ce426f |
# Save/restore bound registers for _dl_runtime_profile
|
|
|
ce426f |
#
|
|
|
ce426f |
# This patch saves and restores bound registers in x86-64 PLT for
|
|
|
ce426f |
# ld.so profile and LD_AUDIT:
|
|
|
ce426f |
#
|
|
|
ce426f |
# * sysdeps/x86_64/bits/link.h (La_x86_64_regs): Add lr_bnd.
|
|
|
ce426f |
# (La_x86_64_retval): Add lrv_bnd0 and lrv_bnd1.
|
|
|
ce426f |
# * sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Save
|
|
|
ce426f |
# Intel MPX bound registers before _dl_profile_fixup.
|
|
|
ce426f |
# * sysdeps/x86_64/dl-trampoline.h: Restore Intel MPX bound
|
|
|
ce426f |
# registers after _dl_profile_fixup. Save and restore bound
|
|
|
ce426f |
# registers bnd0/bnd1 when calling _dl_call_pltexit.
|
|
|
ce426f |
# * sysdeps/x86_64/link-defines.sym (BND_SIZE): New.
|
|
|
ce426f |
# (LR_BND_OFFSET): Likewise.
|
|
|
ce426f |
# (LRV_BND0_OFFSET): Likewise.
|
|
|
ce426f |
# (LRV_BND1_OFFSET): Likewise.
|
|
|
ce426f |
#
|
|
|
ce426f |
# commit a4c75cfd56e536c2b18556e8a482d88dffa0fffc
|
|
|
ce426f |
# Author: Igor Zamyatin <igor.zamyatin@intel.com>
|
|
|
ce426f |
# Date: Tue Apr 1 10:16:04 2014 -0700
|
|
|
ce426f |
#
|
|
|
ce426f |
# Save/restore bound registers in _dl_runtime_resolve
|
|
|
ce426f |
#
|
|
|
ce426f |
# This patch saves and restores bound registers in symbol lookup for x86-64:
|
|
|
ce426f |
#
|
|
|
ce426f |
# 1. Branches without BND prefix clear bound registers.
|
|
|
ce426f |
# 2. x86-64 pass bounds in bound registers as specified in MPX psABI
|
|
|
ce426f |
# extension on hjl/mpx/master branch at
|
|
|
ce426f |
#
|
|
|
ce426f |
# https://github.com/hjl-tools/x86-64-psABI
|
|
|
ce426f |
# https://groups.google.com/forum/#!topic/x86-64-abi/KFsB0XTgWYc
|
|
|
ce426f |
#
|
|
|
ce426f |
# Binutils has been updated to create an alternate PLT to add BND prefix
|
|
|
ce426f |
# when branching to ld.so.
|
|
|
ce426f |
#
|
|
|
ce426f |
# * config.h.in (HAVE_MPX_SUPPORT): New #undef.
|
|
|
ce426f |
# * sysdeps/x86_64/configure.ac: Set HAVE_MPX_SUPPORT.
|
|
|
ce426f |
# * sysdeps/x86_64/configure: Regenerated.
|
|
|
ce426f |
# * sysdeps/x86_64/dl-trampoline.S (REGISTER_SAVE_AREA): New
|
|
|
ce426f |
# macro.
|
|
|
ce426f |
# (REGISTER_SAVE_RAX): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_RCX): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_RDX): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_RSI): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_RDI): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_R8): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_R9): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_BND0): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_BND1): Likewise.
|
|
|
ce426f |
# (REGISTER_SAVE_BND2): Likewise.
|
|
|
ce426f |
# (_dl_runtime_resolve): Use them. Save and restore Intel MPX
|
|
|
ce426f |
# bound registers when calling _dl_fixup.
|
|
|
ce426f |
#
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/config.h.in glibc-2.17-c758a686/config.h.in
|
|
|
ce426f |
--- glibc-2.17-c758a686/config.h.in 2014-09-10 23:26:03.467045808 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/config.h.in 2014-09-10 23:27:41.532851928 -0400
|
|
|
ce426f |
@@ -107,6 +107,9 @@
|
|
|
ce426f |
/* Define if assembler supports AVX512. */
|
|
|
ce426f |
#undef HAVE_AVX512_ASM_SUPPORT
|
|
|
ce426f |
|
|
|
ce426f |
+/* Define if assembler supports Intel MPX. */
|
|
|
ce426f |
+#undef HAVE_MPX_SUPPORT
|
|
|
ce426f |
+
|
|
|
ce426f |
/* Define if gcc supports FMA4. */
|
|
|
ce426f |
#undef HAVE_FMA4_SUPPORT
|
|
|
ce426f |
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/x86/bits/link.h glibc-2.17-c758a686/sysdeps/x86/bits/link.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86/bits/link.h 2014-09-10 23:26:03.467045808 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86/bits/link.h 2014-09-10 23:27:41.533851926 -0400
|
|
|
ce426f |
@@ -93,6 +93,9 @@
|
|
|
ce426f |
uint64_t lr_rsp;
|
|
|
ce426f |
La_x86_64_xmm lr_xmm[8];
|
|
|
ce426f |
La_x86_64_vector lr_vector[8];
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+ __int128 lr_bnd[4];
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
} La_x86_64_regs;
|
|
|
ce426f |
|
|
|
ce426f |
/* Return values for calls from PLT on x86-64. */
|
|
|
ce426f |
@@ -106,6 +109,10 @@
|
|
|
ce426f |
long double lrv_st1;
|
|
|
ce426f |
La_x86_64_vector lrv_vector0;
|
|
|
ce426f |
La_x86_64_vector lrv_vector1;
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+ __int128 lrv_bnd0;
|
|
|
ce426f |
+ __int128 lrv_bnd1;
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
} La_x86_64_retval;
|
|
|
ce426f |
|
|
|
ce426f |
#define La_x32_regs La_x86_64_regs
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/configure glibc-2.17-c758a686/sysdeps/x86_64/configure
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/configure 2014-09-10 23:26:03.573045598 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/configure 2014-09-10 23:27:41.532851928 -0400
|
|
|
ce426f |
@@ -212,6 +212,33 @@
|
|
|
ce426f |
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_novzeroupper" >&5
|
|
|
ce426f |
$as_echo "$libc_cv_cc_novzeroupper" >&6; }
|
|
|
ce426f |
|
|
|
ce426f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Intel MPX support" >&5
|
|
|
ce426f |
+$as_echo_n "checking for Intel MPX support... " >&6; }
|
|
|
ce426f |
+if ${libc_cv_asm_mpx+:} false; then :
|
|
|
ce426f |
+ $as_echo_n "(cached) " >&6
|
|
|
ce426f |
+else
|
|
|
ce426f |
+ cat > conftest.s <<\EOF
|
|
|
ce426f |
+ bndmov %bnd0,(%rsp)
|
|
|
ce426f |
+EOF
|
|
|
ce426f |
+if { ac_try='${CC-cc} -c $ASFLAGS conftest.s 1>&5'
|
|
|
ce426f |
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
|
|
ce426f |
+ (eval $ac_try) 2>&5
|
|
|
ce426f |
+ ac_status=$?
|
|
|
ce426f |
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
|
ce426f |
+ test $ac_status = 0; }; }; then
|
|
|
ce426f |
+ libc_cv_asm_mpx=yes
|
|
|
ce426f |
+else
|
|
|
ce426f |
+ libc_cv_asm_mpx=no
|
|
|
ce426f |
+fi
|
|
|
ce426f |
+rm -f conftest*
|
|
|
ce426f |
+fi
|
|
|
ce426f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_mpx" >&5
|
|
|
ce426f |
+$as_echo "$libc_cv_asm_mpx" >&6; }
|
|
|
ce426f |
+if test $libc_cv_asm_mpx == yes; then
|
|
|
ce426f |
+ $as_echo "#define HAVE_MPX_SUPPORT 1" >>confdefs.h
|
|
|
ce426f |
+
|
|
|
ce426f |
+fi
|
|
|
ce426f |
+
|
|
|
ce426f |
$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
|
|
|
ce426f |
|
|
|
ce426f |
# work around problem with autoconf and empty lines at the end of files
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/configure.in glibc-2.17-c758a686/sysdeps/x86_64/configure.in
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/configure.in 2014-09-10 23:26:03.468045806 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/configure.in 2014-09-10 23:27:41.532851928 -0400
|
|
|
ce426f |
@@ -70,6 +70,21 @@
|
|
|
ce426f |
[libc_cv_cc_novzeroupper=no])
|
|
|
ce426f |
])
|
|
|
ce426f |
|
|
|
ce426f |
+dnl Check whether asm supports Intel MPX
|
|
|
ce426f |
+AC_CACHE_CHECK(for Intel MPX support, libc_cv_asm_mpx, [dnl
|
|
|
ce426f |
+cat > conftest.s <<\EOF
|
|
|
ce426f |
+ bndmov %bnd0,(%rsp)
|
|
|
ce426f |
+EOF
|
|
|
ce426f |
+if AC_TRY_COMMAND(${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD); then
|
|
|
ce426f |
+ libc_cv_asm_mpx=yes
|
|
|
ce426f |
+else
|
|
|
ce426f |
+ libc_cv_asm_mpx=no
|
|
|
ce426f |
+fi
|
|
|
ce426f |
+rm -f conftest*])
|
|
|
ce426f |
+if test $libc_cv_asm_mpx == yes; then
|
|
|
ce426f |
+ AC_DEFINE(HAVE_MPX_SUPPORT)
|
|
|
ce426f |
+fi
|
|
|
ce426f |
+
|
|
|
ce426f |
dnl It is always possible to access static and hidden symbols in an
|
|
|
ce426f |
dnl position independent way.
|
|
|
ce426f |
AC_DEFINE(PI_STATIC_AND_HIDDEN)
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.h glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.h
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.h 2014-09-10 23:26:03.468045806 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.h 2014-09-10 23:27:41.535851922 -0400
|
|
|
ce426f |
@@ -63,6 +63,20 @@
|
|
|
ce426f |
movaps (LR_XMM_OFFSET + XMM_SIZE*6)(%rsp), %xmm6
|
|
|
ce426f |
movaps (LR_XMM_OFFSET + XMM_SIZE*7)(%rsp), %xmm7
|
|
|
ce426f |
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
ce426f |
+ bndmov (LR_BND_OFFSET)(%rsp), %bnd0 # Restore bound
|
|
|
ce426f |
+ bndmov (LR_BND_OFFSET + BND_SIZE)(%rsp), %bnd1 # registers.
|
|
|
ce426f |
+ bndmov (LR_BND_OFFSET + BND_SIZE*2)(%rsp), %bnd2
|
|
|
ce426f |
+ bndmov (LR_BND_OFFSET + BND_SIZE*3)(%rsp), %bnd3
|
|
|
ce426f |
+# else
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x84,0x24;.long (LR_BND_OFFSET)
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x8c,0x24;.long (LR_BND_OFFSET + BND_SIZE)
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x94,0x24;.long (LR_BND_OFFSET + BND_SIZE*2)
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x9c,0x24;.long (LR_BND_OFFSET + BND_SIZE*3)
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+
|
|
|
ce426f |
#ifdef RESTORE_AVX
|
|
|
ce426f |
/* Check if any xmm0-xmm7 registers are changed by audit
|
|
|
ce426f |
module. */
|
|
|
ce426f |
@@ -222,6 +236,16 @@
|
|
|
ce426f |
vmovdqa %xmm1, (LRV_SIZE + XMM_SIZE)(%rcx)
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
ce426f |
+ bndmov %bnd0, LRV_BND0_OFFSET(%rcx) # Preserve returned bounds.
|
|
|
ce426f |
+ bndmov %bnd1, LRV_BND1_OFFSET(%rcx)
|
|
|
ce426f |
+# else
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x81;.long (LRV_BND0_OFFSET)
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x89;.long (LRV_BND1_OFFSET)
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+
|
|
|
ce426f |
fstpt LRV_ST0_OFFSET(%rcx)
|
|
|
ce426f |
fstpt LRV_ST1_OFFSET(%rcx)
|
|
|
ce426f |
|
|
|
ce426f |
@@ -254,6 +278,16 @@
|
|
|
ce426f |
1:
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
ce426f |
+ bndmov LRV_BND0_OFFSET(%rcx), %bnd0 # Restore bound registers.
|
|
|
ce426f |
+ bndmov LRV_BND1_OFFSET(%rcx), %bnd1
|
|
|
ce426f |
+# else
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x81;.long (LRV_BND0_OFFSET)
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x89;.long (LRV_BND1_OFFSET)
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+
|
|
|
ce426f |
fldt LRV_ST1_OFFSET(%rsp)
|
|
|
ce426f |
fldt LRV_ST0_OFFSET(%rsp)
|
|
|
ce426f |
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.S glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.S
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.S 2014-09-10 23:26:03.468045806 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/dl-trampoline.S 2014-09-10 23:27:41.534851924 -0400
|
|
|
ce426f |
@@ -24,6 +24,30 @@
|
|
|
ce426f |
# error RTLD_SAVESPACE_SSE must be aligned to 32 bytes
|
|
|
ce426f |
#endif
|
|
|
ce426f |
|
|
|
ce426f |
+/* Area on stack to save and restore registers used for parameter
|
|
|
ce426f |
+ passing when calling _dl_fixup. */
|
|
|
ce426f |
+#ifdef __ILP32__
|
|
|
ce426f |
+/* X32 saves RCX, RDX, RSI, RDI, R8 and R9 plus RAX. */
|
|
|
ce426f |
+# define REGISTER_SAVE_AREA (8 * 7)
|
|
|
ce426f |
+# define REGISTER_SAVE_RAX 0
|
|
|
ce426f |
+#else
|
|
|
ce426f |
+/* X86-64 saves RCX, RDX, RSI, RDI, R8 and R9 plus RAX as well as BND0,
|
|
|
ce426f |
+ BND1, BND2, BND3. */
|
|
|
ce426f |
+# define REGISTER_SAVE_AREA (8 * 7 + 16 * 4)
|
|
|
ce426f |
+/* Align bound register save area to 16 bytes. */
|
|
|
ce426f |
+# define REGISTER_SAVE_BND0 0
|
|
|
ce426f |
+# define REGISTER_SAVE_BND1 (REGISTER_SAVE_BND0 + 16)
|
|
|
ce426f |
+# define REGISTER_SAVE_BND2 (REGISTER_SAVE_BND1 + 16)
|
|
|
ce426f |
+# define REGISTER_SAVE_BND3 (REGISTER_SAVE_BND2 + 16)
|
|
|
ce426f |
+# define REGISTER_SAVE_RAX (REGISTER_SAVE_BND3 + 16)
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+#define REGISTER_SAVE_RCX (REGISTER_SAVE_RAX + 8)
|
|
|
ce426f |
+#define REGISTER_SAVE_RDX (REGISTER_SAVE_RCX + 8)
|
|
|
ce426f |
+#define REGISTER_SAVE_RSI (REGISTER_SAVE_RDX + 8)
|
|
|
ce426f |
+#define REGISTER_SAVE_RDI (REGISTER_SAVE_RSI + 8)
|
|
|
ce426f |
+#define REGISTER_SAVE_R8 (REGISTER_SAVE_RDI + 8)
|
|
|
ce426f |
+#define REGISTER_SAVE_R9 (REGISTER_SAVE_R8 + 8)
|
|
|
ce426f |
+
|
|
|
ce426f |
.text
|
|
|
ce426f |
.globl _dl_runtime_resolve
|
|
|
ce426f |
.type _dl_runtime_resolve, @function
|
|
|
ce426f |
@@ -31,28 +55,63 @@
|
|
|
ce426f |
cfi_startproc
|
|
|
ce426f |
_dl_runtime_resolve:
|
|
|
ce426f |
cfi_adjust_cfa_offset(16) # Incorporate PLT
|
|
|
ce426f |
- subq $56,%rsp
|
|
|
ce426f |
- cfi_adjust_cfa_offset(56)
|
|
|
ce426f |
- movq %rax,(%rsp) # Preserve registers otherwise clobbered.
|
|
|
ce426f |
- movq %rcx, 8(%rsp)
|
|
|
ce426f |
- movq %rdx, 16(%rsp)
|
|
|
ce426f |
- movq %rsi, 24(%rsp)
|
|
|
ce426f |
- movq %rdi, 32(%rsp)
|
|
|
ce426f |
- movq %r8, 40(%rsp)
|
|
|
ce426f |
- movq %r9, 48(%rsp)
|
|
|
ce426f |
- movq 64(%rsp), %rsi # Copy args pushed by PLT in register.
|
|
|
ce426f |
- movq 56(%rsp), %rdi # %rdi: link_map, %rsi: reloc_index
|
|
|
ce426f |
+ subq $REGISTER_SAVE_AREA,%rsp
|
|
|
ce426f |
+ cfi_adjust_cfa_offset(REGISTER_SAVE_AREA)
|
|
|
ce426f |
+ # Preserve registers otherwise clobbered.
|
|
|
ce426f |
+ movq %rax, REGISTER_SAVE_RAX(%rsp)
|
|
|
ce426f |
+ movq %rcx, REGISTER_SAVE_RCX(%rsp)
|
|
|
ce426f |
+ movq %rdx, REGISTER_SAVE_RDX(%rsp)
|
|
|
ce426f |
+ movq %rsi, REGISTER_SAVE_RSI(%rsp)
|
|
|
ce426f |
+ movq %rdi, REGISTER_SAVE_RDI(%rsp)
|
|
|
ce426f |
+ movq %r8, REGISTER_SAVE_R8(%rsp)
|
|
|
ce426f |
+ movq %r9, REGISTER_SAVE_R9(%rsp)
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+ # We also have to preserve bound registers. These are nops if
|
|
|
ce426f |
+ # Intel MPX isn't available or disabled.
|
|
|
ce426f |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
ce426f |
+ bndmov %bnd0, REGISTER_SAVE_BND0(%rsp)
|
|
|
ce426f |
+ bndmov %bnd1, REGISTER_SAVE_BND1(%rsp)
|
|
|
ce426f |
+ bndmov %bnd2, REGISTER_SAVE_BND2(%rsp)
|
|
|
ce426f |
+ bndmov %bnd3, REGISTER_SAVE_BND3(%rsp)
|
|
|
ce426f |
+# else
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x44,0x24,REGISTER_SAVE_BND0
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x4c,0x24,REGISTER_SAVE_BND1
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x54,0x24,REGISTER_SAVE_BND2
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x5c,0x24,REGISTER_SAVE_BND3
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ # Copy args pushed by PLT in register.
|
|
|
ce426f |
+ # %rdi: link_map, %rsi: reloc_index
|
|
|
ce426f |
+ movq (REGISTER_SAVE_AREA + 8)(%rsp), %rsi
|
|
|
ce426f |
+ movq REGISTER_SAVE_AREA(%rsp), %rdi
|
|
|
ce426f |
call _dl_fixup # Call resolver.
|
|
|
ce426f |
movq %rax, %r11 # Save return value
|
|
|
ce426f |
- movq 48(%rsp), %r9 # Get register content back.
|
|
|
ce426f |
- movq 40(%rsp), %r8
|
|
|
ce426f |
- movq 32(%rsp), %rdi
|
|
|
ce426f |
- movq 24(%rsp), %rsi
|
|
|
ce426f |
- movq 16(%rsp), %rdx
|
|
|
ce426f |
- movq 8(%rsp), %rcx
|
|
|
ce426f |
- movq (%rsp), %rax
|
|
|
ce426f |
- addq $72, %rsp # Adjust stack(PLT did 2 pushes)
|
|
|
ce426f |
- cfi_adjust_cfa_offset(-72)
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+ # Restore bound registers. These are nops if Intel MPX isn't
|
|
|
ce426f |
+ # avaiable or disabled.
|
|
|
ce426f |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
ce426f |
+ bndmov REGISTER_SAVE_BND3(%rsp), %bnd3
|
|
|
ce426f |
+ bndmov REGISTER_SAVE_BND2(%rsp), %bnd2
|
|
|
ce426f |
+ bndmov REGISTER_SAVE_BND1(%rsp), %bnd1
|
|
|
ce426f |
+ bndmov REGISTER_SAVE_BND0(%rsp), %bnd0
|
|
|
ce426f |
+# else
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x5c,0x24,REGISTER_SAVE_BND3
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x54,0x24,REGISTER_SAVE_BND2
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x4c,0x24,REGISTER_SAVE_BND1
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1a,0x44,0x24,REGISTER_SAVE_BND0
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
+ # Get register content back.
|
|
|
ce426f |
+ movq REGISTER_SAVE_R9(%rsp), %r9
|
|
|
ce426f |
+ movq REGISTER_SAVE_R8(%rsp), %r8
|
|
|
ce426f |
+ movq REGISTER_SAVE_RDI(%rsp), %rdi
|
|
|
ce426f |
+ movq REGISTER_SAVE_RSI(%rsp), %rsi
|
|
|
ce426f |
+ movq REGISTER_SAVE_RDX(%rsp), %rdx
|
|
|
ce426f |
+ movq REGISTER_SAVE_RCX(%rsp), %rcx
|
|
|
ce426f |
+ movq REGISTER_SAVE_RAX(%rsp), %rax
|
|
|
ce426f |
+ # Adjust stack(PLT did 2 pushes)
|
|
|
ce426f |
+ addq $(REGISTER_SAVE_AREA + 16), %rsp
|
|
|
ce426f |
+ cfi_adjust_cfa_offset(-(REGISTER_SAVE_AREA + 16))
|
|
|
ce426f |
jmp *%r11 # Jump to function address.
|
|
|
ce426f |
cfi_endproc
|
|
|
ce426f |
.size _dl_runtime_resolve, .-_dl_runtime_resolve
|
|
|
ce426f |
@@ -130,6 +189,20 @@
|
|
|
ce426f |
movaps %xmm6, (LR_XMM_OFFSET + XMM_SIZE*6)(%rsp)
|
|
|
ce426f |
movaps %xmm7, (LR_XMM_OFFSET + XMM_SIZE*7)(%rsp)
|
|
|
ce426f |
|
|
|
ce426f |
+# ifndef __ILP32__
|
|
|
ce426f |
+# ifdef HAVE_MPX_SUPPORT
|
|
|
ce426f |
+ bndmov %bnd0, (LR_BND_OFFSET)(%rsp) # Preserve bound
|
|
|
ce426f |
+ bndmov %bnd1, (LR_BND_OFFSET + BND_SIZE)(%rsp) # registers. Nops if
|
|
|
ce426f |
+ bndmov %bnd2, (LR_BND_OFFSET + BND_SIZE*2)(%rsp) # MPX not available
|
|
|
ce426f |
+ bndmov %bnd3, (LR_BND_OFFSET + BND_SIZE*3)(%rsp) # or disabled.
|
|
|
ce426f |
+# else
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x84,0x24;.long (LR_BND_OFFSET)
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x8c,0x24;.long (LR_BND_OFFSET + BND_SIZE)
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x84,0x24;.long (LR_BND_OFFSET + BND_SIZE*2)
|
|
|
ce426f |
+ .byte 0x66,0x0f,0x1b,0x8c,0x24;.long (LR_BND_OFFSET + BND_SIZE*3)
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+# endif
|
|
|
ce426f |
+
|
|
|
ce426f |
# if defined HAVE_AVX_SUPPORT || defined HAVE_AVX512_ASM_SUPPORT
|
|
|
ce426f |
.data
|
|
|
ce426f |
L(have_avx):
|
|
|
ce426f |
diff -urN glibc-2.17-c758a686/sysdeps/x86_64/link-defines.sym glibc-2.17-c758a686/sysdeps/x86_64/link-defines.sym
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/x86_64/link-defines.sym 2014-09-10 23:26:03.468045806 -0400
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/x86_64/link-defines.sym 2014-09-10 23:27:41.535851922 -0400
|
|
|
ce426f |
@@ -6,6 +6,7 @@
|
|
|
ce426f |
XMM_SIZE sizeof (La_x86_64_xmm)
|
|
|
ce426f |
YMM_SIZE sizeof (La_x86_64_ymm)
|
|
|
ce426f |
ZMM_SIZE sizeof (La_x86_64_zmm)
|
|
|
ce426f |
+BND_SIZE sizeof (__int128)
|
|
|
ce426f |
|
|
|
ce426f |
LR_SIZE sizeof (struct La_x86_64_regs)
|
|
|
ce426f |
LR_RDX_OFFSET offsetof (struct La_x86_64_regs, lr_rdx)
|
|
|
ce426f |
@@ -18,6 +19,9 @@
|
|
|
ce426f |
LR_RSP_OFFSET offsetof (struct La_x86_64_regs, lr_rsp)
|
|
|
ce426f |
LR_XMM_OFFSET offsetof (struct La_x86_64_regs, lr_xmm)
|
|
|
ce426f |
LR_VECTOR_OFFSET offsetof (struct La_x86_64_regs, lr_vector)
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+LR_BND_OFFSET offsetof (struct La_x86_64_regs, lr_bnd)
|
|
|
ce426f |
+#endif
|
|
|
ce426f |
|
|
|
ce426f |
LRV_SIZE sizeof (struct La_x86_64_retval)
|
|
|
ce426f |
LRV_RAX_OFFSET offsetof (struct La_x86_64_retval, lrv_rax)
|
|
|
ce426f |
@@ -28,3 +32,7 @@
|
|
|
ce426f |
LRV_ST1_OFFSET offsetof (struct La_x86_64_retval, lrv_st1)
|
|
|
ce426f |
LRV_VECTOR0_OFFSET offsetof (struct La_x86_64_retval, lrv_vector0)
|
|
|
ce426f |
LRV_VECTOR1_OFFSET offsetof (struct La_x86_64_retval, lrv_vector1)
|
|
|
ce426f |
+#ifndef __ILP32__
|
|
|
ce426f |
+LRV_BND0_OFFSET offsetof (struct La_x86_64_retval, lrv_bnd0)
|
|
|
ce426f |
+LRV_BND1_OFFSET offsetof (struct La_x86_64_retval, lrv_bnd1)
|
|
|
ce426f |
+#endif
|