Blame SOURCES/glibc-rh731833-hwcap-5.patch

147e83
From 3ca2c50727b3e3e22eb3606135a18c6212f516d2 Mon Sep 17 00:00:00 2001
147e83
From: "Ryan S. Arnold" <rsa@linux.vnet.ibm.com>
147e83
Date: Fri, 28 Jun 2013 16:52:49 -0500
147e83
Subject: [PATCH 40/42] PowerPC: Define AT_HWCAP2 bits and AT_HWCAP2 handling
147e83
 for POWER8. (cherry picked from commit
147e83
 89cd956937f46e8f4a0374994965f991642dd408)
147e83
147e83
---
147e83
 sysdeps/powerpc/Makefile                |  2 +-
147e83
 sysdeps/powerpc/bits/hwcap.h            | 25 +++++++++++-----
147e83
 sysdeps/powerpc/dl-procinfo.c           | 10 ++++++-
147e83
 sysdeps/powerpc/dl-procinfo.h           | 53 ++++++++++++++++++++++++---------
147e83
 sysdeps/powerpc/rtld-global-offsets.sym |  1 +
147e83
 6 files changed, 86 insertions(+), 23 deletions(-)
147e83
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/Makefile glibc-2.17-c758a686/sysdeps/powerpc/Makefile
147e83
index 7442b67..f75e625 100644
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/Makefile
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/Makefile
147e83
@@ -17,7 +17,7 @@ endif
147e83
 endif
147e83
 
147e83
 ifeq ($(subdir),csu)
147e83
-# get offset to rtld_global._dl_hwcap
147e83
+# get offset to rtld_global._dl_hwcap and rtld_global._dl_hwcap2
147e83
 gen-as-const-headers += rtld-global-offsets.sym
147e83
 # get offset to __locale_struct.__ctype_tolower
147e83
 gen-as-const-headers += locale-defines.sym
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/bits/hwcap.h glibc-2.17-c758a686/sysdeps/powerpc/bits/hwcap.h
147e83
index 89e7d8b..0c02fc6 100644
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/bits/hwcap.h
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/bits/hwcap.h
147e83
@@ -1,5 +1,5 @@
147e83
-/* Defines for bits in AT_HWCAP.
147e83
-   Copyright (C) 2012 Free Software Foundation, Inc.
147e83
+/* Defines for bits in AT_HWCAP and AT_HWCAP2.
147e83
+   Copyright (C) 2012-2013 Free Software Foundation, Inc.
147e83
    This file is part of the GNU C Library.
147e83
 
147e83
    The GNU C Library is free software; you can redistribute it and/or
147e83
@@ -20,9 +20,9 @@
147e83
 # error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
147e83
 #endif
147e83
 
147e83
-/*
147e83
- * The following must match the kernels asm/cputable.h.
147e83
- */
147e83
+/* The bit numbers must match those in the kernel's asm/cputable.h.  */
147e83
+
147e83
+/* Feature definitions in AT_HWCAP.  */
147e83
 #define PPC_FEATURE_32		    0x80000000 /* 32-bit mode. */
147e83
 #define PPC_FEATURE_64		    0x40000000 /* 64-bit mode. */
147e83
 #define PPC_FEATURE_601_INSTR	    0x20000000 /* 601 chip, Old POWER ISA.  */
147e83
@@ -39,8 +39,9 @@
147e83
 #define PPC_FEATURE_POWER5	    0x00040000 /* POWER5 ISA 2.02 */
147e83
 #define PPC_FEATURE_POWER5_PLUS	    0x00020000 /* POWER5+ ISA 2.03 */
147e83
 #define PPC_FEATURE_CELL_BE	    0x00010000 /* CELL Broadband Engine */
147e83
-#define PPC_FEATURE_BOOKE	    0x00008000
147e83
-#define PPC_FEATURE_SMT		    0x00004000 /* Simultaneous Multi-Threading */
147e83
+#define PPC_FEATURE_BOOKE	    0x00008000 /* ISA Category Embedded */
147e83
+#define PPC_FEATURE_SMT		    0x00004000 /* Simultaneous
147e83
+						  Multi-Threading */
147e83
 #define PPC_FEATURE_ICACHE_SNOOP    0x00002000
147e83
 #define PPC_FEATURE_ARCH_2_05	    0x00001000 /* ISA 2.05 */
147e83
 #define PPC_FEATURE_PA6T	    0x00000800 /* PA Semi 6T Core */
147e83
@@ -51,3 +52,13 @@
147e83
 #define PPC_FEATURE_PSERIES_PERFMON_COMPAT  0x00000040
147e83
 #define PPC_FEATURE_TRUE_LE	    0x00000002
147e83
 #define PPC_FEATURE_PPC_LE	    0x00000001
147e83
+
147e83
+/* Feature definitions in AT_HWCAP2.  */
147e83
+#define PPC_FEATURE2_ARCH_2_07     0x80000000 /* ISA 2.07 */
147e83
+#define PPC_FEATURE2_HAS_HTM       0x40000000 /* Hardware Transactional
147e83
+						 Memory */
147e83
+#define PPC_FEATURE2_HAS_DSCR      0x20000000 /* Data Stream Control
147e83
+						 Register */
147e83
+#define PPC_FEATURE2_HAS_EBB       0x10000000 /* Event Base Branching */
147e83
+#define PPC_FEATURE2_HAS_ISEL      0x08000000 /* Integer Select */
147e83
+#define PPC_FEATURE2_HAS_TAR       0x04000000 /* Target Address Register */
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.c glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.c
147e83
index efab165..6cebf99 100644
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.c
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.c
147e83
@@ -45,7 +45,7 @@
147e83
 #if !defined PROCINFO_DECL && defined SHARED
