]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390x: Fix BZ 496950
authorFlorian Krohm <flo2030@eich-krohm.de>
Wed, 12 Mar 2025 23:10:06 +0000 (23:10 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Wed, 12 Mar 2025 23:10:06 +0000 (23:10 +0000)
Adding a new hardware capability requires changes in several places.
Generally for a new FOO hardware capability:
- add VEX_HWCAPS_S390X_FOO and update VEX_HWCAPS_S390X_ALL in libvex.h
- test the corresponding facility bit in m_machine.c
- add s390_host_has_foo in host_s390_defs.h
- if an insn requiring FOO cannot be implemented on the host by other means
  - add EmFail_S390X_foo in libvex_emnote.h
- handle EmFail_S390X_foo in main_main.c
- update function show_hwcaps_s390x

Occasionally something gets forgotten and this patch adds the forgotten
pieces.
Also add new hardware capabilities vxe2, vxd, msa, msa4, msa8, msa9

Fixes: https://bugs.kde.org/show_bug.cgi?id=496950
NEWS
VEX/priv/host_s390_defs.h
VEX/priv/main_main.c
VEX/pub/libvex.h
VEX/pub/libvex_emnote.h
coregrind/m_extension/extension-s390x.c
coregrind/m_machine.c

diff --git a/NEWS b/NEWS
index 7025d61af7f6fc673b54ccf5d1df6db5e950346e..e6a285585201155c1a75c81f08059fd140b20d0c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -44,6 +44,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 495816  s390x: Fix disassembler segfault for C[G]RT and CL[G]RT
 496370  Illumos: signal handling is broken
 496571  False positive for null key passed to bpf_map_get_next_key syscall.
+496950  s390x: Fix hardware capabilities and EmFail codes
 497130  Recognize new DWARF5 DW_LANG constants
 497455  Update drd/scripts/download-and-build-gcc
 497723  Enabling Ada demangling breaks callgrind differentiation between
index 957585c396d4145b17f4c3eeb45a9f4732faa23c..dcdb6713e98d7a1b8af403e207534dc2e53afee7 100644 (file)
@@ -939,6 +939,8 @@ extern UInt s390_host_hwcaps;
                       (s390_host_hwcaps & (VEX_HWCAPS_S390X_VX))
 #define s390_host_has_msa5 \
                       (s390_host_hwcaps & (VEX_HWCAPS_S390X_MSA5))
+#define s390_host_has_mi2 \
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_MI2))
 #define s390_host_has_lsc2 \
                       (s390_host_hwcaps & (VEX_HWCAPS_S390X_LSC2))
 #define s390_host_has_vxe \
@@ -947,6 +949,18 @@ extern UInt s390_host_hwcaps;
                       (s390_host_hwcaps & (VEX_HWCAPS_S390X_NNPA))
 #define s390_host_has_dflt \
                       (s390_host_hwcaps & (VEX_HWCAPS_S390X_DFLT))
+#define s390_host_has_vxe2 \
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_VXE2))
+#define s390_host_has_vxd \
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_VXD))
+#define s390_host_has_msa \
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_MSA))
+#define s390_host_has_msa4 \
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_MSA4))
+#define s390_host_has_msa8 \
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_MSA8))
+#define s390_host_has_msa9 \
+                      (s390_host_hwcaps & (VEX_HWCAPS_S390X_MSA9))
 #endif /* ndef __VEX_HOST_S390_DEFS_H */
 
 /*---------------------------------------------------------------*/
index 91bb3bbbff7ac75bca8b326116f41790c985e281..80f6d6a6d6916fd7cb73f6e0b0f348202d8f9c74 100644 (file)
@@ -1561,7 +1561,45 @@ const HChar* LibVEX_EmNote_string ( VexEmNote ew )
      case EmFail_S390X_vx:
         return "Encountered an instruction that requires the vector facility.\n"
                "  That facility is not available on this host";
-     default: 
+     case EmFail_S390X_ppno:
+        return "Instruction ppno is not supported on this host.";
+     case EmFail_S390X_vxe:
+        return "Encountered an instruction that requires the vector-extensions"
+               " facility 1.\n"
+               "  That facility is not available on this host";
+     case EmFail_S390X_dflt:
+        return "Encountered an instruction that requires the deflate-conversion"
+               " facility.\n"
+               "  That facility is not available on this host";
+     case EmFail_S390X_nnpa:
+        return "Encountered an instruction that requires the"
+               " neural-network-processing-assist facility.\n"
+               "  That facility is not available on this host";
+     case EmFail_S390X_vxe2:
+        return "Encountered an instruction that requires the vector-extensions\n"
+               " facility 2.\n"
+               "  That facility is not available on this host";
+     case EmFail_S390X_vxd:
+        return "Encountered an instruction that requires the vector-packed-decimal\n"
+               " facility.\n"
+               "  That facility is not available on this host";
+     case EmFail_S390X_msa:
+        return "Encountered an instruction that requires the message-security"
+               " assist.\n"
+               "  That assist is not available on this host";
+     case EmFail_S390X_msa4:
+        return "Encountered an instruction that requires the"
+               " message-security-assist extension 4.\n"
+               "  That extension is not available on this host";
+     case EmFail_S390X_msa8:
+        return "Encountered an instruction that requires the"
+               " message-security-assist extension 8.\n"
+               "  That extension is not available on this host";
+     case EmFail_S390X_msa9:
+        return "Encountered an instruction that requires the"
+               " message-security-assist extension 9.\n"
+               "  That extension is not available on this host";
+     default:
         vpanic("LibVEX_EmNote_string: unknown warning");
    }
 }
