about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan S. Arnold <rsa@linux.vnet.ibm.com>2013-05-15 15:48:17 -0500
committerRyan S. Arnold <rsa@linux.vnet.ibm.com>2013-05-15 15:48:17 -0500
commitd0f03338fd8c314f865b4421b99efd69725ca063 (patch)
treeafd31508b0fbbbddc38db46ffd0a59729d1831f8
parent6d6691c0f4a53c0e1c1915e19e71544c6b55b491 (diff)
downloadglibc-rsa/hwcap2_v3.tar.gz
glibc-rsa/hwcap2_v3.tar.xz
glibc-rsa/hwcap2_v3.zip
PowerPC: Fix AT_HWCAP2 feature bit string output in _dl_procinfo. rsa/hwcap2_v3
-rw-r--r--ChangeLog14
-rw-r--r--sysdeps/powerpc/dl-procinfo.c13
-rw-r--r--sysdeps/powerpc/dl-procinfo.h43
3 files changed, 48 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index cc1b0d31e2..17911d920a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2013-05-14  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>
 
+	* sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Properly
+	placed power8 hwcap strings to fix code that assumed bits incremented
+	from 0 to 31.
+	* sysdeps/powerpc/dl-procinfo.h (_dl_procinfo): Eliminate confusing
+	conditional variable definitions used to re-use a single loop
+	definition.  Replace with simpler redundant loops.  Account for
+	AT_HWCAP2 feature bits starting at bit 31 and decrementing.
+	[_DL_HWCAP_LAST]: New definition.
+	[_DL_HWCAP2_LAST]: New definition.
+	[_DL_HWCAP_COUNT]: Update to 64 to account for available bits, not
+	number of actual hwcap bits that are defined.
+
+2013-05-14  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>
+
 	* sysdeps/powerpc/bits/hwcap.h: Add new AT_HWCAP2 features.
 	[PPC_FEATURE2_ARCH_2_07]: New feature bit for Power ISA 2.07.
 	[PPC_FEATURE2_HAS_HTM]: New feature bit for Hardware Transactional
diff --git a/sysdeps/powerpc/dl-procinfo.c b/sysdeps/powerpc/dl-procinfo.c
index 0fbbc80810..1c87fb00f9 100644
--- a/sysdeps/powerpc/dl-procinfo.c
+++ b/sysdeps/powerpc/dl-procinfo.c
@@ -45,18 +45,25 @@
 #if !defined PROCINFO_DECL && defined SHARED
   ._dl_powerpc_cap_flags
 #else
-PROCINFO_CLASS const char _dl_powerpc_cap_flags[31][10]
+PROCINFO_CLASS const char _dl_powerpc_cap_flags[57][10]
 #endif
 #ifndef PROCINFO_DECL
 = {
-    "ebb", "isel", "tar",
-    "vsx", "arch_2_07", "htm", "dscr",
+    "vsx",
     "arch_2_06", "power6x", "dfp", "pa6t",
     "arch_2_05", "ic_snoop", "smt", "booke",
     "cellbe", "power5+", "power5", "power4",
     "notb", "efpdouble", "efpsingle", "spe",
     "ucache", "4xxmac", "mmu", "fpu",
     "altivec", "ppc601", "ppc64", "ppc32",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "tar", "isel",
+    "ebb", "dscr", "htm", "arch_2_07",
   }
 #endif
 #if !defined SHARED || defined PROCINFO_DECL
diff --git a/sysdeps/powerpc/dl-procinfo.h b/sysdeps/powerpc/dl-procinfo.h
index 3a5ce12c46..d9cd126722 100644
--- a/sysdeps/powerpc/dl-procinfo.h
+++ b/sysdeps/powerpc/dl-procinfo.h
@@ -22,13 +22,18 @@
 #include <ldsodefs.h>
 #include <sysdep.h>	/* This defines the PPC_FEATURE[2]_* macros.  */
 
-/* There are 25 bits used in AT_HWCAP, but they are bits 7..31.  */
+/* There are 25 bits used in AT_HWCAP, but they are bits 7..31.  The feature
+ * definitions started at bit 31 and decremented as new features were added.
+ */
+#define _DL_HWCAP_LAST		31
 #define _DL_HWCAP_FIRST		7
-/* Where AT_HWCAP2 starts relative to _DL_HWCAP_FIRST.  */
-#define _DL_HWCAP2_FIRST	32
 
-/* The total number of used bits relative to _DL_HWCAP_FIRST.  */
-#define _DL_HWCAP_COUNT		38
+/* AT_HWCAP2 feature bits similarily started at bit 31 and decremented as new
+ * features were added.  */
+#define _DL_HWCAP2_LAST		31
+
+/* The total number of available bits relative to (minus) _DL_HWCAP_FIRST.  */
+#define _DL_HWCAP_COUNT		64
 
 /* These bits influence library search.  */
 #define HWCAP_IMPORTANT		(PPC_FEATURE_HAS_ALTIVEC \
@@ -166,31 +171,31 @@ static inline int
 __attribute__ ((unused))
 _dl_procinfo (unsigned int type, int word)
 {
-  unsigned int first, count, str_offset;
-
   switch(type)
     {
     case AT_HWCAP:
       _dl_printf ("AT_HWCAP:       ");
-      first = _DL_HWCAP_FIRST;
-      count = MIN(_DL_HWCAP_COUNT, _DL_HWCAP2_FIRST);
-      str_offset = 0;
+
+      for (int i = _DL_HWCAP_FIRST; i <= _DL_HWCAP_LAST; ++i)
+	if (word & (1 << i))
+	  _dl_printf (" %s", _dl_hwcap_string (i));
       break;
     case AT_HWCAP2:
-      _dl_printf ("AT_HWCAP2:      ");
-      first = 0;
-      count = _DL_HWCAP_COUNT - _DL_HWCAP2_FIRST;
-      str_offset = _DL_HWCAP2_FIRST;
-      break;
+      {
+	unsigned int offset = _DL_HWCAP_LAST + 1;
+
+	_dl_printf ("AT_HWCAP2:      ");
+
+	for (int i = 0; i <= _DL_HWCAP2_LAST; ++i)
+	  if (word & (1 << i))
+	    _dl_printf (" %s", _dl_hwcap_string (offset + i));
+	break;
+      }
     default:
       /* This should not happen.  */
       return -1;
     }
 
-  for (int i = first; i < count; ++i)
-    if (word & (1 << i))
-      _dl_printf (" %s", _dl_hwcap_string (str_offset + i));
-
   _dl_printf ("\n");
 
   return 0;