This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH rsa/hwcap2_v6] Add GLRO(dl_hwcap2) for new AT_HWCAP2 auxv_t a_type.


On Thu, 2013-06-27 at 14:19 -0700, Roland McGrath wrote:
> > This is a stub in patch which leaves dl_hwcap2 out of GLRO unless
> > HWCAP2_AVAIL is (1).
> 
> I'm not sure it's worthwhile to conditionalize it this way.  The cost of
> the support when it's unused is 8 bytes in an internal data structure and
> one extra case/load/store in the auxv-reading code.

I removed the conditional.

> > I realize I need to fix the ChangeLog entries to be properly ports/
> > specific on the actual check-in (they're all in ChangeLog in the
> > commit).  I'll do that on my next check-in.
> 
> You also need to use [...] syntax for #if conditions.

No longer necessary.

> > +  /* Handle in a more sophisticated manner if HWCAP2 is supported.  */
> > +  if (type == AT_HWCAP2)
> > +    return 0;
> 
> This is wrong.  It should return -1 if it's not printing out the info
> itself, so the generic code will print it in hex.  As you have it, the
> AT_HWCAP2 entry will be eaten when present.

My previous code was falling back to the generic mechanism if the
conditional wasn't in place... but yes, you're correct.  The right way
is to return -1 and let handling fallback to the unknown a_type
mechanism.  I've done this in the new version of the patch.

This new patch is in rsa/hwcap2_v6.

Ryan S. Arnold

commit 26e690b2535dc1369fc86a1482f010365f5d4265
Author: Ryan S. Arnold <rsa@linux.vnet.ibm.com>
Date:   Fri Jun 28 09:32:34 2013 -0500

    Add GLRO(dl_hwcap2) for new AT_HWCAP2 auxv_t a_type.

[ChangeLog]
2013-06-28  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>

	* elf/dl-support.c (_dl_hwcap2): Add a new hwcap field for more
	hardware capabilities in support of AT_HWCAP2.
	(_dl_aux_init): Read AT_HWCAP2 into GLRO(dl_hwcap2).
	* elf/dl-sysdep.c (_dl_sysdep_start): Read AT_HWCAP2 into
	GLRO(dl_hwcap2).
	(_dl_show_auxv): Add support for calling _dl_procinfo to display
	AT_HWCAP2.  If a platform doesn't chose to handle displaying AT_HWCAP2
	explicitly the unknown a_type display mechanism is used.
	* misc/getauxval.c (__getauxval): Return GLRO(dl_hwcap2) on AT_HWCAP2.
	* sysdeps/generic/ldsodefs.h (rtld_global_ro): Add _dl_hwcap2 as a new
	struct member.
	* 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/powerpc/dl-procinfo.h (_dl_procinfo): Add TYPE parameter to
	macro prototype for AT_HWCAP2 support.  Make WORD unsigned long int
	rather than signed int.  Stub in handler for TYPE == AT_HWCAP2 to
	return -1 for unknown a_type display fallback.
	* sysdeps/sparc/dl-procinfo.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/dl-procinfo.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/dl-procinfo.h: Likewise.

[ports/ChangeLog.alpha]
2013-06-28  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>

	* sysdeps/alpha/dl-procinfo.h (_dl_procinfo): Add TYPE parameter
	to macro prototype for AT_HWCAP2 support.

[ports/ChangeLog.arm]
2013-06-28  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>

	* sysdeps/unix/sysv/linux/arm/dl-procinfo.h (_dl_procinfo): Add
	TYPE parameter to macro prototype for AT_HWCAP2 support.  Make WORD
	unsigned long int rather than signed int.  Stub in handler for TYPE ==
	AT_HWCAP2 to return -1 for unknown a_type display fallback.

[ports/ChangeLog.mips]
2013-06-28  Ryan S. Arnold  <rsa@linux.vnet.ibm.com>

	* sysdeps/mips/dl-procinfo.h (_dl_procinfo): Add TYPE parameter
	to macro prototype for AT_HWCAP2 support.

diff --git a/elf/dl-support.c b/elf/dl-support.c
index b3ab956..17ea062 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -131,6 +131,8 @@ const ElfW(Phdr) *_dl_phdr;
 size_t _dl_phnum;
 uint64_t _dl_hwcap __attribute__ ((nocommon));
 
+uint64_t _dl_hwcap2 __attribute__ ((nocommon));
+
 /* This is not initialized to HWCAP_IMPORTANT, matching the definition
    of _dl_important_hwcaps, below, where no hwcap strings are ever
    used.  This mask is still used to mediate the lookups in the cache
@@ -214,6 +216,9 @@ _dl_aux_init (ElfW(auxv_t) *av)
       case AT_HWCAP:
 	GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
 	break;
+      case AT_HWCAP2:
+	GLRO(dl_hwcap2) = (unsigned long int) av->a_un.a_val;
+	break;
 #ifdef NEED_DL_SYSINFO
       case AT_SYSINFO:
 	GL(dl_sysinfo) = av->a_un.a_val;
diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index 52de23f..08c74ef 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -156,6 +156,9 @@ _dl_sysdep_start (void **start_argptr,
       case AT_HWCAP:
 	GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val;
 	break;
+      case AT_HWCAP2:
+	GLRO(dl_hwcap2) = (unsigned long int) av->a_un.a_val;
+	break;
       case AT_CLKTCK:
 	GLRO(dl_clktck) = av->a_un.a_val;
 	break;
@@ -303,6 +306,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:       0x", hex },
 	};
       unsigned int idx = (unsigned int) (av->a_type - 2);
 
@@ -314,10 +318,10 @@ _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)
+	  /* These are handled in a special way per platform.  */
+	  if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0)
 	    continue;
 	}
 
