ce426f
From dfb57bf8871503967f23f9ce4bf17479a19cf8e4 Mon Sep 17 00:00:00 2001
ce426f
From: "Ryan S. Arnold" <rsa@linux.vnet.ibm.com>
ce426f
Date: Fri, 28 Jun 2013 16:50:48 -0500
ce426f
Subject: [PATCH 39/42] Add GLRO(dl_hwcap2) for new AT_HWCAP2 auxv_t a_type.
ce426f
 (cherry picked from commit
ce426f
 1ae8bfe07c1ab2444cc1d186321ff1431a1b9f96)
ce426f
ce426f
---
ce426f
 elf/dl-support.c                                |  4 ++++
ce426f
 elf/dl-sysdep.c                                 | 10 +++++++---
ce426f
 misc/getauxval.c                                |  2 ++
ce426f
 ports/sysdeps/alpha/dl-procinfo.h               |  2 +-
ce426f
 ports/sysdeps/mips/dl-procinfo.h                |  2 +-
ce426f
 ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h |  6 +++++-
ce426f
 sysdeps/generic/dl-procinfo.h                   |  2 +-
ce426f
 sysdeps/generic/ldsodefs.h                      |  4 ++++
ce426f
 sysdeps/i386/dl-procinfo.h                      |  2 +-
ce426f
 sysdeps/powerpc/dl-procinfo.h                   |  6 +++++-
ce426f
 sysdeps/s390/dl-procinfo.h                      |  2 +-
ce426f
 sysdeps/sparc/dl-procinfo.h                     |  6 +++++-
ce426f
 sysdeps/unix/sysv/linux/i386/dl-procinfo.h      |  6 +++++-
ce426f
 sysdeps/unix/sysv/linux/s390/dl-procinfo.h      |  6 +++++-
ce426f
 18 files changed, 89 insertions(+), 13 deletions(-)
ce426f
ce426f
diff --git glibc-2.17-c758a686/elf/dl-support.c glibc-2.17-c758a686/elf/dl-support.c
ce426f
index 81e7172..05f53ee 100644
ce426f
--- glibc-2.17-c758a686/elf/dl-support.c
ce426f
+++ glibc-2.17-c758a686/elf/dl-support.c
ce426f
@@ -129,6 +129,7 @@ ElfW(auxv_t) *_dl_auxv;
ce426f
 ElfW(Phdr) *_dl_phdr;
ce426f
 size_t _dl_phnum;
ce426f
 uint64_t _dl_hwcap __attribute__ ((nocommon));
ce426f
+uint64_t _dl_hwcap2 __attribute__ ((nocommon));
ce426f
 
ce426f
 /* This is not initialized to HWCAP_IMPORTANT, matching the definition
ce426f
    of _dl_important_hwcaps, below, where no hwcap strings are ever
ce426f
@@ -212,6 +213,9 @@ _dl_aux_init (ElfW(auxv_t) *av)
ce426f
       case AT_HWCAP:
ce426f
 	GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
ce426f
 	break;
ce426f
+      case AT_HWCAP2:
ce426f
+	GLRO(dl_hwcap2) = (unsigned long int) av->a_un.a_val;
ce426f
+	break;
ce426f
 #ifdef NEED_DL_SYSINFO
ce426f
       case AT_SYSINFO:
ce426f
 	GL(dl_sysinfo) = av->a_un.a_val;
ce426f
diff --git glibc-2.17-c758a686/elf/dl-sysdep.c glibc-2.17-c758a686/elf/dl-sysdep.c
ce426f
index 65a9046..a0d1d04 100644
ce426f
--- glibc-2.17-c758a686/elf/dl-sysdep.c
ce426f
+++ glibc-2.17-c758a686/elf/dl-sysdep.c
ce426f
@@ -156,6 +156,9 @@ _dl_sysdep_start (void **start_argptr,
ce426f
       case AT_HWCAP:
ce426f
 	GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
ce426f
 	break;
ce426f
+      case AT_HWCAP2:
ce426f
+	GLRO(dl_hwcap2) = (unsigned long int) av->a_un.a_val;
ce426f
+	break;
ce426f
       case AT_CLKTCK:
ce426f
 	GLRO(dl_clktck) = av->a_un.a_val;
ce426f
 	break;
ce426f
@@ -298,6 +301,7 @@ _dl_show_auxv (void)
ce426f
 	  [AT_SYSINFO - 2] =		{ "SYSINFO:      0x", hex },
ce426f
 	  [AT_SYSINFO_EHDR - 2] =	{ "SYSINFO_EHDR: 0x", hex },
ce426f
 	  [AT_RANDOM - 2] =		{ "RANDOM:       0x", hex },
ce426f
+	  [AT_HWCAP2 - 2] =		{ "HWCAP2:       0x", hex },
ce426f
 	};
ce426f
       unsigned int idx = (unsigned int) (av->a_type - 2);
ce426f
 
ce426f
@@ -309,10 +313,10 @@ _dl_show_auxv (void)
ce426f
       assert (AT_NULL == 0);
ce426f
       assert (AT_IGNORE == 1);
ce426f
 
ce426f
-      if (av->a_type == AT_HWCAP)
ce426f
+      if (av->a_type == AT_HWCAP || av->a_type == AT_HWCAP2)
ce426f
 	{
ce426f
-	  /* This is handled special.  */
ce426f
-	  if (_dl_procinfo (av->a_un.a_val) == 0)
ce426f
+	  /* These are handled in a special way per platform.  */
ce426f
+	  if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0)
ce426f
 	    continue;
