]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390: STFLE related cleanups (BZ 509562)
authorFlorian Krohm <flo2030@eich-krohm.de>
Fri, 21 Nov 2025 16:54:13 +0000 (16:54 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Fri, 21 Nov 2025 16:54:13 +0000 (16:54 +0000)
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

VEX/priv/guest_s390_toIR.c
VEX/priv/host_s390_defs.h
VEX/priv/main_main.c
VEX/pub/libvex.h
VEX/pub/libvex_emnote.h
coregrind/m_machine.c
none/tests/s390x/stfle.vgtest
tests/s390x_features.c

index 7df56428ee7dc06da0bf206ce90f4e916c6cfd55..5693fd9c190cbec791404f4bd2e9519b0bad9f40 100644 (file)
@@ -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";
 }
index 8fc1a94b9dc59919be7d212f4c77ab5e68df7afe..eaf8a29bfec15619157a698dcc7a2fd7833bf2b6 100644 (file)
@@ -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 \
index c40e642b99cbae4d5c276236df1a7c80e31d8f38..917411558672f00fee8b95b43e80a5b0d09278e9 100644 (file)
@@ -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" },
index a3345af5b8dcf5def6d6be537ef4732c9f72e16f..46001f1050a46acc17befca21a712f8cc04181f2 100644 (file)
@@ -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  | \
index fa6c5bf5c18a3ff2a9f32fad1510871031327dbd..ea452970afb3ae3a9d274e7ffe87b01000125218 100644 (file)
@@ -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,
 
index 73dfaf8ea8bf0622033c3301b6d56db3b0485e3c..711538c07c4e360eea6807cad6f34fcfb501043e 100644 (file)
@@ -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"   },
index 458793df378e38ada5acfe85165be6e5024706f0..5a48c07e6e3de8b817fa0a75eed0e9027ca87dff 100644 (file)
@@ -1,2 +1 @@
 prog:stfle
-prereq: ../../../tests/s390x_features s390x-stfle z196:
index cad15885303252ad452288eba3dd353aa3b85467..1dda2f01f0ac8d7384e3eea1e94c6be519d55e64 100644 (file)
@@ -1,7 +1,5 @@
 /* -*- mode: C; c-basic-offset: 3; -*- */
 
-#include <setjmp.h>
-#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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 ) {