|
|
b9ba6d |
2011-07-24 H.J. Lu <hongjiu.lu@intel.com>
|
|
|
b9ba6d |
|
|
|
b9ba6d |
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Simplify
|
|
|
b9ba6d |
AVX check.
|
|
|
b9ba6d |
|
|
|
b9ba6d |
2011-08-20 Ulrich Drepper <drepper@gmail.com>
|
|
|
b9ba6d |
|
|
|
b9ba6d |
* sysdeps/x86_64/dl-trampoline.h: If MORE_CODE is defined, restore
|
|
|
b9ba6d |
the CFI state in the end.
|
|
|
b9ba6d |
* sysdeps/x86_64/dl-trampoline.S: Define MORE_CODE before first
|
|
|
b9ba6d |
inclusion of dl-trampoline.h.
|
|
|
b9ba6d |
Based on a patch by Jiri Olsa <jolsa@redhat.com>.
|
|
|
b9ba6d |
|
|
|
b9ba6d |
2011-07-23 Ulrich Drepper <drepper@gmail.com>
|
|
|
b9ba6d |
|
|
|
b9ba6d |
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Fix one more
|
|
|
b9ba6d |
typo.
|
|
|
b9ba6d |
(_dl_x86_64_save_sse): Likewise.
|
|
|
b9ba6d |
|
|
|
b9ba6d |
2011-07-22 Ulrich Drepper <drepper@gmail.com>
|
|
|
b9ba6d |
|
|
|
b9ba6d |
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Fix test for
|
|
|
b9ba6d |
OSXSAVE.
|
|
|
b9ba6d |
(_dl_x86_64_save_sse): Likewise.
|
|
|
b9ba6d |
|
|
|
b9ba6d |
2011-07-21 Andreas Schwab <schwab@redhat.com>
|
|
|
b9ba6d |
|
|
|
b9ba6d |
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Fix last
|
|
|
b9ba6d |
change.
|
|
|
b9ba6d |
(_dl_x86_64_save_sse): Use correct AVX check.
|
|
|
b9ba6d |
|
|
|
b9ba6d |
2011-07-20 Ulrich Drepper <drepper@gmail.com>
|
|
|
b9ba6d |
|
|
|
b9ba6d |
[BZ #13007]
|
|
|
b9ba6d |
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): More complete
|
|
|
b9ba6d |
check for AVX enablement so that we don't crash with old kernels and
|
|
|
b9ba6d |
new hardware.
|
|
|
b9ba6d |
* elf/tst-audit4.c: Add same checks here.
|
|
|
b9ba6d |
* elf/tst-audit6.c: Likewise.
|
|
|
b9ba6d |
|
|
|
b9ba6d |
Index: glibc-2.12-2-gc4ccff1/elf/tst-audit4.c
|
|
|
b9ba6d |
===================================================================
|
|
|
b9ba6d |
--- glibc-2.12-2-gc4ccff1.orig/elf/tst-audit4.c
|
|
|
b9ba6d |
+++ glibc-2.12-2-gc4ccff1/elf/tst-audit4.c
|
|
|
b9ba6d |
@@ -6,16 +6,30 @@
|
|
|
b9ba6d |
#include <cpuid.h>
|
|
|
b9ba6d |
#include <immintrin.h>
|
|
|
b9ba6d |
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+static int
|
|
|
b9ba6d |
+avx_enabled (void)
|
|
|
b9ba6d |
+{
|
|
|
b9ba6d |
+ unsigned int eax, ebx, ecx, edx;
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+ if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0
|
|
|
b9ba6d |
+ || (ecx & (bit_AVX | bit_OSXSAVE)) != (bit_AVX | bit_OSXSAVE))
|
|
|
b9ba6d |
+ return 0;
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+ /* Check the OS has AVX and SSE saving enabled. */
|
|
|
b9ba6d |
+ asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+ return (eax & 6) == 6;
|
|
|
b9ba6d |
+}
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
extern __m256i audit_test (__m256i, __m256i, __m256i, __m256i,
|
|
|
b9ba6d |
__m256i, __m256i, __m256i, __m256i);
|
|
|
b9ba6d |
int
|
|
|
b9ba6d |
main (void)
|
|
|
b9ba6d |
{
|
|
|
b9ba6d |
- unsigned int eax, ebx, ecx, edx;
|
|
|
b9ba6d |
-
|
|
|
b9ba6d |
/* Run AVX test only if AVX is supported. */
|
|
|
b9ba6d |
- if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)
|
|
|
b9ba6d |
- && (ecx & bit_AVX))
|
|
|
b9ba6d |
+ if (avx_enabled ())
|
|
|
b9ba6d |
{
|
|
|
b9ba6d |
__m256i ymm = _mm256_setzero_si256 ();
|
|
|
b9ba6d |
__m256i ret = audit_test (ymm, ymm, ymm, ymm, ymm, ymm, ymm, ymm);
|
|
|
b9ba6d |
Index: glibc-2.12-2-gc4ccff1/elf/tst-audit6.c
|
|
|
b9ba6d |
===================================================================
|
|
|
b9ba6d |
--- glibc-2.12-2-gc4ccff1.orig/elf/tst-audit6.c
|
|
|
b9ba6d |
+++ glibc-2.12-2-gc4ccff1/elf/tst-audit6.c
|
|
|
b9ba6d |
@@ -8,14 +8,28 @@
|
|
|
b9ba6d |
extern __m128i audit_test (__m128i, __m128i, __m128i, __m128i,
|
|
|
b9ba6d |
__m128i, __m128i, __m128i, __m128i);
|
|
|
b9ba6d |
|
|
|
b9ba6d |
-int
|
|
|
b9ba6d |
-main (void)
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+static int
|
|
|
b9ba6d |
+avx_enabled (void)
|
|
|
b9ba6d |
{
|
|
|
b9ba6d |
unsigned int eax, ebx, ecx, edx;
|
|
|
b9ba6d |
|
|
|
b9ba6d |
+ if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0
|
|
|
b9ba6d |
+ || (ecx & (bit_AVX | bit_OSXSAVE)) != (bit_AVX | bit_OSXSAVE))
|
|
|
b9ba6d |
+ return 0;
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+ /* Check the OS has AVX and SSE saving enabled. */
|
|
|
b9ba6d |
+ asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+ return (eax & 6) == 6;
|
|
|
b9ba6d |
+}
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+int
|
|
|
b9ba6d |
+main (void)
|
|
|
b9ba6d |
+{
|
|
|
b9ba6d |
/* Run AVX test only if AVX is supported. */
|
|
|
b9ba6d |
- if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)
|
|
|
b9ba6d |
- && (ecx & bit_AVX))
|
|
|
b9ba6d |
+ if (avx_enabled ())
|
|
|
b9ba6d |
{
|
|
|
b9ba6d |
__m128i xmm = _mm_setzero_si128 ();
|
|
|
b9ba6d |
__m128i ret = audit_test (xmm, xmm, xmm, xmm, xmm, xmm, xmm, xmm);
|
|
|
b9ba6d |
Index: glibc-2.12-2-gc4ccff1/sysdeps/x86_64/dl-trampoline.S
|
|
|
b9ba6d |
===================================================================
|
|
|
b9ba6d |
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/x86_64/dl-trampoline.S
|
|
|
b9ba6d |
+++ glibc-2.12-2-gc4ccff1/sysdeps/x86_64/dl-trampoline.S
|
|
|
b9ba6d |
@@ -139,24 +139,31 @@ L(have_avx):
|
|
|
b9ba6d |
movl $1, %eax
|
|
|
b9ba6d |
cpuid
|
|
|
b9ba6d |
movq %r11,%rbx # Restore rbx
|
|
|
b9ba6d |
- movl $1, %eax
|
|
|
b9ba6d |
- testl $(1 << 28), %ecx
|
|
|
b9ba6d |
+ xorl %eax, %eax
|
|
|
b9ba6d |
+ // AVX and XSAVE supported?
|
|
|
b9ba6d |
+ andl $((1 << 28) | (1 << 27)), %ecx
|
|
|
b9ba6d |
+ cmpl $((1 << 28) | (1 << 27)), %ecx
|
|
|
b9ba6d |
jne 2f
|
|
|
b9ba6d |
- negl %eax
|
|
|
b9ba6d |
-2: movl %eax, L(have_avx)(%rip)
|
|
|
b9ba6d |
+ xorl %ecx, %ecx
|
|
|
b9ba6d |
+ // Get XFEATURE_ENABLED_MASK
|
|
|
b9ba6d |
+ xgetbv
|
|
|
b9ba6d |
+ andl $0x6, %eax
|
|
|
b9ba6d |
+2: subl $0x5, %eax
|
|
|
b9ba6d |
+ movl %eax, L(have_avx)(%rip)
|
|
|
b9ba6d |
cmpl $0, %eax
|
|
|
b9ba6d |
|
|
|
b9ba6d |
1: js L(no_avx)
|
|
|
b9ba6d |
|
|
|
b9ba6d |
# define RESTORE_AVX
|
|
|
b9ba6d |
+# define MORE_CODE
|
|
|
b9ba6d |
# include "dl-trampoline.h"
|
|
|
b9ba6d |
|
|
|
b9ba6d |
.align 16
|
|
|
b9ba6d |
L(no_avx):
|
|
|
b9ba6d |
# endif
|
|
|
b9ba6d |
|
|
|
b9ba6d |
-# undef RESTORE_AVX
|
|
|
b9ba6d |
-# include "dl-trampoline.h"
|
|
|
b9ba6d |
+# undef RESTORE_AVX
|
|
|
b9ba6d |
+# include "dl-trampoline.h"
|
|
|
b9ba6d |
|
|
|
b9ba6d |
cfi_endproc
|
|
|
b9ba6d |
.size _dl_runtime_profile, .-_dl_runtime_profile
|
|
|
b9ba6d |
@@ -176,11 +183,20 @@ _dl_x86_64_save_sse:
|
|
|
b9ba6d |
movl $1, %eax
|
|
|
b9ba6d |
cpuid
|
|
|
b9ba6d |
movq %r11,%rbx # Restore rbx
|
|
|
b9ba6d |
- movl $1, %eax
|
|
|
b9ba6d |
- testl $(1 << 28), %ecx
|
|
|
b9ba6d |
+ xorl %eax, %eax
|
|
|
b9ba6d |
+ // AVX and XSAVE supported?
|
|
|
b9ba6d |
+ andl $((1 << 28) | (1 << 27)), %ecx
|
|
|
b9ba6d |
+ cmpl $((1 << 28) | (1 << 27)), %ecx
|
|
|
b9ba6d |
jne 2f
|
|
|
b9ba6d |
- negl %eax
|
|
|
b9ba6d |
-2: movl %eax, L(have_avx)(%rip)
|
|
|
b9ba6d |
+ xorl %ecx, %ecx
|
|
|
b9ba6d |
+ // Get XFEATURE_ENABLED_MASK
|
|
|
b9ba6d |
+ xgetbv
|
|
|
b9ba6d |
+ andl $0x6, %eax
|
|
|
b9ba6d |
+ cmpl $0x6, %eax
|
|
|
b9ba6d |
+ // Nonzero if SSE and AVX state saving is enabled.
|
|
|
b9ba6d |
+ sete %al
|
|
|
b9ba6d |
+2: leal -1(%eax,%eax), %eax
|
|
|
b9ba6d |
+ movl %eax, L(have_avx)(%rip)
|
|
|
b9ba6d |
cmpl $0, %eax
|
|
|
b9ba6d |
|
|
|
b9ba6d |
1: js L(no_avx5)
|
|
|
b9ba6d |
Index: glibc-2.12-2-gc4ccff1/sysdeps/x86_64/dl-trampoline.h
|
|
|
b9ba6d |
===================================================================
|
|
|
b9ba6d |
--- glibc-2.12-2-gc4ccff1.orig/sysdeps/x86_64/dl-trampoline.h
|
|
|
b9ba6d |
+++ glibc-2.12-2-gc4ccff1/sysdeps/x86_64/dl-trampoline.h
|
|
|
b9ba6d |
@@ -195,14 +195,14 @@
|
|
|
b9ba6d |
_dl_call_pltexit. The La_x86_64_regs is being pointed by rsp now,
|
|
|
b9ba6d |
so we just need to allocate the sizeof(La_x86_64_retval) space on
|
|
|
b9ba6d |
the stack, since the alignment has already been taken care of. */
|
|
|
b9ba6d |
-# ifdef RESTORE_AVX
|
|
|
b9ba6d |
+#ifdef RESTORE_AVX
|
|
|
b9ba6d |
/* sizeof(La_x86_64_retval). Need extra space for 2 SSE
|
|
|
b9ba6d |
registers to detect if xmm0/xmm1 registers are changed
|
|
|
b9ba6d |
by audit module. */
|
|
|
b9ba6d |
subq $(LRV_SIZE + XMM_SIZE*2), %rsp
|
|
|
b9ba6d |
-# else
|
|
|
b9ba6d |
+#else
|
|
|
b9ba6d |
subq $LRV_SIZE, %rsp # sizeof(La_x86_64_retval)
|
|
|
b9ba6d |
-# endif
|
|
|
b9ba6d |
+#endif
|
|
|
b9ba6d |
movq %rsp, %rcx # La_x86_64_retval argument to %rcx.
|
|
|
b9ba6d |
|
|
|
b9ba6d |
/* Fill in the La_x86_64_retval structure. */
|
|
|
b9ba6d |
@@ -212,7 +212,7 @@
|
|
|
b9ba6d |
movaps %xmm0, LRV_XMM0_OFFSET(%rcx)
|
|
|
b9ba6d |
movaps %xmm1, LRV_XMM1_OFFSET(%rcx)
|
|
|
b9ba6d |
|
|
|
b9ba6d |
-# ifdef RESTORE_AVX
|
|
|
b9ba6d |
+#ifdef RESTORE_AVX
|
|
|
b9ba6d |
/* This is to support AVX audit modules. */
|
|
|
b9ba6d |
vmovdqu %ymm0, LRV_VECTOR0_OFFSET(%rcx)
|
|
|
b9ba6d |
vmovdqu %ymm1, LRV_VECTOR1_OFFSET(%rcx)
|
|
|
b9ba6d |
@@ -221,14 +221,14 @@
|
|
|
b9ba6d |
by audit module. */
|
|
|
b9ba6d |
vmovdqa %xmm0, (LRV_SIZE)(%rcx)
|
|
|
b9ba6d |
vmovdqa %xmm1, (LRV_SIZE + XMM_SIZE)(%rcx)
|
|
|
b9ba6d |
-# endif
|
|
|
b9ba6d |
+#endif
|
|
|
b9ba6d |
|
|
|
b9ba6d |
fstpt LRV_ST0_OFFSET(%rcx)
|
|
|
b9ba6d |
fstpt LRV_ST1_OFFSET(%rcx)
|
|
|
b9ba6d |
|
|
|
b9ba6d |
movq 24(%rbx), %rdx # La_x86_64_regs argument to %rdx.
|
|
|
b9ba6d |
movq 40(%rbx), %rsi # Copy args pushed by PLT in register.
|
|
|
b9ba6d |
- movq 32(%rbx), %rdi # %rdi: link_map, %rsi: reloc_index
|
|
|
b9ba6d |
+ movq 32(%rbx), %rdi # %rdi: link_map, %rsi: reloc_index
|
|
|
b9ba6d |
call _dl_call_pltexit
|
|
|
b9ba6d |
|
|
|
b9ba6d |
/* Restore return registers. */
|
|
|
b9ba6d |
@@ -238,7 +238,7 @@
|
|
|
b9ba6d |
movaps LRV_XMM0_OFFSET(%rsp), %xmm0
|
|
|
b9ba6d |
movaps LRV_XMM1_OFFSET(%rsp), %xmm1
|
|
|
b9ba6d |
|
|
|
b9ba6d |
-# ifdef RESTORE_AVX
|
|
|
b9ba6d |
+#ifdef RESTORE_AVX
|
|
|
b9ba6d |
/* Check if xmm0/xmm1 registers are changed by audit module. */
|
|
|
b9ba6d |
vpcmpeqq (LRV_SIZE)(%rsp), %xmm0, %xmm2
|
|
|
b9ba6d |
vpmovmskb %xmm2, %esi
|
|
|
b9ba6d |
@@ -253,7 +253,7 @@
|
|
|
b9ba6d |
vmovdqu LRV_VECTOR1_OFFSET(%rsp), %ymm1
|
|
|
b9ba6d |
|
|
|
b9ba6d |
1:
|
|
|
b9ba6d |
-# endif
|
|
|
b9ba6d |
+#endif
|
|
|
b9ba6d |
|
|
|
b9ba6d |
fldt LRV_ST1_OFFSET(%rsp)
|
|
|
b9ba6d |
fldt LRV_ST0_OFFSET(%rsp)
|
|
|
b9ba6d |
@@ -267,3 +267,10 @@
|
|
|
b9ba6d |
# (eats the reloc index and link_map)
|
|
|
b9ba6d |
cfi_adjust_cfa_offset(-48)
|
|
|
b9ba6d |
retq
|
|
|
b9ba6d |
+
|
|
|
b9ba6d |
+#ifdef MORE_CODE
|
|
|
b9ba6d |
+ cfi_adjust_cfa_offset(48)
|
|
|
b9ba6d |
+ cfi_rel_offset(%rbx, 0)
|
|
|
b9ba6d |
+ cfi_def_cfa_register(%rbx)
|
|
|
b9ba6d |
+# undef MORE_CODE
|
|
|
b9ba6d |
+#endif
|