ce426f
 	}
ce426f
 
ce426f
diff --git glibc-2.17-c758a686/misc/getauxval.c glibc-2.17-c758a686/misc/getauxval.c
ce426f
index bff4560..1c1882b 100644
ce426f
--- glibc-2.17-c758a686/misc/getauxval.c
ce426f
+++ glibc-2.17-c758a686/misc/getauxval.c
ce426f
@@ -26,6 +26,8 @@ __getauxval (unsigned long int type)
ce426f
 
ce426f
   if (type == AT_HWCAP)
ce426f
     return GLRO(dl_hwcap);
ce426f
+  else if (type == AT_HWCAP2)
ce426f
+    return GLRO(dl_hwcap2);
ce426f
 
ce426f
   for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
ce426f
     if (p->a_type == type)
ce426f
diff --git glibc-2.17-c758a686/ports/sysdeps/alpha/dl-procinfo.h glibc-2.17-c758a686/ports/sysdeps/alpha/dl-procinfo.h
ce426f
index 3db0efb..c3b27b4 100644
ce426f
--- glibc-2.17-c758a686/ports/sysdeps/alpha/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/ports/sysdeps/alpha/dl-procinfo.h
ce426f
@@ -51,7 +51,7 @@ _dl_string_platform (const char *str)
ce426f
 };
ce426f
 
ce426f
 /* We cannot provide a general printing function.  */
ce426f
-#define _dl_procinfo(word) -1
ce426f
+#define _dl_procinfo(type, word) -1
ce426f
 
ce426f
 /* There are no hardware capabilities defined.  */
ce426f
 #define _dl_hwcap_string(idx) ""
ce426f
diff --git glibc-2.17-c758a686/ports/sysdeps/mips/dl-procinfo.h glibc-2.17-c758a686/ports/sysdeps/mips/dl-procinfo.h
ce426f
index d42aea7..8c9f5c2 100644
ce426f
--- glibc-2.17-c758a686/ports/sysdeps/mips/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/ports/sysdeps/mips/dl-procinfo.h
ce426f
@@ -51,7 +51,7 @@ _dl_string_platform (const char *str)
ce426f
 };
ce426f
 
ce426f
 /* We cannot provide a general printing function.  */
ce426f
-#define _dl_procinfo(word) -1
ce426f
+#define _dl_procinfo(type, word) -1
ce426f
 
ce426f
 /* There are no hardware capabilities defined.  */
ce426f
 #define _dl_hwcap_string(idx) ""
ce426f
diff --git glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
ce426f
index bea7100..c96297b 100644
ce426f
--- glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
ce426f
@@ -31,10 +31,14 @@
ce426f
 
ce426f
 static inline int
ce426f
 __attribute__ ((unused))
