You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(83) |
Oct
(89) |
Nov
(97) |
Dec
(30) |
2024 |
Jan
(25) |
Feb
(73) |
Mar
(76) |
Apr
(122) |
May
(46) |
Jun
(44) |
Jul
(27) |
Aug
(30) |
Sep
(33) |
Oct
(67) |
Nov
(91) |
Dec
(70) |
2025 |
Jan
(44) |
Feb
(36) |
Mar
(85) |
Apr
(100) |
May
(138) |
Jun
(55) |
Jul
(107) |
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Florian K. <fk...@so...> - 2025-08-02 13:23:31
|
https://sourceware.org/cgit/valgrind/commit/?id=75501e34e32124ba8916d84ce9317a29e7266000 commit 75501e34e32124ba8916d84ce9317a29e7266000 Author: Florian Krohm <fl...@ei...> Date: Sat Aug 2 13:22:50 2025 +0000 ARM64 specific changes for BZ 507033 Replace the deprecated Iop_Clz64 with Iop_ClzNat64 which have the same semantics for non-zero inputs. Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033 Diff: --- VEX/priv/guest_arm64_toIR.c | 4 ++-- VEX/priv/host_arm64_isel.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c index e6b92c7a04..f5b445489e 100644 --- a/VEX/priv/guest_arm64_toIR.c +++ b/VEX/priv/guest_arm64_toIR.c @@ -3504,12 +3504,12 @@ Bool dis_ARM64_data_processing_register(/*MB_OUT*/DisResult* dres, if (is64) { assign(dst, IRExpr_ITE(binop(Iop_CmpEQ64, mkexpr(srcZ), mkU64(0)), mkU64(isCLS ? 63 : 64), - unop(Iop_Clz64, mkexpr(srcZ)))); + unop(Iop_ClzNat64, mkexpr(srcZ)))); putIReg64orZR(dd, mkexpr(dst)); } else { assign(dst, IRExpr_ITE(binop(Iop_CmpEQ64, mkexpr(srcZ), mkU64(0)), mkU64(isCLS ? 31 : 32), - unop(Iop_Clz64, mkexpr(srcZ)))); + unop(Iop_ClzNat64, mkexpr(srcZ)))); putIReg32orZR(dd, unop(Iop_64to32, mkexpr(dst))); } DIP("cl%c %s, %s\n", isCLS ? 's' : 'z', diff --git a/VEX/priv/host_arm64_isel.c b/VEX/priv/host_arm64_isel.c index 34c5265590..190d8c8f12 100644 --- a/VEX/priv/host_arm64_isel.c +++ b/VEX/priv/host_arm64_isel.c @@ -2048,7 +2048,7 @@ static HReg iselIntExpr_R_wrk ( ISelEnv* env, IRExpr* e ) addInstr(env, ARM64Instr_Unary(dst, src, ARM64un_NOT)); return dst; } - case Iop_Clz64: { + case Iop_ClzNat64: { HReg dst = newVRegI(env); HReg src = iselIntExpr_R(env, e->Iex.Unop.arg); addInstr(env, ARM64Instr_Unary(dst, src, ARM64un_CLZ)); |
From: Florian K. <fk...@so...> - 2025-08-02 13:14:59
|
https://sourceware.org/cgit/valgrind/commit/?id=8436a7c61c07563bdc9fb1686c82821e74784dcf commit 8436a7c61c07563bdc9fb1686c82821e74784dcf Author: Florian Krohm <fl...@ei...> Date: Sat Aug 2 13:14:31 2025 +0000 ARM specific changes for BZ 507033 Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32. Iop_Clz32 --isel--> ARMun_CLZ --emit--> CLZ insn with CLZ(0) == 32 Hence, any workaround for a zero input value can be removed. Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033 Diff: --- VEX/priv/guest_arm_toIR.c | 12 ++---------- VEX/priv/host_arm_isel.c | 9 +-------- memcheck/tests/vbit-test/irops.c | 4 ++-- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/VEX/priv/guest_arm_toIR.c b/VEX/priv/guest_arm_toIR.c index 2bedccd14d..673e876288 100644 --- a/VEX/priv/guest_arm_toIR.c +++ b/VEX/priv/guest_arm_toIR.c @@ -17100,11 +17100,7 @@ DisResult disInstr_ARM_WRK ( IRTemp arg = newTemp(Ity_I32); IRTemp res = newTemp(Ity_I32); assign(arg, getIRegA(rM)); - assign(res, IRExpr_ITE( - binop(Iop_CmpEQ32, mkexpr(arg), mkU32(0)), - mkU32(32), - unop(Iop_Clz32, mkexpr(arg)) - )); + assign(res, unop(Iop_ClzNat32, mkexpr(arg))); putIRegA(rD, mkexpr(res), condT, Ijk_Boring); DIP("clz%s r%u, r%u\n", nCC(INSN_COND), rD, rM); goto decode_success; @@ -22730,11 +22726,7 @@ DisResult disInstr_THUMB_WRK ( IRTemp arg = newTemp(Ity_I32); IRTemp res = newTemp(Ity_I32); assign(arg, getIRegT(rM1)); - assign(res, IRExpr_ITE( - binop(Iop_CmpEQ32, mkexpr(arg), mkU32(0)), - mkU32(32), - unop(Iop_Clz32, mkexpr(arg)) - )); + assign(res, unop(Iop_ClzNat32, mkexpr(arg))); putIRegT(rD, mkexpr(res), condT); DIP("clz r%u, r%u\n", rD, rM1); goto decode_success; diff --git a/VEX/priv/host_arm_isel.c b/VEX/priv/host_arm_isel.c index d19efe5c3e..4b76a6170a 100644 --- a/VEX/priv/host_arm_isel.c +++ b/VEX/priv/host_arm_isel.c @@ -1870,14 +1870,7 @@ static HReg iselIntExpr_R_wrk ( ISelEnv* env, IRExpr* e ) //zz addInstr(env, X86Instr_Sh32(Xsh_SAR, 31, dst)); //zz return dst; //zz } -//zz case Iop_Ctz32: { -//zz /* Count trailing zeroes, implemented by x86 'bsfl' */ -//zz HReg dst = newVRegI(env); -//zz HReg src = iselIntExpr_R(env, e->Iex.Unop.arg); -//zz addInstr(env, X86Instr_Bsfr32(True,src,dst)); -//zz return dst; -//zz } - case Iop_Clz32: { + case Iop_ClzNat32: { /* Count leading zeroes; easy on ARM. */ HReg dst = newVRegI(env); HReg src = iselIntExpr_R(env, e->Iex.Unop.arg); diff --git a/memcheck/tests/vbit-test/irops.c b/memcheck/tests/vbit-test/irops.c index fdea8919e4..2f0ea8a6af 100644 --- a/memcheck/tests/vbit-test/irops.c +++ b/memcheck/tests/vbit-test/irops.c @@ -109,11 +109,11 @@ static irop_t irops[] = { { DEFOP(Iop_MullU32, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 1 }, // mips asserts { DEFOP(Iop_MullU64, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32, mips assert { DEFOP(Iop_Clz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, // ppc32 asserts - { DEFOP(Iop_Clz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, + { DEFOP(Iop_Clz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_Ctz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_Ctz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_ClzNat64, UNDEF_ALL), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32 asserts - { DEFOP(Iop_ClzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =1, .mips64 = 1 }, + { DEFOP(Iop_ClzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =1, .mips64 = 1 }, { DEFOP(Iop_CtzNat64, UNDEF_ALL), .s390x = 0, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_CtzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_PopCount64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, |
From: Florian K. <fk...@so...> - 2025-08-02 12:44:54
|
https://sourceware.org/cgit/valgrind/commit/?id=697efef3720d5c78c7957ba107fb2f3307f53fd8 commit 697efef3720d5c78c7957ba107fb2f3307f53fd8 Author: Florian Krohm <fl...@ei...> Date: Sat Aug 2 12:43:54 2025 +0000 mips specific changes for BZ 507033 Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32. Likewise for Iop_Clz64. For Iop_Clz32 a CLZ insn will be emitted which behaves naturally when its input is 0. That is: CLZ(0) == 32. Similarly, for Iop_Clz64 a DCLZ will be emitted with DCLZ(0) == 64. That means we can replace Iop_Clz32/64 with Iop_ClzNat32/64 and remove any IR that handles the input-is-zero case. See also commit a5c48217e94. Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033 Diff: --- VEX/priv/guest_mips_toIR.c | 74 +++++++++------------------------------- VEX/priv/host_mips_isel.c | 6 ++-- memcheck/tests/vbit-test/irops.c | 8 ++--- 3 files changed, 23 insertions(+), 65 deletions(-) diff --git a/VEX/priv/guest_mips_toIR.c b/VEX/priv/guest_mips_toIR.c index 1285edad0b..e42fc27825 100644 --- a/VEX/priv/guest_mips_toIR.c +++ b/VEX/priv/guest_mips_toIR.c @@ -17086,14 +17086,10 @@ static UInt disInstr_MIPS_WRK_Special(UInt cins, const VexArchInfo* archinfo, IRTemp tmpRs32 = newTemp(Ity_I32); assign(tmpRs32, mkNarrowTo32(ty, getIReg(rs))); - assign(tmpClz32, unop(Iop_Clz32, mkexpr(tmpRs32))); + assign(tmpClz32, unop(Iop_ClzNat32, mkexpr(tmpRs32))); putIReg(rd, mkWidenFrom32(ty, mkexpr(tmpClz32), True)); } else { - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ32, getIReg(rs), mkU32(0))); - putIReg(rd, IRExpr_ITE(mkexpr(t1), - mkU32(0x00000020), - unop(Iop_Clz32, getIReg(rs)))); + putIReg(rd, unop(Iop_ClzNat32, getIReg(rs))); } } else { ILLEGAL_INSTRUCTON; @@ -17126,21 +17122,14 @@ static UInt disInstr_MIPS_WRK_Special(UInt cins, const VexArchInfo* archinfo, IRTemp tmpRs32 = newTemp(Ity_I32); assign(tmpRs32, mkNarrowTo32(ty, getIReg(rs))); - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ32, mkexpr(tmpRs32), mkU32(0xffffffff))); - assign(tmpClo32, IRExpr_ITE(mkexpr(t1), - mkU32(0x00000020), - unop(Iop_Clz32, unop(Iop_Not32, mkexpr(tmpRs32))))); + assign(tmpClo32, unop(Iop_ClzNat32, + unop(Iop_Not32, mkexpr(tmpRs32)))); putIReg(rd, mkWidenFrom32(ty, mkexpr(tmpClo32), True)); break; } else { - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ32, getIReg(rs), mkU32(0xffffffff))); - putIReg(rd, IRExpr_ITE(mkexpr(t1), - mkU32(0x00000020), - unop(Iop_Clz32, - unop(Iop_Not32, getIReg(rs))))); + putIReg(rd, unop(Iop_ClzNat32, + unop(Iop_Not32, getIReg(rs)))); } } else { ILLEGAL_INSTRUCTON; @@ -17188,11 +17177,7 @@ static UInt disInstr_MIPS_WRK_Special(UInt cins, const VexArchInfo* archinfo, case 1: DIP("dclz r%u, r%u", rd, rs); - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ64, getIReg(rs), mkU64(0))); - putIReg(rd, IRExpr_ITE(mkexpr(t1), - mkU64(0x00000040), - unop(Iop_Clz64, getIReg(rs)))); + putIReg(rd, unop(Iop_ClzNat64, getIReg(rs))); break; } @@ -17225,13 +17210,8 @@ static UInt disInstr_MIPS_WRK_Special(UInt cins, const VexArchInfo* archinfo, case 1: DIP("dclo r%u, r%u", rd, rs); - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ64, getIReg(rs), - mkU64(0xffffffffffffffffULL))); - putIReg(rd, IRExpr_ITE(mkexpr(t1), - mkU64(0x40), - unop(Iop_Clz64, unop(Iop_Not64, - getIReg(rs))))); + putIReg(rd, unop(Iop_ClzNat64, + unop(Iop_Not64, getIReg(rs)))); break; } @@ -18772,14 +18752,10 @@ static UInt disInstr_MIPS_WRK_Special2(UInt cins, const VexArchInfo* archinfo, IRTemp tmpRs32 = newTemp(Ity_I32); assign(tmpRs32, mkNarrowTo32(ty, getIReg(rs))); - assign(tmpClz32, unop(Iop_Clz32, mkexpr(tmpRs32))); + assign(tmpClz32, unop(Iop_ClzNat32, mkexpr(tmpRs32))); putIReg(rd, mkWidenFrom32(ty, mkexpr(tmpClz32), True)); } else { - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ32, getIReg(rs), mkU32(0))); - putIReg(rd, IRExpr_ITE(mkexpr(t1), - mkU32(0x00000020), - unop(Iop_Clz32, getIReg(rs)))); + putIReg(rd, unop(Iop_ClzNat32, getIReg(rs))); } break; @@ -18793,43 +18769,25 @@ static UInt disInstr_MIPS_WRK_Special2(UInt cins, const VexArchInfo* archinfo, IRTemp tmpRs32 = newTemp(Ity_I32); assign(tmpRs32, mkNarrowTo32(ty, getIReg(rs))); - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ32, mkexpr(tmpRs32), mkU32(0xffffffff))); - assign(tmpClo32, IRExpr_ITE(mkexpr(t1), - mkU32(0x00000020), - unop(Iop_Clz32, unop(Iop_Not32, mkexpr(tmpRs32))))); + assign(tmpClo32, unop(Iop_ClzNat32, + unop(Iop_Not32, mkexpr(tmpRs32)))); putIReg(rd, mkWidenFrom32(ty, mkexpr(tmpClo32), True)); break; } else { - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ32, getIReg(rs), mkU32(0xffffffff))); - putIReg(rd, IRExpr_ITE(mkexpr(t1), - mkU32(0x00000020), - unop(Iop_Clz32, - unop(Iop_Not32, getIReg(rs))))); + putIReg(rd, unop(Iop_ClzNat32, unop(Iop_Not32, getIReg(rs)))); break; } } case 0x24: /* Count Leading Zeros in Doubleword - DCLZ; MIPS64 */ DIP("dclz r%u, r%u", rd, rs); - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ64, getIReg(rs), mkU64(0))); - putIReg(rd, IRExpr_ITE(mkexpr(t1), - mkU64(0x00000040), - unop(Iop_Clz64, getIReg(rs)))); + putIReg(rd, unop(Iop_ClzNat64, getIReg(rs))); break; case 0x25: /* Count Leading Ones in Doubleword - DCLO; MIPS64 */ DIP("dclo r%u, r%u", rd, rs); - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ64, getIReg(rs), - mkU64(0xffffffffffffffffULL))); - putIReg(rd, IRExpr_ITE(mkexpr(t1), - mkU64(0x40), - unop(Iop_Clz64, unop(Iop_Not64, - getIReg(rs))))); + putIReg(rd, unop(Iop_ClzNat64, unop(Iop_Not64, getIReg(rs)))); break; default: diff --git a/VEX/priv/host_mips_isel.c b/VEX/priv/host_mips_isel.c index 33e4f52169..2bdfa4a648 100644 --- a/VEX/priv/host_mips_isel.c +++ b/VEX/priv/host_mips_isel.c @@ -2155,13 +2155,13 @@ static HReg iselWordExpr_R_wrk(ISelEnv * env, IRExpr * e) return r_dst; } - case Iop_Clz64: + case Iop_ClzNat64: vassert(mode64); /* fallthrough */ - case Iop_Clz32: { + case Iop_ClzNat32: { HReg r_dst = newVRegI(env); HReg r_src = iselWordExpr_R(env, e->Iex.Unop.arg); - MIPSUnaryOp op = (op_unop == Iop_Clz64) ? Mun_DCLZ : Mun_CLZ; + MIPSUnaryOp op = (op_unop == Iop_ClzNat64) ? Mun_DCLZ : Mun_CLZ; addInstr(env, MIPSInstr_Unary(op, r_dst, r_src)); return r_dst; } diff --git a/memcheck/tests/vbit-test/irops.c b/memcheck/tests/vbit-test/irops.c index e104c18acb..fdea8919e4 100644 --- a/memcheck/tests/vbit-test/irops.c +++ b/memcheck/tests/vbit-test/irops.c @@ -108,12 +108,12 @@ static irop_t irops[] = { { DEFOP(Iop_MullU16, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_MullU32, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 1 }, // mips asserts { DEFOP(Iop_MullU64, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32, mips assert - { DEFOP(Iop_Clz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32 asserts - { DEFOP(Iop_Clz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =1, .mips64 = 1 }, + { DEFOP(Iop_Clz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, // ppc32 asserts + { DEFOP(Iop_Clz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_Ctz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_Ctz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, - { DEFOP(Iop_ClzNat64, UNDEF_ALL), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, // ppc32 asserts - { DEFOP(Iop_ClzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, + { DEFOP(Iop_ClzNat64, UNDEF_ALL), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32 asserts + { DEFOP(Iop_ClzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =1, .mips64 = 1 }, { DEFOP(Iop_CtzNat64, UNDEF_ALL), .s390x = 0, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_CtzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_PopCount64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, |
From: Mark W. <ma...@so...> - 2025-08-02 00:37:22
|
https://sourceware.org/cgit/valgrind/commit/?id=a2c294b3b19ef4af391014e7b3cbc5ec75b2bd68 commit a2c294b3b19ef4af391014e7b3cbc5ec75b2bd68 Author: Martin Cermak <mc...@re...> Date: Fri Aug 1 15:35:04 2025 +0200 Fix execveat() with AT_FDCWD and relative path, add more checks This update does address two closely related problems: 1) In case execveat() is called with a special file descriptor value of AT_FDCWD (-100), it should accept this special value, and interpret the provided pathname as relative to the current working directory of the calling process (like execve(2)) instead of failing with EBADF, as it does without this patch. Covered by LTP testcase execveat01. https://bugs.kde.org/show_bug.cgi?id=506806 2) Add checks preventing execveat() of symlinked programs in case AT_SYMLINK_NOFOLLOW was specified. Add checks preventing execveat() from passing in case invalid flag was specified. Covered by LTP testcase execveat02. https://bugs.kde.org/show_bug.cgi?id=506813 Diff: --- NEWS | 2 ++ coregrind/m_syswrap/syswrap-linux.c | 45 ++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/NEWS b/NEWS index 32bea93531..cf879c8d20 100644 --- a/NEWS +++ b/NEWS @@ -58,6 +58,8 @@ are not entered into bugzilla tend to get forgotten about or ignored. 506076 unimplemented fcntl command: 1028 (F_CREATED_QUERY) 506499 Unhandled syscall 592 (exterrctl - FreeBSD 506795 Better report which clone flags are problematic +506806 Fix execveat() with AT_FDCWD and relative path +506813 The execveat wrapper needs to do more checking 506910 openat2 with RESOLVE_NO_MAGICLINKS succeeds on /proc/self/exe 506928 Wrap (deprecated) linux specific ustat syscall 506929 Wrap (deprecated) linux sysfs syscall diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 66e5ca62e7..c81d941a74 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -13893,12 +13893,12 @@ PRE(sys_execveat) return; #endif + Int arg_1 = (Int) ARG1; const HChar *path = (const HChar*) ARG2; Addr arg_2 = ARG3; Addr arg_3 = ARG4; const HChar *buf; HChar *abs_path = NULL; - Bool check_at_symlink = False; Bool check_pathptr = True; if (ML_(safe_to_deref) (path, 1)) { @@ -13906,8 +13906,12 @@ PRE(sys_execveat) * and just pass the pathname, try to determine * the absolute path otherwise. */ if (path[0] != '/') { - /* Check dirfd is a valid fd. */ - if (!ML_(fd_allowed)(ARG1, "execveat", tid, False)) { + /* Check dirfd is a valid fd. + * BUT: allow special value of AT_FDCWD (-101) per the execveat(2) man page: + * If pathname is relative and dirfd is the special value AT_FDCWD, + * then pathname is interpreted relative to the current working directory + * of the calling process (like execve(2)). */ + if (arg_1 != VKI_AT_FDCWD && !ML_(fd_allowed)(arg_1, "execveat", tid, False)) { SET_STATUS_Failure( VKI_EBADF ); return; } @@ -13915,38 +13919,33 @@ PRE(sys_execveat) set then dirfd describes the whole path. */ if (path[0] == '\0') { if (ARG5 & VKI_AT_EMPTY_PATH) { - if (VG_(resolve_filename)(ARG1, &buf)) { + if (VG_(resolve_filename)(arg_1, &buf)) { path = buf; check_pathptr = False; } } - } - else if (ARG1 == VKI_AT_FDCWD) { - check_at_symlink = True; - } else - if (ARG5 & VKI_AT_SYMLINK_NOFOLLOW) - check_at_symlink = True; - else if (VG_(resolve_filename)(ARG1, &buf)) { + } else if (VG_(resolve_filename)(arg_1, &buf)) { abs_path = VG_(malloc)("execveat", (VG_(strlen)(buf) + 1 + VG_(strlen)(path) + 1)); VG_(sprintf)(abs_path, "%s/%s", buf, path); path = abs_path; check_pathptr = False; - } - else - path = NULL; - if (check_at_symlink) { - struct vg_stat statbuf; - SysRes statres; - - statres = VG_(stat)(path, &statbuf); - if (sr_isError(statres) || VKI_S_ISLNK(statbuf.mode)) { - SET_STATUS_Failure( VKI_ELOOP ); - return; - } } } + if (ARG5 & VKI_AT_SYMLINK_NOFOLLOW) { + struct vg_stat statbuf; + SysRes statres; + statres = VG_(stat)(path, &statbuf); + if (sr_isError(statres) || VKI_S_ISLNK(statbuf.mode)) { + SET_STATUS_Failure( VKI_ELOOP ); + return; + } + } + if(ARG5 & ~(VKI_AT_SYMLINK_NOFOLLOW | VKI_AT_EMPTY_PATH)) { + SET_STATUS_Failure( VKI_EINVAL ); + return; + } } else { SET_STATUS_Failure(VKI_EFAULT); return; |
From: Mark W. <ma...@so...> - 2025-08-01 14:11:12
|
https://sourceware.org/cgit/valgrind/commit/?id=34dff50cf304d1d4f0d5a1ad3f55f8b3d85ae701 commit 34dff50cf304d1d4f0d5a1ad3f55f8b3d85ae701 Author: Martin Cermak <mc...@re...> Date: Fri Aug 1 14:04:24 2025 +0200 Wrap linux specific syscall sysfs The sysfs syscall is deprecated, but in some cases it may still be used. The Linux Test Project covers it. The (obsolete) sysfs() system call returns information about the filesystem types currently present in the kernel. The specific form of the sysfs() call and the information returned depends on the option in effect: 1 Translate the filesystem identifier string fsname into a filesystem type index. 2 Translate the filesystem type index fs_index into a null- terminated filesystem identifier string. This string will be written to the buffer pointed to by buf. Make sure that buf has enough space to accept the string. 3 Return the total number of filesystem types currently present in the kernel. Declare a sys_sysfs wrapper in priv_syswrap-linux.h and hook it for {amd64,arm,mips32,mips64,ppc32,ppc64,s390x,x86}-linux using LINXY with PRE and POST handler in syswrap-linux.c https://bugs.kde.org/show_bug.cgi?id=506929 Diff: --- NEWS | 1 + coregrind/m_syswrap/priv_syswrap-linux.h | 1 + coregrind/m_syswrap/syswrap-amd64-linux.c | 2 +- coregrind/m_syswrap/syswrap-arm-linux.c | 2 +- coregrind/m_syswrap/syswrap-linux.c | 36 ++++++++++++++++++++++++++++++ coregrind/m_syswrap/syswrap-mips32-linux.c | 2 +- coregrind/m_syswrap/syswrap-mips64-linux.c | 10 +-------- coregrind/m_syswrap/syswrap-ppc32-linux.c | 2 +- coregrind/m_syswrap/syswrap-ppc64-linux.c | 2 +- coregrind/m_syswrap/syswrap-s390x-linux.c | 2 +- coregrind/m_syswrap/syswrap-x86-linux.c | 2 +- 11 files changed, 46 insertions(+), 16 deletions(-) diff --git a/NEWS b/NEWS index fe9de908f7..32bea93531 100644 --- a/NEWS +++ b/NEWS @@ -60,6 +60,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 506795 Better report which clone flags are problematic 506910 openat2 with RESOLVE_NO_MAGICLINKS succeeds on /proc/self/exe 506928 Wrap (deprecated) linux specific ustat syscall +506929 Wrap (deprecated) linux sysfs syscall 506930 valgrind allows SIGKILL being reset to SIG_DFL 506967 Implement and override mallinfo2 506970 mmap needs an EBADF fd_allowed check diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index ce10a35f6a..1d5135fc56 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -61,6 +61,7 @@ DECL_TEMPLATE(linux, sys_vmsplice); DECL_TEMPLATE(linux, sys_readahead); DECL_TEMPLATE(linux, sys_move_pages); DECL_TEMPLATE(linux, sys_cachestat); +DECL_TEMPLATE(linux, sys_sysfs); // clone is similar enough between linux variants to have a generic // version, but which will call an extern defined in syswrap-<platform>-linux.c diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index c80286f00b..f15c3dac72 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -636,7 +636,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_ustat, sys_ustat), // 136 GENXY(__NR_statfs, sys_statfs), // 137 GENXY(__NR_fstatfs, sys_fstatfs), // 138 - // (__NR_sysfs, sys_sysfs), // 139 + LINXY(__NR_sysfs, sys_sysfs), // 139 GENX_(__NR_getpriority, sys_getpriority), // 140 GENX_(__NR_setpriority, sys_setpriority), // 141 diff --git a/coregrind/m_syswrap/syswrap-arm-linux.c b/coregrind/m_syswrap/syswrap-arm-linux.c index c5fb08dcc6..4ba9801cea 100644 --- a/coregrind/m_syswrap/syswrap-arm-linux.c +++ b/coregrind/m_syswrap/syswrap-arm-linux.c @@ -711,7 +711,7 @@ static SyscallTableEntry syscall_main_table[] = { GENX_(__NR_fchdir, sys_fchdir), // 133 //zz // (__NR_bdflush, sys_bdflush), // 134 */Linux //zz -//zz // (__NR_sysfs, sys_sysfs), // 135 SVr4 + LINXY(__NR_sysfs, sys_sysfs), // 135 SVr4 LINX_(__NR_personality, sys_personality), // 136 // GENX_(__NR_afs_syscall, sys_ni_syscall), // 137 LINX_(__NR_setfsuid, sys_setfsuid16), // 138 diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 572a42925d..66e5ca62e7 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -4407,6 +4407,42 @@ PRE(sys_syncfs) PRE_REG_READ1(long, "syncfs", unsigned int, fd); } +PRE(sys_sysfs) +{ + FUSE_COMPATIBLE_MAY_BLOCK(); + switch (ARG1) { + case 1: + PRINT("sys_sysfs ( %lu, %lu )", ARG1, ARG2); + PRE_REG_READ2(long, "sysfs", int, flags, const void *, path); + PRE_MEM_RASCIIZ("sysfs(path)", ARG2); + break; + case 2: + PRINT("sys_sysfs ( %lu, %lu, %#" FMT_REGWORD "x )", + ARG1, ARG2, ARG3); + PRE_REG_READ3(long, "sysfs", int, flags, int, desc, void *, path); + PRE_MEM_WRITE("sysfs(path)", ARG3, 1); + break; + case 3: + PRINT("sys_sysfs ( %lu )", ARG1); + PRE_REG_READ1(long, "sysfs", int, flags); + break; + default: + if (VG_(clo_verbosity) >= 1) { + VG_(message)(Vg_DebugMsg, + "WARNING: unhandled sysfs option %lu\n", ARG1); + } + break; + } +} + +POST(sys_sysfs) +{ + if (ARG1 == 2) { + // For option 2, getting the fsname, there is no way to know how big the buffer needs to be. + POST_MEM_WRITE(ARG3, VG_(strlen)((void *)ARG3)); + } +} + PRE(sys_statx) { FUSE_COMPATIBLE_MAY_BLOCK(); diff --git a/coregrind/m_syswrap/syswrap-mips32-linux.c b/coregrind/m_syswrap/syswrap-mips32-linux.c index 684bda4b9a..13cb5d05bc 100644 --- a/coregrind/m_syswrap/syswrap-mips32-linux.c +++ b/coregrind/m_syswrap/syswrap-mips32-linux.c @@ -899,7 +899,7 @@ static SyscallTableEntry syscall_main_table[] = { GENX_ (__NR_getpgid, sys_getpgid), // 132 GENX_ (__NR_fchdir, sys_fchdir), // 133 //.. // (__NR_bdflush, sys_bdflush), // 134 - //.. // (__NR_sysfs, sys_sysfs), // 135 + LINXY (__NR_sysfs, sys_sysfs), // 135 LINX_ (__NR_personality, sys_personality), // 136 //.. GENX_(__NR_afs_syscall, sys_ni_syscall), // 137 LINX_ (__NR_setfsuid, sys_setfsuid), // 138 diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c b/coregrind/m_syswrap/syswrap-mips64-linux.c index 8e2dcbe93c..bdfb203837 100644 --- a/coregrind/m_syswrap/syswrap-mips64-linux.c +++ b/coregrind/m_syswrap/syswrap-mips64-linux.c @@ -216,7 +216,6 @@ SysRes sys_set_tls ( ThreadId tid, Addr tlsptr ) DECL_TEMPLATE (mips_linux, sys_set_thread_area); DECL_TEMPLATE (mips_linux, sys_vmsplice); -DECL_TEMPLATE (mips_linux, sys_sysfs); DECL_TEMPLATE (mips_linux, sys_swapon); DECL_TEMPLATE (mips_linux, sys_swapoff); DECL_TEMPLATE (mips_linux, sys_setdomainname); @@ -259,13 +258,6 @@ PRE(sys_swapoff) PRE_REG_READ1(long, "swapoff", const void *, path); } -PRE(sys_sysfs) -{ - PRINT("sys_sysfs ( %ld, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", - SARG1, ARG2, ARG3); - PRE_REG_READ3(long, "sysfs", int, flags, int, desc, const void *, path); -} - /* Very much MIPS specific */ PRE(sys_cacheflush) { @@ -645,7 +637,7 @@ static SyscallTableEntry syscall_main_table[] = { LINXY (__NR_ustat, sys_ustat), GENXY (__NR_statfs, sys_statfs), GENXY (__NR_fstatfs, sys_fstatfs), - PLAX_ (__NR_sysfs, sys_sysfs), + LINXY (__NR_sysfs, sys_sysfs), GENX_ (__NR_getpriority, sys_getpriority), GENX_ (__NR_setpriority, sys_setpriority), LINXY (__NR_sched_setparam, sys_sched_setparam), diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index d2b59786c4..00d0f56d7b 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -774,7 +774,7 @@ static SyscallTableEntry syscall_table[] = { GENX_(__NR_fchdir, sys_fchdir), // 133 //.. // (__NR_bdflush, sys_bdflush), // 134 */Linux //.. -//.. // (__NR_sysfs, sys_sysfs), // 135 SVr4 + LINXY(__NR_sysfs, sys_sysfs), // 135 SVr4 LINX_(__NR_personality, sys_personality), // 136 //.. GENX_(__NR_afs_syscall, sys_ni_syscall), // 137 LINX_(__NR_setfsuid, sys_setfsuid), // 138 diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index 3d6c2e4eda..87a4c4db90 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -762,7 +762,7 @@ static SyscallTableEntry syscall_table[] = { GENX_(__NR_fchdir, sys_fchdir), // 133 // _____(__NR_bdflush, sys_bdflush), // 134 -// _____(__NR_sysfs, sys_sysfs), // 135 + LINXY(__NR_sysfs, sys_sysfs), // 135 LINX_(__NR_personality, sys_personality), // 136 // _____(__NR_afs_syscall, sys_afs_syscall), // 137 LINX_(__NR_setfsuid, sys_setfsuid), // 138 diff --git a/coregrind/m_syswrap/syswrap-s390x-linux.c b/coregrind/m_syswrap/syswrap-s390x-linux.c index 65a26a02da..ad35a4ebcf 100644 --- a/coregrind/m_syswrap/syswrap-s390x-linux.c +++ b/coregrind/m_syswrap/syswrap-s390x-linux.c @@ -573,7 +573,7 @@ static SyscallTableEntry syscall_table[] = { GENX_(__NR_fchdir, sys_fchdir), // 133 // ?????(__NR_bdflush, ), // 134 -// ?????(__NR_sysfs, ), // 135 + LINXY(__NR_sysfs, sys_sysfs), // 135 LINX_(__NR_personality, sys_personality), // 136 GENX_(137, sys_ni_syscall), /* unimplemented (by the kernel) */ // 137 GENX_(138, sys_ni_syscall), /* unimplemented (by the kernel) */ // 138 diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 0b8373ffa8..9b8c9d861b 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -1320,7 +1320,7 @@ static SyscallTableEntry syscall_table[] = { GENX_(__NR_fchdir, sys_fchdir), // 133 //zz // (__NR_bdflush, sys_bdflush), // 134 */Linux //zz -//zz // (__NR_sysfs, sys_sysfs), // 135 SVr4 + LINXY(__NR_sysfs, sys_sysfs), // 135 SVr4 LINX_(__NR_personality, sys_personality), // 136 GENX_(__NR_afs_syscall, sys_ni_syscall), // 137 LINX_(__NR_setfsuid, sys_setfsuid16), // 138 |
From: Florian K. <fk...@so...> - 2025-07-31 21:31:13
|
https://sourceware.org/cgit/valgrind/commit/?id=a5c48217e94a0fb7bac909a2ff13813ac10f5c37 commit a5c48217e94a0fb7bac909a2ff13813ac10f5c37 Author: Florian Krohm <fl...@ei...> Date: Thu Jul 31 21:28:39 2025 +0000 nanomips specific changes for BZ 507033 Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32. Iop_Clz32 is used to implement the CLZ insn which behaves naturally when the input is 0: CLZ(0) == 32 So it seems as if using Iop_Clz32 is wrong because it has undefined behaviour when the input value is 0. However, the VEX pipeline does this: CLZ insn --ir--> Iop_Clz32 --isel--> NMun_CLZ --emit--> CLZ So it all works out. Essentially the semantics of Iop_Clz32 were redefined to be like Iop_ClzNat32. In IR generation we can drop the special handling for CLO(0) because Iop_ClzNat32 takes care of that. Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033 Diff: --- VEX/priv/guest_nanomips_toIR.c | 10 ++-------- VEX/priv/host_nanomips_isel.c | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/VEX/priv/guest_nanomips_toIR.c b/VEX/priv/guest_nanomips_toIR.c index 3827ac3fc0..fddc1afa44 100644 --- a/VEX/priv/guest_nanomips_toIR.c +++ b/VEX/priv/guest_nanomips_toIR.c @@ -864,23 +864,17 @@ static void nano_pool32Axf_4(DisResult *dres, UInt cins) { UChar rs = (cins >> 16) & 0x1F; UChar rt = (cins >> 21) & 0x1F; - IRTemp t1; switch ((cins >> 9) & 0x7F) { case nano_POOL32Axf4_CLO: { /* clo */ DIP("clo r%u, r%u", rt, rs); - t1 = newTemp(Ity_I1); - assign(t1, binop(Iop_CmpEQ32, getIReg(rs), mkU32(0xffffffff))); - putIReg(rt, IRExpr_ITE(mkexpr(t1), - mkU32(0x00000020), - unop(Iop_Clz32, - unop(Iop_Not32, getIReg(rs))))); + putIReg(rt, unop(Iop_ClzNat32, unop(Iop_Not32, getIReg(rs)))); break; } case nano_POOL32Axf4_CLZ: { /* clz */ DIP("clz r%u, r%u", rt, rs); - putIReg(rt, unop(Iop_Clz32, getIReg(rs))); + putIReg(rt, unop(Iop_ClzNat32, getIReg(rs))); break; } } diff --git a/VEX/priv/host_nanomips_isel.c b/VEX/priv/host_nanomips_isel.c index c4a8f4fe3c..05e4cc5123 100644 --- a/VEX/priv/host_nanomips_isel.c +++ b/VEX/priv/host_nanomips_isel.c @@ -815,7 +815,7 @@ static HReg iselWordExpr_R_wrk(ISelEnv * env, IRExpr * e) return r_dst; } - case Iop_Clz32: { + case Iop_ClzNat32: { HReg r_dst = newVRegI(env); HReg r_src = iselWordExpr_R(env, e->Iex.Unop.arg); addInstr(env, NANOMIPSInstr_Unary(NMun_CLZ, r_dst, r_src)); |
From: Florian K. <fk...@so...> - 2025-07-31 20:57:21
|
https://sourceware.org/cgit/valgrind/commit/?id=42bff04db954b8a214334ad67256c32e88ddc7cf commit 42bff04db954b8a214334ad67256c32e88ddc7cf Author: Florian Krohm <fl...@ei...> Date: Thu Jul 31 20:56:34 2025 +0000 x86 specific changes for BZ 507033 Rework code to use Iop_ClzNat32 instead of the deprecated Iop_Clz32. Likewise for Iop_Ctz32. Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033 Diff: --- VEX/priv/guest_x86_toIR.c | 24 +++++++++++------------- VEX/priv/host_x86_isel.c | 4 ++-- memcheck/tests/vbit-test/irops.c | 8 ++++---- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/VEX/priv/guest_x86_toIR.c b/VEX/priv/guest_x86_toIR.c index 7b31bd7695..11617914d5 100644 --- a/VEX/priv/guest_x86_toIR.c +++ b/VEX/priv/guest_x86_toIR.c @@ -3418,14 +3418,14 @@ static IRTemp gen_LZCNT ( IRType ty, IRTemp src ) binop(Iop_Shl32, mkexpr(src32), mkU8(32 - 8 * sizeofIRType(ty)))); - // Clz32 has undefined semantics when its input is zero, so - // special-case around that. + /* Guard against 0 input value. Use ClzNat32 operator for all other + values */ IRTemp res32 = newTemp(Ity_I32); assign(res32, IRExpr_ITE( binop(Iop_CmpEQ32, mkexpr(src32x), mkU32(0)), mkU32(8 * sizeofIRType(ty)), - unop(Iop_Clz32, mkexpr(src32x)) + unop(Iop_ClzNat32, mkexpr(src32x)) )); IRTemp res = newTemp(ty); @@ -6512,18 +6512,16 @@ UInt dis_bs_E_G ( UChar sorb, Int sz, Int delta, Bool fwds ) elimination of previous stores to this field work better. */ stmt( IRStmt_Put( OFFB_CC_NDEP, mkU32(0) )); - /* Result: iff source value is zero, we can't use - Iop_Clz32/Iop_Ctz32 as they have no defined result in that case. - But anyway, Intel x86 semantics say the result is undefined in - such situations. Hence handle the zero case specially. */ + /* Intel x86 semantics say the result is undefined iff source value is + zero. Hence handle the zero case specially. */ /* Bleh. What we compute: - bsf32: if src == 0 then 0 else Ctz32(src) - bsr32: if src == 0 then 0 else 31 - Clz32(src) + bsf32: if src == 0 then 0 else CtzNat32(src) + bsr32: if src == 0 then 0 else 31 - ClzNat32(src) - bsf16: if src == 0 then 0 else Ctz32(16Uto32(src)) - bsr16: if src == 0 then 0 else 31 - Clz32(16Uto32(src)) + bsf16: if src == 0 then 0 else CtzNat32(16Uto32(src)) + bsr16: if src == 0 then 0 else 31 - ClzNat32(16Uto32(src)) First, widen src to 32 bits if it is not already. @@ -6540,10 +6538,10 @@ UInt dis_bs_E_G ( UChar sorb, Int sz, Int delta, Bool fwds ) IRExpr_ITE( mkexpr(srcB), /* src != 0 */ - fwds ? unop(Iop_Ctz32, mkexpr(src32)) + fwds ? unop(Iop_CtzNat32, mkexpr(src32)) : binop(Iop_Sub32, mkU32(31), - unop(Iop_Clz32, mkexpr(src32))), + unop(Iop_ClzNat32, mkexpr(src32))), /* src == 0 -- leave dst unchanged */ widenUto32( getIReg( sz, gregOfRM(modrm) ) ) ) diff --git a/VEX/priv/host_x86_isel.c b/VEX/priv/host_x86_isel.c index e89b145327..d35df8fc47 100644 --- a/VEX/priv/host_x86_isel.c +++ b/VEX/priv/host_x86_isel.c @@ -1306,14 +1306,14 @@ static HReg iselIntExpr_R_wrk ( ISelEnv* env, const IRExpr* e ) addInstr(env, X86Instr_Sh32(Xsh_SAR, 31, dst)); return dst; } - case Iop_Ctz32: { + case Iop_CtzNat32: { /* Count trailing zeroes, implemented by x86 'bsfl' */ HReg dst = newVRegI(env); HReg src = iselIntExpr_R(env, e->Iex.Unop.arg); addInstr(env, X86Instr_Bsfr32(True,src,dst)); return dst; } - case Iop_Clz32: { + case Iop_ClzNat32: { /* Count leading zeroes. Do 'bsrl' to establish the index of the highest set bit, and subtract that value from 31. */ diff --git a/memcheck/tests/vbit-test/irops.c b/memcheck/tests/vbit-test/irops.c index 1794191a7f..e104c18acb 100644 --- a/memcheck/tests/vbit-test/irops.c +++ b/memcheck/tests/vbit-test/irops.c @@ -109,13 +109,13 @@ static irop_t irops[] = { { DEFOP(Iop_MullU32, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 1 }, // mips asserts { DEFOP(Iop_MullU64, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32, mips assert { DEFOP(Iop_Clz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32 asserts - { DEFOP(Iop_Clz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =1, .mips64 = 1 }, + { DEFOP(Iop_Clz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =1, .mips64 = 1 }, { DEFOP(Iop_Ctz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, - { DEFOP(Iop_Ctz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, + { DEFOP(Iop_Ctz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_ClzNat64, UNDEF_ALL), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, // ppc32 asserts - { DEFOP(Iop_ClzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, + { DEFOP(Iop_ClzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_CtzNat64, UNDEF_ALL), .s390x = 0, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, - { DEFOP(Iop_CtzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, + { DEFOP(Iop_CtzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_PopCount64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_PopCount32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_CmpLT32S, UNDEF_ALL), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =1, .mips64 = 1 }, |
From: Florian K. <fk...@so...> - 2025-07-31 20:50:17
|
https://sourceware.org/cgit/valgrind/commit/?id=96dfb3b4753a93db3fa0eed1c8bf73c568d3984a commit 96dfb3b4753a93db3fa0eed1c8bf73c568d3984a Author: Florian Krohm <fl...@ei...> Date: Thu Jul 31 20:45:29 2025 +0000 amd64 specific changes for BZ 507033 Rework code to use Iop_ClzNat64 instead of the deprecated Iop_Clz64. Likewise for Iop_Ctz64. Part of fixing https://bugs.kde.org/show_bug.cgi?id=507033 Diff: --- VEX/priv/guest_amd64_toIR.c | 39 +++++++++++++++++++-------------------- VEX/priv/host_amd64_isel.c | 4 ++-- memcheck/tests/vbit-test/irops.c | 8 ++++---- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c index 57a8a434b8..c98b55c063 100644 --- a/VEX/priv/guest_amd64_toIR.c +++ b/VEX/priv/guest_amd64_toIR.c @@ -5075,14 +5075,14 @@ static IRTemp gen_LZCNT ( IRType ty, IRTemp src ) binop(Iop_Shl64, mkexpr(src64), mkU8(64 - 8 * sizeofIRType(ty)))); - // Clz64 has undefined semantics when its input is zero, so - // special-case around that. + /* Guard against 0 input value. Use ClzNat64 operator for all other + values */ IRTemp res64 = newTemp(Ity_I64); assign(res64, IRExpr_ITE( binop(Iop_CmpEQ64, mkexpr(src64x), mkU64(0)), mkU64(8 * sizeofIRType(ty)), - unop(Iop_Clz64, mkexpr(src64x)) + unop(Iop_ClzNat64, mkexpr(src64x)) )); IRTemp res = newTemp(ty); @@ -5103,14 +5103,14 @@ static IRTemp gen_TZCNT ( IRType ty, IRTemp src ) IRTemp src64 = newTemp(Ity_I64); assign(src64, widenUto64( mkexpr(src) )); - // Ctz64 has undefined semantics when its input is zero, so - // special-case around that. + /* Guard against 0 input value. Use CtzNat64 operator for all other + values */ IRTemp res64 = newTemp(Ity_I64); assign(res64, IRExpr_ITE( binop(Iop_CmpEQ64, mkexpr(src64), mkU64(0)), mkU64(8 * sizeofIRType(ty)), - unop(Iop_Ctz64, mkexpr(src64)) + unop(Iop_CtzNat64, mkexpr(src64)) )); IRTemp res = newTemp(ty); @@ -8421,30 +8421,28 @@ ULong dis_bs_E_G ( const VexAbiInfo* vbi, elimination of previous stores to this field work better. */ stmt( IRStmt_Put( OFFB_CC_NDEP, mkU64(0) )); - /* Result: iff source value is zero, we can't use - Iop_Clz64/Iop_Ctz64 as they have no defined result in that case. - But anyway, amd64 semantics say the result is undefined in - such situations. Hence handle the zero case specially. */ + /* amd64 semantics say the result is undefined iff source value is + zero. Hence handle the zero case specially. */ /* Bleh. What we compute: bsf64: if src == 0 then {dst is unchanged} - else Ctz64(src) + else CtzNat64(src) bsr64: if src == 0 then {dst is unchanged} - else 63 - Clz64(src) + else 63 - ClzNat64(src) bsf32: if src == 0 then {dst is unchanged} - else Ctz64(32Uto64(src)) + else CtzNat64(32Uto64(src)) bsr32: if src == 0 then {dst is unchanged} - else 63 - Clz64(32Uto64(src)) + else 63 - ClzNat64(32Uto64(src)) bsf16: if src == 0 then {dst is unchanged} - else Ctz64(32Uto64(16Uto32(src))) + else CtzNat64(32Uto64(16Uto32(src))) bsr16: if src == 0 then {dst is unchanged} - else 63 - Clz64(32Uto64(16Uto32(src))) + else 63 - ClzNat64(32Uto64(16Uto32(src))) */ /* The main computation, guarding against zero. */ @@ -8452,10 +8450,10 @@ ULong dis_bs_E_G ( const VexAbiInfo* vbi, IRExpr_ITE( mkexpr(srcB), /* src != 0 */ - fwds ? unop(Iop_Ctz64, mkexpr(src64)) + fwds ? unop(Iop_CtzNat64, mkexpr(src64)) : binop(Iop_Sub64, mkU64(63), - unop(Iop_Clz64, mkexpr(src64))), + unop(Iop_ClzNat64, mkexpr(src64))), /* src == 0 -- leave dst unchanged */ widenUto64( getIRegG( sz, pfx, modrm ) ) ) @@ -18606,8 +18604,9 @@ static Long dis_PEXTRQ ( const VexAbiInfo* vbi, Prefix pfx, static IRExpr* math_CTZ32(IRExpr *exp) { - /* Iop_Ctz32 isn't implemented by the amd64 back end, so use Iop_Ctz64. */ - return unop(Iop_64to32, unop(Iop_Ctz64, unop(Iop_32Uto64, exp))); + /* Iop_CtzNat32 isn't implemented by the amd64 back end, so use + Iop_CtzNat64. */ + return unop(Iop_64to32, unop(Iop_CtzNat64, unop(Iop_32Uto64, exp))); } static Long dis_PCMPISTRI_3A ( UChar modrm, UInt regNoL, UInt regNoR, diff --git a/VEX/priv/host_amd64_isel.c b/VEX/priv/host_amd64_isel.c index 21d20c77f0..f0e21ab983 100644 --- a/VEX/priv/host_amd64_isel.c +++ b/VEX/priv/host_amd64_isel.c @@ -1628,14 +1628,14 @@ static HReg iselIntExpr_R_wrk ( ISelEnv* env, const IRExpr* e ) addInstr(env, AMD64Instr_Sh64(Ash_SAR, 63, dst)); return dst; } - case Iop_Ctz64: { + case Iop_CtzNat64: { /* Count trailing zeroes, implemented by amd64 'bsfq' */ HReg dst = newVRegI(env); HReg src = iselIntExpr_R(env, e->Iex.Unop.arg); addInstr(env, AMD64Instr_Bsfr64(True,src,dst)); return dst; } - case Iop_Clz64: { + case Iop_ClzNat64: { /* Count leading zeroes. Do 'bsrq' to establish the index of the highest set bit, and subtract that value from 63. */ diff --git a/memcheck/tests/vbit-test/irops.c b/memcheck/tests/vbit-test/irops.c index 33c78fef1a..1794191a7f 100644 --- a/memcheck/tests/vbit-test/irops.c +++ b/memcheck/tests/vbit-test/irops.c @@ -108,13 +108,13 @@ static irop_t irops[] = { { DEFOP(Iop_MullU16, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_MullU32, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 1 }, // mips asserts { DEFOP(Iop_MullU64, UNDEF_LEFT), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32, mips assert - { DEFOP(Iop_Clz64, UNDEF_ALL), .s390x = 0, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32 asserts + { DEFOP(Iop_Clz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 1 }, // ppc32 asserts { DEFOP(Iop_Clz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 1, .ppc64 = 1, .ppc32 = 1, .mips32 =1, .mips64 = 1 }, - { DEFOP(Iop_Ctz64, UNDEF_ALL), .s390x = 0, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, + { DEFOP(Iop_Ctz64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_Ctz32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, - { DEFOP(Iop_ClzNat64, UNDEF_ALL), .s390x = 1, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, // ppc32 asserts + { DEFOP(Iop_ClzNat64, UNDEF_ALL), .s390x = 1, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, // ppc32 asserts { DEFOP(Iop_ClzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, - { DEFOP(Iop_CtzNat64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, + { DEFOP(Iop_CtzNat64, UNDEF_ALL), .s390x = 0, .amd64 = 1, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_CtzNat32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_PopCount64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 =0, .mips64 = 0 }, { DEFOP(Iop_PopCount32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 =0, .mips64 = 0 }, |
From: Mark W. <ma...@kl...> - 2025-07-31 16:39:38
|
Hi Florian, On Thu, 2025-07-31 at 18:03 +0200, Florian Krohm wrote: > On 31.07.25 13:26, Mark Wielaard wrote: > > https://sourceware.org/cgit/valgrind/commit/?id=ab551753fad6a87acbb8a87a80ed5f5578bfd29c > > > > commit ab551753fad6a87acbb8a87a80ed5f5578bfd29c > > Author: Martin Cermak <mc...@re...> > > Date: Fri Jul 18 17:11:49 2025 +0200 > > > > Implement and override mallinfo2 > > > > Implement and override mallinfo2. Add a testcase covering mallinfo2. > > That testcase produces several compiler warnings on amd64-linux with glibc 2.35. Oops. That is what I get for not using -Werror... Sorry. Missed that. > E.g. > > mallinfo2.c:21:22: warning: format ‘%d’ expects argument of type ‘int’, but > argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] > > The fix is to use %zu but I'm not sure whether mallinfo2 is defined the same way > on all supported platforms. Yes, that is the correct fix. mallinfo2 only exists (with all mallinfo fields being size_t) on platforms that have a bogus mallinfo function/struct (with fields being ints that can overflow...) Fix pushed as: commit 2ab7b57c9785de7809d3e34386c5fb4978756123 Author: Mark Wielaard <ma...@kl...> Date: Thu Jul 31 18:34:31 2025 +0200 memcheck/tests/mallinfo2.c use %zu to print mallinfo2 fields Thanks, Mark |
From: Mark W. <ma...@so...> - 2025-07-31 16:39:23
|
https://sourceware.org/cgit/valgrind/commit/?id=2ab7b57c9785de7809d3e34386c5fb4978756123 commit 2ab7b57c9785de7809d3e34386c5fb4978756123 Author: Mark Wielaard <ma...@kl...> Date: Thu Jul 31 18:34:31 2025 +0200 memcheck/tests/mallinfo2.c use %zu to print mallinfo2 fields Diff: --- memcheck/tests/mallinfo2.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/memcheck/tests/mallinfo2.c b/memcheck/tests/mallinfo2.c index 23667a5b1d..8cdaa789e6 100644 --- a/memcheck/tests/mallinfo2.c +++ b/memcheck/tests/mallinfo2.c @@ -18,16 +18,16 @@ static size_t check(size_t min, size_t max) if (! s_quiet) { - printf("arena = %d\n", mi.arena); /* non-mmapped space allocated from system */ - printf("ordblks = %d\n", mi.ordblks); /* number of free chunks */ - printf("smblks = %d\n", mi.smblks); /* number of fastbin blocks */ - printf("hblks = %d\n", mi.hblks); /* number of mmapped regions */ - printf("hblkhd = %d\n", mi.hblkhd); /* space in mmapped regions */ - printf("usmblks = %d\n", mi.usmblks); /* maximum total allocated space */ - printf("fsmblks = %d\n", mi.fsmblks); /* space available in freed fastbin blocks */ - printf("uordblks = %d\n", mi.uordblks); /* total allocated space */ - printf("fordblks = %d\n", mi.fordblks); /* total free space */ - printf("keepcost = %d\n", mi.keepcost); /* top-most, releasable (via malloc_trim) space */ + printf("arena = %zu\n", mi.arena); /* non-mmapped space allocated from system */ + printf("ordblks = %zu\n", mi.ordblks); /* number of free chunks */ + printf("smblks = %zu\n", mi.smblks); /* number of fastbin blocks */ + printf("hblks = %zu\n", mi.hblks); /* number of mmapped regions */ + printf("hblkhd = %zu\n", mi.hblkhd); /* space in mmapped regions */ + printf("usmblks = %zu\n", mi.usmblks); /* maximum total allocated space */ + printf("fsmblks = %zu\n", mi.fsmblks); /* space available in freed fastbin blocks */ + printf("uordblks = %zu\n", mi.uordblks); /* total allocated space */ + printf("fordblks = %zu\n", mi.fordblks); /* total free space */ + printf("keepcost = %zu\n", mi.keepcost); /* top-most, releasable (via malloc_trim) space */ printf("(min = %zu, max = %zu)\n", min, max); printf("\n"); } |
From: Florian K. <fl...@ei...> - 2025-07-31 16:03:23
|
On 31.07.25 13:26, Mark Wielaard wrote: > https://sourceware.org/cgit/valgrind/commit/?id=ab551753fad6a87acbb8a87a80ed5f5578bfd29c > > commit ab551753fad6a87acbb8a87a80ed5f5578bfd29c > Author: Martin Cermak <mc...@re...> > Date: Fri Jul 18 17:11:49 2025 +0200 > > Implement and override mallinfo2 > > Implement and override mallinfo2. Add a testcase covering mallinfo2. That testcase produces several compiler warnings on amd64-linux with glibc 2.35. E.g. mallinfo2.c:21:22: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=] The fix is to use %zu but I'm not sure whether mallinfo2 is defined the same way on all supported platforms. Florian |
From: Mark W. <ma...@so...> - 2025-07-31 11:26:19
|
https://sourceware.org/cgit/valgrind/commit/?id=ab551753fad6a87acbb8a87a80ed5f5578bfd29c commit ab551753fad6a87acbb8a87a80ed5f5578bfd29c Author: Martin Cermak <mc...@re...> Date: Fri Jul 18 17:11:49 2025 +0200 Implement and override mallinfo2 Implement and override mallinfo2. Add a testcase covering mallinfo2. Exclude irrelevant LTP tests trying to cover mallinfo2. https://bugs.kde.org/show_bug.cgi?id=506967 Diff: --- .gitignore | 1 + NEWS | 1 + auxprogs/ltp-excludes.txt | 5 + configure.ac | 1 + coregrind/m_mallocfree.c | 35 +++++++ coregrind/m_replacemalloc/vg_replace_malloc.c | 28 ++++++ coregrind/m_scheduler/scheduler.c | 1 + coregrind/pub_core_mallocfree.h | 16 ++++ coregrind/pub_core_replacemalloc.h | 1 + memcheck/tests/Makefile.am | 3 + memcheck/tests/mallinfo2.c | 133 ++++++++++++++++++++++++++ memcheck/tests/mallinfo2.stderr.exp | 11 +++ memcheck/tests/mallinfo2.vgtest | 3 + 13 files changed, 239 insertions(+) diff --git a/.gitignore b/.gitignore index 0283b8d5b7..e48a2ab0ed 100644 --- a/.gitignore +++ b/.gitignore @@ -943,6 +943,7 @@ /memcheck/tests/Makefile /memcheck/tests/Makefile.in /memcheck/tests/mallinfo +/memcheck/tests/mallinfo2 /memcheck/tests/malloc1 /memcheck/tests/malloc2 /memcheck/tests/malloc3 diff --git a/NEWS b/NEWS index 00c785dfdb..fe9de908f7 100644 --- a/NEWS +++ b/NEWS @@ -61,6 +61,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 506910 openat2 with RESOLVE_NO_MAGICLINKS succeeds on /proc/self/exe 506928 Wrap (deprecated) linux specific ustat syscall 506930 valgrind allows SIGKILL being reset to SIG_DFL +506967 Implement and override mallinfo2 506970 mmap needs an EBADF fd_allowed check 507173 s390x: Crash when constant folding is disabled diff --git a/auxprogs/ltp-excludes.txt b/auxprogs/ltp-excludes.txt index b03111e20d..0d00bab8a6 100644 --- a/auxprogs/ltp-excludes.txt +++ b/auxprogs/ltp-excludes.txt @@ -29,3 +29,8 @@ fcntl36_64 clone08 close_range02 kcmp03 +# Test fails because it tests something valgrind doesn't support: +# We don't have fastbins so smblks & fsmblks are always 0. Also we +# don't have a separate mmap allocator so set hblks & hblkhd to 0. +mallinfo02 +mallinfo2_01 diff --git a/configure.ac b/configure.ac index 804493c2f2..6183179db1 100755 --- a/configure.ac +++ b/configure.ac @@ -4952,6 +4952,7 @@ AC_CHECK_FUNCS([ \ getaddrinfo \ klogctl \ mallinfo \ + mallinfo2 \ memchr \ memfd_create \ memset \ diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index dbbcb93961..e7c80af710 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -2433,6 +2433,41 @@ void VG_(mallinfo) ( ThreadId tid, struct vg_mallinfo* mi ) mi->keepcost = 0; // may want some value in here } +// The aforementioned older function, mallinfo(), is deprecated since the type +// used for the fields is too small. +void VG_(mallinfo2) ( ThreadId tid, struct vg_mallinfo2* mi ) +{ + UWord i, free_blocks, free_blocks_size; + Arena* a = arenaId_to_ArenaP(VG_AR_CLIENT); + + // Traverse free list and calculate free blocks statistics. + // This may seem slow but glibc works the same way. + free_blocks_size = free_blocks = 0; + for (i = 0; i < N_MALLOC_LISTS; i++) { + Block* b = a->freelist[i]; + if (b == NULL) continue; + for (;;) { + free_blocks++; + free_blocks_size += (UWord)get_pszB(a, b); + b = get_next_b(b); + if (b == a->freelist[i]) break; + } + } + + // We don't have fastbins so smblks & fsmblks are always 0. Also we don't + // have a separate mmap allocator so set hblks & hblkhd to 0. + mi->arena = a->stats__bytes_mmaped; + mi->ordblks = free_blocks + VG_(free_queue_length); + mi->smblks = 0; + mi->hblks = 0; + mi->hblkhd = 0; + mi->usmblks = 0; + mi->fsmblks = 0; + mi->uordblks = a->stats__bytes_on_loan - VG_(free_queue_volume); + mi->fordblks = free_blocks_size + VG_(free_queue_volume); + mi->keepcost = 0; // may want some value in here +} + SizeT VG_(arena_redzone_size) ( ArenaId aid ) { ensure_mm_init (VG_AR_CLIENT); diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index aff2d27b3c..808096152b 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -103,6 +103,7 @@ 10190 PANIC 10200 MALLOC_STATS 10210 MALLINFO + 10215 MALLINFO2 10220 DEFAULT_ZONE 10230 CREATE_ZONE 10240 ZONE_FROM_PTR @@ -2523,6 +2524,33 @@ static void panic(const char *str) #endif +/*---------------------- mallinfo2 ----------------------*/ + +// mi must be static; if it is auto then Memcheck thinks it is +// uninitialised when used by the caller of this function, because Memcheck +// doesn't know that the call to mallinfo2 fills in mi. +#define MALLINFO2(soname, fnname) \ + \ + struct vg_mallinfo2 VG_REPLACE_FUNCTION_EZU(10215,soname,fnname) ( void ); \ + struct vg_mallinfo2 VG_REPLACE_FUNCTION_EZU(10215,soname,fnname) ( void ) \ + { \ + static struct vg_mallinfo2 mi; \ + DO_INIT; \ + MALLOC_TRACE("mallinfo2()\n"); \ + (void)VALGRIND_NON_SIMD_CALL1( info.mallinfo2, &mi ); \ + return mi; \ + } + +#if defined(VGO_linux) + MALLINFO2(VG_Z_LIBC_SONAME, mallinfo2); + MALLINFO2(SO_SYN_MALLOC, mallinfo2); + +#elif defined(VGO_darwin) + //MALLINFO2(VG_Z_LIBC_SONAME, mallinfo2); + +#endif + + /*------------------ Darwin zone stuff ------------------*/ #if defined(VGO_darwin) diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 1623dda5a0..1e77944cdd 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -2147,6 +2147,7 @@ void do_client_request ( ThreadId tid ) info->tl_malloc_usable_size = VG_(tdict).tool_malloc_usable_size; info->mallinfo = VG_(mallinfo); + info->mallinfo2 = VG_(mallinfo2); info->clo_trace_malloc = VG_(clo_trace_malloc); info->clo_realloc_zero_bytes_frees = VG_(clo_realloc_zero_bytes_frees); diff --git a/coregrind/pub_core_mallocfree.h b/coregrind/pub_core_mallocfree.h index df9648cea4..3ae9eb486a 100644 --- a/coregrind/pub_core_mallocfree.h +++ b/coregrind/pub_core_mallocfree.h @@ -106,6 +106,21 @@ struct vg_mallinfo { int keepcost; /* top-most, releasable (via malloc_trim) space */ }; +/* This struct definition MUST match the system one. */ +/* SVID2/XPG mallinfo structure */ +struct vg_mallinfo2 { + SizeT arena; /* total space allocated from system */ + SizeT ordblks; /* number of non-inuse chunks */ + SizeT smblks; /* unused -- always zero */ + SizeT hblks; /* number of mmapped regions */ + SizeT hblkhd; /* total space in mmapped regions */ + SizeT usmblks; /* unused -- always zero */ + SizeT fsmblks; /* unused -- always zero */ + SizeT uordblks; /* total allocated space */ + SizeT fordblks; /* total non-inuse space */ + SizeT keepcost; /* top-most, releasable (via malloc_trim) space */ +}; + extern void* VG_(arena_malloc) ( ArenaId arena, const HChar* cc, SizeT nbytes ); extern void VG_(arena_free) ( ArenaId arena, void* ptr ); extern void* VG_(arena_calloc) ( ArenaId arena, const HChar* cc, @@ -132,6 +147,7 @@ extern SizeT VG_(arena_malloc_usable_size) ( ArenaId aid, void* payload ); extern SizeT VG_(arena_redzone_size) ( ArenaId aid ); extern void VG_(mallinfo) ( ThreadId tid, struct vg_mallinfo* mi ); +extern void VG_(mallinfo2) ( ThreadId tid, struct vg_mallinfo2* mi ); // VG_(arena_perm_malloc) is for permanent allocation of small blocks. // See VG_(perm_malloc) in pub_tool_mallocfree.h for more details. diff --git a/coregrind/pub_core_replacemalloc.h b/coregrind/pub_core_replacemalloc.h index f26884c4fd..4f9c5bb1a3 100644 --- a/coregrind/pub_core_replacemalloc.h +++ b/coregrind/pub_core_replacemalloc.h @@ -54,6 +54,7 @@ struct vg_mallocfunc_info { void* (*tl_realloc) (ThreadId tid, void* p, SizeT size); SizeT (*tl_malloc_usable_size) (ThreadId tid, void* payload); void (*mallinfo) (ThreadId tid, struct vg_mallinfo* mi); + void (*mallinfo2) (ThreadId tid, struct vg_mallinfo2* mi); Bool clo_trace_malloc; Bool clo_realloc_zero_bytes_frees; }; diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index aceed97b27..91d58b48b8 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -261,6 +261,7 @@ EXTRA_DIST = \ long_namespace_xml.stderr.exp long_namespace_xml.stderr.exp-freebsd \ long-supps.vgtest long-supps.stderr.exp long-supps.supp \ mallinfo.stderr.exp mallinfo.vgtest \ + mallinfo2.stderr.exp mallinfo2.vgtest \ malloc_free_fill.vgtest \ malloc_free_fill.stderr.exp \ malloc_usable.stderr.exp malloc_usable.vgtest \ @@ -521,6 +522,7 @@ check_PROGRAMS = \ leak-segv-jmp \ long-supps \ mallinfo \ + mallinfo2 \ malloc_free_fill \ malloc_usable malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \ match-overrun \ @@ -682,6 +684,7 @@ bug472219_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ calloc_overflow_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_ALLOC_SIZE_LARGER_THAN@ malloc_usable_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_MAYBE_UNINITIALIZED@ @FLAG_W_NO_UNINITIALIZED@ mallinfo_CFLAGS = $(AM_CFLAGS) -Wno-deprecated-declarations +mallinfo2_CFLAGS = $(AM_CFLAGS) -Wno-deprecated-declarations malloc3_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_ALLOC_SIZE_LARGER_THAN@ sbfragment_CFLAGS = $(AM_CFLAGS) -Wno-deprecated-declarations strchr_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@ diff --git a/memcheck/tests/mallinfo2.c b/memcheck/tests/mallinfo2.c new file mode 100644 index 0000000000..23667a5b1d --- /dev/null +++ b/memcheck/tests/mallinfo2.c @@ -0,0 +1,133 @@ +#include "tests/malloc.h" +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> // getopt() +#include "../config.h" + + +static int s_quiet = 0; + + +#if defined(HAVE_MALLINFO2) +static size_t check(size_t min, size_t max) +{ + struct mallinfo2 mi; + size_t used; + + mi = mallinfo2(); + + if (! s_quiet) + { + printf("arena = %d\n", mi.arena); /* non-mmapped space allocated from system */ + printf("ordblks = %d\n", mi.ordblks); /* number of free chunks */ + printf("smblks = %d\n", mi.smblks); /* number of fastbin blocks */ + printf("hblks = %d\n", mi.hblks); /* number of mmapped regions */ + printf("hblkhd = %d\n", mi.hblkhd); /* space in mmapped regions */ + printf("usmblks = %d\n", mi.usmblks); /* maximum total allocated space */ + printf("fsmblks = %d\n", mi.fsmblks); /* space available in freed fastbin blocks */ + printf("uordblks = %d\n", mi.uordblks); /* total allocated space */ + printf("fordblks = %d\n", mi.fordblks); /* total free space */ + printf("keepcost = %d\n", mi.keepcost); /* top-most, releasable (via malloc_trim) space */ + printf("(min = %zu, max = %zu)\n", min, max); + printf("\n"); + } + + // size checks + used = mi.uordblks + mi.hblkhd; + if (used < min) + exit(1); + + if (used > max) + exit(2); + + // used should be reasonably close to min + // define "reasonably" as within 20% + if (used/5*4 > min) + exit(3); + + // sanity checks + if ((mi.ordblks == 0) != (mi.fordblks == 0)) + exit(10); + + if ((mi.smblks == 0) != (mi.fsmblks == 0)) + exit(11); + + if ((mi.hblks == 0) != (mi.hblkhd == 0)) + exit(12); + + if (mi.keepcost > mi.fordblks) + exit(13); + + if (mi.fsmblks > mi.fordblks) + exit(14); + + // arena should be reasonably close to fordblks + uordblks + if (mi.arena < mi.fordblks + mi.uordblks) + exit(15); + + if (mi.arena/5*4 > mi.fordblks + mi.uordblks) + exit(16); + + return used; +} +#else +static size_t check(size_t min, size_t max) +{ + if (! s_quiet) + { + printf("mallinfo() is not supported on this platform.\n"); + printf("\n"); + } + return 0; +} +#endif + +int main(int argc, char** argv) +{ + void* ptr[40]; + int i; + size_t min, max; + int optchar; + + while ((optchar = getopt(argc, argv, "q")) != EOF) + { + switch (optchar) + { + case 'q': + s_quiet = 1; + break; + default: + fprintf(stderr, "Usage: %s [-q].\n", argv[0]); + return 1; + } + } + + min = 0; + for (i = 1; i <= 40; i++) + { + int size = i * i * 8; + min += size; + ptr[i - 1] = malloc(size); + }; + + max = check(min, (size_t)-1); + + for (i = 1; i <= 20; i++) + { + int size = i * i * 8; + min -= size; + max -= size; + free(ptr[i - 1]); + }; + + check(min, max); + + for ( ; i <= 40; i++) + { + free(ptr[i - 1]); + } + + fprintf(stderr, "Success.\n"); + + return 0; +} diff --git a/memcheck/tests/mallinfo2.stderr.exp b/memcheck/tests/mallinfo2.stderr.exp new file mode 100644 index 0000000000..65f7e5b13d --- /dev/null +++ b/memcheck/tests/mallinfo2.stderr.exp @@ -0,0 +1,11 @@ + +Success. + +HEAP SUMMARY: + in use at exit: ... bytes in ... blocks + total heap usage: ... allocs, ... frees, ... bytes allocated + +For a detailed leak analysis, rerun with: --leak-check=full + +For lists of detected and suppressed errors, rerun with: -s +ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) diff --git a/memcheck/tests/mallinfo2.vgtest b/memcheck/tests/mallinfo2.vgtest new file mode 100644 index 0000000000..ba76920727 --- /dev/null +++ b/memcheck/tests/mallinfo2.vgtest @@ -0,0 +1,3 @@ +prog: mallinfo2 +args: -q +stderr_filter: filter_allocs |
From: Mark W. <ma...@so...> - 2025-07-30 16:41:11
|
https://sourceware.org/cgit/valgrind/commit/?id=bc66a6e865d952ac51ffb0e63c127ce7cd977b98 commit bc66a6e865d952ac51ffb0e63c127ce7cd977b98 Author: Alexandra Hájková <aha...@re...> Date: Tue Jul 29 09:49:26 2025 -0400 Add fd_allowed and POST_newFd_RES to all syscalls that use or return fds This makes sure all file descriptors that take a file descriptor check that the file descriptor is valid. Also makes sure that the --modify-fds=high option affects all sycalls that return a file descriptor. https://bugs.kde.org/show_bug.cgi?id=493430 Diff: --- NEWS | 1 + coregrind/m_syswrap/syswrap-generic.c | 23 +++++++++++++ coregrind/m_syswrap/syswrap-linux.c | 61 +++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/NEWS b/NEWS index 636bf61dd9..00c785dfdb 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 338803 Handling of dwz debug alt files or cross-CU is broken 418756 MAP_FIXED_NOREPLACE mmap flag unsupported +493430 Review all syscalls that use or return (new) file descriptors 493434 Add --track-fds=bad mode (no "leak" tracking) 501741 syscall cachestat not wrapped 502359 Add --modify-fds=yes option diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 7ac86fbbc0..c7d58bc106 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -2944,6 +2944,8 @@ PRE(sys_fsync) *flags |= SfMayBlock; PRINT("sys_fsync ( %" FMT_REGWORD "u )", ARG1); PRE_REG_READ1(long, "fsync", unsigned int, fd); + if ( !ML_(fd_allowed)(ARG1, "fsync", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_fdatasync) @@ -2951,6 +2953,8 @@ PRE(sys_fdatasync) *flags |= SfMayBlock; PRINT("sys_fdatasync ( %" FMT_REGWORD "u )", ARG1); PRE_REG_READ1(long, "fdatasync", unsigned int, fd); + if ( !ML_(fd_allowed)(ARG1, "fdatasync", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_msync) @@ -3215,6 +3219,8 @@ PRE(sys_fstatfs) PRE_REG_READ2(long, "fstatfs", unsigned int, fd, struct statfs *, buf); PRE_MEM_WRITE( "fstatfs(buf)", ARG2, sizeof(struct vki_statfs) ); + if ( !ML_(fd_allowed)(ARG1, "fstatfs", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } POST(sys_fstatfs) @@ -3230,6 +3236,8 @@ PRE(sys_fstatfs64) PRE_REG_READ3(long, "fstatfs64", unsigned int, fd, vki_size_t, size, struct statfs64 *, buf); PRE_MEM_WRITE( "fstatfs64(buf)", ARG3, ARG2 ); + if ( !ML_(fd_allowed)(ARG1, "fstatfs64", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } POST(sys_fstatfs64) { @@ -3288,6 +3296,8 @@ PRE(sys_flock) *flags |= SfMayBlock; PRINT("sys_flock ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2 ); PRE_REG_READ2(long, "flock", unsigned int, fd, unsigned int, operation); + if ( !ML_(fd_allowed)(ARG1, "flock", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } // Pre_read a char** argument. @@ -3818,6 +3828,8 @@ PRE(sys_fchdir) FUSE_COMPATIBLE_MAY_BLOCK(); PRINT("sys_fchdir ( %" FMT_REGWORD "u )", ARG1); PRE_REG_READ1(long, "fchdir", unsigned int, fd); + if ( !ML_(fd_allowed)(ARG1, "fchdir", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_fchown) @@ -3827,6 +3839,8 @@ PRE(sys_fchown) FMT_REGWORD "u )", ARG1, ARG2, ARG3); PRE_REG_READ3(long, "fchown", unsigned int, fd, vki_uid_t, owner, vki_gid_t, group); + if ( !ML_(fd_allowed)(ARG1, "fchown", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_fchmod) @@ -3834,6 +3848,8 @@ PRE(sys_fchmod) FUSE_COMPATIBLE_MAY_BLOCK(); PRINT("sys_fchmod ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); PRE_REG_READ2(long, "fchmod", unsigned int, fildes, vki_mode_t, mode); + if ( !ML_(fd_allowed)(ARG1, "fchmod", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } #if !defined(VGP_nanomips_linux) && !defined (VGO_freebsd) @@ -3910,6 +3926,8 @@ PRE(sys_ftruncate) *flags |= SfMayBlock; PRINT("sys_ftruncate ( %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1, ARG2); PRE_REG_READ2(long, "ftruncate", unsigned int, fd, unsigned long, length); + if ( !ML_(fd_allowed)(ARG1, "ftruncate", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_truncate) @@ -3936,6 +3954,8 @@ PRE(sys_ftruncate64) PRE_REG_READ2(long, "ftruncate64", unsigned int,fd, UWord,length); #endif + if ( !ML_(fd_allowed)(ARG1, "ftruncate64", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_truncate64) @@ -4801,6 +4821,9 @@ PRE(sys_poll) PRE_MEM_READ( "poll(ufds.fd)", (Addr)(&ufds[i].fd), sizeof(ufds[i].fd) ); if (ML_(safe_to_deref)(&ufds[i].fd, sizeof(ufds[i].fd)) && ufds[i].fd >= 0) { + if (!ML_(fd_allowed)(ufds[i].fd, "poll(ufds.fd)", tid, False)) { + /* do nothing? Just let fd_allowed produce a warning? */ + } PRE_MEM_READ( "poll(ufds.events)", (Addr)(&ufds[i].events), sizeof(ufds[i].events) ); } diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 552fceee8d..572a42925d 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -2518,6 +2518,8 @@ PRE(sys_fadvise64) PRE_REG_READ5(long, "fadvise64", int, fd, vki_u32, MERGE64_FIRST(offset), vki_u32, MERGE64_SECOND(offset), vki_size_t, len, int, advice); + if ( !ML_(fd_allowed)(SARG1, "fadvise64", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_fadvise64_64) @@ -2527,6 +2529,8 @@ PRE(sys_fadvise64_64) PRE_REG_READ6(long, "fadvise64_64", int, fd, vki_u32, MERGE64_FIRST(offset), vki_u32, MERGE64_SECOND(offset), vki_u32, MERGE64_FIRST(len), vki_u32, MERGE64_SECOND(len), int, advice); + if ( !ML_(fd_allowed)(SARG1, "fadvise64_64", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } /* --------------------------------------------------------------------- @@ -2861,6 +2865,8 @@ PRE(sys_fanotify_mark) int, dfd, const char *, pathname); if (ARG5) PRE_MEM_RASCIIZ( "fanotify_mark(path)", ARG5); + if ( !ML_(fd_allowed)(SARG1, "fanotify_mark", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); #else # error Unexpected word size #endif @@ -2897,6 +2903,7 @@ PRE(sys_inotify_init1) POST(sys_inotify_init1) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "inotify_init", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -2943,6 +2950,7 @@ PRE(sys_mq_open) POST(sys_mq_open) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "mq_open", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -3373,6 +3381,7 @@ PRE(sys_timerfd_create) } POST(sys_timerfd_create) { + POST_newFd_RES; if (linux_kernel_2_6_22()) { /* 2.6.22 kernel: timerfd system call. */ @@ -3615,6 +3624,9 @@ PRE(sys_fchown16) FMT_REGWORD "u )", ARG1, ARG2, ARG3); PRE_REG_READ3(long, "fchown16", unsigned int, fd, vki_old_uid_t, owner, vki_old_gid_t, group); + if ( !ML_(fd_allowed)(ARG1, "fchown16", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); + } /* --------------------------------------------------------------------- @@ -3709,6 +3721,9 @@ PRE(sys_fgetxattr) int, fd, char *, name, void *, value, vki_size_t, size); PRE_MEM_RASCIIZ( "fgetxattr(name)", ARG2 ); PRE_MEM_WRITE( "fgetxattr(value)", ARG3, ARG4 ); + if ( !ML_(fd_allowed)(SARG1, "fgetxattr", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); + } POST(sys_fgetxattr) { @@ -3756,6 +3771,9 @@ PRE(sys_flistxattr) PRE_REG_READ3(ssize_t, "flistxattr", int, fd, char *, list, vki_size_t, size); PRE_MEM_WRITE( "flistxattr(list)", ARG2, ARG3 ); + if ( !ML_(fd_allowed)(ARG1, "flistxattr", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); + } POST(sys_flistxattr) { @@ -3789,6 +3807,9 @@ PRE(sys_fremovexattr) PRINT("sys_fremovexattr ( %ld, %#" FMT_REGWORD "x )", SARG1, ARG2); PRE_REG_READ2(long, "fremovexattr", int, fd, char *, name); PRE_MEM_RASCIIZ( "fremovexattr(name)", ARG2 ); + if ( !ML_(fd_allowed)(SARG1, "fremovexattr", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); + } /* --------------------------------------------------------------------- @@ -4151,6 +4172,7 @@ PRE(sys_perf_event_open) POST(sys_perf_event_open) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "perf_event_open", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -4229,6 +4251,7 @@ PRE(sys_memfd_create) POST(sys_memfd_create) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "memfd_create", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -4255,6 +4278,7 @@ POST(sys_landlock_create_ruleset) { /* Returns either the abi version or a file descriptor. */ if (ARG3 != VKI_LANDLOCK_CREATE_RULESET_VERSION) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "landlock_create_ruleset", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -4295,6 +4319,7 @@ PRE(sys_memfd_secret) POST(sys_memfd_secret) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "memfd_secret", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -4626,6 +4651,7 @@ PRE(sys_signalfd) } POST(sys_signalfd) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "signalfd", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -4647,6 +4673,7 @@ PRE(sys_signalfd4) } POST(sys_signalfd4) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "signalfd4", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -6143,6 +6170,8 @@ PRE(sys_fchownat) int, dfd, const char *, path, vki_uid_t, owner, vki_gid_t, group); PRE_MEM_RASCIIZ( "fchownat(path)", ARG2 ); + if ( !ML_(fd_allowed)(SARG1, "fchownat", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_futimesat) @@ -6156,6 +6185,9 @@ PRE(sys_futimesat) PRE_MEM_RASCIIZ( "futimesat(filename)", ARG2 ); if (ARG3 != 0) PRE_MEM_READ( "futimesat(tvp)", ARG3, 2 * sizeof(struct vki_timeval) ); + if ( !ML_(fd_allowed)(SARG1, "futimesat", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); + } PRE(sys_utimensat) @@ -6345,6 +6377,9 @@ PRE(sys_fchmodat) PRE_REG_READ3(long, "fchmodat", int, dfd, const char *, path, vki_mode_t, mode); PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2 ); + if ( !ML_(fd_allowed)(SARG1, "fchmodat", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); + } PRE(sys_cachestat) @@ -6377,6 +6412,8 @@ PRE(sys_fchmodat2) int, dfd, const char *, path, vki_mode_t, mode, unsigned int, flags); PRE_MEM_RASCIIZ( "fchmodat2(pathname)", ARG2 ); + if ( !ML_(fd_allowed)(SARG1, "fchmodat2", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_faccessat) @@ -6387,6 +6424,9 @@ PRE(sys_faccessat) PRE_REG_READ3(long, "faccessat", int, dfd, const char *, pathname, int, mode); PRE_MEM_RASCIIZ( "faccessat(pathname)", ARG2 ); + if ( !ML_(fd_allowed)(SARG1, "faccessat", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); + } PRE(sys_faccessat2) @@ -6397,6 +6437,8 @@ PRE(sys_faccessat2) PRE_REG_READ4(long, "faccessat2", int, dfd, const char *, pathname, int, mode, int, flags); PRE_MEM_RASCIIZ( "faccessat2(pathname)", ARG2 ); + if ( !ML_(fd_allowed)(SARG1, "faccessat2", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_name_to_handle_at) @@ -6441,6 +6483,7 @@ PRE(sys_open_by_handle_at) POST(sys_open_by_handle_at) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "open_by_handle_at", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -7014,6 +7057,8 @@ PRE(sys_finit_module) PRE_REG_READ3(long, "finit_module", int, fd, const char *, params, int, flags); PRE_MEM_RASCIIZ("finit_module(params)", ARG2); + if ( !ML_(fd_allowed)(ARG1, "finit_module", tid, False) ) + SET_STATUS_Failure( VKI_EBADF ); } PRE(sys_delete_module) @@ -7284,6 +7329,7 @@ POST(sys_fcntl) { vg_assert(SUCCESS); if (ARG2 == VKI_F_DUPFD) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "fcntl(DUPFD)", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -7293,6 +7339,7 @@ POST(sys_fcntl) } } else if (ARG2 == VKI_F_DUPFD_CLOEXEC) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "fcntl(DUPFD_CLOEXEC)", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -7398,6 +7445,7 @@ POST(sys_fcntl64) { vg_assert(SUCCESS); if (ARG2 == VKI_F_DUPFD) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "fcntl64(DUPFD)", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -7407,6 +7455,7 @@ POST(sys_fcntl64) } } else if (ARG2 == VKI_F_DUPFD_CLOEXEC) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "fcntl64(DUPFD_CLOEXEC)", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -13521,6 +13570,7 @@ POST(sys_bpf) case VKI_BPF_MAP_GET_FD_BY_ID: case VKI_BPF_BTF_GET_FD_BY_ID: case VKI_BPF_RAW_TRACEPOINT_OPEN: + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "bpf", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE); @@ -13543,6 +13593,7 @@ POST(sys_bpf) break; case VKI_BPF_PROG_LOAD: /* Return a file descriptor for loaded program, write into log_buf. */ + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "bpf", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE); @@ -13571,6 +13622,7 @@ POST(sys_bpf) break; case VKI_BPF_BTF_LOAD: /* Return a file descriptor for BTF data, write into btf_log_buf. */ + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "bpf", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE); @@ -13729,6 +13781,7 @@ PRE(sys_io_uring_setup) POST(sys_io_uring_setup) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "io_uring_setup", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -14104,6 +14157,7 @@ PRE(sys_openat2) POST(sys_openat2) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "openat2", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -14120,6 +14174,7 @@ PRE(sys_pidfd_open) POST(sys_pidfd_open) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "pidfd", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -14138,6 +14193,7 @@ PRE(sys_pidfd_getfd) POST(sys_pidfd_getfd) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "pidfd_getfd", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -14167,6 +14223,7 @@ PRE(sys_open_tree) POST(sys_open_tree) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "open_tree", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -14219,6 +14276,7 @@ PRE(sys_fsopen) POST(sys_fsopen) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "fsopen", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -14239,6 +14297,7 @@ PRE(sys_fsmount) POST(sys_fsmount) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "fsmount", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -14284,6 +14343,7 @@ PRE(sys_fspick) POST(sys_fspick) { + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "fspick", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); @@ -14304,6 +14364,7 @@ PRE(sys_userfaultfd) POST(sys_userfaultfd) { vg_assert(SUCCESS); + POST_newFd_RES; if (!ML_(fd_allowed)(RES, "userfaultfd", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); |
From: Florian K. <fk...@so...> - 2025-07-30 15:43:48
|
https://sourceware.org/cgit/valgrind/commit/?id=d34c697d35ba405efd1a20eaa705f63d0a5d2b1e commit d34c697d35ba405efd1a20eaa705f63d0a5d2b1e Author: Florian Krohm <fl...@ei...> Date: Wed Jul 30 14:08:32 2025 +0000 s390: New Principles of Operations is out Diff: --- README.s390 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.s390 b/README.s390 index 528eafc5cc..d2236d29fa 100644 --- a/README.s390 +++ b/README.s390 @@ -42,6 +42,6 @@ Reading Material (1) ELF ABI s390x Supplement https://github.com/IBM/s390x-abi/releases (2) z/Architecture Principles of Operation - https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf + https://www.ibm.com/docs/en/module_1678991624569/pdf/SA22-7832-14.pdf (3) Collection of z/Architecture publications https://linux.mainframe.blog/zarchitecture-principles-of-operation/ |
From: Florian K. <fk...@so...> - 2025-07-30 15:09:53
|
https://sourceware.org/cgit/valgrind/commit/?id=d2fea8d23e85ed573094f6d945b224f3e730e90c commit d2fea8d23e85ed573094f6d945b224f3e730e90c Author: Florian Krohm <fl...@ei...> Date: Wed Jul 30 14:44:40 2025 +0000 Fix a panic message. That code snippet is executed for both Iend_BE and Iend_LE. Diff: --- memcheck/mc_translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memcheck/mc_translate.c b/memcheck/mc_translate.c index 05e6d59afa..b4e499cc00 100644 --- a/memcheck/mc_translate.c +++ b/memcheck/mc_translate.c @@ -6064,7 +6064,7 @@ void do_shadow_Store ( MCEnv* mce, case Ity_I32: c = IRConst_U32 (V_BITS32_DEFINED); break; case Ity_I16: c = IRConst_U16 (V_BITS16_DEFINED); break; case Ity_I8: c = IRConst_U8 (V_BITS8_DEFINED); break; - default: VG_(tool_panic)("memcheck:do_shadow_Store(LE)"); + default: VG_(tool_panic)("memcheck:do_shadow_Store"); } vdata = IRExpr_Const( c ); } |
From: Florian K. <fl...@ei...> - 2025-07-30 10:15:45
|
U256 is a 16-byte wide type defined as an array of UInts and therefore presumably meant to represent 256 bit wide integers. There are, however, no IROps operating on or yielding such a value. The type is only used to declare guest_YMM0 etc. in libvex_guest_amd64.h But those registers are vector registers. Therefore, V256 is the proper type. The reg-tested attached patch removes the U256 typedef and adds a V128 [2] variant to V256. I realise that this is an incompatible change in the VEX API. But given that U256 is effectively a dead type within VEX I was wondering whether we have to go through some kind of deprecation protocol. OK? Florian |
From: Mark W. <ma...@kl...> - 2025-07-30 00:29:13
|
Sourceware infrastructure community updates for Q2 2025 Sourceware has provided the infrastructure for core toolchain and developer tools projects for more than 25 years. https://sourceware.org/sourceware-25-roadmap.html Keep Sourceware worry-free, friendly and independent by donating https://sourceware.org/donate.html support our fiscal sponser SFC https://sfconservancy.org/sustainer and/or support OSUOSL for hosting Free Software projects https://osuosl.org/donate/ Every quarter we provide a summary of news about Sourceware infrastructure: - Sourceware @ Conservancy Year Two - Anubis for more services, now without javascript challenge - Sourceware servers on the move - Red Hat Community Cage server move - OSUOSL datacenter move - The Road to Porto: Cauldron in September - Thanks Christopher Faylor (cgf) - Signed-commit leaderboard - Sourceware Organization, Contact and Open Office hours = Sourceware @ Conservancy Year Two In May we celebrated that Sourceware got a financial and administrative home at the Software Freedom Conservancy two years ago https://sfconservancy.org/news/2023/may/15/sourceware-joins-sfc/ Conservancy has helped us turn from a purely volunteer into a professional organization with an Project Leadership Committee, monthly open office hours, multiple hardware services partners, expanded services, and a more diverse funding model that allows us to enter into contracts with paid contractors or staff if necessary. Read all about the last year communications, user survey, the new services, cyber security and regulations, new and upgraded hardware, and our finances: https://inbox.sourceware.org/202...@gn... = Anubis for more services, now without javascript challenge What started as an experiment for patchwork and bunsen has now been rolled out to most other services, cgit, gitweb, bugzilla, wikis and the forge. The latest version of Anubis contains a non-javascript challenge which has been used for bugzilla as an experiment and seems as effective as the javascript challenge. So it has now been rolled out to all services. = Sourceware servers on the move All our servers will be moving later this year because both our hardware services partners will move datacenters. The Sourceware PLC decided to take advantage of this move by adding more/bigger machines. - Red Hat Community Cage server move This https://www.osci.io/tenants/ impacts server2 (main server), server3 (backup server) and forge.sourceware.org. We will add a new bigger server which has 3x memory [24x64GB], 10x storage [6x3.84TB], 2x cpu ish [2x28 cores] compared to the current servers. The new data center also has a a faster/bigger network pipe. The new server1 was made possible thanks to the FUTO grant, individual Sourceware donations and Red Hat OSPO CommInfra & IT teams. It has already been installed in the new RDU3 data center. But doesn't have network yet (will be added in two weeks). We like to have the new server1 setup and in production before the move of the other two servers so there is a minimum of downtime. We discussed a plan to do this and how we can use this for moving some services in their own isolated VMs, and which resources need to be untangled for that at the last Open Office hour. https://sourceware.org/sourceware-wiki/Migration2025/ - OSUOSL datacenter move This https://osuosl.org/communities/ impacts sourceware-builder1, sourceware-builder2, arm64-1, arm64-2 and the snapshots server. The OSL might be able to upgrade the first two CI x86_64 builders which would be great since we expect the experimental forge to also want to add CI for merge requests. But they would like us to cover some of the co-location hosting costs if possible. = The Road to Porto: Cauldron in September The next GNU Tools Cauldron, taking place in Porto, Portugal, on September 26-28, 2025. https://inbox.sourceware.org/87o...@or.../ https://gcc.gnu.org/wiki/cauldron2025 https://gnu-tools-cauldron.org/ Various Sourceware Project Leadership Committee members will be there to discuss various infrastructure projects and experiments. = Signed-commit census leaderboard How is your project doing on signed commits? Analyzing branch HEAD since 2025-01-01 cygwin-calm 32 commits 32 signed 100% 1 committers 1 signers 100% cygwin-setup 11 commits 11 signed 100% 1 committers 1 signers 100% gitsigur 5 commits 5 signed 100% 1 committers 1 signers 100% bunsen 163 commits 136 signed 83% 2 committers 2 signers 100% annobin 48 commits 39 signed 81% 2 committers 1 signers 50% systemtap 67 commits 50 signed 74% 4 committers 3 signers 75% builder 58 commits 18 signed 31% 4 committers 3 signers 75% elfutils 102 commits 14 signed 13% 4 committers 2 signers 50% lvm2 428 commits 41 signed 9% 7 committers 1 signers 14% glibc 741 commits 74 signed 9% 33 committers 2 signers 6% gcc 5659 commits 447 signed 7% 152 committers 10 signers 6% debugedit 15 commits 1 signed 6% 2 committers 1 signers 50% newlib-cygwin 416 commits 26 signed 6% 14 committers 2 signers 14% binutils-gdb 2244 commits 80 signed 3% 79 committers 5 signers 6% libabigail 81 commits 2 signed 2% 2 committers 1 signers 50% bzip2 2 commits 0 signed 0% 1 committers 0 signers 0% dwz 9 commits 0 signed 0% 2 committers 0 signers 0% insight 54 commits 0 signed 0% 1 committers 0 signers 0% forge 12 commits 0 signed 0% 1 committers 0 signers 0% valgrind 332 commits 0 signed 0% 6 committers 0 signers 0% = Thanks Christopher Faylor (cgf) Since 1999 Christopher Faylor has been one of the Cygwin project leads for 15 years. He was list maintainer for cygwin, sourceware and gcc mailinglists for 20 years. And handled spam almost daily so we could have open lists. He was one of the founding members of the Sourceware Project Leadership Committee (PLC). Sourceware wouldn't be what it is today without him. But after 25 years of being involved with Sourceware and 2 years serving on the PLC he decided to resign. We thank him for all he did and all his insights making Sourceware a worry-free, friendly home for core toolchain and developer tools projects. The PLC https://sourceware.org/mission.html#plc now consists of 7 members. The mandatory minimum number of Members is 4. And no more than 2 Members may be Financially-Related to the same Entity. If you are interested in joining the PLC please read the https://sourceware.org/Conservancy-Sourceware-FSA.pdf Fiscal Sponsorship Agreement, the Conflict of Interest Policy https://sfconservancy.org/projects/policies/conflict-of-interest-policy.html and contact us at pl...@so.... If you rather help with more technical tasks please join the overseers list: https://sourceware.org/mailman/listinfo/overseers = Sourceware Organization, Contact and Open Office hours We can be reached through irc, email and bugzilla https://sourceware.org/mission.html#organization There is also a fediverse account for for announcements, notices about downtime and temporary issues with our network. https://fosstodon.org/@sourceware Every second Friday of the month is the Sourceware Overseers Open Office hour in #overseers on irc.libera.chat from 16:00 till 17:00 UTC. Please feel free to drop by with any Sourceware services and hosting questions. If you aren't already and want to keep up to date on Sourceware infrastructure services then please also subscribe to the overseers mailinglist https://sourceware.org/mailman/listinfo/overseers Do you or your company want to sponsor Sourceware plans financially https://sourceware.org/sourceware-security-vision.html#plans donate hardware or services then contact us at sp...@so... Sourceware PLC, Frank Ch. Eigler, Ian Kelling, Ian Lance Taylor, Tom Tromey, Jon Turney, Mark J. Wielaard and Elena Zannoni |
From: Florian K. <fk...@so...> - 2025-07-28 09:52:44
|
https://sourceware.org/cgit/valgrind/commit/?id=b7ce61bec4c7c86cec0b2896d62c8b3a73015610 commit b7ce61bec4c7c86cec0b2896d62c8b3a73015610 Author: Florian Krohm <fl...@ei...> Date: Mon Jul 28 09:51:55 2025 +0000 README_DEVELOPERS: change a few path names for consistency Diff: --- README_DEVELOPERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README_DEVELOPERS b/README_DEVELOPERS index a3360580eb..fc5a801295 100644 --- a/README_DEVELOPERS +++ b/README_DEVELOPERS @@ -271,12 +271,12 @@ without too much problem by following these steps: export VALGRIND_LIB=$DIR/.in_place VALGRIND_LIB is where the default.supp and vgpreload_ libraries - are found (which is under /usr/libexec/valgrind for an installed + are found (which is under /usr/local/libexec/valgrind for an installed version). (2) Run gdb on the tool executable. Eg: - gdb /usr/local/lib/valgrind/lackey-ppc32-linux + gdb /usr/local/libexec/valgrind/lackey-ppc32-linux or |
From: Florian K. <fl...@ei...> - 2025-07-27 20:42:03
|
Hi Paul, thanks for helping me out. On 27.07.25 18:23, Paul Floyd via Valgrind-developers wrote: > > I think that you are just missing the --tool=none argument to the tool. Indeed, it just didn't occur to me that I'd have to specify --tool=none when I had explicitly launched none-amd64-linux... Might be worth a warning when VG_(clo_toolname) and the launched tool executable are not in synch.. Florian |
From: Paul F. <pj...@wa...> - 2025-07-27 16:40:32
|
On 7/27/25 14:58, Florian Krohm wrote: > The way VALGRIND_LAUNCHER is defined in README_DEVELOPERS line 274 > suggests that --prefix=/usr/local was used when configuring. > But then VALGRIND_LIB needs adjustment and the path to the tool exec > as well. > At least that is what I observe. Yes I think that both those changes should be made. configure defaults to /usr/local, and libexec is right (not lib). The paths may be different for system installed packages. FreeBSD uses /usr/local but Solaris just uses /usr as does Debian. A+ Paul |
From: Paul F. <pj...@wa...> - 2025-07-27 16:23:47
|
On 7/27/25 15:24, Florian Krohm wrote: > > I suppose people rarely debug the none tool. I found out because the > iropt tester runs under "none" auspices... > Off-hand I have no idea what might be causing it. > Hi Florian I think that you are just missing the --tool=none argument to the tool. Once loaded in gdb you need to use something like run --tool=none ./foo (or start gdb with --args or use set args before the run). If you leave out the "--tool=none" it will default to the memcheck options but with none as the tool. This isn't just a gdb thing. For instance (with the VALGRIND_* env vars set) ./.in_place/none-amd64-freebsd -q ./foo --2850-- VG_USERREQ__CLIENT_CALL1: func=0x0 0x0 (I don't know why I'm getting a USERREQ moan, it's caused by an ifunc) and ./.in_place/none-amd64-freebsd -q --tool=none ./foo 0x4e09000 A+ Paul |
From: Florian K. <fl...@ei...> - 2025-07-27 13:25:08
|
Consider this program: #include <stdio.h> #include <stdlib.h> int main(void) { return fprintf(stderr, "%p\n", (void *)malloc(10)); } Compile this into foo and run in the root of the source tree: ./coregrind/valgrind --tool=none ./foo prints some address as expected. Running this under gdb like so: export VALGRIND_LAUNCHER=./coregrind/valgrind export VALGRIND_LIB=./.in_place gdb -q -n ./.in_place/none-amd64-linux memory allocation fails and the output is (nil) This is unexpected.. and not new... Release 3.18.1 behaves the same way.. Which makes me think, that maybe I'm missing something? I suppose people rarely debug the none tool. I found out because the iropt tester runs under "none" auspices... Off-hand I have no idea what might be causing it. Florian |
From: Florian K. <fl...@ei...> - 2025-07-27 12:58:47
|
The way VALGRIND_LAUNCHER is defined in README_DEVELOPERS line 274 suggests that --prefix=/usr/local was used when configuring. But then VALGRIND_LIB needs adjustment and the path to the tool exec as well. At least that is what I observe. diff --git a/README_DEVELOPERS b/README_DEVELOPERS index a3360580e..fc5a80129 100644 --- a/README_DEVELOPERS +++ b/README_DEVELOPERS @@ -271,12 +271,12 @@ without too much problem by following these steps: export VALGRIND_LIB=$DIR/.in_place VALGRIND_LIB is where the default.supp and vgpreload_ libraries - are found (which is under /usr/libexec/valgrind for an installed + are found (which is under /usr/local/libexec/valgrind for an installed version). (2) Run gdb on the tool executable. Eg: - gdb /usr/local/lib/valgrind/lackey-ppc32-linux + gdb /usr/local/libexec/valgrind/lackey-ppc32-linux or |
From: Florian K. <fk...@so...> - 2025-07-25 21:21:25
|
https://sourceware.org/cgit/valgrind/commit/?id=6d4745a6c9c0596f664a4b1b4c7c5ac815fde7d4 commit 6d4745a6c9c0596f664a4b1b4c7c5ac815fde7d4 Author: Florian Krohm <fl...@ei...> Date: Fri Jul 25 21:20:47 2025 +0000 iropt-test: .vgtest tweaks Diff: --- none/tests/iropt-test/iropt-test-sec.vgtest | 3 ++- none/tests/iropt-test/iropt-test.vgtest | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/none/tests/iropt-test/iropt-test-sec.vgtest b/none/tests/iropt-test/iropt-test-sec.vgtest index e8d4cc7025..38ada46550 100644 --- a/none/tests/iropt-test/iropt-test-sec.vgtest +++ b/none/tests/iropt-test/iropt-test-sec.vgtest @@ -1,4 +1,5 @@ prog: iropt-test prereq: test -x iropt-test-sec +#args: -v -v -r10 +args: -r100 vgopts: -q --vex-guest-chase=no - diff --git a/none/tests/iropt-test/iropt-test.vgtest b/none/tests/iropt-test/iropt-test.vgtest index de31de6046..9136b105c9 100644 --- a/none/tests/iropt-test/iropt-test.vgtest +++ b/none/tests/iropt-test/iropt-test.vgtest @@ -2,4 +2,3 @@ prog: iropt-test #args: -v -v -r10 args: -r100 vgopts: -q --vex-guest-chase=no - |
From: Florian K. <fk...@so...> - 2025-07-25 21:12:23
|
https://sourceware.org/cgit/valgrind/commit/?id=5a159cf245ff4fec2fd148c899ce7a0380ca3d04 commit 5a159cf245ff4fec2fd148c899ce7a0380ca3d04 Author: Florian Krohm <fl...@ei...> Date: Fri Jul 25 21:11:57 2025 +0000 iropt-test: Refactor code Refactor code in preparation for running each testcase twice: once with constant folding and once without. - remove function print_opnd - remove function complain - factor out function get_expected_value - checking the result moved to valgrind_execute_test - make IRICB a static global in valgrind.c - new_iricb now returns a pointer to it Diff: --- none/tests/iropt-test/binary.c | 41 ++++++++--------------------------- none/tests/iropt-test/main.c | 4 ++-- none/tests/iropt-test/unary.c | 38 +++++++------------------------- none/tests/iropt-test/util.c | 29 ------------------------- none/tests/iropt-test/valgrind.c | 47 +++++++++++++++++++++++++++++++--------- none/tests/iropt-test/vtest.h | 6 ++--- 6 files changed, 58 insertions(+), 107 deletions(-) diff --git a/none/tests/iropt-test/binary.c b/none/tests/iropt-test/binary.c index 62c9faeb35..0d40a4da3e 100644 --- a/none/tests/iropt-test/binary.c +++ b/none/tests/iropt-test/binary.c @@ -26,7 +26,7 @@ #include <stdint.h> // UINT64_MAX #include "vtest.h" -static void check_result(const irop_t *, const test_data_t *); +static uint64_t get_expected_value(const irop_t *, const test_data_t *); static void run_tests(const irop_t *, test_data_t *); static void run_shift_tests(const irop_t *, test_data_t *); static int is_shift_op(IROp); @@ -59,8 +59,7 @@ run_selected_tests(const irop_t *op, test_data_t *data) if (is_division_op(op->op) && opnd_r->value == 0) continue; - valgrind_execute_test(op, data); - check_result(op, data); + valgrind_execute_test(op, data, get_expected_value(op, data)); } } } @@ -79,8 +78,7 @@ run_random_tests(const irop_t *op, test_data_t *data) if (is_division_op(op->op) && opnd_r->value == 0) continue; - valgrind_execute_test(op, data); - check_result(op, data); + valgrind_execute_test(op, data, get_expected_value(op, data)); } } @@ -101,8 +99,7 @@ run_shift_tests(const irop_t *op, test_data_t *data) for (unsigned j = 0; j < max_shift_amount; ++j) { opnd_r->value = j; - valgrind_execute_test(op, data); - check_result(op, data); + valgrind_execute_test(op, data, get_expected_value(op, data)); } } @@ -111,8 +108,7 @@ run_shift_tests(const irop_t *op, test_data_t *data) opnd_l->value = get_random_value(opnd_l->type); opnd_r->value = get_random_value(opnd_r->type) & max_shift_amount; - valgrind_execute_test(op, data); - check_result(op, data); + valgrind_execute_test(op, data, get_expected_value(op, data)); } } @@ -125,11 +121,10 @@ run_tests(const irop_t *op, test_data_t *data) } -/* Check the result of a binary operation. */ -static void -check_result(const irop_t *op, const test_data_t *data) +/* Compute the expected result of a binary operation. */ +static uint64_t +get_expected_value(const irop_t *op, const test_data_t *data) { - uint64_t result = data->result.value; uint64_t opnd_l = data->opnds[0].value; uint64_t opnd_r = data->opnds[1].value; uint64_t expected; @@ -384,25 +379,7 @@ check_result(const irop_t *op, const test_data_t *data) panic(__func__); } - if (verbose > 1) { - printf("expected: value = "); - print_value(stdout, expected, bitsof_irtype(data->result.type)); - printf("\n"); - } - - int ok = 1; - switch (data->result.type) { - case Ity_I1: ok = result == expected; break; - case Ity_I8: ok = result == expected; break; - case Ity_I16: ok = result == expected; break; - case Ity_I32: ok = result == expected; break; - case Ity_I64: ok = result == expected; break; - default: - panic(__func__); - } - - if (! ok) - complain(op, data, expected); + return expected; } diff --git a/none/tests/iropt-test/main.c b/none/tests/iropt-test/main.c index 9f1cc5083a..8fcf9fb453 100644 --- a/none/tests/iropt-test/main.c +++ b/none/tests/iropt-test/main.c @@ -81,9 +81,9 @@ main(int argc, char *argv[]) test_data_t *data = new_test_data(op); - IRICB iricb = new_iricb(op, data); + IRICB *iricb = new_iricb(op, data); - valgrind_vex_init_for_iri(&iricb); + valgrind_vex_init_for_iri(iricb); switch (op->num_opnds) { case 1: diff --git a/none/tests/iropt-test/unary.c b/none/tests/iropt-test/unary.c index e6554cef60..fa961f28a7 100644 --- a/none/tests/iropt-test/unary.c +++ b/none/tests/iropt-test/unary.c @@ -27,9 +27,9 @@ #include <stdint.h> // UINT64_MAX #include "vtest.h" -static void check_result(const irop_t *, const test_data_t *); static void run_selected_tests(const irop_t *, test_data_t *); static void run_random_tests(const irop_t *, test_data_t *); +static uint64_t get_expected_value(const irop_t *, const test_data_t *); static uint64_t left(uint64_t, unsigned); static uint32_t popcount(uint64_t); static uint32_t clz(uint64_t, unsigned); @@ -49,8 +49,7 @@ test_unary_op(const irop_t *op, test_data_t *data) for (unsigned i = 0; i <= max; ++i) { opnd->value = i; - valgrind_execute_test(op, data); - check_result(op, data); + valgrind_execute_test(op, data, get_expected_value(op, data)); } break; } @@ -78,8 +77,7 @@ run_selected_tests(const irop_t *op, test_data_t *data) for (unsigned i = 0; i < num_val; ++i) { opnd->value = values[i]; - valgrind_execute_test(op, data); - check_result(op, data); + valgrind_execute_test(op, data, get_expected_value(op, data)); } } @@ -93,17 +91,15 @@ run_random_tests(const irop_t *op, test_data_t *data) for (unsigned i = 0; i < num_random_tests; ++i) { opnd->value = get_random_value(opnd->type); - valgrind_execute_test(op, data); - check_result(op, data); + valgrind_execute_test(op, data, get_expected_value(op, data)); } } -/* Check the result of a unary operation. */ -static void -check_result(const irop_t *op, const test_data_t *data) +/* Compute the expected result of a unary operation. */ +static uint64_t +get_expected_value(const irop_t *op, const test_data_t *data) { - uint64_t result = data->result.value; uint64_t opnd = data->opnds[0].value; uint64_t expected; @@ -209,25 +205,7 @@ check_result(const irop_t *op, const test_data_t *data) panic("%s: operator %s not handled\n", __func__, op->name); } - if (verbose > 1) { - printf("expected: value = "); - print_value(stdout, expected, bitsof_irtype(data->result.type)); - printf("\n"); - } - - int ok = 1; - switch (data->result.type) { - case Ity_I1: ok = result == expected; break; - case Ity_I8: ok = result == expected; break; - case Ity_I16: ok = result == expected; break; - case Ity_I32: ok = result == expected; break; - case Ity_I64: ok = result == expected; break; - default: - panic(__func__); - } - - if (! ok) - complain(op, data, expected); + return expected; } diff --git a/none/tests/iropt-test/util.c b/none/tests/iropt-test/util.c index 18b671114c..f34936611e 100644 --- a/none/tests/iropt-test/util.c +++ b/none/tests/iropt-test/util.c @@ -44,27 +44,6 @@ panic(const char *fmt, ...) } -/* Issue a complaint because the result of an operation differs from what - was expected. */ -void -complain(const irop_t *op, const test_data_t *data, uint64_t expected) -{ - fprintf(stderr, "*** Incorrect result for operator %s\n", op->name); - - for (unsigned i = 0; i < op->num_opnds; ++i) { - fprintf(stderr, " opnd %u: ", i); - print_opnd(stderr, &data->opnds[i]); - fprintf(stderr, "\n"); - } - fprintf(stderr, " result: "); - print_opnd(stderr, &data->result); - fprintf(stderr, "\n"); - fprintf(stderr, " expect: "); - print_value(stderr, expected, bitsof_irtype(op->result_type)); - fprintf(stderr, "\n"); -} - - void print_value(FILE *fp, uint64_t val, unsigned num_bits) { @@ -83,14 +62,6 @@ print_value(FILE *fp, uint64_t val, unsigned num_bits) } -void -print_opnd(FILE *fp, const opnd_t *opnd) -{ - fprintf(fp, "value = "); - print_value(fp, opnd->value, bitsof_irtype(opnd->type)); -} - - unsigned bitsof_irtype(IRType ty) { diff --git a/none/tests/iropt-test/valgrind.c b/none/tests/iropt-test/valgrind.c index e482909b16..004c8a09a4 100644 --- a/none/tests/iropt-test/valgrind.c +++ b/none/tests/iropt-test/valgrind.c @@ -26,9 +26,10 @@ #include "valgrind.h" // VALGRIND_VEX_INJECT_IR #include "vtest.h" +static IRICB iricb; /* Return a completely initialised control block */ -IRICB +IRICB * new_iricb(const irop_t *op, test_data_t *data) { IRICB_iropt_payload cb; @@ -45,7 +46,10 @@ new_iricb(const irop_t *op, test_data_t *data) cb.num_operands = op->num_opnds; - return (IRICB) { .kind = IRICB_iropt, .iropt = cb }; + iricb.kind = IRICB_iropt; + iricb.iropt = cb; + + return &iricb; } @@ -69,24 +73,47 @@ valgrind_vex_inject_ir(void) /* Execute the test under valgrind. Well, yes, we're not really executing it here, just preparing for it... */ void -valgrind_execute_test(const irop_t *op, test_data_t *data) +valgrind_execute_test(const irop_t *op, test_data_t *data, uint64_t expected) { - if (verbose > 1) + if (verbose > 1) { printf("---------- Running a test\n"); - for (unsigned i = 0; i < op->num_opnds; ++i) { - if (verbose > 1) { - printf("opnd #%u: ", i); - print_opnd(stdout, &data->opnds[i]); + for (unsigned i = 0; i < op->num_opnds; ++i) { + const opnd_t *opnd = data->opnds + i; + printf("opnd %u: value = ", i); + print_value(stdout, opnd->value, bitsof_irtype(opnd->type)); printf("\n"); } } valgrind_vex_inject_ir(); + uint64_t result = data->result.value; + unsigned num_result_bits = bitsof_irtype(data->result.type); if (verbose > 1) { - printf("result: "); - print_opnd(stdout, &data->result); + printf("result: value = "); + print_value(stdout, result, num_result_bits); printf("\n"); + printf("expected: value = "); + print_value(stdout, expected, num_result_bits); + printf("\n"); + } + + /* Check result */ + if (result != expected) { + fprintf(stderr, "*** Incorrect result for operator %s\n", op->name); + + for (unsigned i = 0; i < op->num_opnds; ++i) { + const opnd_t *opnd = data->opnds + i; + fprintf(stderr, " opnd %u: ", i); + print_value(stderr, opnd->value, bitsof_irtype(opnd->type)); + fprintf(stderr, "\n"); + } + fprintf(stderr, " result: "); + print_value(stderr, result, num_result_bits); + fprintf(stderr, "\n"); + fprintf(stderr, " expect: "); + print_value(stderr, expected, num_result_bits); + fprintf(stderr, "\n"); } } diff --git a/none/tests/iropt-test/vtest.h b/none/tests/iropt-test/vtest.h index 47b397f681..f31f3c3ce4 100644 --- a/none/tests/iropt-test/vtest.h +++ b/none/tests/iropt-test/vtest.h @@ -69,19 +69,17 @@ typedef struct { /* Function prototypes */ -void print_opnd(FILE *, const opnd_t *); void print_value(FILE *, uint64_t, unsigned); void test_unary_op(const irop_t *, test_data_t *); void test_binary_op(const irop_t *, test_data_t *); void valgrind_vex_init_for_iri(IRICB *); -void valgrind_execute_test(const irop_t *, test_data_t *); +void valgrind_execute_test(const irop_t *, test_data_t *, uint64_t); -IRICB new_iricb(const irop_t *, test_data_t *); +IRICB *new_iricb(const irop_t *, test_data_t *); void panic(const char *, ...) __attribute__((noreturn)); -void complain(const irop_t *, const test_data_t *, uint64_t expected); unsigned bitsof_irtype(IRType); uint64_t get_random_value(IRType); |