|
From: Florian K. <fk...@so...> - 2025-11-25 09:14:37
|
https://sourceware.org/cgit/valgrind/commit/?id=2acc312dbcc098a9e33adcbbc309c6a7edfa9d41 commit 2acc312dbcc098a9e33adcbbc309c6a7edfa9d41 Author: Florian Krohm <fl...@ei...> Date: Tue Nov 25 09:14:11 2025 +0000 s390: general-instructions-extension facility related cleanups (BZ 509562) The general-instructions-extension facility is always present on the supported machines. - Remove VEX_HWCAPS_S390X_GIE and s390_host_has_gie - Remove wrapper functions: s390_emit_MFYw, s390_emit_MHYw, s390_emit_MSFIw - Update tests/s390x_features.c Part of fixing https://bugs.kde.org/show_bug.cgi?id=509562 Diff: --- VEX/priv/host_s390_defs.c | 101 +++++----------------------------------------- VEX/priv/host_s390_defs.h | 2 - VEX/priv/host_s390_isel.c | 2 +- VEX/priv/main_main.c | 1 - VEX/pub/libvex.h | 4 +- coregrind/m_machine.c | 1 - tests/s390x_features.c | 2 - 7 files changed, 12 insertions(+), 101 deletions(-) diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index 7b8dbe63db..dde8d65466 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -2108,8 +2108,6 @@ s390_emit_AGHI(UChar *p, UChar r1, UShort i2) static UChar * s390_emit_AGSI(UChar *p, UChar i2, UChar b1, UShort dl1, UChar dh1) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("agsi"), SDXB(dh1, dl1, 0, b1), INT((Int)(Char)i2)); @@ -2120,8 +2118,6 @@ s390_emit_AGSI(UChar *p, UChar i2, UChar b1, UShort dl1, UChar dh1) static UChar * s390_emit_ASI(UChar *p, UChar i2, UChar b1, UShort dl1, UChar dh1) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("asi"), SDXB(dh1, dl1, 0, b1), INT((Int)(Char)i2)); @@ -3092,8 +3088,6 @@ s390_emit_M(UChar *p, UChar r1, UChar x2, UChar b2, UShort d2) static UChar * s390_emit_MFY(UChar *p, UChar r1, UChar x2, UChar b2, UShort dl2, UChar dh2) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("mfy"), GPR(r1), SDXB(dh2, dl2, x2, b2)); @@ -3134,8 +3128,6 @@ s390_emit_MH(UChar *p, UChar r1, UChar x2, UChar b2, UShort d2) static UChar * s390_emit_MHY(UChar *p, UChar r1, UChar x2, UChar b2, UShort dl2, UChar dh2) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("mhy"), GPR(r1), SDXB(dh2, dl2, x2, b2)); @@ -3246,8 +3238,6 @@ s390_emit_MSG(UChar *p, UChar r1, UChar x2, UChar b2, UShort dl2, UChar dh2) static UChar * s390_emit_MSFI(UChar *p, UChar r1, UInt i2) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("msfi"), GPR(r1), INT(i2)); @@ -3258,8 +3248,6 @@ s390_emit_MSFI(UChar *p, UChar r1, UInt i2) static UChar * s390_emit_MSGFI(UChar *p, UChar r1, UInt i2) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("msgfi"), GPR(r1), INT(i2)); @@ -3290,8 +3278,6 @@ s390_emit_MVI(UChar *p, UChar i2, UChar b1, UShort d1) static UChar * s390_emit_MVHHI(UChar *p, UChar b1, UShort d1, UShort i2) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("mvhhi"), UDXB(d1, 0, b1), INT((Int)(Short)i2)); @@ -3302,8 +3288,6 @@ s390_emit_MVHHI(UChar *p, UChar b1, UShort d1, UShort i2) static UChar * s390_emit_MVHI(UChar *p, UChar b1, UShort d1, UShort i2) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("mvhi"), UDXB(d1, 0, b1), INT((Int)(Short)i2)); @@ -3314,8 +3298,6 @@ s390_emit_MVHI(UChar *p, UChar b1, UShort d1, UShort i2) static UChar * s390_emit_MVGHI(UChar *p, UChar b1, UShort d1, UShort i2) { - vassert(s390_host_has_gie); - if (UNLIKELY(vex_traceflags & VEX_TRACE_ASM)) S390_DISASM(MNM("mvghi"), UDXB(d1, 0, b1), INT((Int)(Short)i2)); @@ -5107,46 +5089,6 @@ s390_emit_load_32imm(UChar *p, UChar reg, UInt val) /*--- Wrapper functions ---*/ /*------------------------------------------------------------*/ -/* r1[32:63],r1+1[32:63] = r1+1[32:63] * memory[op2addr][0:31] */ -static UChar * -s390_emit_MFYw(UChar *p, UChar r1, UChar x, UChar b, UShort dl, UChar dh) -{ - if (s390_host_has_gie) { - return s390_emit_MFY(p, r1, x, b, dl, dh); - } - - /* Load from memory into R0, then MULTIPLY with R1 */ - p = s390_emit_LY(p, R0, x, b, dl, dh); - return s390_emit_MR(p, r1, R0); -} - -/* r1[32:63] = r1[32:63] * memory[op2addr][0:15] */ -static UChar * -s390_emit_MHYw(UChar *p, UChar r1, UChar x, UChar b, UShort dl, UChar dh) -{ - if (s390_host_has_gie) { - return s390_emit_MHY(p, r1, x, b, dl, dh); - } - - /* Load from memory into R0, then MULTIPLY with R1 */ - p = s390_emit_LHY(p, R0, x, b, dl, dh); - return s390_emit_MSR(p, r1, R0); -} - -/* r1[32:63] = r1[32:63] * i2 */ -static UChar * -s390_emit_MSFIw(UChar *p, UChar r1, UInt i2) -{ - if (s390_host_has_gie) { - return s390_emit_MSFI(p, r1, i2); - } - - /* Load I2 into R0; then MULTIPLY R0 with R1 */ - p = s390_emit_load_32imm(p, R0, i2); - return s390_emit_MSR(p, r1, R0); -} - - static UChar * s390_emit_LGDRw(UChar *p, UChar r1, UChar r2) { @@ -6785,8 +6727,6 @@ s390_insn_madd(UChar size, s390_amode *dst, UChar delta, ULong value) /* This insn will be mapped to an ASI or AGSI so we can only allow base register plus 12-bit / 20-bit displacement. */ vassert(dst->tag == S390_AMODE_B12 || dst->tag == S390_AMODE_B20); - /* ASI and AGSI require the GIE facility */ - vassert(s390_host_has_gie); insn->tag = S390_INSN_MADD; insn->size = size; @@ -8173,17 +8113,8 @@ s390_insn_load_immediate_emit(UChar *buf, const s390_insn *insn) static UChar * s390_emit_ilih(UChar *buf, UChar size, UChar dst, UChar r2) { - if (s390_host_has_gie) - return s390_emit_RISBG(buf, dst, r2, 64 - 8 * size, 63 - 4 * size, - 4 * size); - - /* Clear dst's upper half. */ - buf = s390_emit_SLLG(buf, dst, dst, 0, DISP20(64 - 4 * size)); - buf = s390_emit_SRLG(buf, dst, dst, 0, DISP20(64 - 4 * size)); - - /* Shift r2 by appropriate amount and OR it into dst. */ - buf = s390_emit_SLLG(buf, R0, r2, 0, DISP20(4 * size)); - return s390_emit_OGR(buf, dst, R0); + return s390_emit_RISBG(buf, dst, r2, 64 - 8 * size, 63 - 4 * size, + 4 * size); } @@ -8366,7 +8297,7 @@ s390_insn_alu_emit(UChar *buf, const s390_insn *insn) return s390_emit_SHY(buf, dst, x, b, DISP20(d)); case S390_ALU_MUL: - return s390_emit_MHYw(buf, dst, x, b, DISP20(d)); + return s390_emit_MHY(buf, dst, x, b, DISP20(d)); /* For bitwise operations: Move two bytes from memory into scratch register r0; then perform operation */ @@ -8497,7 +8428,7 @@ s390_insn_alu_emit(UChar *buf, const s390_insn *insn) return s390_emit_AFI(buf, dst, value); case S390_ALU_SUB: return s390_emit_SLFI(buf, dst, value); - case S390_ALU_MUL: return s390_emit_MSFIw(buf, dst, value); + case S390_ALU_MUL: return s390_emit_MSFI(buf, dst, value); case S390_ALU_AND: return s390_emit_NILF(buf, dst, value); case S390_ALU_OR: return s390_emit_OILF(buf, dst, value); case S390_ALU_XOR: return s390_emit_XILF(buf, dst, value); @@ -8530,7 +8461,7 @@ s390_insn_alu_emit(UChar *buf, const s390_insn *insn) return s390_emit_SGR(buf, dst, R0); case S390_ALU_MUL: - if (ulong_fits_signed_32bit(value) && s390_host_has_gie) { + if (ulong_fits_signed_32bit(value)) { return s390_emit_MSGFI(buf, dst, value); } /* Load constant into R0 then add */ @@ -9367,7 +9298,7 @@ s390_insn_mul_emit(UChar *buf, const s390_insn *insn) case S390_AMODE_B20: case S390_AMODE_BX20: if (signed_multiply) - return s390_emit_MFYw(buf, r1, x, b, DISP20(d)); + return s390_emit_MFY(buf, r1, x, b, DISP20(d)); else return s390_emit_ML(buf, r1, x, b, DISP20(d)); } @@ -10329,7 +10260,7 @@ s390_insn_mimm_emit(UChar *buf, const s390_insn *insn) return s390_emit_MVI(buf, value & 0xFF, b, d); } - if (s390_host_has_gie && ulong_fits_signed_16bit(value)) { + if (ulong_fits_signed_16bit(value)) { value &= 0xFFFF; switch (insn->size) { case 2: return s390_emit_MVHHI(buf, b, d, value); @@ -10734,13 +10665,7 @@ s390_insn_evcheck_emit(UChar *buf, const s390_insn *insn, d = amode->d; /* Decrement the dispatch counter in the guest state */ - if (s390_host_has_gie) { - buf = s390_emit_ASI(buf, -1, b, DISP20(d)); /* 6 bytes */ - } else { - buf = s390_emit_LHI(buf, R0, -1); /* 4 bytes */ - buf = s390_emit_A(buf, R0, 0, b, d); /* 4 bytes */ - buf = s390_emit_ST(buf, R0, 0, b, d); /* 4 bytes */ - } + buf = s390_emit_ASI(buf, -1, b, DISP20(d)); /* 6 bytes */ /* Jump over the next insn if >= 0 */ buf = s390_emit_BRC(buf, S390_CC_HE, (4 + 6 + 2) / 2); /* 4 bytes */ @@ -10771,13 +10696,7 @@ s390_insn_profinc_emit(UChar *buf, template will be patched once the memory location is known. For now we do this with address == 0. */ buf = s390_tchain_load64(buf, S390_REGNO_TCHAIN_SCRATCH, 0); - if (s390_host_has_gie) { - buf = s390_emit_AGSI(buf, 1, S390_REGNO_TCHAIN_SCRATCH, DISP20(0)); - } else { - buf = s390_emit_LGHI(buf, R0, 1); - buf = s390_emit_AG( buf, R0, 0, S390_REGNO_TCHAIN_SCRATCH, DISP20(0)); - buf = s390_emit_STG(buf, R0, 0, S390_REGNO_TCHAIN_SCRATCH, DISP20(0)); - } + buf = s390_emit_AGSI(buf, 1, S390_REGNO_TCHAIN_SCRATCH, DISP20(0)); return buf; } @@ -11223,7 +11142,7 @@ emit_S390Instr(Bool *is_profinc, UChar *buf, Int nbuf, const s390_insn *insn, Int evCheckSzB_S390(void) { - return s390_host_has_gie ? 18 : 24; + return 18; } diff --git a/VEX/priv/host_s390_defs.h b/VEX/priv/host_s390_defs.h index 9b5e3f00ac..1845ccd002 100644 --- a/VEX/priv/host_s390_defs.h +++ b/VEX/priv/host_s390_defs.h @@ -918,8 +918,6 @@ VexInvalRange patchProfInc_S390(VexEndness endness_host, extern UInt s390_host_hwcaps; /* Convenience macros to test installed facilities */ -#define s390_host_has_gie \ - (s390_host_hwcaps & (VEX_HWCAPS_S390X_GIE)) #define s390_host_has_fgx \ (s390_host_hwcaps & (VEX_HWCAPS_S390X_FGX)) #define s390_host_has_lsc \ diff --git a/VEX/priv/host_s390_isel.c b/VEX/priv/host_s390_isel.c index a0d9b75373..9cb9b65d3b 100644 --- a/VEX/priv/host_s390_isel.c +++ b/VEX/priv/host_s390_isel.c @@ -5006,7 +5006,7 @@ s390_isel_stmt(ISelEnv *env, IRStmt *stmt) we can use a memory-to-memory insn */ difference = new_value - old_value; - if (s390_host_has_gie && ulong_fits_signed_8bit(difference)) { + if (ulong_fits_signed_8bit(difference)) { am = s390_amode_for_guest_state(offset); addInstr(env, s390_insn_madd(sizeofIRType(tyd), am, (difference & 0xFF), new_value)); diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index da3ccbd821..c1cda11038 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -1902,7 +1902,6 @@ static const HChar* show_hwcaps_s390x ( UInt hwcaps ) UInt hwcaps_bit; HChar name[6]; } hwcaps_list[] = { - { VEX_HWCAPS_S390X_GIE, "gie" }, { VEX_HWCAPS_S390X_FGX, "fgx" }, { VEX_HWCAPS_S390X_LSC, "lsc" }, { VEX_HWCAPS_S390X_PFPO, "pfpo" }, diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index cef40335ef..b5ae0ebcc7 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -162,7 +162,6 @@ typedef #define VEX_S390X_MODEL_UNKNOWN 19 /* always last in list */ #define VEX_S390X_MODEL_MASK 0x3F -#define VEX_HWCAPS_S390X_GIE (1<<8) /* General-instruction-extension facility */ #define VEX_HWCAPS_S390X_FGX (1<<10) /* FPR-GR transfer facility */ #define VEX_HWCAPS_S390X_LSC (1<<16) /* Conditional load/store facility */ #define VEX_HWCAPS_S390X_PFPO (1<<17) /* Perform floating point ops facility */ @@ -179,8 +178,7 @@ typedef #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_GIE | \ - VEX_HWCAPS_S390X_FGX | \ +#define VEX_HWCAPS_S390X_ALL (VEX_HWCAPS_S390X_FGX | \ VEX_HWCAPS_S390X_LSC | \ VEX_HWCAPS_S390X_PFPO | \ VEX_HWCAPS_S390X_VX | \ diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c index e7aca5cb32..7f794fd873 100644 --- a/coregrind/m_machine.c +++ b/coregrind/m_machine.c @@ -1565,7 +1565,6 @@ Bool VG_(machine_get_hwcaps)( void ) UInt hwcaps_bit; const HChar name[6]; // may need adjustment for new facility names } fac_hwcaps[] = { - { False, 34, VEX_HWCAPS_S390X_GIE, "GIE" }, { False, 41, VEX_HWCAPS_S390X_FGX, "FGX" }, { False, 45, VEX_HWCAPS_S390X_LSC, "LSC" }, { False, 44, VEX_HWCAPS_S390X_PFPO, "PFPO" }, diff --git a/tests/s390x_features.c b/tests/s390x_features.c index 593c8c556b..fa96ee8f4d 100644 --- a/tests/s390x_features.c +++ b/tests/s390x_features.c @@ -229,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-genins") == 0 ) { - match = facilities[0] & FAC_BIT(34); } else if (strcmp(feature, "s390x-exrl") == 0 ) { match = facilities[0] & FAC_BIT(35); } else if (strcmp(feature, "s390x-pfpo") == 0 ) { |