076f82
commit 0c03cb54c808173d8e7ba96f6152dfcf627ac496
076f82
Author: Stefan Liebler <stli@linux.ibm.com>
076f82
Date:   Wed Apr 13 14:36:09 2022 +0200
076f82
076f82
    S390: Add new s390 platform z16.
076f82
    
076f82
    The new IBM z16 is added to platform string array.
076f82
    The macro _DL_PLATFORMS_COUNT is incremented.
076f82
    
076f82
    _dl_hwcaps_subdir is extended by "z16" if HWCAP_S390_VXRS_PDE2
076f82
    is set. HWCAP_S390_NNPA is not tested in _dl_hwcaps_subdirs_active
076f82
    as those instructions may be replaced or removed in future.
076f82
    
076f82
    tst-glibc-hwcaps.c is extended in order to test z16 via new marker5.
076f82
    
076f82
    A fatal glibc error is dumped if glibc was build with architecture
076f82
    level set for z16, but run on an older machine. (See dl-hwcap-check.h)
076f82
    
076f82
    (cherry picked from commit 2376944b9e5c0364b9fb473e4d8dabca31b57167)
076f82
076f82
Conflicts:
076f82
	sysdeps/s390/s390-64/dl-hwcap-check.h - Use GCCMACRO__ARCH__.
076f82
	- Backported f01d482f0355a7029d0715ace0ccf3323e7e94bc requires it.
076f82
076f82
diff --git a/elf/Makefile b/elf/Makefile
076f82
index 3e17a0706f5ec2df..8e2dd91c583f9a62 100644
076f82
--- a/elf/Makefile
076f82
+++ b/elf/Makefile
076f82
@@ -571,6 +571,11 @@ modules-names = \
076f82
   libmarkermod4-2 \
076f82
   libmarkermod4-3 \
076f82
   libmarkermod4-4 \
076f82
+  libmarkermod5-1 \
076f82
+  libmarkermod5-2 \
076f82
+  libmarkermod5-3 \
076f82
+  libmarkermod5-4 \
076f82
+  libmarkermod5-5 \
076f82
   ltglobmod1 \
076f82
   ltglobmod2 \
076f82
   neededobj1 \
076f82
@@ -2412,6 +2417,7 @@ LDFLAGS-libmarkermod1-1.so += -Wl,-soname,libmarkermod1.so
076f82
 LDFLAGS-libmarkermod2-1.so += -Wl,-soname,libmarkermod2.so
076f82
 LDFLAGS-libmarkermod3-1.so += -Wl,-soname,libmarkermod3.so
076f82
 LDFLAGS-libmarkermod4-1.so += -Wl,-soname,libmarkermod4.so
076f82
+LDFLAGS-libmarkermod5-1.so += -Wl,-soname,libmarkermod5.so
076f82
 $(objpfx)libmarkermod%.os : markermodMARKER-VALUE.c
076f82
 	$(compile-command.c) \
076f82
 	  -DMARKER=marker$(firstword $(subst -, ,$*)) \
076f82
@@ -2424,6 +2430,8 @@ $(objpfx)libmarkermod3.so: $(objpfx)libmarkermod3-1.so
076f82
 	cp $< $@
076f82
 $(objpfx)libmarkermod4.so: $(objpfx)libmarkermod4-1.so
076f82
 	cp $< $@
076f82
+$(objpfx)libmarkermod5.so: $(objpfx)libmarkermod5-1.so
076f82
+	cp $< $@
076f82
 
076f82
 # tst-glibc-hwcaps-prepend checks that --glibc-hwcaps-prepend is
076f82
 # preferred over auto-detected subdirectories.
076f82
diff --git a/elf/tst-glibc-hwcaps-cache.script b/elf/tst-glibc-hwcaps-cache.script
076f82
index c3271f61f9e50f2e..d58fc8c5de3c5198 100644
076f82
--- a/elf/tst-glibc-hwcaps-cache.script
076f82
+++ b/elf/tst-glibc-hwcaps-cache.script
076f82
@@ -4,6 +4,7 @@
076f82
 cp $B/elf/libmarkermod2-1.so $L/libmarkermod2.so