ce426f
-_dl_procinfo (int word)
ce426f
+_dl_procinfo (unsigned int type, unsigned long int word)
ce426f
 {
ce426f
   int i;
ce426f
 
ce426f
+  /* Fallback to unknown output mechanism.  */
ce426f
+  if (type == AT_HWCAP2)
ce426f
+    return -1;
ce426f
+
ce426f
   _dl_printf ("AT_HWCAP:   ");
ce426f
 
ce426f
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
ce426f
diff --git glibc-2.17-c758a686/sysdeps/generic/dl-procinfo.h glibc-2.17-c758a686/sysdeps/generic/dl-procinfo.h
ce426f
index c2bf914..0345717 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/generic/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/generic/dl-procinfo.h
ce426f
@@ -21,7 +21,7 @@
ce426f
 #define _DL_PROCINFO_H	1
ce426f
 
ce426f
 /* We cannot provide a general printing function.  */
ce426f
-#define _dl_procinfo(word) -1
ce426f
+#define _dl_procinfo(type, word) -1
ce426f
 
ce426f
 /* There are no hardware capabilities defined.  */
ce426f
 #define _dl_hwcap_string(idx) ""
ce426f
diff --git glibc-2.17-c758a686/sysdeps/generic/ldsodefs.h glibc-2.17-c758a686/sysdeps/generic/ldsodefs.h
ce426f
index c667e34..5635d72 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/generic/ldsodefs.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/generic/ldsodefs.h
ce426f
@@ -548,6 +548,10 @@ struct rtld_global_ro
ce426f
   EXTERN struct link_map *_dl_sysinfo_map;
ce426f
 #endif
ce426f
 
ce426f
+  /* Mask for more hardware capabilities that are available on some
ce426f
+     platforms.  */
ce426f
+  EXTERN uint64_t _dl_hwcap2;
ce426f
+
ce426f
 #ifdef SHARED
ce426f
   /* We add a function table to _rtld_global which is then used to
ce426f
      call the function instead of going through the PLT.  The result
ce426f
diff --git glibc-2.17-c758a686/sysdeps/i386/dl-procinfo.h glibc-2.17-c758a686/sysdeps/i386/dl-procinfo.h
ce426f
index 6ecaac2..38e902d 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/i386/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/i386/dl-procinfo.h
ce426f
@@ -61,7 +61,7 @@ enum
ce426f
 };
ce426f
 
ce426f
 /* We cannot provide a general printing function.  */
ce426f
-#define _dl_procinfo(word) -1
ce426f
+#define _dl_procinfo(type, word) -1
ce426f
 
ce426f
 static inline const char *
ce426f
 __attribute__ ((unused))
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.h glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.h
ce426f
index 0939dcf..7732ed2 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.h
ce426f
@@ -159,8 +159,12 @@ _dl_string_platform (const char *str)
ce426f
 #ifdef IS_IN_rtld
ce426f
 static inline int
ce426f
 __attribute__ ((unused))
ce426f
-_dl_procinfo (int word)
ce426f
+_dl_procinfo (unsigned int type, unsigned long int word)
ce426f
 {
ce426f
+  /* Fallback to unknown output mechanism.  */
ce426f
+  if (type == AT_HWCAP2)
ce426f
+    return -1;
ce426f
+
ce426f
   _dl_printf ("AT_HWCAP:       ");
ce426f
 
ce426f
   for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
ce426f
diff --git glibc-2.17-c758a686/sysdeps/s390/dl-procinfo.h glibc-2.17-c758a686/sysdeps/s390/dl-procinfo.h
ce426f
index 97dcf07..26de043 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/s390/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/s390/dl-procinfo.h
ce426f
@@ -56,7 +56,7 @@ enum
ce426f
 			  | HWCAP_S390_EIMM | HWCAP_S390_DFP)
ce426f
 
ce426f
 /* We cannot provide a general printing function.  */
ce426f
-#define _dl_procinfo(word) -1
ce426f
+#define _dl_procinfo(type, word) -1
ce426f
 
ce426f
 static inline const char *
ce426f
 __attribute__ ((unused))
ce426f
diff --git glibc-2.17-c758a686/sysdeps/sparc/dl-procinfo.h glibc-2.17-c758a686/sysdeps/sparc/dl-procinfo.h
ce426f
index 6ae8768..a05d458 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/sparc/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/sparc/dl-procinfo.h
ce426f
@@ -28,10 +28,14 @@
ce426f
 
ce426f
 static inline int
ce426f
 __attribute__ ((unused))
ce426f
-_dl_procinfo (int word)
ce426f
+_dl_procinfo (unsigned int type, unsigned long int word)
ce426f
 {
ce426f
   int i;
ce426f
 
ce426f
+  /* Fallback to unknown output mechanism.  */
ce426f
+  if (type == AT_HWCAP2)
ce426f
+    return -1;
ce426f
+
ce426f
   _dl_printf ("AT_HWCAP:   ");
ce426f
 
ce426f
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
ce426f
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/i386/dl-procinfo.h glibc-2.17-c758a686/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
ce426f
index 4c61357..23f4501 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
ce426f
@@ -24,12 +24,16 @@
ce426f
 #undef _dl_procinfo
ce426f
 static inline int
ce426f
 __attribute__ ((unused))
ce426f
-_dl_procinfo (int word)
ce426f
+_dl_procinfo (unsigned int type, unsigned long int word)
ce426f
 {
ce426f
   /* This table should match the information from arch/i386/kernel/setup.c
ce426f
      in the kernel sources.  */
ce426f
   int i;
ce426f
 
ce426f
+  /* Fallback to unknown output mechanism.  */
ce426f
+  if (type == AT_HWCAP2)
ce426f
+    return -1;
ce426f
+
ce426f
   _dl_printf ("AT_HWCAP:   ");
ce426f
 
ce426f
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
ce426f
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/s390/dl-procinfo.h glibc-2.17-c758a686/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
ce426f
index f36ba55..759738e 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
ce426f
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
ce426f
@@ -24,12 +24,16 @@
ce426f
 #undef _dl_procinfo
ce426f
 static inline int
ce426f
 __attribute__ ((unused))
ce426f
-_dl_procinfo (int word)
ce426f
+_dl_procinfo (unsigned int type, unsigned long int word)
ce426f
 {
ce426f
   /* This table should match the information from arch/s390/kernel/setup.c
ce426f
      in the kernel sources.  */
ce426f
   int i;
ce426f
 
ce426f
+  /* Fallback to unknown output mechanism.  */
ce426f
+  if (type == AT_HWCAP2)
ce426f
+    return -1;
ce426f
+
ce426f
   _dl_printf ("AT_HWCAP:   ");
ce426f
 
ce426f
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
ce426f
-- 
ce426f
1.7.11.7
ce426f