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