076f82
 cp $B/elf/libmarkermod3-1.so $L/libmarkermod3.so
076f82
 cp $B/elf/libmarkermod4-1.so $L/libmarkermod4.so
076f82
+cp $B/elf/libmarkermod5-1.so $L/libmarkermod5.so
076f82
 
076f82
 mkdirp 0770 $L/glibc-hwcaps/power9
076f82
 cp $B/elf/libmarkermod2-2.so $L/glibc-hwcaps/power9/libmarkermod2.so
076f82
@@ -20,6 +21,11 @@ mkdirp 0770 $L/glibc-hwcaps/z15
076f82
 cp $B/elf/libmarkermod4-2.so $L/glibc-hwcaps/z13/libmarkermod4.so
076f82
 cp $B/elf/libmarkermod4-3.so $L/glibc-hwcaps/z14/libmarkermod4.so
076f82
 cp $B/elf/libmarkermod4-4.so $L/glibc-hwcaps/z15/libmarkermod4.so
076f82
+mkdirp 0770 $L/glibc-hwcaps/z16
076f82
+cp $B/elf/libmarkermod5-2.so $L/glibc-hwcaps/z13/libmarkermod5.so
076f82
+cp $B/elf/libmarkermod5-3.so $L/glibc-hwcaps/z14/libmarkermod5.so
076f82
+cp $B/elf/libmarkermod5-4.so $L/glibc-hwcaps/z15/libmarkermod5.so
076f82
+cp $B/elf/libmarkermod5-5.so $L/glibc-hwcaps/z16/libmarkermod5.so
076f82
 
076f82
 mkdirp 0770 $L/glibc-hwcaps/x86-64-v2
076f82
 cp $B/elf/libmarkermod2-2.so $L/glibc-hwcaps/x86-64-v2/libmarkermod2.so
076f82
diff --git a/sysdeps/s390/dl-procinfo.c b/sysdeps/s390/dl-procinfo.c
076f82
index 155f0bd99eccb3f9..755b54ff13a0fa2f 100644
076f82
--- a/sysdeps/s390/dl-procinfo.c
076f82
+++ b/sysdeps/s390/dl-procinfo.c
076f82
@@ -64,11 +64,12 @@ PROCINFO_CLASS const char _dl_s390_cap_flags[23][9]
076f82
 #if !defined PROCINFO_DECL && defined SHARED
076f82
   ._dl_s390_platforms
076f82
 #else
076f82
-PROCINFO_CLASS const char _dl_s390_platforms[10][7]
076f82
+PROCINFO_CLASS const char _dl_s390_platforms[11][7]
076f82
 #endif
076f82
 #ifndef PROCINFO_DECL
076f82
 = {
076f82
-    "g5", "z900", "z990", "z9-109", "z10", "z196", "zEC12", "z13", "z14", "z15"
076f82
+    "g5", "z900", "z990", "z9-109", "z10", "z196", "zEC12", "z13", "z14", "z15",
076f82
+    "z16"
076f82
   }
076f82
 #endif
076f82
 #if !defined SHARED || defined PROCINFO_DECL
076f82
diff --git a/sysdeps/s390/dl-procinfo.h b/sysdeps/s390/dl-procinfo.h
076f82
index e4e3e334a5b3d47c..d44e1dd97441bd90 100644
076f82
--- a/sysdeps/s390/dl-procinfo.h
076f82
+++ b/sysdeps/s390/dl-procinfo.h
076f82
@@ -23,7 +23,7 @@
076f82
 
076f82
 #define _DL_HWCAP_COUNT 23
076f82
 
076f82
-#define _DL_PLATFORMS_COUNT	10
076f82
+#define _DL_PLATFORMS_COUNT	11
076f82
 
076f82
 /* The kernel provides up to 32 capability bits with elf_hwcap.  */
076f82
 #define _DL_FIRST_PLATFORM	32