diff --git a/misc/getauxval.c b/misc/getauxval.c
index 4321e37..e0317fd 100644
--- a/misc/getauxval.c
+++ b/misc/getauxval.c
@@ -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_hwcap2);
 
   for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
     if (p->a_type == type)
diff --git a/ports/sysdeps/alpha/dl-procinfo.h b/ports/sysdeps/alpha/dl-procinfo.h
index 523d966..0344dbc 100644
--- a/ports/sysdeps/alpha/dl-procinfo.h
+++ b/ports/sysdeps/alpha/dl-procinfo.h
@@ -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) ""
diff --git a/ports/sysdeps/mips/dl-procinfo.h b/ports/sysdeps/mips/dl-procinfo.h
index 5cc9a44..e96550c 100644
--- a/ports/sysdeps/mips/dl-procinfo.h
+++ b/ports/sysdeps/mips/dl-procinfo.h
@@ -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) ""
diff --git a/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h b/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
index 161e86c..251653a 100644
--- a/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
+++ b/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
@@ -31,10 +31,14 @@
 
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
 {
   int i;
 
+  /* Fallback to unknown output mechanism.  */
+  if (type == AT_HWCAP2)
+    return -1;
+
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
diff --git a/sysdeps/generic/dl-procinfo.h b/sysdeps/generic/dl-procinfo.h
index 90c87d9..a184a59 100644
--- a/sysdeps/generic/dl-procinfo.h
+++ b/sysdeps/generic/dl-procinfo.h
@@ -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) ""
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index cb17204..e7b0516 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -554,6 +554,10 @@ struct rtld_global_ro
   EXTERN struct link_map *_dl_sysinfo_map;
 #endif
 
+  /* Mask for more hardware capabilities that are available on some
+     platforms.  */
+  EXTERN uint64_t _dl_hwcap2;
+
 #ifdef SHARED
   /* We add a function table to _rtld_global which is then used to
      call the function instead of going through the PLT.  The result
diff --git a/sysdeps/i386/dl-procinfo.h b/sysdeps/i386/dl-procinfo.h
index 883fa7f..233a325 100644
--- a/sysdeps/i386/dl-procinfo.h
+++ b/sysdeps/i386/dl-procinfo.h
@@ -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))
diff --git a/sysdeps/powerpc/dl-procinfo.h b/sysdeps/powerpc/dl-procinfo.h
index 1c978ba..9531a2a 100644
--- a/sysdeps/powerpc/dl-procinfo.h
+++ b/sysdeps/powerpc/dl-procinfo.h
@@ -159,8 +159,12 @@ _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 long int word)
 {
+  /* Fallback to unknown output mechanism.  */
+  if (type == AT_HWCAP2)
+    return -1;
+
   _dl_printf ("AT_HWCAP:       ");
 
   for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
diff --git a/sysdeps/s390/dl-procinfo.h b/sysdeps/s390/dl-procinfo.h
index 717f6f9..45e27f1 100644
--- a/sysdeps/s390/dl-procinfo.h
+++ b/sysdeps/s390/dl-procinfo.h
@@ -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))
diff --git a/sysdeps/sparc/dl-procinfo.h b/sysdeps/sparc/dl-procinfo.h
index a18b099..71b279a 100644
--- a/sysdeps/sparc/dl-procinfo.h
+++ b/sysdeps/sparc/dl-procinfo.h
@@ -27,10 +27,14 @@
 
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
 {
   int i;
 
+  /* Fallback to unknown output mechanism.  */
+  if (type == AT_HWCAP2)
+    return -1;
+
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
diff --git a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
index a82f8f5..10f1c00 100644
--- a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
@@ -24,12 +24,16 @@
 #undef _dl_procinfo
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
 {
   /* This table should match the information from arch/i386/kernel/setup.c
      in the kernel sources.  */
   int i;
 
+  /* Fallback to unknown output mechanism.  */
+  if (type == AT_HWCAP2)
+    return -1;
+
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)
diff --git a/sysdeps/unix/sysv/linux/s390/dl-procinfo.h b/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
index 5ca4b76..3312304 100644
--- a/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
@@ -24,12 +24,16 @@
 #undef _dl_procinfo
 static inline int
 __attribute__ ((unused))
-_dl_procinfo (int word)
+_dl_procinfo (unsigned int type, unsigned long int word)
 {
   /* This table should match the information from arch/s390/kernel/setup.c
      in the kernel sources.  */
   int i;
 
+  /* Fallback to unknown output mechanism.  */
+  if (type == AT_HWCAP2)
+    return -1;
+
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < _DL_HWCAP_COUNT; ++i)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]