diff options
author | Ulrich Drepper <drepper@gmail.com> | 2012-01-26 07:45:14 -0500 |
---|---|---|
committer | Carlos O'Donell <carlos_odonell@mentor.com> | 2012-05-01 22:15:39 -0400 |
commit | c37ba8a2607dd45527d01299bc25730369501dca (patch) | |
tree | 080a36d2f14a2152bc20e4fc081bd1007a4f2711 /sysdeps | |
parent | 3088c58cbb15172e01cd9cc7e21ed06bc2b27889 (diff) | |
download | glibc-c37ba8a2607dd45527d01299bc25730369501dca.zip glibc-c37ba8a2607dd45527d01299bc25730369501dca.tar.gz glibc-c37ba8a2607dd45527d01299bc25730369501dca.tar.bz2 |
Reset bit_AVX in __cpu_features is OS support is missing
(cherry picked from commit afc5ed09cbce5d6fd48b3a8c5ec427b31f996880)
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/x86_64/multiarch/init-arch.c | 14 | ||||
-rw-r--r-- | sysdeps/x86_64/multiarch/init-arch.h | 3 |
2 files changed, 15 insertions, 2 deletions
diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c index 65b0ee9..4fabbee 100644 --- a/sysdeps/x86_64/multiarch/init-arch.c +++ b/sysdeps/x86_64/multiarch/init-arch.c @@ -1,6 +1,6 @@ /* Initialize CPU feature data. This file is part of the GNU C Library. - Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@redhat.com>. The GNU C Library is free software; you can redistribute it and/or @@ -144,6 +144,18 @@ __init_cpu_features (void) else kind = arch_kind_other; + if (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_AVX) + { + /* Reset the AVX bit in case OSXSAVE is disabled. */ + if ((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_OSXSAVE) == 0 + || ({ unsigned int xcrlow; + unsigned int xcrhigh; + asm ("xgetbv" + : "=a" (xcrlow), "=d" (xcrhigh) : "c" (0)); + (xcrlow & 6) != 6; })) + __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx &= ~bit_AVX; + } + __cpu_features.family = family; __cpu_features.model = model; atomic_write_barrier (); diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h index 2a1df39..408e5ae 100644 --- a/sysdeps/x86_64/multiarch/init-arch.h +++ b/sysdeps/x86_64/multiarch/init-arch.h @@ -1,5 +1,5 @@ /* This file is part of the GNU C Library. - Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -27,6 +27,7 @@ #define bit_SSSE3 (1 << 9) #define bit_SSE4_1 (1 << 19) #define bit_SSE4_2 (1 << 20) +#define bit_OSXSAVE (1 << 27) #define bit_AVX (1 << 28) #define bit_POPCOUNT (1 << 23) #define bit_FMA (1 << 12) |