076f82
diff --git a/sysdeps/s390/s390-64/Makefile b/sysdeps/s390/s390-64/Makefile
076f82
index e5da26871c862e63..66ed844e68df5159 100644
076f82
--- a/sysdeps/s390/s390-64/Makefile
076f82
+++ b/sysdeps/s390/s390-64/Makefile
076f82
@@ -7,8 +7,11 @@ CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
076f82
 CFLAGS-dl-load.c += -Wno-unused
076f82
 CFLAGS-dl-reloc.c += -Wno-unused
076f82
 
076f82
-$(objpfx)tst-glibc-hwcaps: $(objpfx)libmarkermod2-1.so \
076f82
-  $(objpfx)libmarkermod3-1.so $(objpfx)libmarkermod4-1.so
076f82
+$(objpfx)tst-glibc-hwcaps: \
076f82
+  $(objpfx)libmarkermod2-1.so \
076f82
+  $(objpfx)libmarkermod3-1.so \
076f82
+  $(objpfx)libmarkermod4-1.so \
076f82
+  $(objpfx)libmarkermod5-1.so
076f82
 $(objpfx)tst-glibc-hwcaps.out: \
076f82
   $(objpfx)libmarkermod2.so \
076f82
     $(objpfx)glibc-hwcaps/z13/libmarkermod2.so \
076f82
@@ -19,6 +22,11 @@ $(objpfx)tst-glibc-hwcaps.out: \
076f82
     $(objpfx)glibc-hwcaps/z13/libmarkermod4.so \
076f82
     $(objpfx)glibc-hwcaps/z14/libmarkermod4.so \
076f82
     $(objpfx)glibc-hwcaps/z15/libmarkermod4.so \
076f82
+  $(objpfx)libmarkermod5.so \
076f82
+    $(objpfx)glibc-hwcaps/z13/libmarkermod5.so \
076f82
+    $(objpfx)glibc-hwcaps/z14/libmarkermod5.so \
076f82
+    $(objpfx)glibc-hwcaps/z15/libmarkermod5.so \
076f82
+    $(objpfx)glibc-hwcaps/z16/libmarkermod5.so
076f82
 
076f82
 $(objpfx)glibc-hwcaps/z13/libmarkermod2.so: $(objpfx)libmarkermod2-2.so
076f82
 	$(make-target-directory)
076f82
@@ -38,6 +46,19 @@ $(objpfx)glibc-hwcaps/z14/libmarkermod4.so: $(objpfx)libmarkermod4-3.so
076f82
 $(objpfx)glibc-hwcaps/z15/libmarkermod4.so: $(objpfx)libmarkermod4-4.so
076f82
 	$(make-target-directory)
076f82
 	cp $< $@
076f82
+$(objpfx)glibc-hwcaps/z13/libmarkermod5.so: $(objpfx)libmarkermod5-2.so
076f82
+	$(make-target-directory)
076f82
+	cp $< $@
076f82
+$(objpfx)glibc-hwcaps/z14/libmarkermod5.so: $(objpfx)libmarkermod5-3.so
076f82
+	$(make-target-directory)
076f82
+	cp $< $@
076f82
+$(objpfx)glibc-hwcaps/z15/libmarkermod5.so: $(objpfx)libmarkermod5-4.so
076f82
+	$(make-target-directory)
076f82
+	cp $< $@
076f82
+$(objpfx)glibc-hwcaps/z16/libmarkermod5.so: $(objpfx)libmarkermod5-5.so
076f82
+	$(make-target-directory)
076f82
+	cp $< $@
076f82
+
076f82
 
076f82
 ifeq (no,$(build-hardcoded-path-in-tests))
076f82
 # This is an ld.so.cache test, and RPATH/RUNPATH in the executable
076f82
diff --git a/sysdeps/s390/s390-64/dl-hwcap-check.h b/sysdeps/s390/s390-64/dl-hwcap-check.h
076f82
index 27f7e245b1d1a9e9..52c609571b32f4ab 100644
076f82
--- a/sysdeps/s390/s390-64/dl-hwcap-check.h
076f82
+++ b/sysdeps/s390/s390-64/dl-hwcap-check.h
076f82
@@ -26,7 +26,11 @@ static inline void
076f82
 dl_hwcap_check (void)
