From: Florian Krohm Date: Fri, 21 Nov 2025 16:54:13 +0000 (+0000) Subject: s390: STFLE related cleanups (BZ 509562) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bd977bff8a394600fa532e5ab71d6b5ffe9f3c9;p=thirdparty%2Fvalgrind.git s390: STFLE related cleanups (BZ 509562) The STFLE insn is always present on the supported machines. - Remove s390_host_has_stfle, VEX_HWCAPS_S390X_STFLE, and EmFail_S390X_stfle - Update tests/s390x_features.c Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562 --- diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index 7df56428e..5693fd9c1 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -15825,10 +15825,6 @@ s390_irgen_STCKE(IRTemp op2addr) static const HChar * s390_irgen_STFLE(UChar b2, UShort d2) { - if (! s390_host_has_stfle) { - emulation_failure(EmFail_S390X_stfle); - return "stfle"; - } extension(S390_EXT_STFLE, b2 | (d2 << 8)); return "stfle"; } diff --git a/VEX/priv/host_s390_defs.h b/VEX/priv/host_s390_defs.h index 8fc1a94b9..eaf8a29bf 100644 --- a/VEX/priv/host_s390_defs.h +++ b/VEX/priv/host_s390_defs.h @@ -928,8 +928,6 @@ extern UInt s390_host_hwcaps; (s390_host_hwcaps & (VEX_HWCAPS_S390X_FGX)) #define s390_host_has_etf2 \ (s390_host_hwcaps & (VEX_HWCAPS_S390X_ETF2)) -#define s390_host_has_stfle \ - (s390_host_hwcaps & (VEX_HWCAPS_S390X_STFLE)) #define s390_host_has_etf3 \ (s390_host_hwcaps & (VEX_HWCAPS_S390X_ETF3)) #define s390_host_has_fpext \ diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index c40e642b9..917411558 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -1549,8 +1549,6 @@ const HChar* LibVEX_EmNote_string ( VexEmNote ew ) return "Encountered an insn with the IEEE-invalid-operation-exception\n" " control (XiC) bit set to 1. This is not supported. Continuing anyway.\n" " IEEE-invalid-operation exceptions will not be suppressed."; - case EmFail_S390X_stfle: - return "Instruction stfle is not supported on this host"; case EmFail_S390X_pfpo: return "Instruction pfpo is not supported on this host"; case EmFail_S390X_DFP_insn: @@ -1927,7 +1925,6 @@ static const HChar* show_hwcaps_s390x ( UInt hwcaps ) { VEX_HWCAPS_S390X_GIE, "gie" }, { VEX_HWCAPS_S390X_DFP, "dfp" }, { VEX_HWCAPS_S390X_FGX, "fgx" }, - { VEX_HWCAPS_S390X_STFLE, "stfle" }, { VEX_HWCAPS_S390X_ETF2, "etf2" }, { VEX_HWCAPS_S390X_ETF3, "etf3" }, { VEX_HWCAPS_S390X_FPEXT, "fpext" }, diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index a3345af5b..46001f105 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -167,7 +167,6 @@ typedef #define VEX_HWCAPS_S390X_DFP (1<<9) /* Decimal floating point facility */ #define VEX_HWCAPS_S390X_FGX (1<<10) /* FPR-GR transfer facility */ #define VEX_HWCAPS_S390X_ETF2 (1<<11) /* ETF2-enhancement facility */ -#define VEX_HWCAPS_S390X_STFLE (1<<12) /* STFLE facility */ #define VEX_HWCAPS_S390X_ETF3 (1<<13) /* ETF3-enhancement facility */ #define VEX_HWCAPS_S390X_FPEXT (1<<15) /* Floating point extension facility */ #define VEX_HWCAPS_S390X_LSC (1<<16) /* Conditional load/store facility */ @@ -191,7 +190,6 @@ typedef VEX_HWCAPS_S390X_GIE | \ VEX_HWCAPS_S390X_DFP | \ VEX_HWCAPS_S390X_FGX | \ - VEX_HWCAPS_S390X_STFLE | \ VEX_HWCAPS_S390X_FPEXT | \ VEX_HWCAPS_S390X_LSC | \ VEX_HWCAPS_S390X_ETF3 | \ diff --git a/VEX/pub/libvex_emnote.h b/VEX/pub/libvex_emnote.h index fa6c5bf5c..ea452970a 100644 --- a/VEX/pub/libvex_emnote.h +++ b/VEX/pub/libvex_emnote.h @@ -99,9 +99,6 @@ typedef in VEX and is expected to be zero. */ EmWarn_S390X_XiC_not_zero, - /* stfle insn is not supported on this host */ - EmFail_S390X_stfle, - /* pfpo insn is not supported on this host */ EmFail_S390X_pfpo, diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c index 73dfaf8ea..711538c07 100644 --- a/coregrind/m_machine.c +++ b/coregrind/m_machine.c @@ -513,10 +513,10 @@ Int VG_(machine_arm_archlevel) = 4; #endif -/* For hwcaps detection on ppc32/64, s390x, and arm we'll need to do SIGILL +/* For hwcaps detection on ppc32/64, mips and arm we'll need to do SIGILL testing, so we need a VG_MINIMAL_JMP_BUF. */ #if defined(VGA_ppc32) || defined(VGA_ppc64be) || defined(VGA_ppc64le) \ - || defined(VGA_arm) || defined(VGA_s390x) || defined(VGA_mips32) \ + || defined(VGA_arm) || defined(VGA_mips32) \ || defined(VGA_mips64) || defined(VGA_arm64) #include "pub_core_libcsetjmp.h" static VG_MINIMAL_JMP_BUF(env_unsup_insn); @@ -1533,8 +1533,7 @@ Bool VG_(machine_get_hwcaps)( void ) vki_sigaction_fromK_t saved_sigill_act; vki_sigaction_toK_t tmp_sigill_act; - volatile Bool have_STFLE; - Int i, r, model; + Int i, model; /* If the model is "unknown" don't treat this as an error. Assume this is a brand-new machine model for which we don't have the @@ -1547,63 +1546,24 @@ Bool VG_(machine_get_hwcaps)( void ) VG_(exit)(1); } - /* Unblock SIGILL and stash away the old action for that signal */ - VG_(sigemptyset)(&tmp_set); - VG_(sigaddset)(&tmp_set, VKI_SIGILL); - - r = VG_(sigprocmask)(VKI_SIG_UNBLOCK, &tmp_set, &saved_set); - vg_assert(r == 0); - - r = VG_(sigaction)(VKI_SIGILL, NULL, &saved_sigill_act); - vg_assert(r == 0); - tmp_sigill_act = saved_sigill_act; - - /* NODEFER: signal handler does not return (from the kernel's point of - view), hence if it is to successfully catch a signal more than once, - we need the NODEFER flag. */ - tmp_sigill_act.sa_flags &= ~VKI_SA_RESETHAND; - tmp_sigill_act.sa_flags &= ~VKI_SA_SIGINFO; - tmp_sigill_act.sa_flags |= VKI_SA_NODEFER; - tmp_sigill_act.ksa_handler = handler_unsup_insn; - VG_(sigaction)(VKI_SIGILL, &tmp_sigill_act, NULL); - - /* Determine hwcaps. Note, we cannot use the stfle insn because it - is not supported on z900. */ - - /* Check availability of STFLE. If available store facility bits - in hoststfle. */ ULong hoststfle[S390_NUM_FACILITY_DW]; for (i = 0; i < S390_NUM_FACILITY_DW; ++i) hoststfle[i] = 0; - have_STFLE = True; - if (VG_MINIMAL_SETJMP(env_unsup_insn)) { - have_STFLE = False; - } else { - register ULong reg0 asm("0") = S390_NUM_FACILITY_DW - 1; + register ULong reg0 asm("0") = S390_NUM_FACILITY_DW - 1; - __asm__(".insn s,0xb2b00000,%0" /* stfle */ + __asm__(".insn s,0xb2b00000,%0" /* stfle */ : "=Q"(hoststfle), "+d"(reg0) : : "cc"); - } - /* Restore signals */ - r = VG_(sigaction)(VKI_SIGILL, &saved_sigill_act, NULL); - vg_assert(r == 0); - r = VG_(sigprocmask)(VKI_SIG_SETMASK, &saved_set, NULL); - vg_assert(r == 0); va = VexArchS390X; vai.endness = VexEndnessBE; vai.hwcaps = model; - if (have_STFLE) vai.hwcaps |= VEX_HWCAPS_S390X_STFLE; - /* Detect presence of certain facilities using the STFLE insn. - Note, that these facilities were introduced at the same time or later - as STFLE, so the absence of STLFE implies the absence of the facility - we're trying to detect. */ + /* Detect presence of certain facilities using the STFLE insn. */ struct fac_hwcaps_map { UInt installed; UInt facility_bit; @@ -1615,7 +1575,6 @@ Bool VG_(machine_get_hwcaps)( void ) { False, 42, VEX_HWCAPS_S390X_DFP, "DFP" }, { False, 41, VEX_HWCAPS_S390X_FGX, "FGX" }, { False, 24, VEX_HWCAPS_S390X_ETF2, "ETF2" }, - { False, 7, VEX_HWCAPS_S390X_STFLE, "STFLE" }, { False, 30, VEX_HWCAPS_S390X_ETF3, "ETF3" }, { False, 37, VEX_HWCAPS_S390X_FPEXT, "FPEXT" }, { False, 45, VEX_HWCAPS_S390X_LSC, "LSC" }, diff --git a/none/tests/s390x/stfle.vgtest b/none/tests/s390x/stfle.vgtest index 458793df3..5a48c07e6 100644 --- a/none/tests/s390x/stfle.vgtest +++ b/none/tests/s390x/stfle.vgtest @@ -1,2 +1 @@ prog:stfle -prereq: ../../../tests/s390x_features s390x-stfle z196: diff --git a/tests/s390x_features.c b/tests/s390x_features.c index cad158853..1dda2f01f 100644 --- a/tests/s390x_features.c +++ b/tests/s390x_features.c @@ -1,7 +1,5 @@ /* -*- mode: C; c-basic-offset: 3; -*- */ -#include -#include #include #include #include @@ -40,8 +38,6 @@ // z900:z9 -- Host needs to be at least a z900 and at most a z9. // Any model in between is OK, too. -jmp_buf env; - #if defined(VGA_s390x) // Features that require kernel support should be checked against HWCAP instead @@ -58,11 +54,6 @@ jmp_buf env; /* Number of double words needed to store all facility bits. */ #define S390_NUM_FACILITY_DW 3 -void handle_sigill(int signum) -{ - longjmp(env, 1); -} - static void clear_facilities(unsigned long long *ret) { unsigned int index; @@ -74,15 +65,9 @@ static void clear_facilities(unsigned long long *ret) void stfle(unsigned long long *ret) { - signal(SIGILL, handle_sigill); - if (setjmp(env)) { - /* stfle not available: assume no facilities */ - clear_facilities(ret); - } else { - register unsigned long long r0 asm("0") = S390_NUM_FACILITY_DW - 1; - asm volatile(".insn s,0xb2b00000,%0\n" /* stfle */ - : "=m" (*ret), "+d"(r0) :: "cc", "memory"); - } + register unsigned long long r0 asm("0") = S390_NUM_FACILITY_DW - 1; + asm volatile(".insn s,0xb2b00000,%0\n" /* stfle */ + : "=m" (*ret), "+d"(r0) :: "cc", "memory"); } @@ -244,8 +229,6 @@ static int go(char *feature, char *cpu) match = (facilities[0] & FAC_BIT(1)) && (facilities[0] & FAC_BIT(2)); } else if (strcmp(feature, "s390x-n3") == 0 ) { match = facilities[0] & FAC_BIT(0); - } else if (strcmp(feature, "s390x-stfle") == 0 ) { - match = facilities[0] & FAC_BIT(7); } else if (strcmp(feature, "s390x-eimm") == 0 ) { match = facilities[0] & FAC_BIT(21); } else if (strcmp(feature, "s390x-genins") == 0 ) {