]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add support for AT_HWCAP2. rsa/hwcap2_v4
authorRyan S. Arnold <rsa@linux.vnet.ibm.com>
Thu, 13 Jun 2013 19:13:39 +0000 (14:13 -0500)
committerRyan S. Arnold <rsa@linux.vnet.ibm.com>
Thu, 13 Jun 2013 19:13:39 +0000 (14:13 -0500)
19 files changed:
ChangeLog
elf/dl-support.c
elf/dl-sysdep.c
elf/elf.h
misc/getauxval.c
ports/ChangeLog.alpha
ports/ChangeLog.arm
ports/ChangeLog.mips
ports/sysdeps/alpha/dl-procinfo.h
ports/sysdeps/mips/dl-procinfo.h
ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
sysdeps/generic/dl-procinfo.h
sysdeps/i386/dl-procinfo.h
sysdeps/powerpc/dl-procinfo.c
sysdeps/powerpc/dl-procinfo.h
sysdeps/s390/dl-procinfo.h
sysdeps/sparc/dl-procinfo.h
sysdeps/unix/sysv/linux/i386/dl-procinfo.h
sysdeps/unix/sysv/linux/s390/dl-procinfo.h

index 985173df5e8d6d8b26c8ad0d0e9a511eeeeb5501..888292d971866757a9b5eae0c35206573a9fd40f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2013-06-13  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>
+
+       * elf/dl-support.c (_dl_aux_init): Add support for AT_HWCAP2.
+       * elf/dl-sysdep.c (_dl_sysdep_start, _dl_show_auxv): Likewise.
+       * misc/getauxval.c (__getauxval): Likewise.
+       * elf/elf.h (AT_HWCAP2): Add a new a_type entry.
+       * sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Extend for
+       for an additional 32 AT_HWCAP2 flags.
+       * sysdeps/powerpc/dl-procinfo.h (_dl_procinfo): Add support for
+       displaying AT_HWCAP2 strings.  Add TYPE parameter.  Make WORD unsigned
+       rather than signed.
+       * sysdeps/generic/dl-procinfo.h (_dl_procinfo): Add TYPE parameter to
+       macro prototype for AT_HWCAP2 support.
+       * sysdeps/i386/dl-procinfo.h: Likewise.
+       * sysdeps/s390/dl-procinfo.h: Likewise.
+       * sysdeps/sparc/dl-procinfo.h (_dl_procinfo): Add TYPE parameter for
+       future AT_HWCAP2 support.  Make WORD unsigned rather than signed.
+       * sysdeps/unix/sysv/linux/i386/dl-procinfo.h: Likewise.
+       * sysdeps/unix/sysv/linux/s390/dl-procinfo.h: Likewise.
+
 2013-06-13  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
        * NEWS: Fix note on clock function precision.  Text by Roland
index b3ab9560ad75bf367f8368de3511bbe5d1e4b2f9..208bc6b54f15819bceee1eedfa42f477b20db9fe 100644 (file)
@@ -194,6 +194,10 @@ _dl_aux_init (ElfW(auxv_t) *av)
   uid_t uid = 0;
   gid_t gid = 0;
 
+  /* Don't rely on a specific order of AT_HWCAP and AT_HWCAP2.  Collate into a
+     zeroed temp and assign to _dl_hwcap after the auxv has been parsed.  */
+  uint64_t hwcap = 0;
+
   _dl_auxv = av;
   for (; av->a_type != AT_NULL; ++av)
     switch (av->a_type)
@@ -212,8 +216,12 @@ _dl_aux_init (ElfW(auxv_t) *av)
        GL(dl_phnum) = av->a_un.a_val;
        break;
       case AT_HWCAP:
-       GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
+       hwcap |= (unsigned long int) av->a_un.a_val;
+       break;
+      case AT_HWCAP2:
+       hwcap |= (uint64_t) av->a_un.a_val << 32;
        break;
+
 #ifdef NEED_DL_SYSINFO
       case AT_SYSINFO:
        GL(dl_sysinfo) = av->a_un.a_val;