076f82
 {
076f82
 #if defined __ARCH__
076f82
-# if GCCMACRO__ARCH__ >= 13
076f82
+# if GCCMACRO__ARCH__ >= 14
076f82
+  if (!(GLRO(dl_hwcap) & HWCAP_S390_VXRS_PDE2))
076f82
+    _dl_fatal_printf ("\
076f82
+Fatal glibc error: CPU lacks VXRS_PDE2 support (z16 or later required)\n");
076f82
+# elif GCCMACRO__ARCH__ >= 13
076f82
   if (!(GLRO(dl_hwcap) & HWCAP_S390_VXRS_EXT2))
076f82
     _dl_fatal_printf ("\
076f82
 Fatal glibc error: CPU lacks VXRS_EXT2 support (z15 or later required)\n");
076f82
diff --git a/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c b/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c
076f82
index b9d094f3d73c2d7a..187d732d560c4a62 100644
076f82
--- a/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c
076f82
+++ b/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c
076f82
@@ -19,8 +19,8 @@
076f82
 #include <dl-hwcaps.h>
076f82
 #include <ldsodefs.h>
076f82
 
076f82
-const char _dl_hwcaps_subdirs[] = "z15:z14:z13";
076f82
-enum { subdirs_count = 3 }; /* Number of components in _dl_hwcaps_subdirs.  */
076f82
+const char _dl_hwcaps_subdirs[] = "z16:z15:z14:z13";
076f82
+enum { subdirs_count = 4 }; /* Number of components in _dl_hwcaps_subdirs.  */
076f82
 
076f82
 uint32_t
076f82
 _dl_hwcaps_subdirs_active (void)
076f82
@@ -50,5 +50,12 @@ _dl_hwcaps_subdirs_active (void)
076f82
     return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
076f82
   ++active;
076f82
 
076f82
+  /* z16.
076f82
+   Note: We do not list HWCAP_S390_NNPA here as, according to the Principles of
076f82
+   Operation, those instructions may be replaced or removed in future.  */
076f82
+  if (!(GLRO (dl_hwcap) & HWCAP_S390_VXRS_PDE2))
076f82
+    return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
076f82
+  ++active;
076f82
+
076f82
   return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
076f82
 }
076f82
diff --git a/sysdeps/s390/s390-64/tst-glibc-hwcaps.c b/sysdeps/s390/s390-64/tst-glibc-hwcaps.c
076f82
index 02397a478c552516..f3b8ef3dec80d2d1 100644
076f82
--- a/sysdeps/s390/s390-64/tst-glibc-hwcaps.c
076f82
+++ b/sysdeps/s390/s390-64/tst-glibc-hwcaps.c
076f82
@@ -25,6 +25,7 @@
076f82
 extern int marker2 (void);
076f82
 extern int marker3 (void);
076f82
 extern int marker4 (void);
076f82
+extern int marker5 (void);
076f82
 
076f82
 /* Return the arch level, 10 for the baseline libmarkermod*.so's.  */
076f82
 static int
076f82
@@ -63,9 +64,11 @@ compute_level (void)
076f82
     return 12;
076f82
   if (strcmp (platform, "z15") == 0)
076f82
     return 13;
076f82
+  if (strcmp (platform, "z16") == 0)
076f82
+    return 14;
076f82
   printf ("warning: unrecognized AT_PLATFORM value: %s\n", platform);
076f82
-  /* Assume that the new platform supports z15.  */
076f82
-  return 13;
076f82
+  /* Assume that the new platform supports z16.  */
076f82
+  return 14;
076f82
 }
076f82
 
076f82
 static int
076f82
@@ -76,6 +79,7 @@ do_test (void)
076f82
   TEST_COMPARE (marker2 (), MIN (level - 9, 2));
076f82
   TEST_COMPARE (marker3 (), MIN (level - 9, 3));
076f82
   TEST_COMPARE (marker4 (), MIN (level - 9, 4));
076f82
+  TEST_COMPARE (marker5 (), MIN (level - 9, 5));
076f82
   return 0;
076f82
 }
076f82