@@ -1894,7 +1932,14 @@ static const HChar* show_hwcaps_s390x ( UInt hwcaps )
       { VEX_HWCAPS_S390X_MI2,   "mi2" },
       { VEX_HWCAPS_S390X_LSC2,  "lsc2" },
       { VEX_HWCAPS_S390X_VXE,   "vxe" },
+      { VEX_HWCAPS_S390X_NNPA,  "nnpa" },
       { VEX_HWCAPS_S390X_DFLT,  "dflt" },
+      { VEX_HWCAPS_S390X_VXE2,  "vxe2" },
+      { VEX_HWCAPS_S390X_VXD,   "vxd" },
+      { VEX_HWCAPS_S390X_MSA,   "msa" },
+      { VEX_HWCAPS_S390X_MSA4,  "msa4" },
+      { VEX_HWCAPS_S390X_MSA8,  "msa8" },
+      { VEX_HWCAPS_S390X_MSA9,  "msa9" },
    };
    /* Allocate a large enough buffer */
    static HChar buf[sizeof prefix + 
index d99be23a02e77add048a59b034d6faf85cd0f1db..2dbfbe770e2b47a94c2cbf88afeddd0fa5a944fb 100644 (file)
@@ -134,7 +134,7 @@ typedef
 /* s390x: Hardware capability encoding
 
    Bits [26:31] encode the machine model (see VEX_S390X_MODEL... below)
-   Bits [0:20]  encode specific hardware capabilities
+   Bits [0:25]  encode specific hardware capabilities
                 (see VEX_HWAPS_S390X_... below)
 */
 
@@ -174,12 +174,18 @@ typedef
 #define VEX_HWCAPS_S390X_LSC   (1<<16)  /* Conditional load/store facility */
 #define VEX_HWCAPS_S390X_PFPO  (1<<17)  /* Perform floating point ops facility */
 #define VEX_HWCAPS_S390X_VX    (1<<18)  /* Vector facility */
-#define VEX_HWCAPS_S390X_MSA5  (1<<19)  /* message security assistance facility */
-#define VEX_HWCAPS_S390X_MI2   (1<<20)  /* miscellaneous-instruction-extensions facility 2 */
+#define VEX_HWCAPS_S390X_MSA5  (1<<19)  /* Message-security-assistance facility 5 */
+#define VEX_HWCAPS_S390X_MI2   (1<<20)  /* Miscellaneous-instruction-extensions facility 2 */
 #define VEX_HWCAPS_S390X_LSC2  (1<<21)  /* Conditional load/store facility2 */
 #define VEX_HWCAPS_S390X_VXE   (1<<22)  /* Vector-enhancements facility */
 #define VEX_HWCAPS_S390X_NNPA  (1<<23)  /* NNPA facility */
 #define VEX_HWCAPS_S390X_DFLT  (1<<24)  /* Deflate-conversion facility */
+#define VEX_HWCAPS_S390X_VXE2  (1<<25)  /* Vector-enhancements facility 2 */
+#define VEX_HWCAPS_S390X_VXD   (1<<26)  /* Vector packed-decimal facility */
+#define VEX_HWCAPS_S390X_MSA   (1<<27)  /* Message-security assist */
+#define VEX_HWCAPS_S390X_MSA4  (1<<28)  /* Message-security-assist extension 4 */
+#define VEX_HWCAPS_S390X_MSA8  (1<<29)  /* Message-security-assist extension 8 */
+#define VEX_HWCAPS_S390X_MSA9  (1<<30)  /* Message-security-assist extension 9 */
 
 /* Special value representing all available s390x hwcaps */
 #define VEX_HWCAPS_S390X_ALL   (VEX_HWCAPS_S390X_LDISP | \
@@ -200,7 +206,13 @@ typedef
                                 VEX_HWCAPS_S390X_LSC2  | \
                                 VEX_HWCAPS_S390X_VXE   | \
                                 VEX_HWCAPS_S390X_NNPA  | \
-                                VEX_HWCAPS_S390X_DFLT)
+                                VEX_HWCAPS_S390X_DFLT  | \
+                                VEX_HWCAPS_S390X_VXE2  | \
+                                VEX_HWCAPS_S390X_VXD   | \
+                                VEX_HWCAPS_S390X_MSA   | \
+                                VEX_HWCAPS_S390X_MSA4  | \
+                                VEX_HWCAPS_S390X_MSA8  | \
+                                VEX_HWCAPS_S390X_MSA9)
 
 #define VEX_HWCAPS_S390X(x)  ((x) & ~VEX_S390X_MODEL_MASK)
 #define VEX_S390X_MODEL(x)   ((x) &  VEX_S390X_MODEL_MASK)
