|
|
e354a5 |
commit fdf8fbca455ca3ef57235bde907bcc6a624ac5aa
|
|
|
e354a5 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
e354a5 |
Date: Thu Dec 10 13:51:18 2020 +0100
|
|
|
e354a5 |
|
|
|
e354a5 |
s390x: Add glibc-hwcaps support
|
|
|
e354a5 |
|
|
|
e354a5 |
Subdirectories z13, z14, z15 can be selected, mostly based on the
|
|
|
e354a5 |
level of support for vector instructions.
|
|
|
e354a5 |
|
|
|
e354a5 |
Co-Authored-By: Stefan Liebler <stli@linux.ibm.com>
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/elf/Makefile b/elf/Makefile
|
|
|
e354a5 |
index 63c61ad63677ec63..67029930dd2cb461 100644
|
|
|
e354a5 |
--- a/elf/Makefile
|
|
|
e354a5 |
+++ b/elf/Makefile
|
|
|
e354a5 |
@@ -1751,7 +1751,7 @@ $(objpfx)argv0test.out: tst-rtld-argv0.sh $(objpfx)ld.so \
|
|
|
e354a5 |
# glibc-hwcaps mechanism for this architecture). Used to obtain test
|
|
|
e354a5 |
# coverage for some glibc-hwcaps tests for the widest possible range
|
|
|
e354a5 |
# of systems.
|
|
|
e354a5 |
-glibc-hwcaps-first-subdirs-for-tests = power9 x86-64-v2
|
|
|
e354a5 |
+glibc-hwcaps-first-subdirs-for-tests = power9 x86-64-v2 z13
|
|
|
e354a5 |
|
|
|
e354a5 |
# The test modules are parameterized by preprocessor macros.
|
|
|
e354a5 |
LDFLAGS-libmarkermod1-1.so += -Wl,-soname,libmarkermod1.so
|
|
|
e354a5 |
diff --git a/elf/tst-glibc-hwcaps-cache.script b/elf/tst-glibc-hwcaps-cache.script
|
|
|
e354a5 |
index 6a4675f9bd30e02f..c3271f61f9e50f2e 100644
|
|
|
e354a5 |
--- a/elf/tst-glibc-hwcaps-cache.script
|
|
|
e354a5 |
+++ b/elf/tst-glibc-hwcaps-cache.script
|
|
|
e354a5 |
@@ -11,6 +11,16 @@ mkdirp 0770 $L/glibc-hwcaps/power10
|
|
|
e354a5 |
cp $B/elf/libmarkermod3-2.so $L/glibc-hwcaps/power9/libmarkermod3.so
|
|
|
e354a5 |
cp $B/elf/libmarkermod3-3.so $L/glibc-hwcaps/power10/libmarkermod3.so
|
|
|
e354a5 |
|
|
|
e354a5 |
+mkdirp 0770 $L/glibc-hwcaps/z13
|
|
|
e354a5 |
+cp $B/elf/libmarkermod2-2.so $L/glibc-hwcaps/z13/libmarkermod2.so
|
|
|
e354a5 |
+mkdirp 0770 $L/glibc-hwcaps/z14
|
|
|
e354a5 |
+cp $B/elf/libmarkermod3-2.so $L/glibc-hwcaps/z13/libmarkermod3.so
|
|
|
e354a5 |
+cp $B/elf/libmarkermod3-3.so $L/glibc-hwcaps/z14/libmarkermod3.so
|
|
|
e354a5 |
+mkdirp 0770 $L/glibc-hwcaps/z15
|
|
|
e354a5 |
+cp $B/elf/libmarkermod4-2.so $L/glibc-hwcaps/z13/libmarkermod4.so
|
|
|
e354a5 |
+cp $B/elf/libmarkermod4-3.so $L/glibc-hwcaps/z14/libmarkermod4.so
|
|
|
e354a5 |
+cp $B/elf/libmarkermod4-4.so $L/glibc-hwcaps/z15/libmarkermod4.so
|
|
|
e354a5 |
+
|
|
|
e354a5 |
mkdirp 0770 $L/glibc-hwcaps/x86-64-v2
|
|
|
e354a5 |
cp $B/elf/libmarkermod2-2.so $L/glibc-hwcaps/x86-64-v2/libmarkermod2.so
|
|
|
e354a5 |
mkdirp 0770 $L/glibc-hwcaps/x86-64-v3
|
|
|
e354a5 |
diff --git a/sysdeps/s390/s390-64/Makefile b/sysdeps/s390/s390-64/Makefile
|
|
|
e354a5 |
index b4d793bb3dd1f703..e5da26871c862e63 100644
|
|
|
e354a5 |
--- a/sysdeps/s390/s390-64/Makefile
|
|
|
e354a5 |
+++ b/sysdeps/s390/s390-64/Makefile
|
|
|
e354a5 |
@@ -6,4 +6,43 @@ ifeq ($(subdir),elf)
|
|
|
e354a5 |
CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
|
|
|
e354a5 |
CFLAGS-dl-load.c += -Wno-unused
|
|
|
e354a5 |
CFLAGS-dl-reloc.c += -Wno-unused
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+$(objpfx)tst-glibc-hwcaps: $(objpfx)libmarkermod2-1.so \
|
|
|
e354a5 |
+ $(objpfx)libmarkermod3-1.so $(objpfx)libmarkermod4-1.so
|
|
|
e354a5 |
+$(objpfx)tst-glibc-hwcaps.out: \
|
|
|
e354a5 |
+ $(objpfx)libmarkermod2.so \
|
|
|
e354a5 |
+ $(objpfx)glibc-hwcaps/z13/libmarkermod2.so \
|
|
|
e354a5 |
+ $(objpfx)libmarkermod3.so \
|
|
|
e354a5 |
+ $(objpfx)glibc-hwcaps/z13/libmarkermod3.so \
|
|
|
e354a5 |
+ $(objpfx)glibc-hwcaps/z14/libmarkermod3.so \
|
|
|
e354a5 |
+ $(objpfx)libmarkermod4.so \
|
|
|
e354a5 |
+ $(objpfx)glibc-hwcaps/z13/libmarkermod4.so \
|
|
|
e354a5 |
+ $(objpfx)glibc-hwcaps/z14/libmarkermod4.so \
|
|
|
e354a5 |
+ $(objpfx)glibc-hwcaps/z15/libmarkermod4.so \
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+$(objpfx)glibc-hwcaps/z13/libmarkermod2.so: $(objpfx)libmarkermod2-2.so
|
|
|
e354a5 |
+ $(make-target-directory)
|
|
|
e354a5 |
+ cp $< $@
|
|
|
e354a5 |
+$(objpfx)glibc-hwcaps/z13/libmarkermod3.so: $(objpfx)libmarkermod3-2.so
|
|
|
e354a5 |
+ $(make-target-directory)
|
|
|
e354a5 |
+ cp $< $@
|
|
|
e354a5 |
+$(objpfx)glibc-hwcaps/z14/libmarkermod3.so: $(objpfx)libmarkermod3-3.so
|
|
|
e354a5 |
+ $(make-target-directory)
|
|
|
e354a5 |
+ cp $< $@
|
|
|
e354a5 |
+$(objpfx)glibc-hwcaps/z13/libmarkermod4.so: $(objpfx)libmarkermod4-2.so
|
|
|
e354a5 |
+ $(make-target-directory)
|
|
|
e354a5 |
+ cp $< $@
|
|
|
e354a5 |
+$(objpfx)glibc-hwcaps/z14/libmarkermod4.so: $(objpfx)libmarkermod4-3.so
|
|
|
e354a5 |
+ $(make-target-directory)
|
|
|
e354a5 |
+ cp $< $@
|
|
|
e354a5 |
+$(objpfx)glibc-hwcaps/z15/libmarkermod4.so: $(objpfx)libmarkermod4-4.so
|
|
|
e354a5 |
+ $(make-target-directory)
|
|
|
e354a5 |
+ cp $< $@
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ifeq (no,$(build-hardcoded-path-in-tests))
|
|
|
e354a5 |
+# This is an ld.so.cache test, and RPATH/RUNPATH in the executable
|
|
|
e354a5 |
+# interferes with its test objectives.
|
|
|
e354a5 |
+tests-container += tst-glibc-hwcaps-cache
|
|
|
e354a5 |
endif
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+endif # $(subdir) == elf
|
|
|
e354a5 |
diff --git a/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c b/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c
|
|
|
e354a5 |
new file mode 100644
|
|
|
e354a5 |
index 0000000000000000..3673808a458350ad
|
|
|
e354a5 |
--- /dev/null
|
|
|
e354a5 |
+++ b/sysdeps/s390/s390-64/dl-hwcaps-subdirs.c
|
|
|
e354a5 |
@@ -0,0 +1,54 @@
|
|
|
e354a5 |
+/* Architecture-specific glibc-hwcaps subdirectories. s390x version.
|
|
|
e354a5 |
+ Copyright (C) 2020 Free Software Foundation, Inc.
|
|
|
e354a5 |
+ This file is part of the GNU C Library.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
e354a5 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
e354a5 |
+ License as published by the Free Software Foundation; either
|
|
|
e354a5 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
e354a5 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e354a5 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
e354a5 |
+ Lesser General Public License for more details.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
e354a5 |
+ License along with the GNU C Library; if not, see
|
|
|
e354a5 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#include <dl-hwcaps.h>
|
|
|
e354a5 |
+#include <ldsodefs.h>
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+const char _dl_hwcaps_subdirs[] = "z15:z14:z13";
|
|
|
e354a5 |
+enum { subdirs_count = 3 }; /* Number of components in _dl_hwcaps_subdirs. */
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+uint32_t
|
|
|
e354a5 |
+_dl_hwcaps_subdirs_active (void)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ int active = 0;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ /* Test in reverse preference order. */
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ /* z13. */
|
|
|
e354a5 |
+ if (!(GLRO (dl_hwcap) & HWCAP_S390_VX))
|
|
|
e354a5 |
+ return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
|
|
|
e354a5 |
+ ++active;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ /* z14. */
|
|
|
e354a5 |
+ if (!((GLRO (dl_hwcap) & HWCAP_S390_VXD)
|
|
|
e354a5 |
+ && (GLRO (dl_hwcap) & HWCAP_S390_VXE)
|
|
|
e354a5 |
+ && (GLRO (dl_hwcap) & HWCAP_S390_GS)))
|
|
|
e354a5 |
+ return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
|
|
|
e354a5 |
+ ++active;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ /* z15.
|
|
|
e354a5 |
+ Note: We do not list HWCAP_S390_SORT and HWCAP_S390_DFLT here as,
|
|
|
e354a5 |
+ according to the Principles of Operation, those may be replaced or removed
|
|
|
e354a5 |
+ in future. */
|
|
|
e354a5 |
+ if (!((GLRO (dl_hwcap) & HWCAP_S390_VXRS_EXT2)
|
|
|
e354a5 |
+ && (GLRO (dl_hwcap) & HWCAP_S390_VXRS_PDE)))
|
|
|
e354a5 |
+ return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
|
|
|
e354a5 |
+ ++active;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
diff --git a/sysdeps/s390/s390-64/tst-glibc-hwcaps.c b/sysdeps/s390/s390-64/tst-glibc-hwcaps.c
|
|
|
e354a5 |
new file mode 100644
|
|
|
e354a5 |
index 0000000000000000..690f0d5fab36eb59
|
|
|
e354a5 |
--- /dev/null
|
|
|
e354a5 |
+++ b/sysdeps/s390/s390-64/tst-glibc-hwcaps.c
|
|
|
e354a5 |
@@ -0,0 +1,82 @@
|
|
|
e354a5 |
+/* glibc-hwcaps subdirectory test. s390x version.
|
|
|
e354a5 |
+ Copyright (C) 2020 Free Software Foundation, Inc.
|
|
|
e354a5 |
+ This file is part of the GNU C Library.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
e354a5 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
e354a5 |
+ License as published by the Free Software Foundation; either
|
|
|
e354a5 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
e354a5 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e354a5 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
e354a5 |
+ Lesser General Public License for more details.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
e354a5 |
+ License along with the GNU C Library; if not, see
|
|
|
e354a5 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#include <stdio.h>
|
|
|
e354a5 |
+#include <string.h>
|
|
|
e354a5 |
+#include <support/check.h>
|
|
|
e354a5 |
+#include <sys/auxv.h>
|
|
|
e354a5 |
+#include <sys/param.h>
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+extern int marker2 (void);
|
|
|
e354a5 |
+extern int marker3 (void);
|
|
|
e354a5 |
+extern int marker4 (void);
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+/* Return the arch level, 10 for the baseline libmarkermod*.so's. */
|
|
|
e354a5 |
+static int
|
|
|
e354a5 |
+compute_level (void)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ const char *platform = (const char *) getauxval (AT_PLATFORM);
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ /* The arch* versions refer to the edition of the Principles of
|
|
|
e354a5 |
+ Operation, and they are off by two when compared with the recent
|
|
|
e354a5 |
+ product names. (The code below should not be considered an
|
|
|
e354a5 |
+ accurate mapping to Principles of Operation editions for earlier
|
|
|
e354a5 |
+ AT_PLATFORM strings). */
|
|
|
e354a5 |
+ if (strcmp (platform, "z900") == 0)
|
|
|
e354a5 |
+ return 10;
|
|
|
e354a5 |
+ if (strcmp (platform, "z990") == 0)
|
|
|
e354a5 |
+ return 10;
|
|
|
e354a5 |
+ if (strcmp (platform, "z9-109") == 0)
|
|
|
e354a5 |
+ return 10;
|
|
|
e354a5 |
+ if (strcmp (platform, "z10") == 0)
|
|
|
e354a5 |
+ return 10;
|
|
|
e354a5 |
+ if (strcmp (platform, "z196") == 0)
|
|
|
e354a5 |
+ return 10;
|
|
|
e354a5 |
+ if (strcmp (platform, "zEC12") == 0)
|
|
|
e354a5 |
+ return 10;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ /* If we are running on z13 or newer and the kernel was booted with novx,
|
|
|
e354a5 |
+ then AT_PLATFORM is z13 or newer, but _dl_hwcaps_subdirs_active will
|
|
|
e354a5 |
+ return zero and the _dl_hwcaps_subdirs are not searched. */
|
|
|
e354a5 |
+ const unsigned long int hwcap = getauxval (AT_HWCAP);
|
|
|
e354a5 |
+ if ((hwcap & HWCAP_S390_VX) == 0)
|
|
|
e354a5 |
+ return 10;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ if (strcmp (platform, "z13") == 0)
|
|
|
e354a5 |
+ return 11;
|
|
|
e354a5 |
+ if (strcmp (platform, "z14") == 0)
|
|
|
e354a5 |
+ return 12;
|
|
|
e354a5 |
+ if (strcmp (platform, "z15") == 0)
|
|
|
e354a5 |
+ return 13;
|
|
|
e354a5 |
+ printf ("warning: unrecognized AT_PLATFORM value: %s\n", platform);
|
|
|
e354a5 |
+ /* Assume that the new platform supports z15. */
|
|
|
e354a5 |
+ return 13;
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+static int
|
|
|
e354a5 |
+do_test (void)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ int level = compute_level ();
|
|
|
e354a5 |
+ printf ("info: detected architecture level: arch%d\n", level);
|
|
|
e354a5 |
+ TEST_COMPARE (marker2 (), MIN (level - 9, 2));
|
|
|
e354a5 |
+ TEST_COMPARE (marker3 (), MIN (level - 9, 3));
|
|
|
e354a5 |
+ TEST_COMPARE (marker4 (), MIN (level - 9, 4));
|
|
|
e354a5 |
+ return 0;
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#include <support/test-driver.c>
|