@@ -252,6 +260,9 @@ _dl_aux_init (ElfW(auxv_t) *av)
       DL_PLATFORM_AUXV
 # endif
       }
+
+  GLRO(dl_hwcap) = hwcap;
+
   if (seen == 0xf)
     {
       __libc_enable_secure = uid != 0 || gid != 0;
index 52de23f44b1bd37938cbb078f23eaa000a591892..4179cd5b34a4777583ea3af15f5db24ab0cbc60c 100644 (file)
@@ -107,6 +107,10 @@ _dl_sysdep_start (void **start_argptr,
   uintptr_t new_sysinfo = 0;
 #endif
 
+  /* Don't rely on a specific order of AT_HWCAP and AT_HWCAP2.  Collate into a
+     zeroed temp and assign to _dl_hwcap after the auxv has been parsed.  */
+  uint64_t hwcap = 0;
+
   __libc_stack_end = DL_STACK_END (start_argptr);
   DL_FIND_ARG_COMPONENTS (start_argptr, _dl_argc, INTUSE(_dl_argv), _environ,
                          GLRO(dl_auxv));
@@ -154,7 +158,10 @@ _dl_sysdep_start (void **start_argptr,
        GLRO(dl_platform) = (void *) av->a_un.a_val;
        break;
       case AT_HWCAP:
-       GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
+       hwcap |= (unsigned long int) av->a_un.a_val;
+       break;
+      case AT_HWCAP2:
+       hwcap |= (uint64_t) av->a_un.a_val << 32;
        break;
       case AT_CLKTCK:
        GLRO(dl_clktck) = av->a_un.a_val;
@@ -180,6 +187,8 @@ _dl_sysdep_start (void **start_argptr,
 #endif
       }
 
+  GLRO(dl_hwcap) = hwcap;
+
 #ifndef HAVE_AUX_SECURE
   if (seen != -1)
     {
@@ -303,6 +312,7 @@ _dl_show_auxv (void)
          [AT_SYSINFO - 2] =            { "SYSINFO:      0x", hex },
          [AT_SYSINFO_EHDR - 2] =       { "SYSINFO_EHDR: 0x", hex },
          [AT_RANDOM - 2] =             { "RANDOM:       0x", hex },
+         [AT_HWCAP2 - 2] =             { "HWCAP2:       ", hex },
        };
       unsigned int idx = (unsigned int) (av->a_type - 2);
 
@@ -314,10 +324,11 @@ _dl_show_auxv (void)
       assert (AT_NULL == 0);
       assert (AT_IGNORE == 1);
 
-      if (av->a_type == AT_HWCAP)
+      if (av->a_type == AT_HWCAP || av->a_type == AT_HWCAP2)
        {
-         /* This is handled special.  */
-         if (_dl_procinfo (av->a_un.a_val) == 0)
+         /* HWCAP bits are translated into representative strings, per
+            platform.  */
+         if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0)
            continue;
        }
 
index 4ad4f3999991362e3077a4fd162a9c889d17364b..6c82965d45d2eda054d5a490c6f7f4857fdc1db0 100644 (file)
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -993,7 +993,7 @@ typedef struct
 
 /* Some more special a_type values describing the hardware.  */
 #define AT_PLATFORM    15              /* String identifying platform.  */
-#define AT_HWCAP       16              /* Machine dependent hints about
+#define AT_HWCAP       16              /* Machine-dependent hints about
                                           processor capabilities.  */
 
 /* This entry gives some information about the FPU initialization
@@ -1015,6 +1015,9 @@ typedef struct
 
 #define AT_RANDOM      25              /* Address of 16 random bytes.  */
 
+#define AT_HWCAP2      26              /* More machine-dependent hints
+                                          about processor capabilities.  */
+
 #define AT_EXECFN      31              /* Filename of executable.  */
 
 /* Pointer to the global system page used for system calls and other
index 4321e3718a8492214ebd9cfa2cfc359b815b293b..0d699229f66a91661c5feba4fa32fe38640b93b4 100644 (file)
@@ -26,6 +26,8 @@ __getauxval (unsigned long int type)
 
   if (type == AT_HWCAP)
     return GLRO(dl_hwcap);
+  else if (type == AT_HWCAP2)
+    return GLRO(dl_hwcap) >> 32;
 
   for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
     if (p->a_type == type)
index 3646955a031353c9b321ef473aab3e70bd3e3c47..6ef2b120c24ccf6c5333a4dde36e80ffcffc6ee0 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-13  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>
+
+       * sysdeps/alpha/dl-procinfo.h (_dl_procinfo): Add TYPE parameter for
+       AT_HWCAP2 support.
+
 2013-06-05  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/alpha/bits/atomic.h: Remove trailing whitespace.
index 28ebfdf5ba5ab3a0e5459c0e721c59be3dd44908..f149f93f9872b314b20474e779bfdde3aca727da 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-13  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>
+
+       * sysdeps/unix/sysv/linux/arm/dl-procinfo.h (_dl_procinfo): Add
+       TYPE parameter for AT_HWCAP2 support.  Make WORD unsigned.
+
 2013-06-11  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/arm/math-tests.h [__SOFTFP__] (EXCEPTION_TESTS_float):
index 487bd029775baef391f4c9fe88dcf21fb1d4400c..c2e29c9471e7112617018c62cf946393a85d9838 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-13  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>
+
+       * sysdeps/mips/dl-procinfo.h (_dl_procinfo): Add TYPE parameter for
+       AT_HWCAP2 support.
+
 2013-06-05  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/mips/fpu/fgetexcptflg.c: Remove trailing whitespace.
index 523d9667613b156bd2901c9f1fa82d9a80f32923..0344dbc968f294dcce382519e8588fd9c20e60d3 100644 (file)
@@ -51,7 +51,7 @@ _dl_string_platform (const char *str)
 };
 
 /* We cannot provide a general printing function.  */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
 
 /* There are no hardware capabilities defined.  */
 #define _dl_hwcap_string(idx) ""
index 5cc9a44446eb12f0eb504e13f2b16674fb450eb5..e96550c402f5955ec6f2aa9847c11cc2b84e9854 100644 (file)
@@ -51,7 +51,7 @@ _dl_string_platform (const char *str)
 };
 
 /* We cannot provide a general printing function.  */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
 
 /* There are no hardware capabilities defined.  */
 #define _dl_hwcap_string(idx) ""
index 161e86c796462cce4cc592c3b8039bbf65eb2bfb..8f718144b8b4134457986b20596d5cf28c68f163 100644 (file)
 
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned int word)
 {
   int i;
 
+  /* Unused for now.  */
+  if (type == AT_HWCAP2)
+    return 0;
+
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
index 90c87d942a26975dd390a806cae14db21cfa6f94..a184a5918a34fc741b38b62df0d8af462cc997dd 100644 (file)
@@ -21,7 +21,7 @@
 #define _DL_PROCINFO_H 1
 
 /* We cannot provide a general printing function.  */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
 
 /* There are no hardware capabilities defined.  */
 #define _dl_hwcap_string(idx) ""
index 883fa7f0abc8ff6f285de2a2220e3233379cb9f5..233a3257e3a93d493e29b19ad9f53f131a9e3e3c 100644 (file)
@@ -61,7 +61,7 @@ enum
 };
 
 /* We cannot provide a general printing function.  */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
 
 static inline const char *
 __attribute__ ((unused))
