1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

S390: Influence hwcaps/stfle via GLIBC_TUNABLES.

This patch enables the option to influence hwcaps and stfle bits used
by the s390 specific ifunc-resolvers.  The currently x86-specific
tunable glibc.cpu.hwcaps is also used on s390x to achieve the task. In
addition the user can also set a CPU arch-level like z13 instead of
single HWCAP and STFLE features.

Note that the tunable only handles the features which are really used
in the IFUNC-resolvers.  All others are ignored as the values are only
used inside glibc.  Thus we can influence:
- HWCAP_S390_VXRS (z13)
- HWCAP_S390_VXRS_EXT (z14)
- HWCAP_S390_VXRS_EXT2 (z15)
- STFLE_MIE3 (z15)

The influenced hwcap/stfle-bits are stored in the s390-specific
cpu_features struct which also contains reserved fields for future
usage.

The ifunc-resolvers and users of stfle bits are adjusted to use the
information from cpu_features struct.

On 31bit, the ELF_MACHINE_IRELATIVE macro is now also defined.
Otherwise the new ifunc-resolvers segfaults as they depend on
the not yet processed_rtld_global_ro@GLIBC_PRIVATE relocation.
This commit is contained in:
Stefan Liebler
2023-02-02 14:57:50 +01:00
parent 0b9d2d4a76
commit 41f67ccbe9
12 changed files with 423 additions and 64 deletions

View File

@ -18,6 +18,7 @@
#include <unistd.h>
#include <dl-procinfo.h>
#include <cpu-features.h>
static long int linux_sysconf (int name);
@ -44,12 +45,14 @@ get_cache_info (int level, int attr, int type)
|| type < CACHE_TYPE_DATA || type > CACHE_TYPE_INSTRUCTION)
return 0L;
const struct cpu_features *features = &GLRO(dl_s390_cpu_features);
/* Check if ecag-instruction is available.
ecag - extract CPU attribute (only in zarch; arch >= z10; in as 2.24) */
if (!(GLRO (dl_hwcap) & HWCAP_S390_STFLE)
if (!(features->hwcap & HWCAP_S390_STFLE)
#if !defined __s390x__
|| !(GLRO (dl_hwcap) & HWCAP_S390_ZARCH)
|| !(GLRO (dl_hwcap) & HWCAP_S390_HIGH_GPRS)
|| !(features->hwcap & HWCAP_S390_ZARCH)
|| !(features->hwcap & HWCAP_S390_HIGH_GPRS)
#endif /* !__s390x__ */
)
{
@ -62,25 +65,7 @@ get_cache_info (int level, int attr, int type)
return 0L;
}
/* Store facility list and check for z10.
(see ifunc-resolver for details) */
register unsigned long reg0 __asm__("0") = 0;
#ifdef __s390x__
unsigned long stfle_bits;
# define STFLE_Z10_MASK (1UL << (63 - 34))
#else
unsigned long long stfle_bits;
# define STFLE_Z10_MASK (1ULL << (63 - 34))
#endif /* !__s390x__ */
__asm__ __volatile__(".machine push" "\n\t"
".machinemode \"zarch_nohighgprs\"\n\t"
".machine \"z9-109\"" "\n\t"
"stfle %0" "\n\t"
".machine pop" "\n"
: "=QS" (stfle_bits), "+d" (reg0)
: : "cc");
if (!(stfle_bits & STFLE_Z10_MASK))
if (!S390_IS_Z10 (features->stfle_bits))
{
/* We are at least on a z9 machine.
Return 256byte for LINESIZE for L1 d/i-cache,