index 77880a2702843d9057e4ed114cefbf4405fa51ad..c3ebcf420349fc53d9c8ed359d4e990dc58de908 100644 (file)
@@ -124,10 +124,42 @@ typedef
       /* ppno insn is not supported on this host */
       EmFail_S390X_ppno,
 
-      /* insn needs vector-enhancements facility which is not available on this
-         host */
+      /* insn needs vector-enhancements facility 1 which is not available on
+         this host */
       EmFail_S390X_vxe,
 
+      /* insn needs deflate-conversion facility which is not available on
+         this host */
+      EmFail_S390X_dflt,
+
+      /* insn needs neural-network-processing-assist facility which is not
+         available on this host */
+      EmFail_S390X_nnpa,
+
+      /* insn needs vector-enhancements facility 2 which is not available on
+         this host */
+      EmFail_S390X_vxe2,
+
+      /* insn needs vector-packed-decimal facility which is not available on
+         this host */
+      EmFail_S390X_vxd,
+
+      /* insn needs message-security assist which is not available on
+         this host */
+      EmFail_S390X_msa,
+
+      /* insn needs message-security-assist extension 4 which is not available
+         on this host */
+      EmFail_S390X_msa4,
+
+      /* insn needs message-security-assist extension 8 which is not available
+         on this host */
+      EmFail_S390X_msa8,
+
+      /* insn needs message-security-assist extension 9 which is not available
+         on this host */
+      EmFail_S390X_msa9,
+
       EmNote_NUMBER
    }
    VexEmNote;
index 34e2e0409d8090a2a6d3af0ff603e17f2d78dd5c..8a17c6fbddef5a9dbbeaa7d0546c13a783fbf957 100644 (file)
@@ -862,8 +862,7 @@ static enum ExtensionError do_extension_STFLE(ThreadState* tst, ULong variant)
       (S390_SETBITS(128, 131)
        /* 132: unassigned */
        /* 133: guarded-storage, not supported */
-       /* 134: vector packed decimal, not supported */
-       | S390_SETBITS(135, 135)
+       | S390_SETBITS(134, 135)
        /* 136: unassigned */
        /* 137: unassigned */
        | S390_SETBITS(138, 142)
index 3b3671455f5111368f4709f02c28b2e1759c5afd..eaa18b0b61f018c6f5d13d1a07c97185b24ae960 100644 (file)
@@ -1620,11 +1620,13 @@ Bool VG_(machine_get_hwcaps)( void )
         UInt hwcaps_bit;
         const HChar name[6];   // may need adjustment for new facility names
      } fac_hwcaps[] = {
+        { False,  18,  VEX_HWCAPS_S390X_LDISP, "LDISP" },
         { False,  21,  VEX_HWCAPS_S390X_EIMM,  "EIMM"  },
         { False,  34,  VEX_HWCAPS_S390X_GIE,   "GIE"   },
         { 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,  25,  VEX_HWCAPS_S390X_STCKF, "STCKF" },
         { False,  37,  VEX_HWCAPS_S390X_FPEXT, "FPEXT" },
@@ -1637,6 +1639,12 @@ Bool VG_(machine_get_hwcaps)( void )
         { False, 135,  VEX_HWCAPS_S390X_VXE,   "VXE"   },
         { False, 151,  VEX_HWCAPS_S390X_DFLT,  "DFLT"  },
         { False, 165,  VEX_HWCAPS_S390X_NNPA,  "NNPA"  },
+        { False, 148,  VEX_HWCAPS_S390X_VXE2,  "VXE2"  },
+        { False, 134,  VEX_HWCAPS_S390X_VXD,   "VXD"   },
+        { False,  17,  VEX_HWCAPS_S390X_MSA,   "MSA"   },
+        { False,  77,  VEX_HWCAPS_S390X_MSA4,  "MSA4"  },
+        { False, 146,  VEX_HWCAPS_S390X_MSA8,  "MSA8"  },
+        { False, 155,  VEX_HWCAPS_S390X_MSA9,  "MSA9"  },
      };
 
      /* Set hwcaps according to the detected facilities */