index 0f5c2b3d6d3915f1d2bbdad1d7fe68cc48f018f1..cb97ed19ad9db8d49100aefabf663ab3f03525e9 100644 (file)
@@ -45,7 +45,7 @@
 #if !defined PROCINFO_DECL && defined SHARED
   ._dl_powerpc_cap_flags
 #else
-PROCINFO_CLASS const char _dl_powerpc_cap_flags[25][10]
+PROCINFO_CLASS const char _dl_powerpc_cap_flags[57][10]
 #endif
 #ifndef PROCINFO_DECL
 = {
@@ -56,6 +56,14 @@ PROCINFO_CLASS const char _dl_powerpc_cap_flags[25][10]
     "notb", "efpdouble", "efpsingle", "spe",
     "ucache", "4xxmac", "mmu", "fpu",
     "altivec", "ppc601", "ppc64", "ppc32",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
+    "", "", "", "",
   }
 #endif
 #if !defined SHARED || defined PROCINFO_DECL
index 568fe19dde2b36044ab33dda83bf84135956d5e9..0ffc4f7c6344be66aaff95b7359b9058b18f4dc8 100644 (file)
 #define _DL_PROCINFO_H 1
 
 #include <ldsodefs.h>
-#include <sysdep.h>    /* This defines the PPC_FEATURE_* macros.  */
+#include <sysdep.h>    /* This defines the PPC_FEATURE[2]_* macros.  */
 