147e83
   ._dl_powerpc_cap_flags
147e83
 #else
147e83
-PROCINFO_CLASS const char _dl_powerpc_cap_flags[25][10]
147e83
+PROCINFO_CLASS const char _dl_powerpc_cap_flags[57][10]
147e83
 #endif
147e83
 #ifndef PROCINFO_DECL
147e83
 = {
147e83
@@ -56,6 +56,14 @@ PROCINFO_CLASS const char _dl_powerpc_cap_flags[25][10]
147e83
     "notb", "efpdouble", "efpsingle", "spe",
147e83
     "ucache", "4xxmac", "mmu", "fpu",
147e83
     "altivec", "ppc601", "ppc64", "ppc32",
147e83
+    "", "", "", "",
147e83
+    "", "", "", "",
147e83
+    "", "", "", "",
147e83
+    "", "", "", "",
147e83
+    "", "", "", "",
147e83
+    "", "", "", "",
147e83
+    "", "", "tar", "isel",
147e83
+    "ebb", "dscr", "htm", "arch_2_07",
147e83
   }
147e83
 #endif
147e83
 #if !defined SHARED || defined PROCINFO_DECL
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.h glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.h
147e83
index 7732ed2..dc3b70e 100644
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.h
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/dl-procinfo.h
147e83
@@ -20,11 +20,21 @@
147e83
 #define _DL_PROCINFO_H 1
147e83
 
147e83
 #include <ldsodefs.h>
147e83
-#include <sysdep.h>	/* This defines the PPC_FEATURE_* macros.  */
147e83
+#include <sysdep.h>	/* This defines the PPC_FEATURE[2]_* macros.  */
147e83
 
147e83
 /* There are 25 bits used, but they are bits 7..31.  */
147e83
 #define _DL_HWCAP_FIRST		7
147e83
-#define _DL_HWCAP_COUNT		32
147e83
+
147e83
+/* The total number of available bits (including those prior to
147e83
+   _DL_HWCAP_FIRST).  Some of these bits might not be used.  */
147e83
+#define _DL_HWCAP_COUNT		64
147e83
+
147e83
+/* Features started at bit 31 and decremented as new features were added.  */
147e83
+#define _DL_HWCAP_LAST		31
147e83
+
147e83
+/* AT_HWCAP2 features started at bit 31 and decremented as new features were
147e83
+   added.  HWCAP2 feature bits start at bit 0.  */
147e83
+#define _DL_HWCAP2_LAST		31
147e83
 
147e83
 /* These bits influence library search.  */
147e83
 #define HWCAP_IMPORTANT		(PPC_FEATURE_HAS_ALTIVEC \
147e83
@@ -161,18 +171,33 @@ static inline int
147e83
 __attribute__ ((unused))
147e83
 _dl_procinfo (unsigned int type, unsigned long int word)
147e83
 {
147e83
-  /* Fallback to unknown output mechanism.  */
147e83
-  if (type == AT_HWCAP2)
147e83
-    return -1;
147e83
-
147e83
-  _dl_printf ("AT_HWCAP:       ");
147e83
-
147e83
-  for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
147e83
-    if (word & (1 << i))
147e83
-      _dl_printf (" %s", _dl_hwcap_string (i));
147e83
-
147e83
-  _dl_printf ("\n");
147e83
-
147e83
+  switch(type)
147e83
+    {
147e83
+    case AT_HWCAP:
147e83
+      _dl_printf ("AT_HWCAP:       ");
147e83
+
147e83
+      for (int i = _DL_HWCAP_FIRST; i <= _DL_HWCAP_LAST; ++i)
147e83
+       if (word & (1 << i))
147e83
+         _dl_printf (" %s", _dl_hwcap_string (i));
147e83
+      break;
147e83
+    case AT_HWCAP2:
147e83
+      {
147e83
+       unsigned int offset = _DL_HWCAP_LAST + 1;
147e83
+
147e83
+       _dl_printf ("AT_HWCAP2:      ");
147e83
+
147e83
+        /* We have to go through them all because the kernel added the
147e83
+          AT_HWCAP2 features starting with the high bits.  */
147e83
+       for (int i = 0; i <= _DL_HWCAP2_LAST; ++i)
147e83
+         if (word & (1 << i))
147e83
+           _dl_printf (" %s", _dl_hwcap_string (offset + i));
147e83
+       break;
147e83
+      }
147e83
+    default:
147e83
+      /* This should not happen.  */
147e83
+      return -1;
147e83
+    }
147e83
+   _dl_printf ("\n");
147e83
   return 0;
147e83
 }
147e83
 #endif
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/rtld-global-offsets.sym glibc-2.17-c758a686/sysdeps/powerpc/rtld-global-offsets.sym
147e83
index ff4e97f..f5ea5a1 100644
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/rtld-global-offsets.sym
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/rtld-global-offsets.sym
147e83
@@ -5,3 +5,4 @@
147e83
 #define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem)
147e83
 
147e83
 RTLD_GLOBAL_RO_DL_HWCAP_OFFSET	rtld_global_ro_offsetof (_dl_hwcap)
147e83
+RTLD_GLOBAL_RO_DL_HWCAP2_OFFSET	rtld_global_ro_offsetof (_dl_hwcap2)
147e83
-- 
147e83
1.7.11.7
147e83