about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2012-01-26 07:45:14 -0500
committerUlrich Drepper <drepper@gmail.com>2012-01-26 07:45:14 -0500
commitafc5ed09cbce5d6fd48b3a8c5ec427b31f996880 (patch)
treeeb37cecd40d16a579528f698c7d4274697bb8fac
parentbdb6de1d6d5d2a538e34fd453331acd0f664f6ed (diff)
downloadglibc-afc5ed09cbce5d6fd48b3a8c5ec427b31f996880.tar.gz
glibc-afc5ed09cbce5d6fd48b3a8c5ec427b31f996880.tar.xz
glibc-afc5ed09cbce5d6fd48b3a8c5ec427b31f996880.zip
Reset bit_AVX in __cpu_features is OS support is missing
-rw-r--r--ChangeLog7
-rw-r--r--NEWS4
-rw-r--r--sysdeps/x86_64/multiarch/init-arch.c14
-rw-r--r--sysdeps/x86_64/multiarch/init-arch.h3
4 files changed, 24 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index a0b355e853..1e2284f4ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-01-26  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #13583]
+	* sysdeps/x86_64/multiarch/init-arch.h: Define bit_OSXSAVE.
+	* sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features): If
+	bit_AVX is set also check OSXAVE/XCR0 and reset bit_AVX if necessary.
+
 2012-01-25  Joseph Myers  <joseph@codesourcery.com>
 
 	* elf/tst-unique3.cc (gets): Remove declaration.
diff --git a/NEWS b/NEWS
index 5e062afdaa..42e09c18b0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes.  2012-1-10
+GNU C Library NEWS -- history of user-visible changes.  2012-1-26
 Copyright (C) 1992-2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 See the end for copying conditions.
 
@@ -10,7 +10,7 @@ Version 2.16
 * The following bugs are resolved with this release:
 
   13525, 13526, 13527, 13528, 13529, 13531, 13532, 13533, 13547, 13530,
-  13551, 13552, 13553, 13555, 13559
+  13551, 13552, 13553, 13555, 13559, 13583
 
 * ISO C11 support:
 
diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c
index 65b0ee93e5..4fabbee06d 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 2a1df393c4..408e5aeb89 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)