-/* There are 25 bits used, 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
-#define _DL_HWCAP_COUNT                32
+
+/* AT_HWCAP2 feature bits similarily started at bit 31 and decremented as new
+   features were added.  HWCAP2 feature bits start at bit 0.  */
+#define _DL_HWCAP2_LAST                31
+
+/* The total number of available bits (including those prior to
+   _DL_HWCAP_FIRST).  Some of these bits might not be used.  */
+#define _DL_HWCAP_COUNT                64
 
 /* These bits influence library search.  */
 #define HWCAP_IMPORTANT                (PPC_FEATURE_HAS_ALTIVEC \
@@ -153,15 +163,37 @@ _dl_string_platform (const char *str)
 }
 
 #ifdef IS_IN_rtld
+
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned int word)
 {
-  _dl_printf ("AT_HWCAP:       ");
-
-  for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
-    if (word & (1 << i))
-      _dl_printf (" %s", _dl_hwcap_string (i));
+  switch(type)
+    {
+    case AT_HWCAP:
+      _dl_printf ("AT_HWCAP:       ");
+
+      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:
+      {
+       unsigned int offset = _DL_HWCAP_LAST + 1;
+
+       _dl_printf ("AT_HWCAP2:      ");
+
+        /* We have to go through them all because the kernel added the
+          AT_HWCAP2 features starting with the high bits.  */
+       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;
+    }
 
   _dl_printf ("\n");
 
index 717f6f9a50807c612e58201a037155af14f3b9bb..45e27f1023d1e9088ea225436a669ed6f411eba1 100644 (file)
@@ -56,7 +56,7 @@ enum
                          | HWCAP_S390_EIMM | HWCAP_S390_DFP)
 
 /* We cannot provide a general printing function.  */
-#define _dl_procinfo(word) -1
+#define _dl_procinfo(type, word) -1
 
 static inline const char *
 __attribute__ ((unused))
index a18b099586f8d9fdf615f17fe11f3adaf9126f89..1594ee0e91994f28adae8d7a5e4f63b69e673d7b 100644 (file)
 
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned int word)
 {
   int i;
 
+  /* Unused for now.  */
+  if (type == AT_HWCAP2)
+    return 0;
+
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
index a82f8f5b8d45c8d2e17de86cad5c1e5c796c270d..225a5eb8dce0a380dc5a9200c6f5b460c7c3b44a 100644 (file)
 #undef _dl_procinfo
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned int word)
 {
   /* This table should match the information from arch/i386/kernel/setup.c
      in the kernel sources.  */
   int i;
 
+  /* Unused for now.  */
+  if (type == AT_HWCAP2)
+    return 0;
+
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
index 5ca4b76ca72527cf57412b8acdf8fac7f1e31840..eb60fc2ba8840d43ceefe46e90f70fd65b60ee9b 100644 (file)
 #undef _dl_procinfo
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned int word)
 {
   /* This table should match the information from arch/s390/kernel/setup.c
      in the kernel sources.  */
   int i;
 
+  /* Unused for now.  */
+  if (type == AT_HWCAP2)
+    return 0;
+
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)