From: Florian Krohm Date: Wed, 12 Mar 2025 23:10:06 +0000 (+0000) Subject: s390x: Fix BZ 496950 X-Git-Tag: VALGRIND_3_25_0~104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=744e47c8ff5bd9a7908b63b9d053b32bac18d686;p=thirdparty%2Fvalgrind.git s390x: Fix BZ 496950 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 --- diff --git a/NEWS b/NEWS index 7025d61af..e6a285585 100644 --- 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 diff --git a/VEX/priv/host_s390_defs.h b/VEX/priv/host_s390_defs.h index 957585c39..dcdb6713e 100644 --- a/VEX/priv/host_s390_defs.h +++ b/VEX/priv/host_s390_defs.h @@ -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 */ /*---------------------------------------------------------------*/ diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index 91bb3bbbf..80f6d6a6d 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -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 + diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index d99be23a0..2dbfbe770 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -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) diff --git a/VEX/pub/libvex_emnote.h b/VEX/pub/libvex_emnote.h index 77880a270..c3ebcf420 100644 --- a/VEX/pub/libvex_emnote.h +++ b/VEX/pub/libvex_emnote.h @@ -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; diff --git a/coregrind/m_extension/extension-s390x.c b/coregrind/m_extension/extension-s390x.c index 34e2e0409..8a17c6fbd 100644 --- a/coregrind/m_extension/extension-s390x.c +++ b/coregrind/m_extension/extension-s390x.c @@ -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) diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c index 3b3671455..eaa18b0b6 100644 --- a/coregrind/m_machine.c +++ b/coregrind/m_machine.c @@ -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 */