Blame SOURCES/glibc-rh841653-16.patch

147e83
Index: glibc-2.17-c758a686/elf/rtld.c
147e83
===================================================================
147e83
--- glibc-2.17-c758a686.orig/elf/rtld.c
147e83
+++ glibc-2.17-c758a686/elf/rtld.c
147e83
@@ -2478,6 +2478,11 @@ process_envvars (enum mode *modep)
147e83
   GLRO(dl_profile_output)
147e83
     = &"/var/tmp\0/var/profile"[INTUSE(__libc_enable_secure) ? 9 : 0];
147e83
 
147e83
+  /* RHEL 7 specific change:
147e83
+     Without the tunables farmework we simulate tunables only for
147e83
+     use with enabling transactional memory.  */
147e83
+  _dl_process_tunable_env_entries ();
147e83
+
147e83
   while ((envline = _dl_next_ld_env_entry (&runp)) != NULL)
147e83
     {
147e83
       size_t len = 0;
147e83
Index: glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/x86/elision-conf.c
147e83
===================================================================
147e83
--- glibc-2.17-c758a686.orig/nptl/sysdeps/unix/sysv/linux/x86/elision-conf.c
147e83
+++ glibc-2.17-c758a686/nptl/sysdeps/unix/sysv/linux/x86/elision-conf.c
147e83
@@ -68,8 +68,18 @@ elision_init (int argc __attribute__ ((u
147e83
 {
147e83
   int elision_available = HAS_CPU_FEATURE (RTM);
147e83
 #ifdef ENABLE_LOCK_ELISION
147e83
-  __pthread_force_elision = __libc_enable_secure ? 0 : elision_available;
147e83
-  __rwlock_rtm_enabled = __libc_enable_secure ? 0 : elision_available;
147e83
+  if (!__libc_enable_secure && elision_available)
147e83
+    {
147e83
+      /* RHEL 7 specific change: Check if elision is enabled for the
147e83
+	 process.  */
147e83
+      __pthread_force_elision = GLRO(dl_elision_enabled);
147e83
+      __rwlock_rtm_enabled = GLRO(dl_elision_enabled);
147e83
+    }
147e83
+  else
147e83
+    {
147e83
+      __pthread_force_elision = 0;
147e83
+      __rwlock_rtm_enabled = 0;
147e83
+    }
147e83
 #endif
147e83
 }
147e83
 
147e83
Index: glibc-2.17-c758a686/sysdeps/generic/ldsodefs.h
147e83
===================================================================
147e83
--- glibc-2.17-c758a686.orig/sysdeps/generic/ldsodefs.h
147e83
+++ glibc-2.17-c758a686/sysdeps/generic/ldsodefs.h
147e83
@@ -557,6 +557,9 @@ struct rtld_global_ro
147e83
      platforms.  */
147e83
   EXTERN uint64_t _dl_hwcap2;
147e83
 
147e83
+  /* RHEL 7 specific change: Is elision enabled for this process?  */
147e83
+  EXTERN bool _dl_elision_enabled;
147e83
+
147e83
 #ifdef SHARED
147e83
   /* We add a function table to _rtld_global which is then used to
147e83
      call the function instead of going through the PLT.  The result
147e83
@@ -893,6 +896,10 @@ extern void _dl_show_auxv (void) interna
147e83
    other.  */
147e83
 extern char *_dl_next_ld_env_entry (char ***position) internal_function;
147e83
 
147e83
+/* RHEL 7 specific change:
147e83
+   Manually process RHEL 7-specific tunable entries.  */
147e83
+extern void _dl_process_tunable_env_entries (void) internal_function;
147e83
+
147e83
 /* Return an array with the names of the important hardware capabilities.  */
147e83
 extern const struct r_strlenpair *_dl_important_hwcaps (const char *platform,
147e83
 							size_t paltform_len,
147e83
Index: glibc-2.17-c758a686/elf/dl-support.c
147e83
===================================================================
147e83
--- glibc-2.17-c758a686.orig/elf/dl-support.c
147e83
+++ glibc-2.17-c758a686/elf/dl-support.c
147e83
@@ -123,6 +123,10 @@ size_t _dl_phnum;
147e83
 uint64_t _dl_hwcap __attribute__ ((nocommon));
147e83
 uint64_t _dl_hwcap2 __attribute__ ((nocommon));
147e83
 
147e83
+/* RHEL 7-specific change: Is elision enabled for the process?
147e83
+   Static library definition.  */
147e83
+bool _dl_elision_enabled;
147e83
+
147e83
 /* This is not initialized to HWCAP_IMPORTANT, matching the definition
147e83
    of _dl_important_hwcaps, below, where no hwcap strings are ever
147e83
    used.  This mask is still used to mediate the lookups in the cache
147e83
@@ -289,6 +293,9 @@ _dl_non_dynamic_init (void)
147e83
     _dl_profile_output
147e83
       = &"/var/tmp\0/var/profile"[__libc_enable_secure ? 9 : 0];
147e83
 
147e83
+  /* RHEL 7 specific change: Process tunables at startup.  */
147e83
+  _dl_process_tunable_env_entries ();
147e83
+
147e83
   if (__libc_enable_secure)
147e83
     {
147e83
       static const char unsecure_envvars[] =
147e83
Index: glibc-2.17-c758a686/sysdeps/x86_64/multiarch/strstr-c.c
147e83
===================================================================
147e83
--- glibc-2.17-c758a686.orig/sysdeps/x86_64/multiarch/strstr-c.c
147e83
+++ glibc-2.17-c758a686/sysdeps/x86_64/multiarch/strstr-c.c
147e83
@@ -17,6 +17,10 @@
147e83
    License along with the GNU C Library; if not, see
147e83
    <http://www.gnu.org/licenses/>.  */
147e83
 
147e83
+/* RHEL 7-specific: Define multiple versions only for the definition in
147e83
+   libc.  Don't define multiple versions for strstr in static library
147e83
+   since we need strstr before initialization has happened.  */
147e83
+#if defined SHARED && IS_IN (libc)
147e83
 /* Redefine strstr so that the compiler won't complain about the type
147e83
    mismatch with the IFUNC selector in strong_alias, below.  */
147e83
 #undef  strstr
147e83
@@ -30,9 +34,11 @@
147e83
 # define libc_hidden_builtin_def(name) \
147e83
   __hidden_ver1 (__strstr_sse2, __GI_strstr, __strstr_sse2);
147e83
 #endif
147e83
+#endif
147e83
 
147e83
 #include "string/strstr.c"
147e83
 
147e83
+#if defined SHARED && IS_IN (libc)
147e83
 extern __typeof (__redirect_strstr) __strstr_sse42 attribute_hidden;
147e83
 extern __typeof (__redirect_strstr) __strstr_sse2_unaligned attribute_hidden;
147e83
 extern __typeof (__redirect_strstr) __strstr_sse2 attribute_hidden;
147e83
@@ -48,3 +54,5 @@ libc_ifunc (__libc_strstr, HAS_CPU_FEATU
147e83
 
147e83
 #undef strstr
147e83
 strong_alias (__libc_strstr, strstr)
147e83
+#endif
147e83
+
147e83
Index: glibc-2.17-c758a686/elf/Makefile
147e83
===================================================================
147e83
--- glibc-2.17-c758a686.orig/elf/Makefile
147e83
+++ glibc-2.17-c758a686/elf/Makefile
147e83
@@ -35,6 +35,10 @@ dl-routines	= $(addprefix dl-,load looku
147e83
 ifeq (yes,$(use-ldconfig))
147e83
 dl-routines += dl-cache
147e83
 endif
147e83
+
147e83
+# RHEL 7-specific change: Add rudimentary tunables support.
147e83
+dl-routines += dl-tunables
147e83
+
147e83
 all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
147e83
 # But they are absent from the shared libc, because that code is in ld.so.
147e83
 elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
147e83
Index: glibc-2.17-c758a686/elf/dl-tunables.c
147e83
===================================================================
147e83
--- /dev/null
147e83
+++ glibc-2.17-c758a686/elf/dl-tunables.c
147e83
@@ -0,0 +1,60 @@
147e83
+/* RHEL 7-specific rudimentary tunables handling.
147e83
+   Copyright (C) 2017 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
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#include <string.h>
147e83
+#include <unistd.h>
147e83
+#include <ldsodefs.h>
147e83
+#include <elision-conf.h>
147e83
+
147e83
+/* RHEL 7 specific change:
147e83
+   Manually process RHEL 7-specific tunable entries.  */
147e83
+void
147e83
+internal_function
147e83
+_dl_process_tunable_env_entries (void)
147e83
+{
147e83
+#if HAVE_ELISION
147e83
+  char **ep;
147e83
+  const char *envname = { "RHEL_GLIBC_TUNABLES" };
147e83
+# define TUNABLE_ELISION 0
147e83
+# define TUNABLE_MAX 1
147e83
+  const char *tunables[TUNABLE_MAX] = { "glibc.elision.enable=1" };
147e83
+
147e83
+  ep = __environ;
147e83
+  while (*ep != NULL)
147e83
+    {
147e83
+      size_t cnt = 0;
147e83
+
147e83
+      while ((*ep)[cnt] == envname[cnt] && envname[cnt] != '\0')
147e83
+        ++cnt;
147e83
+
147e83
+      if (envname[cnt] == '\0' && (*ep)[cnt] == '=')
147e83
+        {
147e83
+          /* Found it.  */
147e83
+          char *found;
147e83
+          found = strstr (*ep, tunables[TUNABLE_ELISION]);
147e83
+          /* Process TUNABLE_ELISION:
147e83
+             Note: elision-conf.c applies security checks.  */
147e83
+          if (found != NULL)
147e83
+	    GLRO(dl_elision_enabled) = true;
147e83
+          /* Continue the loop in case NAME appears again.  */
147e83
+        }
147e83
+
147e83
+      ++ep;
147e83
+    }
147e83
+#endif
147e83
+}