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
(65) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Paul F. <pj...@wa...> - 2024-03-28 20:01:23
|
On 28-03-24 17:36, Mark Wielaard wrote: > It is of course harmless because just a comment. But I think this > part was meant for Bug 484426 aarch64: 0.5 gets rounded to 0? It > conflicts with the patch attached for that bug. Hi Mark It was unintentional. I added the comment when analyzing the code on my amd64 desktop. I resolved the conflict when I pushed the changes (and added the testcase from bugzilla). A+ Paul |
From: Paul F. <pa...@so...> - 2024-03-28 19:56:21
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=dc30fbf673953fefb115d2cf441119ee28039c9c commit dc30fbf673953fefb115d2cf441119ee28039c9c Author: Paul Floyd <pj...@wa...> Date: Thu Mar 28 20:55:38 2024 +0100 Bug 484426 - aarch64: 0.5 gets rounded to 0 Diff: --- .gitignore | 1 + NEWS | 1 + VEX/priv/guest_arm64_toIR.c | 35 ++++++++++++++------------- VEX/priv/host_arm64_defs.c | 45 +++++++++++++++++++++++++++++------ VEX/priv/host_arm64_defs.h | 2 ++ VEX/priv/host_arm64_isel.c | 24 +++++++++++++++++++ VEX/priv/ir_defs.c | 17 +++++++++++-- VEX/pub/libvex_ir.h | 5 ++++ memcheck/mc_translate.c | 6 ++++- memcheck/tests/vbit-test/irops.c | 4 ++++ none/tests/arm64/Makefile.am | 4 ++++ none/tests/arm64/bug484426.cpp | 8 +++++++ none/tests/arm64/bug484426.stderr.exp | 0 none/tests/arm64/bug484426.stdout.exp | 1 + none/tests/arm64/bug484426.vgtest | 3 +++ 15 files changed, 129 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 982305c355..31a93cd29b 100644 --- a/.gitignore +++ b/.gitignore @@ -1781,6 +1781,7 @@ /none/tests/arm64/Makefile.in /none/tests/arm64/allexec /none/tests/arm64/atomics_v81 +/none/tests/arm64/bug484426 /none/tests/arm64/crc32 /none/tests/arm64/cvtf_imm /none/tests/arm64/fmadd_sub diff --git a/NEWS b/NEWS index 7922646f31..3160bbe213 100644 --- a/NEWS +++ b/NEWS @@ -73,6 +73,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 481131 [PATCH] x86 regtest: fix clobber lists in generated asm statements 483786 Incorrect parameter indexing in FreeBSD clock_nanosleep syscall wrapper 484002 Add suppression for invalid read in glibc's __wcpncpy_avx2() via wcsxfrm() +484426 aarch64: 0.5 gets rounded to 0 n-i-bz Add redirect for memccpy To see details of a given bug, visit diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c index 3b33c48c3e..c7e395b4b6 100644 --- a/VEX/priv/guest_arm64_toIR.c +++ b/VEX/priv/guest_arm64_toIR.c @@ -44,8 +44,7 @@ least significant mantissa bit is incorrect. Fix: use the IR multiply-add IROps instead. - * FRINTA, FRINTN are kludged .. they just round to nearest. No special - handling for the "ties" case. FRINTX might be dubious too. + * FRINTX might be need updating to set the inexact computation FPSR flag * Ditto FCVTXN. No idea what "round to odd" means. This implementation just rounds to nearest. @@ -15074,22 +15073,23 @@ Bool dis_AdvSIMD_fp_data_proc_1_source(/*MB_OUT*/DisResult* dres, UInt insn) 001 +inf (FRINTP) 010 -inf (FRINTM) 011 zero (FRINTZ) - 000 tieeven (FRINTN) -- !! FIXME KLUDGED !! - 100 tieaway (FRINTA) -- !! FIXME KLUDGED !! + 000 tieeven (FRINTN) + 100 tieaway (FRINTA) 110 per FPCR + "exact = TRUE" (FRINTX) 101 unallocated */ - Bool isD = (ty & 1) == 1; - UInt rm = opcode & BITS6(0,0,0,1,1,1); - IRType ity = isD ? Ity_F64 : Ity_F32; - IRExpr* irrmE = NULL; - UChar ch = '?'; + Bool isD = (ty & 1) == 1; + UInt rm = opcode & BITS6(0,0,0,1,1,1); + IRType ity = isD ? Ity_F64 : Ity_F32; + IRExpr* irrmE = NULL; + UChar ch = '?'; + IROp op = isD ? Iop_RoundF64toInt : Iop_RoundF32toInt; + Bool isBinop = True; switch (rm) { case BITS3(0,1,1): ch = 'z'; irrmE = mkU32(Irrm_ZERO); break; case BITS3(0,1,0): ch = 'm'; irrmE = mkU32(Irrm_NegINF); break; case BITS3(0,0,1): ch = 'p'; irrmE = mkU32(Irrm_PosINF); break; - // The following is a kludge. Should be: Irrm_NEAREST_TIE_AWAY_0 - case BITS3(1,0,0): ch = 'a'; irrmE = mkU32(Irrm_NEAREST); break; + case BITS3(1,0,0): ch = 'a'; isBinop = False; op = isD ? Iop_RoundF64toIntA0 : Iop_RoundF32toIntA0; break; // I am unsure about the following, due to the "integral exact" // description in the manual. What does it mean? (frintx, that is) // PJF exact means that if the rounding can't be done without @@ -15099,17 +15099,18 @@ Bool dis_AdvSIMD_fp_data_proc_1_source(/*MB_OUT*/DisResult* dres, UInt insn) ch = 'x'; irrmE = mkexpr(mk_get_IR_rounding_mode()); break; case BITS3(1,1,1): ch = 'i'; irrmE = mkexpr(mk_get_IR_rounding_mode()); break; - // The following is a kludge. There's no Irrm_ value to represent - // this ("to nearest, with ties to even") - case BITS3(0,0,0): ch = 'n'; irrmE = mkU32(Irrm_NEAREST); break; + case BITS3(0,0,0): ch = 'n'; isBinop = False; op = isD ? Iop_RoundF64toIntE : Iop_RoundF32toIntE; break; default: break; } - if (irrmE) { + if (irrmE || !isBinop) { IRTemp src = newTemp(ity); IRTemp dst = newTemp(ity); assign(src, getQRegLO(nn, ity)); - assign(dst, binop(isD ? Iop_RoundF64toInt : Iop_RoundF32toInt, - irrmE, mkexpr(src))); + if (isBinop) { + assign(dst, binop(op, irrmE, mkexpr(src))); + } else { + assign(dst, unop(op, mkexpr(src))); + } putQReg128(dd, mkV128(0x0000)); putQRegLO(dd, mkexpr(dst)); DIP("frint%c %s, %s\n", diff --git a/VEX/priv/host_arm64_defs.c b/VEX/priv/host_arm64_defs.c index 39c6aaa46b..0b59c87cd3 100644 --- a/VEX/priv/host_arm64_defs.c +++ b/VEX/priv/host_arm64_defs.c @@ -572,11 +572,13 @@ static const HChar* showARM64FpTriOp ( ARM64FpTriOp op ) { static const HChar* showARM64FpUnaryOp ( ARM64FpUnaryOp op ) { switch (op) { - case ARM64fpu_NEG: return "neg "; - case ARM64fpu_ABS: return "abs "; - case ARM64fpu_SQRT: return "sqrt "; - case ARM64fpu_RINT: return "rinti"; - case ARM64fpu_RECPX: return "recpx"; + case ARM64fpu_NEG: return "neg "; + case ARM64fpu_ABS: return "abs "; + case ARM64fpu_SQRT: return "sqrt "; + case ARM64fpu_RINT: return "rinti"; + case ARM64fpu_RINTA0: return "rinta"; + case ARM64fpu_RINTE: return "rintn"; + case ARM64fpu_RECPX: return "recpx"; default: vpanic("showARM64FpUnaryOp"); } } @@ -2968,6 +2970,7 @@ static inline UInt qregEnc ( HReg r ) #define X00000 BITS8(0,0,0, 0,0,0,0,0) #define X00001 BITS8(0,0,0, 0,0,0,0,1) +#define X00100 BITS8(0,0,0, 0,0,1,0,0) #define X00110 BITS8(0,0,0, 0,0,1,1,0) #define X00111 BITS8(0,0,0, 0,0,1,1,1) #define X01000 BITS8(0,0,0, 0,1,0,0,0) @@ -4582,7 +4585,21 @@ Int emit_ARM64Instr ( /*MB_MOD*/Bool* is_profInc, *p++ = X_3_8_5_6_5_5(X000, X11110011, X00111, X110000, dN, dD); goto done; } - /* + /* + 000, 11110 01 1,001 10,0 10000 n d FRINTA Dd, Dm (round away from zero) + */ + if (i->ARM64in.VUnaryD.op == ARM64fpu_RINTA0) { + *p++ = X_3_8_5_6_5_5(X000, X11110011, X00110, X010000, dN, dD); + goto done; + } + /* + 000, 11110 01 1,001 10,0 10000 n d FRINTN Dd, Dm (round to even) + */ + if (i->ARM64in.VUnaryD.op == ARM64fpu_RINTE) { + *p++ = X_3_8_5_6_5_5(X000, X11110011, X00100, X010000, dN, dD); + goto done; + } + /* 010, 11110 11 1,0000 1,1111 10 n d FRECPX Dd, Dm */ if (i->ARM64in.VUnaryD.op == ARM64fpu_RECPX) { @@ -4620,7 +4637,21 @@ Int emit_ARM64Instr ( /*MB_MOD*/Bool* is_profInc, *p++ = X_3_8_5_6_5_5(X000, X11110001, X00111, X110000, sN, sD); goto done; } - /* + /* + 000, 11110 00 1,001 11,1 10000 n d FRINTA Sd, Sm (round away from zero) + */ + if (i->ARM64in.VUnaryS.op == ARM64fpu_RINTA0) { + *p++ = X_3_8_5_6_5_5(X000, X11110001, X00110, X010000, sN, sD); + goto done; + } + /* + 000, 11110 00 1,001 11,1 10000 n d FRINTN Sd, Sm (round to even) + */ + if (i->ARM64in.VUnaryS.op == ARM64fpu_RINTE) { + *p++ = X_3_8_5_6_5_5(X000, X11110001, X00100, X010000, sN, sD); + goto done; + } + /* 010, 11110 10 1,0000 1,1111 10 n d FRECPX Sd, Sm */ if (i->ARM64in.VUnaryS.op == ARM64fpu_RECPX) { diff --git a/VEX/priv/host_arm64_defs.h b/VEX/priv/host_arm64_defs.h index dc686dff7f..e78d8045ff 100644 --- a/VEX/priv/host_arm64_defs.h +++ b/VEX/priv/host_arm64_defs.h @@ -321,6 +321,8 @@ typedef ARM64fpu_ABS, ARM64fpu_SQRT, ARM64fpu_RINT, + ARM64fpu_RINTA0, + ARM64fpu_RINTE, ARM64fpu_RECPX, ARM64fpu_INVALID } diff --git a/VEX/priv/host_arm64_isel.c b/VEX/priv/host_arm64_isel.c index 1fa61edb2d..645358586f 100644 --- a/VEX/priv/host_arm64_isel.c +++ b/VEX/priv/host_arm64_isel.c @@ -3438,6 +3438,18 @@ static HReg iselDblExpr_wrk ( ISelEnv* env, IRExpr* e ) addInstr(env, ARM64Instr_VCvtI2F(cvt_op, dst, src)); return dst; } + case Iop_RoundF64toIntA0: { + HReg src = iselDblExpr(env, e->Iex.Unop.arg); + HReg dst = newVRegD(env); + addInstr(env, ARM64Instr_VUnaryD(ARM64fpu_RINTA0, dst, src)); + return dst; + } + case Iop_RoundF64toIntE: { + HReg src = iselDblExpr(env, e->Iex.Unop.arg); + HReg dst = newVRegD(env); + addInstr(env, ARM64Instr_VUnaryD(ARM64fpu_RINTE, dst, src)); + return dst; + } default: break; } @@ -3626,6 +3638,18 @@ static HReg iselFltExpr_wrk ( ISelEnv* env, IRExpr* e ) addInstr(env, ARM64Instr_VCvtHS(True/*hToS*/, dst, src)); return dst; } + case Iop_RoundF32toIntA0: { + HReg src = iselFltExpr(env, e->Iex.Unop.arg); + HReg dst = newVRegD(env); + addInstr(env, ARM64Instr_VUnaryS(ARM64fpu_RINTA0, dst, src)); + return dst; + } + case Iop_RoundF32toIntE: { + HReg src = iselFltExpr(env, e->Iex.Unop.arg); + HReg dst = newVRegD(env); + addInstr(env, ARM64Instr_VUnaryS(ARM64fpu_RINTE, dst, src)); + return dst; + } default: break; } diff --git a/VEX/priv/ir_defs.c b/VEX/priv/ir_defs.c index 0ef49eaa6a..93e9a98d50 100644 --- a/VEX/priv/ir_defs.c +++ b/VEX/priv/ir_defs.c @@ -440,7 +440,11 @@ void ppIROp ( IROp op ) case Iop_RoundF128toInt: vex_printf("RoundF128toInt"); return; case Iop_RoundF64toInt: vex_printf("RoundF64toInt"); return; + case Iop_RoundF64toIntA0: vex_printf("RoundF64toIntA0"); return; + case Iop_RoundF64toIntE: vex_printf("RoundF64toIntE"); return; case Iop_RoundF32toInt: vex_printf("RoundF32toInt"); return; + case Iop_RoundF32toIntA0: vex_printf("RoundF32toIntA0"); return; + case Iop_RoundF32toIntE: vex_printf("RoundF32toIntE"); return; case Iop_RoundF64toF32: vex_printf("RoundF64toF32"); return; case Iop_ReinterpV128asI128: vex_printf("ReinterpV128asI128"); return; @@ -1470,8 +1474,10 @@ Bool primopMightTrap ( IROp op ) case Iop_Yl2xp1F64: case Iop_PRemF64: case Iop_PRemC3210F64: case Iop_PRem1F64: case Iop_PRem1C3210F64: case Iop_ScaleF64: case Iop_SinF64: case Iop_CosF64: case Iop_TanF64: - case Iop_2xm1F64: case Iop_RoundF128toInt: case Iop_RoundF64toInt: - case Iop_RoundF32toInt: case Iop_MAddF32: case Iop_MSubF32: + case Iop_2xm1F64: case Iop_RoundF128toInt: + case Iop_RoundF64toInt: case Iop_RoundF64toIntA0: case Iop_RoundF64toIntE: + case Iop_RoundF32toInt: case Iop_RoundF32toIntA0: case Iop_RoundF32toIntE: + case Iop_MAddF32: case Iop_MSubF32: case Iop_MAddF64: case Iop_MSubF64: case Iop_MAddF64r32: case Iop_MSubF64r32: case Iop_RSqrtEst5GoodF64: case Iop_RoundF64toF64_NEAREST: @@ -3402,6 +3408,10 @@ void typeOfPrimop ( IROp op, case Iop_RecpExpF32: BINARY(ity_RMode,Ity_F32, Ity_F32); + case Iop_RoundF32toIntA0: + case Iop_RoundF32toIntE: + UNARY(Ity_F32, Ity_F32); + case Iop_SqrtF16: BINARY(ity_RMode, Ity_F16, Ity_F16); @@ -3479,6 +3489,9 @@ void typeOfPrimop ( IROp op, case Iop_2xm1F64: case Iop_RoundF64toInt: BINARY(ity_RMode,Ity_F64, Ity_F64); + case Iop_RoundF64toIntA0: case Iop_RoundF64toIntE: + UNARY(Ity_F64, Ity_F64); + case Iop_MAddF64: case Iop_MSubF64: case Iop_MAddF64r32: case Iop_MSubF64r32: QUATERNARY(ity_RMode,Ity_F64,Ity_F64,Ity_F64, Ity_F64); diff --git a/VEX/pub/libvex_ir.h b/VEX/pub/libvex_ir.h index 85805bb69b..1b4efdc90e 100644 --- a/VEX/pub/libvex_ir.h +++ b/VEX/pub/libvex_ir.h @@ -782,8 +782,13 @@ typedef as F128) */ Iop_RoundF64toInt, /* F64 value to nearest integral value (still as F64) */ + Iop_RoundF64toIntA0, /* As Iop_RoundF64toInt but ties to above zero*/ + + Iop_RoundF64toIntE, /* As Iop_RoundF64toInt but ties to even */ Iop_RoundF32toInt, /* F32 value to nearest integral value (still as F32) */ + Iop_RoundF32toIntA0, /* As Iop_RoundF32toInt but ties to above zero*/ + Iop_RoundF32toIntE, /* As Iop_RoundF32toInt but ties to even */ /* --- guest s390 specifics, not mandated by 754. --- */ diff --git a/memcheck/mc_translate.c b/memcheck/mc_translate.c index ec8ac53217..05e6d59afa 100644 --- a/memcheck/mc_translate.c +++ b/memcheck/mc_translate.c @@ -5288,6 +5288,8 @@ IRExpr* expr2vbits_Unop ( MCEnv* mce, IROp op, IRAtom* atom ) case Iop_RoundF64toF64_NegINF: case Iop_RoundF64toF64_PosINF: case Iop_RoundF64toF64_ZERO: + case Iop_RoundF64toIntA0: + case Iop_RoundF64toIntE: case Iop_D32toD64: case Iop_I32StoD64: case Iop_I32UtoD64: @@ -5305,7 +5307,9 @@ IRExpr* expr2vbits_Unop ( MCEnv* mce, IROp op, IRAtom* atom ) case Iop_TruncF64asF32: case Iop_NegF32: case Iop_AbsF32: - case Iop_F16toF32: + case Iop_F16toF32: + case Iop_RoundF32toIntA0: + case Iop_RoundF32toIntE: return mkPCastTo(mce, Ity_I32, vatom); case Iop_AbsF16: diff --git a/memcheck/tests/vbit-test/irops.c b/memcheck/tests/vbit-test/irops.c index 24f258bf0c..1ab0ee2fc0 100644 --- a/memcheck/tests/vbit-test/irops.c +++ b/memcheck/tests/vbit-test/irops.c @@ -293,7 +293,11 @@ static irop_t irops[] = { { DEFOP(Iop_2xm1F64, UNDEF_ALL), .s390x = 0, .amd64 = 1, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0, .mips64 = 0 }, { DEFOP(Iop_RoundF128toInt, UNDEF_ALL), .s390x = 1, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0, .mips64 = 0 }, { DEFOP(Iop_RoundF64toInt, UNDEF_ALL), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0, .mips64 = 1 }, + { DEFOP(Iop_RoundF64toIntA0, UNDEF_ALL), .arm64 = 1 }, + { DEFOP(Iop_RoundF64toIntE, UNDEF_ALL), .arm64 = 1 }, { DEFOP(Iop_RoundF32toInt, UNDEF_ALL), .s390x = 1, .amd64 = 1, .x86 = 1, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 1, .mips64 = 1 }, + { DEFOP(Iop_RoundF32toIntA0, UNDEF_ALL), .arm64 = 1 }, + { DEFOP(Iop_RoundF32toIntE, UNDEF_ALL), .arm64 = 1 }, { DEFOP(Iop_MAddF32, UNDEF_ALL), .s390x = 1, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0, .mips64 = 1 }, { DEFOP(Iop_MSubF32, UNDEF_ALL), .s390x = 1, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0, .mips64 = 1 }, { DEFOP(Iop_MAddF64, UNDEF_ALL), .s390x = 1, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 = 0, .mips64 = 1 }, diff --git a/none/tests/arm64/Makefile.am b/none/tests/arm64/Makefile.am index cc0ed14811..e9570459de 100644 --- a/none/tests/arm64/Makefile.am +++ b/none/tests/arm64/Makefile.am @@ -4,6 +4,7 @@ include $(top_srcdir)/Makefile.tool-tests.am dist_noinst_SCRIPTS = filter_stderr EXTRA_DIST = \ + bug484426.stdout.exp bug484426.stderr.exp bug484426.vgtest \ crc32.stdout.exp crc32.stderr.exp crc32.vgtest \ cvtf_imm.stdout.exp cvtf_imm.stderr.exp cvtf_imm.vgtest \ fp_and_simd.stdout.exp fp_and_simd.stderr.exp fp_and_simd.vgtest \ @@ -22,6 +23,7 @@ EXTRA_DIST = \ check_PROGRAMS = \ allexec \ + bug484426 \ cvtf_imm \ fp_and_simd \ integer \ @@ -51,6 +53,8 @@ AM_CCASFLAGS += @FLAG_M64@ allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@ +bug484426_SOURCES = bug484426.cpp + crc32_CFLAGS = $(AM_CFLAGS) -march=armv8-a+crc atomics_v81_CFLAGS = $(AM_CFLAGS) -march=armv8.1-a simd_v81_CFLAGS = $(AM_CFLAGS) -march=armv8.1-a+crypto diff --git a/none/tests/arm64/bug484426.cpp b/none/tests/arm64/bug484426.cpp new file mode 100644 index 0000000000..3b1657ffb8 --- /dev/null +++ b/none/tests/arm64/bug484426.cpp @@ -0,0 +1,8 @@ +#include <cmath> +#include <iostream> + +int main(int argc, char** argv) +{ + float value = std::stof(argv[1]); + std::cout << std::round(value) << "\n"; +} diff --git a/none/tests/arm64/bug484426.stderr.exp b/none/tests/arm64/bug484426.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/none/tests/arm64/bug484426.stdout.exp b/none/tests/arm64/bug484426.stdout.exp new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/none/tests/arm64/bug484426.stdout.exp @@ -0,0 +1 @@ +1 diff --git a/none/tests/arm64/bug484426.vgtest b/none/tests/arm64/bug484426.vgtest new file mode 100644 index 0000000000..e4afbec40c --- /dev/null +++ b/none/tests/arm64/bug484426.vgtest @@ -0,0 +1,3 @@ +prog: bug484426 +args: 0.5 +vgopts: -q |
From: Andreas A. <ar...@so...> - 2024-03-28 18:23:29
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=901df047ce73b1bf93da77a02f78460025102e1d commit 901df047ce73b1bf93da77a02f78460025102e1d Author: Andreas Arnez <ar...@li...> Date: Wed Mar 27 19:35:43 2024 +0100 s390x: Update tracking of implemented insns for z16 List the instructions first introduced with z16 in s390-opcodes.csv. Also mention the unimplemented ones in guest_s390_toIR.c and add new extended mnemonics to the script s390-check-opcodes.pl. For ease of use, add support for invoking the script without command line arguments. Diff: --- VEX/priv/guest_s390_toIR.c | 14 ++++++++++++++ auxprogs/s390-check-opcodes.pl | 33 +++++++++++++++++++++++++-------- docs/internals/s390-opcodes.csv | 19 +++++++++++++++++++ 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index ceb4084ace..1f105e9517 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -20067,6 +20067,8 @@ s390_decode_4byte_and_irgen(const UChar *bytes) case 0x8000: /* SSM */ goto unimplemented; case 0x8200: /* LPSW */ goto unimplemented; case 0x9300: /* TS */ goto unimplemented; + case 0xb200: /* LBEAR */ goto unimplemented; + case 0xb201: /* STBEAR */ goto unimplemented; case 0xb202: /* STIDP */ goto unimplemented; case 0xb204: /* SCK */ goto unimplemented; case 0xb205: s390_format_S_RD(s390_irgen_STCK, S_b2(ovl), S_d2(ovl)); @@ -20158,6 +20160,7 @@ s390_decode_4byte_and_irgen(const UChar *bytes) case 0xb286: /* QSI */ goto unimplemented; case 0xb287: /* LSCTL */ goto unimplemented; case 0xb28e: /* QCTRI */ goto unimplemented; + case 0xb28f: /* QPACI */ goto unimplemented; case 0xb299: s390_format_S_RD(s390_irgen_SRNM, S_b2(ovl), S_d2(ovl)); goto ok; case 0xb29c: s390_format_S_RD(s390_irgen_STFPC, S_b2(ovl), S_d2(ovl)); @@ -20604,6 +20607,7 @@ s390_decode_4byte_and_irgen(const UChar *bytes) case 0xb938: /* SORTL */ goto unimplemented; case 0xb939: /* DFLTCC */ goto unimplemented; case 0xb93a: /* KDSA */ goto unimplemented; + case 0xb93b: /* NNPA */ goto unimplemented; case 0xb93c: s390_format_RRE_RR(s390_irgen_PPNO, RRE_r1(ovl), RRE_r2(ovl)); goto ok; case 0xb93e: /* KIMD */ goto unimplemented; @@ -20695,6 +20699,7 @@ s390_decode_4byte_and_irgen(const UChar *bytes) case 0xb989: s390_format_RRE_RR(s390_irgen_SLBGR, RRE_r1(ovl), RRE_r2(ovl)); goto ok; case 0xb98a: /* CSPG */ goto unimplemented; + case 0xb98b: /* RDP */ goto unimplemented; case 0xb98d: /* EPSW */ goto unimplemented; case 0xb98e: /* IDTE */ goto unimplemented; case 0xb98f: /* CRDTE */ goto unimplemented; @@ -21521,7 +21526,9 @@ s390_decode_6byte_and_irgen(const UChar *bytes) VRS_rxb(ovl)); goto ok; case 0xe60000000049ULL: /* VLIP */ goto unimplemented; case 0xe60000000050ULL: /* VCVB */ goto unimplemented; + case 0xe60000000051ULL: /* VCLZDP */ goto unimplemented; case 0xe60000000052ULL: /* VCVBG */ goto unimplemented; + case 0xe60000000054ULL: /* VUPKZH */ goto unimplemented; case 0xe60000000055ULL: s390_format_VRRa_VVMM(s390_irgen_VCNF, VRRa_v1(ovl), VRRa_v2(ovl), VRRa_m3(ovl), VRRa_m4(ovl), @@ -21542,8 +21549,11 @@ s390_decode_6byte_and_irgen(const UChar *bytes) case 0xe60000000059ULL: /* VSRP */ goto unimplemented; case 0xe6000000005aULL: /* VCVDG */ goto unimplemented; case 0xe6000000005bULL: /* VPSOP */ goto unimplemented; + case 0xe6000000005cULL: /* VUPKZL */ goto unimplemented; case 0xe6000000005fULL: /* VTP */ goto unimplemented; + case 0xe60000000070ULL: /* VPKZR */ goto unimplemented; case 0xe60000000071ULL: /* VAP */ goto unimplemented; + case 0xe60000000072ULL: /* VSRPR */ goto unimplemented; case 0xe60000000073ULL: /* VSP */ goto unimplemented; case 0xe60000000075ULL: s390_format_VRRa_VVVMM(s390_irgen_VCRNF, VRRa_v1(ovl), VRRa_v2(ovl), @@ -21553,8 +21563,11 @@ s390_decode_6byte_and_irgen(const UChar *bytes) case 0xe60000000077ULL: /* VCP */ goto unimplemented; case 0xe60000000078ULL: /* VMP */ goto unimplemented; case 0xe60000000079ULL: /* VMSP */ goto unimplemented; + case 0xe60000000074ULL: /* VSCHP */ goto unimplemented; case 0xe6000000007aULL: /* VDP */ goto unimplemented; case 0xe6000000007bULL: /* VRP */ goto unimplemented; + case 0xe6000000007cULL: /* VSCSHP */ goto unimplemented; + case 0xe6000000007dULL: /* VCSPH */ goto unimplemented; case 0xe6000000007eULL: /* VSDP */ goto unimplemented; case 0xe70000000000ULL: s390_format_VRX_VRRDM(s390_irgen_VLEB, VRX_v1(ovl), VRX_x2(ovl), VRX_b2(ovl), @@ -22202,6 +22215,7 @@ s390_decode_6byte_and_irgen(const UChar *bytes) case 0xeb000000006eULL: s390_format_SIY_IRD(s390_irgen_ALSI, SIY_i2(ovl), SIY_b1(ovl), SIY_dl1(ovl), SIY_dh1(ovl)); goto ok; + case 0xeb0000000071ULL: /* LPSWEY */ goto unimplemented; case 0xeb000000007aULL: s390_format_SIY_IRD(s390_irgen_AGSI, SIY_i2(ovl), SIY_b1(ovl), SIY_dl1(ovl), SIY_dh1(ovl)); goto ok; diff --git a/auxprogs/s390-check-opcodes.pl b/auxprogs/s390-check-opcodes.pl index 3abb0c8fbb..5262a74d8f 100755 --- a/auxprogs/s390-check-opcodes.pl +++ b/auxprogs/s390-check-opcodes.pl @@ -14,14 +14,24 @@ use warnings; #------------------------------------------------------------------ my $num_arg = $#ARGV + 1; -if ($num_arg != 3) { +my $csv_file; +my $opc_file; +my $toir_file; + +if ($num_arg == 0) { + my $cwd = `pwd`; + my ($basedir) = $cwd =~ m|(.*)/valgrind/|; + $csv_file = "$basedir/valgrind/docs/internals/s390-opcodes.csv"; + $opc_file = "$basedir/binutils-gdb/opcodes/s390-opc.txt"; + $toir_file = "$basedir/valgrind/VEX/priv/guest_s390_toIR.c"; +} elsif ($num_arg == 3) { + $csv_file = $ARGV[0]; + $opc_file = $ARGV[1]; + $toir_file = $ARGV[2]; +} else { die "usage: s390-check-opcodes s390-opcodes.csv s390-opc.txt guest_s390_toIR.c\n"; } -my $csv_file = $ARGV[0]; -my $opc_file = $ARGV[1]; -my $toir_file = $ARGV[2]; - my %opc_desc = (); my %csv_desc = (); my %csv_implemented = (); @@ -36,13 +46,19 @@ my %known_arch = map {($_ => 1)} my @extended_mnemonics = ( "bi", # extended mnemonic for bic 'brul?', + 'jc', # brc 'jasl?', - 'jctg?', + 'jct[gh]?', 'jg?nop', 'jxleg?', 'jxhg?', 'l[de]rv', + 'lfi', # iilf + 'llg[fh]i', # llilf, llill + 'notg?r', # nork, nogrk 'risbgn?z', + 'risb[hl]gz', + 'r[onx]sbgt', 'st[de]rv', "va[bhfgq]", "vacc[bhfgq]", @@ -121,6 +137,7 @@ my @extended_mnemonics = ( "vsbcbiq", "vsbiq", "vscbi[bhfgq]", + "vsch[sdx]p", # vschp (short/long/extended) "vseg[bfh]", 'vstbr[hfgq]', 'vster[hfg]', @@ -347,9 +364,9 @@ foreach my $opc (keys %csv_desc) { #---------------------------------------------------- foreach my $opc (keys %opc_desc) { if (defined $csv_desc{$opc}) { - if ($opc_desc{$opc} ne $csv_desc{$opc}) { + if (lc($opc_desc{$opc}) ne lc($csv_desc{$opc})) { print "*** opcode $opc differs:\n"; - print " binutils: $opc_desc{$opc}\n"; + print " binutils: $opc_desc{$opc}\n"; print " opcodes.csv: $csv_desc{$opc}\n"; } } diff --git a/docs/internals/s390-opcodes.csv b/docs/internals/s390-opcodes.csv index cd0b4b375e..b41d9bd2b5 100644 --- a/docs/internals/s390-opcodes.csv +++ b/docs/internals/s390-opcodes.csv @@ -1746,3 +1746,22 @@ wclfeb,"vector fp convert to logical 32 bit",implemented,arch13 dfltcc,"deflate conversion call","not implemented",arch13 sortl,"sort lists","not implemented",arch13 kdsa,"compute digital signature authentication","not implemented",arch13 +vschp,"decimal scale and convert to hfp","not implemented",arch14 +vscshp,"decimal scale and convert and split to hfp","not implemented",arch14 +vcsph,"vector convert hfp to scaled decimal","not implemented",arch14 +vclzdp,"vector count leading zero digits","not implemented",arch14 +vpkzr,"vector pack zoned register","not implemented",arch14 +vsrpr,"vector shift and round decimal register","not implemented",arch14 +vupkzh,"vector unpack zoned high","not implemented",arch14 +vupkzl,"vector unpack zoned low","not implemented",arch14 +nnpa,"neural network processing assist","not implemented",arch14 +vclfnh,"vector fp convert and lengthen from nnp high","implemented",arch14 +vclfnl,"vector fp convert and lengthen from nnp low","implemented",arch14 +vcrnf,"vector fp convert and round to nnp","implemented",arch14 +vcfn,"vector fp convert from nnp","implemented",arch14 +vcnf,"vector fp convert to nnp","implemented",arch14 +rdp,"reset dat protection",N/A,"privileged instruction" +lpswey,"load PSW extended",N/A,"privileged instruction" +lbear,"load bear",N/A,"privileged instruction" +stbear,"store bear",N/A,"privileged instruction" +qpaci,"query processor activity counter information",N/A,"privileged instruction" |
From: Andreas A. <ar...@so...> - 2024-03-28 18:23:29
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=c502a01b4bcba4b30db0dd166700b9be7bae832d commit c502a01b4bcba4b30db0dd166700b9be7bae832d Author: Andreas Arnez <ar...@li...> Date: Wed Mar 27 12:44:37 2024 +0100 s390x: Add support for NNPA facility vector instructions Add support for the vector instructions introduced with the NNPA facility, i.e, VCNF, VCLFNH, VCFN, VCLFNL, and VCRNF. These instructions convert floating-point data between the usual binary FP format (IEEE) and the NNPA-specific format. Implement them with dirty helpers. The NNPA instruction itself will be addressed with a separate patch. Diff: --- VEX/priv/guest_s390_defs.h | 8 ++- VEX/priv/guest_s390_helpers.c | 27 +++++++++ VEX/priv/guest_s390_toIR.c | 128 ++++++++++++++++++++++++++++++++++++++++++ VEX/priv/host_s390_defs.h | 2 + VEX/pub/libvex.h | 4 +- VEX/pub/libvex_s390x_common.h | 1 + coregrind/m_machine.c | 1 + include/vki/vki-s390x-linux.h | 1 + 8 files changed, 170 insertions(+), 2 deletions(-) diff --git a/VEX/priv/guest_s390_defs.h b/VEX/priv/guest_s390_defs.h index 24f3798c1a..1436ce3e8e 100644 --- a/VEX/priv/guest_s390_defs.h +++ b/VEX/priv/guest_s390_defs.h @@ -278,6 +278,11 @@ typedef enum { S390_VEC_OP_VFMAX, S390_VEC_OP_VBPERM, S390_VEC_OP_VMSL, + S390_VEC_OP_VCNF, + S390_VEC_OP_VCLFNH, + S390_VEC_OP_VCFN, + S390_VEC_OP_VCLFNL, + S390_VEC_OP_VCRNF, S390_VEC_OP_LAST // supposed to be the last element in enum } s390x_vec_op_t; @@ -295,12 +300,13 @@ typedef union { unsigned int v4 : 5; // argument two of operation or // zero for unary and binary operations + unsigned int m3 : 4; // field m3 of insn or zero if it's missing unsigned int m4 : 4; // field m4 of insn or zero if it's missing unsigned int m5 : 4; // field m5 of insn or zero if it's missing unsigned int m6 : 4; // field m6 of insn or zero if it's missing unsigned int i3 : 12; // field i3 of insn or zero if it's missing unsigned int read_only: 1; // don't write result to Guest State - unsigned int reserved : 11; // reserved for future + unsigned int reserved : 7; // reserved for future }; ULong serialized; } s390x_vec_op_details_t; diff --git a/VEX/priv/guest_s390_helpers.c b/VEX/priv/guest_s390_helpers.c index 008f8c6c8c..d60e4ce3c0 100644 --- a/VEX/priv/guest_s390_helpers.c +++ b/VEX/priv/guest_s390_helpers.c @@ -2593,6 +2593,11 @@ s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state, [S390_VEC_OP_VFMAX] = {0xe7, 0xef}, [S390_VEC_OP_VBPERM]= {0xe7, 0x85}, [S390_VEC_OP_VMSL] = {0xe7, 0xb8}, + [S390_VEC_OP_VCNF] = {0xe6, 0x55}, + [S390_VEC_OP_VCLFNH]= {0xe6, 0x56}, + [S390_VEC_OP_VCFN] = {0xe6, 0x5d}, + [S390_VEC_OP_VCLFNL]= {0xe6, 0x5e}, + [S390_VEC_OP_VCRNF] = {0xe6, 0x75}, }; union { @@ -2632,6 +2637,16 @@ s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state, UInt rxb : 4; UInt op2 : 8; } VRRc; + struct { + UInt op1 : 8; + UInt v1 : 4; + UInt v2 : 4; + UInt : 12; + UInt m4 : 4; + UInt m3 : 4; + UInt rxb : 4; + UInt op2 : 8; + } VRRa; struct { UInt op1 : 8; UInt v1 : 4; @@ -2687,6 +2702,7 @@ s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state, case S390_VEC_OP_VFMIN: case S390_VEC_OP_VFMAX: case S390_VEC_OP_VBPERM: + case S390_VEC_OP_VCRNF: the_insn.VRRc.v1 = 1; the_insn.VRRc.v2 = 2; the_insn.VRRc.v3 = 3; @@ -2696,6 +2712,17 @@ s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state, the_insn.VRRc.m6 = d->m6; break; + case S390_VEC_OP_VCNF: + case S390_VEC_OP_VCLFNH: + case S390_VEC_OP_VCFN: + case S390_VEC_OP_VCLFNL: + the_insn.VRRa.v1 = 1; + the_insn.VRRa.v2 = 2; + the_insn.VRRa.rxb = 0b1100; + the_insn.VRRa.m3 = d->m3; + the_insn.VRRa.m4 = d->m4; + break; + case S390_VEC_OP_VFTCI: the_insn.VRIe.v1 = 1; the_insn.VRIe.v2 = 2; diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index 81cce9fb48..ceb4084ace 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -19723,6 +19723,113 @@ s390_irgen_VSTEBRG(UChar v1, IRTemp op2addr, UChar m3) return "vstebrg"; } +static const HChar * +s390_irgen_VCxx(const HChar *mnem, s390x_vec_op_details_t details, + UShort v2_offs, UShort v2_size) +{ + s390_insn_assert(mnem, s390_host_has_nnpa); + + IRDirty* d = unsafeIRDirty_0_N(0, "s390x_dirtyhelper_vec_op", + &s390x_dirtyhelper_vec_op, + mkIRExprVec_2(IRExpr_GSPTR(), + mkU64(details.serialized))); + d->nFxState = 2; + vex_bzero(&d->fxState, sizeof(d->fxState)); + d->fxState[0].fx = Ifx_Read; + d->fxState[0].offset = S390X_GUEST_OFFSET(guest_v0) + + details.v2 * sizeof(V128) + v2_offs; + d->fxState[0].size = v2_size; + d->fxState[1].fx = Ifx_Write; + d->fxState[1].offset = S390X_GUEST_OFFSET(guest_v0) + + details.v1 * sizeof(V128); + d->fxState[1].size = sizeof(V128); + + stmt(IRStmt_Dirty(d)); + return mnem; +} + +static const HChar * +s390_irgen_VCNF(UChar v1, UChar v2, UChar m3, UChar m4) +{ + s390x_vec_op_details_t details = { .serialized = 0ULL }; + details.op = S390_VEC_OP_VCNF; + details.v1 = v1; + details.v2 = v2; + details.m3 = m3; + details.m4 = m4; + return s390_irgen_VCxx("vcnf", details, 0, sizeof(V128)); +} + +static const HChar * +s390_irgen_VCLFNH(UChar v1, UChar v2, UChar m3, UChar m4) +{ + s390x_vec_op_details_t details = { .serialized = 0ULL }; + details.op = S390_VEC_OP_VCLFNH; + details.v1 = v1; + details.v2 = v2; + details.m3 = m3; + details.m4 = m4; + return s390_irgen_VCxx("vclfnh", details, 0, sizeof(V128) / 2); +} + +static const HChar * +s390_irgen_VCFN(UChar v1, UChar v2, UChar m3, UChar m4) +{ + s390x_vec_op_details_t details = { .serialized = 0ULL }; + details.op = S390_VEC_OP_VCFN; + details.v1 = v1; + details.v2 = v2; + details.m3 = m3; + details.m4 = m4; + return s390_irgen_VCxx("vcfn", details, 0, sizeof(V128)); +} + +static const HChar * +s390_irgen_VCLFNL(UChar v1, UChar v2, UChar m3, UChar m4) +{ + s390x_vec_op_details_t details = { .serialized = 0ULL }; + details.op = S390_VEC_OP_VCLFNL; + details.v1 = v1; + details.v2 = v2; + details.m3 = m3; + details.m4 = m4; + return s390_irgen_VCxx("vclfnl", details, sizeof(V128) / 2, + sizeof(V128) / 2); +} + +static const HChar * +s390_irgen_VCRNF(UChar v1, UChar v2, UChar v3, UChar m4, UChar m5) +{ + s390_insn_assert("vcrnf", s390_host_has_nnpa); + + s390x_vec_op_details_t details = { .serialized = 0ULL }; + details.op = S390_VEC_OP_VCRNF; + details.v1 = v1; + details.v2 = v2; + details.v3 = v3; + details.m4 = m4; + details.m5 = m5; + details.m6 = 0; + IRDirty* d = unsafeIRDirty_0_N(0, "s390x_dirtyhelper_vec_op", + &s390x_dirtyhelper_vec_op, + mkIRExprVec_2(IRExpr_GSPTR(), + mkU64(details.serialized))); + d->nFxState = 3; + vex_bzero(&d->fxState, sizeof(d->fxState)); + d->fxState[0].fx = Ifx_Read; + d->fxState[0].offset = S390X_GUEST_OFFSET(guest_v0) + v2 * sizeof(V128); + d->fxState[0].size = sizeof(V128); + d->fxState[1].fx = Ifx_Read; + d->fxState[1].offset = S390X_GUEST_OFFSET(guest_v0) + v3 * sizeof(V128); + d->fxState[1].size = sizeof(V128); + d->fxState[2].fx = Ifx_Write; + d->fxState[2].offset = S390X_GUEST_OFFSET(guest_v0) + v1 * sizeof(V128); + d->fxState[2].size = sizeof(V128); + + stmt(IRStmt_Dirty(d)); + return "vcrnf"; +} + /* New insns are added here. If an insn is contingent on a facility being installed also check whether the list of supported facilities in function @@ -21415,6 +21522,22 @@ s390_decode_6byte_and_irgen(const UChar *bytes) case 0xe60000000049ULL: /* VLIP */ goto unimplemented; case 0xe60000000050ULL: /* VCVB */ goto unimplemented; case 0xe60000000052ULL: /* VCVBG */ goto unimplemented; + case 0xe60000000055ULL: s390_format_VRRa_VVMM(s390_irgen_VCNF, + VRRa_v1(ovl), VRRa_v2(ovl), + VRRa_m3(ovl), VRRa_m4(ovl), + VRRa_rxb(ovl)); goto ok; + case 0xe60000000056ULL: s390_format_VRRa_VVMM(s390_irgen_VCLFNH, + VRRa_v1(ovl), VRRa_v2(ovl), + VRRa_m3(ovl), VRRa_m4(ovl), + VRRa_rxb(ovl)); goto ok; + case 0xe6000000005dULL: s390_format_VRRa_VVMM(s390_irgen_VCFN, + VRRa_v1(ovl), VRRa_v2(ovl), + VRRa_m3(ovl), VRRa_m4(ovl), + VRRa_rxb(ovl)); goto ok; + case 0xe6000000005eULL: s390_format_VRRa_VVMM(s390_irgen_VCLFNL, + VRRa_v1(ovl), VRRa_v2(ovl), + VRRa_m3(ovl), VRRa_m4(ovl), + VRRa_rxb(ovl)); goto ok; case 0xe60000000058ULL: /* VCVD */ goto unimplemented; case 0xe60000000059ULL: /* VSRP */ goto unimplemented; case 0xe6000000005aULL: /* VCVDG */ goto unimplemented; @@ -21422,6 +21545,11 @@ s390_decode_6byte_and_irgen(const UChar *bytes) case 0xe6000000005fULL: /* VTP */ goto unimplemented; case 0xe60000000071ULL: /* VAP */ goto unimplemented; case 0xe60000000073ULL: /* VSP */ goto unimplemented; + case 0xe60000000075ULL: s390_format_VRRa_VVVMM(s390_irgen_VCRNF, + VRRa_v1(ovl), VRRa_v2(ovl), + VRRa_v3(ovl), + VRRa_m3(ovl), VRRa_m4(ovl), + VRRa_rxb(ovl)); goto ok; case 0xe60000000077ULL: /* VCP */ goto unimplemented; case 0xe60000000078ULL: /* VMP */ goto unimplemented; case 0xe60000000079ULL: /* VMSP */ goto unimplemented; diff --git a/VEX/priv/host_s390_defs.h b/VEX/priv/host_s390_defs.h index 375cc8402a..912db61041 100644 --- a/VEX/priv/host_s390_defs.h +++ b/VEX/priv/host_s390_defs.h @@ -943,6 +943,8 @@ extern UInt s390_host_hwcaps; (s390_host_hwcaps & (VEX_HWCAPS_S390X_LSC2)) #define s390_host_has_vxe \ (s390_host_hwcaps & (VEX_HWCAPS_S390X_VXE)) +#define s390_host_has_nnpa \ + (s390_host_hwcaps & (VEX_HWCAPS_S390X_NNPA)) #endif /* ndef __VEX_HOST_S390_DEFS_H */ /*---------------------------------------------------------------*/ diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 27bb6e0f46..42c013c1ec 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -175,6 +175,7 @@ typedef #define VEX_HWCAPS_S390X_MI2 (1<<20) /* miscellaneous-instruction-extensions facility 2 */ #define VEX_HWCAPS_S390X_LSC2 (1<<21) /* Conditional load/store facility2 */ #define VEX_HWCAPS_S390X_VXE (1<<22) /* Vector-enhancements facility */ +#define VEX_HWCAPS_S390X_NNPA (1<<23) /* NNPA facility */ /* Special value representing all available s390x hwcaps */ #define VEX_HWCAPS_S390X_ALL (VEX_HWCAPS_S390X_LDISP | \ @@ -193,7 +194,8 @@ typedef VEX_HWCAPS_S390X_MSA5 | \ VEX_HWCAPS_S390X_MI2 | \ VEX_HWCAPS_S390X_LSC2 | \ - VEX_HWCAPS_S390X_VXE) + VEX_HWCAPS_S390X_VXE | \ + VEX_HWCAPS_S390X_NNPA) #define VEX_HWCAPS_S390X(x) ((x) & ~VEX_S390X_MODEL_MASK) #define VEX_S390X_MODEL(x) ((x) & VEX_S390X_MODEL_MASK) diff --git a/VEX/pub/libvex_s390x_common.h b/VEX/pub/libvex_s390x_common.h index 0fbe4145a9..256541b568 100644 --- a/VEX/pub/libvex_s390x_common.h +++ b/VEX/pub/libvex_s390x_common.h @@ -106,6 +106,7 @@ #define S390_FAC_VXE 135 // vector enhancements facility 1 #define S390_FAC_VXE2 148 // vector enhancements facility 2 #define S390_FAC_DFLT 151 // deflate-conversion facility +#define S390_FAC_NNPA 165 // NNPA facility /*--------------------------------------------------------------*/ diff --git a/coregrind/m_machine.c b/coregrind/m_machine.c index a4c2218bfb..0793836512 100644 --- a/coregrind/m_machine.c +++ b/coregrind/m_machine.c @@ -1591,6 +1591,7 @@ Bool VG_(machine_get_hwcaps)( void ) { False, S390_FAC_MI2, VEX_HWCAPS_S390X_MI2, "MI2" }, { False, S390_FAC_LSC2, VEX_HWCAPS_S390X_LSC2, "LSC2" }, { False, S390_FAC_VXE, VEX_HWCAPS_S390X_VXE, "VXE" }, + { False, S390_FAC_NNPA, VEX_HWCAPS_S390X_NNPA, "NNPA" }, }; /* Set hwcaps according to the detected facilities */ diff --git a/include/vki/vki-s390x-linux.h b/include/vki/vki-s390x-linux.h index 9d1cf1dde7..829382f7b2 100644 --- a/include/vki/vki-s390x-linux.h +++ b/include/vki/vki-s390x-linux.h @@ -809,6 +809,7 @@ typedef vki_s390_regs vki_elf_gregset_t; #define VKI_HWCAP_S390_VXRS 2048 #define VKI_HWCAP_S390_VXRS_EXT 8192 #define VKI_HWCAP_S390_VXRS_EXT2 32768 +#define VKI_HWCAP_S390_NNPA (1<<20) //---------------------------------------------------------------------- |
From: Mark W. <ma...@kl...> - 2024-03-28 16:36:30
|
Hi Paul, On Wed, Mar 27, 2024 at 08:02:28PM +0000, Paul Floyd wrote: > https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f3e96c80230b7fe9f9d90bd30f1d91e70c0bd7e3 > > commit f3e96c80230b7fe9f9d90bd30f1d91e70c0bd7e3 > Author: Paul Floyd <pj...@wa...> > Date: Wed Mar 27 21:01:20 2024 +0100 > > Darwin: add syswrap for necp_open > > From Louis Brunner. It's marked for 10.15 in his repo but I get > --50575-- WARNING: unhandled amd64-darwin syscall: unix:501 > on 10.13 > > Diff: > --- > VEX/priv/guest_arm64_toIR.c | 3 +++ > coregrind/m_syswrap/priv_syswrap-darwin.h | 2 +- > coregrind/m_syswrap/syswrap-darwin.c | 9 ++++++++- > 3 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c > index 9076a61a63..8a8743866b 100644 > --- a/VEX/priv/guest_arm64_toIR.c > +++ b/VEX/priv/guest_arm64_toIR.c > @@ -15087,6 +15087,9 @@ Bool dis_AdvSIMD_fp_data_proc_1_source(/*MB_OUT*/DisResult* dres, UInt insn) > case BITS3(1,0,0): ch = 'a'; irrmE = mkU32(Irrm_NEAREST); break; > // I am unsure about the following, due to the "integral exact" > // description in the manual. What does it mean? (frintx, that is) > + // PJF exact means that if the rounding can't be done without > + // precision loss (dst numerically equal to src after the rounding) > + // then an exception is raised / the IXC bit gets set in the FPSR > case BITS3(1,1,0): > ch = 'x'; irrmE = mkexpr(mk_get_IR_rounding_mode()); break; > case BITS3(1,1,1): It is of course harmless because just a comment. But I think this part was meant for Bug 484426 aarch64: 0.5 gets rounded to 0? It conflicts with the patch attached for that bug. Cheers, Mark |
From: Paul F. <pa...@so...> - 2024-03-28 16:15:30
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e65c8cc7098e16616668ed2f91abe8b40fdd1533 commit e65c8cc7098e16616668ed2f91abe8b40fdd1533 Author: Paul Floyd <pj...@wa...> Date: Thu Mar 28 17:14:14 2024 +0100 coverity: one dead code, one unread assignment and one NULL check Diff: --- VEX/priv/guest_x86_helpers.c | 6 +----- coregrind/m_debuginfo/debuginfo.c | 3 +-- coregrind/m_debuginfo/readelf.c | 3 +-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/VEX/priv/guest_x86_helpers.c b/VEX/priv/guest_x86_helpers.c index 7743c63a47..135e997c48 100644 --- a/VEX/priv/guest_x86_helpers.c +++ b/VEX/priv/guest_x86_helpers.c @@ -2798,7 +2798,7 @@ ULong x86g_use_seg_selector ( HWord ldt, HWord gdt, /* Convert the segment selector onto a table index */ seg_selector >>= 3; - vassert(seg_selector < 8192); + vassert(seg_selector < VEX_GUEST_X86_GDT_NENT); if (tiBit == 0) { @@ -2807,10 +2807,6 @@ ULong x86g_use_seg_selector ( HWord ldt, HWord gdt, if (gdt == 0) goto bad; - /* Check for access to non-existent entry. */ - if (seg_selector >= VEX_GUEST_X86_GDT_NENT) - goto bad; - the_descrs = (VexGuestX86SegDescr*)gdt; base = get_segdescr_base (&the_descrs[seg_selector]); limit = get_segdescr_limit(&the_descrs[seg_selector]); diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 5939e7b3a7..6f923c736e 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -693,7 +693,6 @@ static void check_CFSI_related_invariants ( const DebugInfo* di ) "DiCfsi invariant (1) verification failed"); } } - di2 = NULL; } /* degenerate case: all r-x sections are empty */ @@ -2822,7 +2821,7 @@ const HChar* VG_(describe_IP)(DiEpoch ep, Addr eip, const InlIPCursor *iipc) ? VG_(get_fnname_w_offset) (ep, eip, &buf_fn) : VG_(get_fnname) (ep, eip, &buf_fn); } else { - const DiInlLoc *next_inl = iipc && iipc->next_inltab >= 0 + const DiInlLoc *next_inl = iipc && iipc->di && iipc->next_inltab >= 0 ? & iipc->di->inltab[iipc->next_inltab] : NULL; vg_assert (next_inl); diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index b1f863fe59..7a654e1513 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -859,7 +859,7 @@ void read_elf_symtab__normal( disym.isText = is_text; disym.isIFunc = is_ifunc; disym.isGlobal = is_global; - if (cstr) { ML_(dinfo_free)(cstr); cstr = NULL; } + ML_(dinfo_free)(cstr); vg_assert(disym.pri_name); vg_assert(GET_TOCPTR_AVMA(disym.avmas) == 0); /* has no role except on ppc64be-linux */ @@ -879,7 +879,6 @@ void read_elf_symtab__normal( GET_LOCAL_EP_AVMA(disym.avmas)); } } - } } } |
From: Paul F. <pa...@so...> - 2024-03-28 08:07:57
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=ba728d01c09438a044a57888e89654789a12d8c9 commit ba728d01c09438a044a57888e89654789a12d8c9 Author: Paul Floyd <pj...@wa...> Date: Thu Mar 28 09:06:23 2024 +0100 coverity: dead code and overflows Overflows deliberate. Dead code probably not. Diff: --- VEX/priv/guest_amd64_helpers.c | 2 -- VEX/priv/guest_arm64_toIR.c | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/VEX/priv/guest_amd64_helpers.c b/VEX/priv/guest_amd64_helpers.c index adb5c7287e..da1cabc3cb 100644 --- a/VEX/priv/guest_amd64_helpers.c +++ b/VEX/priv/guest_amd64_helpers.c @@ -3662,7 +3662,6 @@ ULong amd64g_calculate_RCR ( ULong arg, } break; case 4: - while (tempCOUNT >= 33) tempCOUNT -= 33; cf = (rflags_in >> AMD64G_CC_SHIFT_C) & 1; of = ((arg >> 31) ^ cf) & 1; while (tempCOUNT > 0) { @@ -3730,7 +3729,6 @@ ULong amd64g_calculate_RCL ( ULong arg, of = ((arg >> 63) ^ cf) & 1; break; case 4: - while (tempCOUNT >= 33) tempCOUNT -= 33; cf = (rflags_in >> AMD64G_CC_SHIFT_C) & 1; while (tempCOUNT > 0) { tempcf = (arg >> 31) & 1; diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c index 8a8743866b..3b33c48c3e 100644 --- a/VEX/priv/guest_arm64_toIR.c +++ b/VEX/priv/guest_arm64_toIR.c @@ -8047,8 +8047,13 @@ static Bool AdvSIMDExpandImm ( /*OUT*/ULong* res, case 1: testimm8 = True; imm64 = Replicate32x2(imm8 << 8UL); break; case 2: + // Coverity is right but we want the overflow, Replicate32x2 expects + // (and asserts) that the top 32bits be zero so if we get rid of the + // overflow we would need to add a mask. So just let it overflow. + // coverity[OVERFLOW_BEFORE_WIDEN:FALSE] testimm8 = True; imm64 = Replicate32x2(imm8 << 16UL); break; case 3: + // coverity[OVERFLOW_BEFORE_WIDEN:FALSE] testimm8 = True; imm64 = Replicate32x2(imm8 << 24UL); break; case 4: testimm8 = False; imm64 = Replicate16x4(imm8); break; |
From: Paul F. <pa...@so...> - 2024-03-27 20:10:10
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4a608e1601aa2961596ff65a9b639ceecb8fd264 commit 4a608e1601aa2961596ff65a9b639ceecb8fd264 Author: Paul Floyd <pj...@wa...> Date: Wed Mar 27 21:09:11 2024 +0100 Darwin syscall: and now necp_client_action Also from Louis Brunner and also on 10.13 at least Diff: --- coregrind/m_syswrap/priv_syswrap-darwin.h | 2 +- coregrind/m_syswrap/syswrap-darwin.c | 129 +++++++++++++++++++++++++++++- 2 files changed, 129 insertions(+), 2 deletions(-) diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index e70960b8a3..c0313fd7ca 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -623,7 +623,7 @@ DECL_TEMPLATE(darwin, guarded_writev_np); // 487 #if DARWIN_VERS >= DARWIN_10_12 DECL_TEMPLATE(darwin, getentropy); // 500 DECL_TEMPLATE(darwin, necp_open); // 501 -// NYI necp_client_action // 502 +DECL_TEMPLATE(darwin, necp_client_action); // 502 // 503 // 504 // 505 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index 74a7f1e52c..6b0f591495 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -10113,6 +10113,133 @@ PRE(necp_open) PRE_REG_READ1(int, "necp_open", int, flags); } +PRE(necp_client_action) +{ + PRINT("necp_client_action(%lu, %#lx, %#lx, %lu, %#lx, %lu)", + ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); + PRE_REG_READ6(int, "necp_client_action", + int, necp_fd, uint32_t, action, + unsigned char*, client_id, size_t, client_id_len, + uint8_t*, buffer, size_t, buffer_size); + + switch (ARG2 /* request */) { + case VKI_NECP_CLIENT_ACTION_ADD: + if (ARG4 != sizeof(uuid_t) || ARG6 == 0 || ARG6 > VKI_NECP_MAX_CLIENT_PARAMETERS_SIZE) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_WRITE( "necp_client_action(ADD, client_id)", ARG3, ARG4); + PRE_MEM_READ( "necp_client_action(ADD, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_CLAIM: + if (ARG4 != sizeof(uuid_t)) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(CLAIM, client_id)", ARG3, ARG4); + break; + case VKI_NECP_CLIENT_ACTION_REMOVE: + if (ARG4 != sizeof(uuid_t) || (ARG5 != 0 && ARG6 != VKI_IFNET_STATS_PER_FLOW_SIZE)) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(REMOVE, client_id)", ARG3, ARG4); + PRE_MEM_READ( "necp_client_action(REMOVE, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_COPY_PARAMETERS: + if ((ARG3 != 0 && ARG4 != sizeof(uuid_t)) || ARG6 == 0) { + SET_STATUS_Failure( VKI_EINVAL ); + } + if (ARG3 != 0) { + PRE_MEM_READ( "necp_client_action(COPY_PARAMETERS, client_id)", ARG3, ARG4); + } + PRE_MEM_READ( "necp_client_action(COPY_PARAMETERS, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_COPY_RESULT: + if ((ARG3 != 0 && ARG4 != sizeof(uuid_t)) || ARG6 == 0) { + SET_STATUS_Failure( VKI_EINVAL ); + } + if (ARG3 != 0) { + PRE_MEM_READ( "necp_client_action(COPY_RESULT, client_id)", ARG3, ARG4); + } + PRE_MEM_READ( "necp_client_action(COPY_RESULT, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_COPY_UPDATED_RESULT: + if ((ARG3 != 0 && ARG4 != sizeof(uuid_t)) || ARG6 == 0) { + SET_STATUS_Failure( VKI_EINVAL ); + } + if (ARG3 != 0) { + PRE_MEM_READ( "necp_client_action(COPY_UPDATED_RESULT, client_id)", ARG3, ARG4); + } + PRE_MEM_READ( "necp_client_action(COPY_UPDATED_RESULT, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_COPY_LIST: + if (ARG6 < sizeof(u_int32_t)) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(COPY_LIST, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_AGENT: + if (ARG4 != sizeof(uuid_t) || ARG6 == 0) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(AGENT, client_id)", ARG3, ARG4); + PRE_MEM_READ( "necp_client_action(AGENT, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_COPY_AGENT: + if (ARG4 != sizeof(uuid_t) || ARG6 == 0) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(COPY_AGENT, client_id)", ARG3, ARG4); + PRE_MEM_READ( "necp_client_action(COPY_AGENT, buffer)", ARG5, ARG6); + PRE_MEM_WRITE( "necp_client_action(COPY_AGENT, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_AGENT_USE: + if (ARG4 != sizeof(uuid_t) || ARG6 != sizeof(struct vki_necp_agent_use_parameters)) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(AGENT_USE, client_id)", ARG3, ARG4); + PRE_MEM_READ( "necp_client_action(AGENT_USE, buffer)", ARG5, ARG6); + PRE_MEM_WRITE( "necp_client_action(AGENT_USE, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_COPY_INTERFACE: + if (ARG4 != sizeof(u_int32_t) || ARG6 < sizeof(struct vki_necp_interface_details_legacy)) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(COPY_INTERFACE, client_id)", ARG3, ARG4); + PRE_MEM_WRITE( "necp_client_action(COPY_INTERFACE, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_COPY_ROUTE_STATISTICS: + if (ARG4 != sizeof(uuid_t) || ARG6 < VKI_NECP_STAT_COUNTS_SIZE) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(COPY_ROUTE_STATISTICS, client_id)", ARG3, ARG4); + PRE_MEM_WRITE( "necp_client_action(COPY_ROUTE_STATISTICS, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_UPDATE_CACHE: + if (ARG4 != sizeof(uuid_t) || ARG6 != sizeof(struct vki_necp_cache_buffer)) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(UPDATE_CACHE, client_id)", ARG3, ARG4); + PRE_MEM_READ( "necp_client_action(UPDATE_CACHE, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_COPY_CLIENT_UPDATE: + if (ARG4 != sizeof(uuid_t) || ARG6 == 0) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_WRITE( "necp_client_action(COPY_CLIENT_UPDATE, client_id)", ARG3, ARG4); + PRE_MEM_WRITE( "necp_client_action(COPY_CLIENT_UPDATE, buffer)", ARG5, ARG6); + break; + case VKI_NECP_CLIENT_ACTION_SIGN: + if (ARG4 < sizeof(struct vki_necp_client_signable) || ARG6 != VKI_NECP_CLIENT_ACTION_SIGN_TAG_LENGTH) { + SET_STATUS_Failure( VKI_EINVAL ); + } + PRE_MEM_READ( "necp_client_action(SIGN, client_id)", ARG3, ARG4); + PRE_MEM_WRITE( "necp_client_action(SIGN, buffer)", ARG5, ARG6); + break; + default: + VG_(printf)("UNKNOWN necp_client_action action %#lx\n", ARG2); + break; + } +} + static const HChar *ulop_name(int op) { switch (op) { @@ -10993,7 +11120,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_renameatx_np), // 488 MACXY(__NR_getentropy, getentropy), // 500 MACX_(__NR_necp_open, necp_open), // 501 -// _____(__NR_necp_client_action), // 502 + MACX_(__NR_necp_client_action, necp_client_action), // 502 _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(503)), // ??? _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(504)), // ??? _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(505)), // ??? |
From: Paul F. <pa...@so...> - 2024-03-27 20:02:40
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f3e96c80230b7fe9f9d90bd30f1d91e70c0bd7e3 commit f3e96c80230b7fe9f9d90bd30f1d91e70c0bd7e3 Author: Paul Floyd <pj...@wa...> Date: Wed Mar 27 21:01:20 2024 +0100 Darwin: add syswrap for necp_open From Louis Brunner. It's marked for 10.15 in his repo but I get --50575-- WARNING: unhandled amd64-darwin syscall: unix:501 on 10.13 Diff: --- VEX/priv/guest_arm64_toIR.c | 3 +++ coregrind/m_syswrap/priv_syswrap-darwin.h | 2 +- coregrind/m_syswrap/syswrap-darwin.c | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c index 9076a61a63..8a8743866b 100644 --- a/VEX/priv/guest_arm64_toIR.c +++ b/VEX/priv/guest_arm64_toIR.c @@ -15087,6 +15087,9 @@ Bool dis_AdvSIMD_fp_data_proc_1_source(/*MB_OUT*/DisResult* dres, UInt insn) case BITS3(1,0,0): ch = 'a'; irrmE = mkU32(Irrm_NEAREST); break; // I am unsure about the following, due to the "integral exact" // description in the manual. What does it mean? (frintx, that is) + // PJF exact means that if the rounding can't be done without + // precision loss (dst numerically equal to src after the rounding) + // then an exception is raised / the IXC bit gets set in the FPSR case BITS3(1,1,0): ch = 'x'; irrmE = mkexpr(mk_get_IR_rounding_mode()); break; case BITS3(1,1,1): diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index ae1c36761e..e70960b8a3 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -622,7 +622,7 @@ DECL_TEMPLATE(darwin, guarded_writev_np); // 487 #endif /* DARWIN_VERS >= DARWIN_10_11 */ #if DARWIN_VERS >= DARWIN_10_12 DECL_TEMPLATE(darwin, getentropy); // 500 -// NYI necp_open // 501 +DECL_TEMPLATE(darwin, necp_open); // 501 // NYI necp_client_action // 502 // 503 // 504 diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index cc54486bab..74a7f1e52c 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -10100,12 +10100,19 @@ PRE(getentropy) void*, buffer, size_t, size); PRE_MEM_WRITE( "getentropy(buffer)", ARG1, ARG2 ); } + POST(getentropy) { vg_assert(SUCCESS); POST_MEM_WRITE( ARG1, ARG2 ); } +PRE(necp_open) +{ + PRINT("necp_open(%#lx)", ARG1); + PRE_REG_READ1(int, "necp_open", int, flags); +} + static const HChar *ulop_name(int op) { switch (op) { @@ -10985,7 +10992,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_clonefileat), // 462 // _____(__NR_renameatx_np), // 488 MACXY(__NR_getentropy, getentropy), // 500 -// _____(__NR_necp_open), // 501 + MACX_(__NR_necp_open, necp_open), // 501 // _____(__NR_necp_client_action), // 502 _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(503)), // ??? _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(504)), // ??? |
From: Paul F. <pa...@so...> - 2024-03-27 19:51:48
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=17d504da0b0d02103fe9cdd47a4a0fb56450aec1 commit 17d504da0b0d02103fe9cdd47a4a0fb56450aec1 Author: Paul Floyd <pj...@wa...> Date: Wed Mar 27 20:51:02 2024 +0100 Darwin DRD: suppressions for macOS 10.13 Diff: --- darwin17.supp | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/darwin17.supp b/darwin17.supp index 76ef05f6ac..2354672d05 100644 --- a/darwin17.supp +++ b/darwin17.supp @@ -825,3 +825,140 @@ fun:pthread_rwlock_init Memcheck:Cond fun:ccaes_vng_ctr_crypt } +{ + OSX1013:nanosleep + drd:ConflictingAccess + fun:nanosleep +} +{ + OSX1013:_pthread_join + drd:ConflictingAccess + fun:_pthread_join +} +{ + OSX1013:usleep + drd:ConflictingAccess + fun:pthread_testcancel + fun:usleep +} +{ + OSX1013:_pthread_join_cleanup + drd:ConflictingAccess + fun:_pthread_join_cleanup +} +{ + OSX1013:pthread_mutex_destroy + drd:ConflictingAccess + fun:pthread_mutex_destroy +} +{ + OSX1013:pthread_cond_destroy + drd:ConflictingAccess + fun:pthread_cond_destroy +} +{ + OSX1013:pthread_mutex_unlock + drd:ConflictingAccess + fun:pthread_mutex_unlock +} +{ + OSX1013:pthread_mutex_lock + drd:ConflictingAccess + fun:pthread_mutex_lock +} +{ + OSX1013:_pthread_deallocate + drd:ConflictingAccess + fun:_pthread_deallocate +} +{ + OSX1013:std::timed_mutex::unlock + drd:ConflictingAccess + fun:_ZNSt3__111timed_mutex6unlockEv +} +{ + std::timed_mutex::try_lock_until + drd:ConflictingAccess + fun:_ZNSt3__111timed_mutex14try_lock_untilINS_6chrono12steady_clockENS2_8durationIxNS_5ratio* +} +{ + OSX1013:_pthread_cond_updateval + drd:ConflictingAccess + fun:_pthread_cond_updateval +} +{ + OSX1013:pthread_cond_signal + drd:ConflictingAccess + fun:pthread_cond_signal +} +{ + OSX1013:_pthread_mutex_droplock + drd:ConflictingAccess + fun:_pthread_mutex_droplock +} +{ + OSX1013:_pthread_cond_wait + drd:ConflictingAccess + fun:_pthread_cond_wait +} +{ + OSX1013:mach_timebase_info + drd:ConflictingAccess + fun:mach_timebase_info +} +{ + OSX1013:pthread_testcancel + drd:ConflictingAccess + fun:pthread_testcancel +} +# take care with this, don't want to suppress anything in user +# thread functions +{ + OSX1013:_pthread_body + drd:ConflictingAccess + fun:_pthread_body +} +{ + OSX1013:exit + drd:ConflictingAccess + ... + fun:exit +} +{ + OSX1013:freeaddrinfo + drd:ConflictingAccess + fun:freeaddrinfo +} +{ + OSX1013:getaddrinfo + drd:ConflictingAccess + ... + fun:getaddrinfo +} +{ + OSX1013:cache_fill + drd:ConflictingAccess + fun:_ZN7cache_t10reallocateEjj + fun:cache_fill +} +{ + OSX1013:os_unfair_lock + drd:ConflictingAccess + ... + fun:*os_unfair_lock* +} +{ + OSX1013:objc_msgSend + drd:ConflictingAccess + fun:objc_msgSend +} +{ + OSX1013:cache_fill + drd:ConflictingAccess + fun:cache_fill +} +{ + OSX1013:_nc_table + drd:ConflictingAccess + fun:_nc_table_* +} |
From: Paul F. <pa...@so...> - 2024-03-27 14:57:17
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=82addc7a9a3f6e35615024e3904d6bfec54e456f commit 82addc7a9a3f6e35615024e3904d6bfec54e456f Author: Paul Floyd <pj...@wa...> Date: Wed Mar 27 15:53:42 2024 +0100 Dawrin regtest: mostly more filtering Changed str_tester to always call memcmp. Apple clang 10 seems to evaluate some of these at compile time, and gets it wrong. The runtime gets it right. Diff: --- memcheck/tests/Makefile.am | 3 ++- memcheck/tests/filter_allocs | 3 ++- memcheck/tests/filter_libc_variants | 5 +++++ memcheck/tests/memcmptest.stderr.exp2 | 4 ---- memcheck/tests/memcmptest.vgtest | 1 + memcheck/tests/str_tester.c | 16 ++++++++-------- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index e08c124f78..2bf96aded7 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -74,6 +74,7 @@ dist_noinst_SCRIPTS = \ filter_allocs \ filter_leak_cases_possible \ filter_leak_cpp_interior \ + filter_libc_variants \ filter_xml \ filter_strchr \ filter_varinfo3 \ @@ -268,7 +269,7 @@ EXTRA_DIST = \ memalign_args.stderr.exp-solaris \ memccpy1.stderr.exp memccpy1.stdout.exp memccpy1.vgtest \ memccpy2.stderr.exp memccpy2.vgtest \ - memcmptest.stderr.exp memcmptest.stderr.exp2 \ + memcmptest.stderr.exp \ memcmptest.stdout.exp memcmptest.vgtest \ memmem.stderr.exp memmem.vgtest \ mempool.stderr.exp mempool.vgtest \ diff --git a/memcheck/tests/filter_allocs b/memcheck/tests/filter_allocs index f6fd1235da..2f3d04fac4 100755 --- a/memcheck/tests/filter_allocs +++ b/memcheck/tests/filter_allocs @@ -2,5 +2,6 @@ ./filter_stderr "$@" | sed -e "s/in use at exit: [0-9,]* bytes in [0-9,]* blocks/in use at exit: ... bytes in ... blocks/" \ - -e "s/total heap usage: [0-9,]* allocs, [0-9,]* frees, [0-9,]* bytes allocated/total heap usage: ... allocs, ... frees, ... bytes allocated/" + -e "s/total heap usage: [0-9,]* allocs, [0-9,]* frees, [0-9,]* bytes allocated/total heap usage: ... allocs, ... frees, ... bytes allocated/" \ + -e "s/suppressed: .*blocks/suppressed: 0 bytes in 0 blocks/" diff --git a/memcheck/tests/filter_libc_variants b/memcheck/tests/filter_libc_variants new file mode 100755 index 0000000000..dce64d4a71 --- /dev/null +++ b/memcheck/tests/filter_libc_variants @@ -0,0 +1,5 @@ +#! /bin/sh + +./filter_stderr "$@" | + +sed 's/ _platform_memcmp / memcmp /;s/ bcmp / memcmp /' diff --git a/memcheck/tests/memcmptest.stderr.exp2 b/memcheck/tests/memcmptest.stderr.exp2 deleted file mode 100644 index b58969f2fa..0000000000 --- a/memcheck/tests/memcmptest.stderr.exp2 +++ /dev/null @@ -1,4 +0,0 @@ -Conditional jump or move depends on uninitialised value(s) - at 0x........: bcmp (vg_replace_strmem.c:...) - by 0x........: main (memcmptest.c:13) - diff --git a/memcheck/tests/memcmptest.vgtest b/memcheck/tests/memcmptest.vgtest index 0509f9fad9..380519af65 100644 --- a/memcheck/tests/memcmptest.vgtest +++ b/memcheck/tests/memcmptest.vgtest @@ -1,2 +1,3 @@ prog: memcmptest vgopts: -q +stderr_filter: filter_libc_variants diff --git a/memcheck/tests/str_tester.c b/memcheck/tests/str_tester.c index 1201bbfc22..d910b69092 100644 --- a/memcheck/tests/str_tester.c +++ b/memcheck/tests/str_tester.c @@ -979,14 +979,14 @@ static void test_memcmp (void) { it = "memcmp"; - check(memcmp("a", "a", 1) == 0, 1); /* Identity. */ - check(memcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */ - check(memcmp("abcd", "abce", 4) < 0, 3); /* Honestly unequal. */ - check(memcmp("abce", "abcd", 4) > 0, 4); - check(memcmp("alph", "beta", 4) < 0, 5); - check(memcmp("a\203", "a\003", 2) > 0, 6); - check(memcmp("abce", "abcd", 3) == 0, 7); /* Count limited. */ - check(memcmp("abc", "def", 0) == 0, 8); /* Zero count. */ + check((memcmp)("a", "a", 1) == 0, 1); /* Identity. */ + check((memcmp)("abc", "abc", 3) == 0, 2); /* Multicharacter. */ + check((memcmp)("abcd", "abce", 4) < 0, 3); /* Honestly unequal. */ + check((memcmp)("abce", "abcd", 4) > 0, 4); + check((memcmp)("alph", "beta", 4) < 0, 5); + check((memcmp)("a\203", "a\003", 2) > 0, 6); + check((memcmp)("abce", "abcd", 3) == 0, 7); /* Count limited. */ + check((memcmp)("abc", "def", 0) == 0, 8); /* Zero count. */ } static void |
From: Paul F. <pa...@so...> - 2024-03-27 12:52:59
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=5caadd1f943904e6d00a097069c61993911e4a6a commit 5caadd1f943904e6d00a097069c61993911e4a6a Author: Paul Floyd <pj...@wa...> Date: Wed Mar 27 13:52:02 2024 +0100 Darwin regtest: add suppression for zone memalign Diff: --- memcheck/tests/posix_memalign_supp.supp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/memcheck/tests/posix_memalign_supp.supp b/memcheck/tests/posix_memalign_supp.supp index 9f6b5441cb..a38ba23b0c 100644 --- a/memcheck/tests/posix_memalign_supp.supp +++ b/memcheck/tests/posix_memalign_supp.supp @@ -12,3 +12,21 @@ fun:posix_memalign fun:main } + +# Darwin uses zones +{ + posix_memalign size + Memcheck:BadSize + fun:malloc_zone_memalign + fun:posix_memalign + fun:main +} + +{ + posix_memalign align + Memcheck:BadAlign + fun:malloc_zone_memalign + fun:posix_memalign + fun:main +} + |
From: Paul F. <pa...@so...> - 2024-03-27 12:47:52
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=8796e55e04bc132ba0721e3f5000ef137663c317 commit 8796e55e04bc132ba0721e3f5000ef137663c317 Author: Paul Floyd <pj...@wa...> Date: Wed Mar 27 13:41:37 2024 +0100 Darwin: merge some fixes for macOS up to 10.13 From https://github.com/LouisBrunner/valgrind-macos Thanks, Louis Brunner Before == 742 tests, 312 stderr failures, 93 stdout failures, 0 stderrB failures, 0 stdoutB failures, 4 post failures == After == 748 tests, 293 stderr failures, 71 stdout failures, 0 stderrB failures, 0 stdoutB failures, 4 post failures == Diff: --- coregrind/fixup_macho_loadcmds.c | 4 + coregrind/m_syswrap/priv_syswrap-darwin.h | 17 +- coregrind/m_syswrap/syswrap-amd64-darwin.c | 3 + coregrind/m_syswrap/syswrap-darwin.c | 417 +++++++++++++++++++++-------- include/vki/vki-darwin.h | 4 + include/vki/vki-scnums-darwin.h | 4 + 6 files changed, 335 insertions(+), 114 deletions(-) diff --git a/coregrind/fixup_macho_loadcmds.c b/coregrind/fixup_macho_loadcmds.c index cdb3622a50..1a5cdf62ad 100644 --- a/coregrind/fixup_macho_loadcmds.c +++ b/coregrind/fixup_macho_loadcmds.c @@ -440,6 +440,10 @@ void modify_macho_loadcmds ( HChar* filename, if (DEBUGPRINTING) printf("LC_UNIXTHREAD"); break; + case LC_SOURCE_VERSION: + if (DEBUGPRINTING) + printf("LC_SOURCE_VERSION"); + break; default: if (DEBUGPRINTING) printf("???"); diff --git a/coregrind/m_syswrap/priv_syswrap-darwin.h b/coregrind/m_syswrap/priv_syswrap-darwin.h index c2dd3507f0..ae1c36761e 100644 --- a/coregrind/m_syswrap/priv_syswrap-darwin.h +++ b/coregrind/m_syswrap/priv_syswrap-darwin.h @@ -225,7 +225,11 @@ DECL_TEMPLATE(darwin, gethostuuid); // 142 DECL_TEMPLATE(darwin, mount); // 167 // old ustat DECL_TEMPLATE(darwin, csops); // 169 +#if DARWIN_VERS >= DARWIN_10_8 +DECL_TEMPLATE(darwin, csops_audittoken); // 170 +#else // old table +#endif // old wait3 // old rpause // NYI waitid 173 @@ -290,7 +294,9 @@ DECL_TEMPLATE(darwin, exchangedata); // 223 // NYI searchfs 225 // GEN delete 226 // NYI copyfile 226 -// 228 +#if DARWIN_VERS >= DARWIN_10_6 +DECL_TEMPLATE(darwin, fgetattrlist); // 228 +#endif // 229 // GEN poll 230 DECL_TEMPLATE(darwin, watchevent); // 231 @@ -471,7 +477,7 @@ DECL_TEMPLATE(darwin, __thread_selfid); // 372 DECL_TEMPLATE(darwin, kevent_qos); // 374 #endif /* DARWIN_VERS >= DARWIN_10_11 */ #if DARWIN_VERS >= DARWIN_10_13 -// NYI kevent_id // 375 +DECL_TEMPLATE(darwin, kevent_id); // 375 #endif /* DARWIN_VERS >= DARWIN_10_13 */ // 376 // 377 @@ -635,8 +641,8 @@ DECL_TEMPLATE(darwin, ulock_wake); // 516 // NYI fclonefileat // 517 // NYI fs_snapshot // 518 // 519 -// NYI terminate_with_payload // 520 -// NYI abort_with_payload // 521 +DECL_TEMPLATE(darwin, terminate_with_payload); // 520 +DECL_TEMPLATE(darwin, abort_with_payload); // 521 #endif /* DARWIN_VERS >= DARWIN_10_12 */ #if DARWIN_VERS >= DARWIN_10_13 // NYI necp_session_open // 522 @@ -765,7 +771,7 @@ DECL_TEMPLATE(darwin, task_for_pid); DECL_TEMPLATE(darwin, pid_for_task); #if DARWIN_VERS >= DARWIN_10_13 -// NYI thread_get_special_reply_port // 50 +DECL_TEMPLATE(darwin, thread_get_special_reply_port); #endif /* DARWIN_VERS >= DARWIN_10_13 */ #if DARWIN_VERS >= DARWIN_10_12 @@ -825,6 +831,7 @@ extern void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem extern Addr pthread_starter; extern Addr wqthread_starter; extern SizeT pthread_structsize; +extern SizeT pthread_tsd_offset; #endif diff --git a/coregrind/m_syswrap/syswrap-amd64-darwin.c b/coregrind/m_syswrap/syswrap-amd64-darwin.c index 5b70e8377c..6227352eee 100644 --- a/coregrind/m_syswrap/syswrap-amd64-darwin.c +++ b/coregrind/m_syswrap/syswrap-amd64-darwin.c @@ -361,6 +361,9 @@ void pthread_hijack(Addr self, Addr kport, Addr func, Addr func_arg, vex->guest_R8 = stacksize; vex->guest_R9 = flags; vex->guest_RSP = sp; +#if DARWIN_VERS >= DARWIN_10_12 + vex->guest_GS_CONST = self + pthread_tsd_offset; +#endif // Record thread's stack and Mach port and pthread struct tst->os_state.pthread = self; diff --git a/coregrind/m_syswrap/syswrap-darwin.c b/coregrind/m_syswrap/syswrap-darwin.c index d6d18ff21d..cc54486bab 100644 --- a/coregrind/m_syswrap/syswrap-darwin.c +++ b/coregrind/m_syswrap/syswrap-darwin.c @@ -2063,16 +2063,38 @@ POST(kevent64) Addr pthread_starter = 0; Addr wqthread_starter = 0; SizeT pthread_structsize = 0; +SizeT pthread_tsd_offset = 0; PRE(bsdthread_register) { +#if DARWIN_VERS >= DARWIN_10_12 + PRINT("bsdthread_register( %#lx, %#lx, %lu, %#lx, %#lx, %#lx, %#lx )", + ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7); + PRE_REG_READ7(int,"__bsdthread_register", void *,"threadstart", + void *,"wqthread", size_t,"pthsize", + void *,"stack_addr_hint", void *,"targetconc_ptr", + uint32_t,"dispatchqueue_offset", uint32_t,"tsd_offset"); +#else PRINT("bsdthread_register( %#lx, %#lx, %lu )", ARG1, ARG2, ARG3); PRE_REG_READ3(int,"__bsdthread_register", void *,"threadstart", void *,"wqthread", size_t,"pthsize"); +#endif pthread_starter = ARG1; wqthread_starter = ARG2; pthread_structsize = ARG3; + #if DARWIN_VERS >= DARWIN_10_12 + typedef struct { + uint64_t version; + uint64_t dispatch_queue_offset; + uint64_t main_qos; + uint32_t tsd_offset; + uint32_t return_to_kernel_offset; + uint32_t mach_thread_self_offset; + } __attribute__ ((packed)) _pthread_registration_data; + + pthread_tsd_offset = ((_pthread_registration_data*) ARG4)->tsd_offset; + #endif ARG1 = (Word)&pthread_hijack_asm; ARG2 = (Word)&wqthread_hijack_asm; } @@ -2203,13 +2225,10 @@ PRE(__mac_syscall) PRE(exit) { ThreadId t; - ThreadState* tst; PRINT("darwin exit( %ld )", SARG1); PRE_REG_READ1(void, "exit", int, status); - tst = VG_(get_ThreadState)(tid); - /* A little complex; find all the threads with the same threadgroup as this one (including this one), and mark them to exit */ for (t = 1; t < VG_N_THREADS; t++) { @@ -3079,38 +3098,38 @@ static void scan_attrlist(ThreadId tid, struct vki_attrlist *attrList, #if DARWIN_VERS >= DARWIN_10_6 { ATTR_CMN_RETURNED_ATTRS, sizeof(attribute_set_t) }, #endif - { ATTR_CMN_NAME, -1 }, - { ATTR_CMN_DEVID, sizeof(dev_t) }, - { ATTR_CMN_FSID, sizeof(fsid_t) }, - { ATTR_CMN_OBJTYPE, sizeof(fsobj_type_t) }, - { ATTR_CMN_OBJTAG, sizeof(fsobj_tag_t) }, - { ATTR_CMN_OBJID, sizeof(fsobj_id_t) }, - { ATTR_CMN_OBJPERMANENTID, sizeof(fsobj_id_t) }, - { ATTR_CMN_PAROBJID, sizeof(fsobj_id_t) }, - { ATTR_CMN_SCRIPT, sizeof(text_encoding_t) }, - { ATTR_CMN_CRTIME, sizeof(struct timespec) }, - { ATTR_CMN_MODTIME, sizeof(struct timespec) }, - { ATTR_CMN_CHGTIME, sizeof(struct timespec) }, - { ATTR_CMN_ACCTIME, sizeof(struct timespec) }, - { ATTR_CMN_BKUPTIME, sizeof(struct timespec) }, - { ATTR_CMN_FNDRINFO, 32 /*FileInfo+ExtendedFileInfo, or FolderInfo+ExtendedFolderInfo*/ }, - { ATTR_CMN_OWNERID, sizeof(uid_t) }, - { ATTR_CMN_GRPID, sizeof(gid_t) }, - { ATTR_CMN_ACCESSMASK, sizeof(uint32_t) }, - { ATTR_CMN_NAMEDATTRCOUNT, sizeof(uint32_t) }, - { ATTR_CMN_NAMEDATTRLIST, -1 }, - { ATTR_CMN_FLAGS, sizeof(uint32_t) }, - { ATTR_CMN_USERACCESS, sizeof(uint32_t) }, - { ATTR_CMN_EXTENDED_SECURITY, -1 }, - { ATTR_CMN_UUID, sizeof(guid_t) }, - { ATTR_CMN_GRPUUID, sizeof(guid_t) }, - { ATTR_CMN_FILEID, sizeof(uint64_t) }, - { ATTR_CMN_PARENTID, sizeof(uint64_t) }, + { ATTR_CMN_NAME, -1 }, + { ATTR_CMN_DEVID, sizeof(dev_t) }, + { ATTR_CMN_FSID, sizeof(fsid_t) }, + { ATTR_CMN_OBJTYPE, sizeof(fsobj_type_t) }, + { ATTR_CMN_OBJTAG, sizeof(fsobj_tag_t) }, + { ATTR_CMN_OBJID, sizeof(fsobj_id_t) }, + { ATTR_CMN_OBJPERMANENTID, sizeof(fsobj_id_t) }, + { ATTR_CMN_PAROBJID, sizeof(fsobj_id_t) }, + { ATTR_CMN_SCRIPT, sizeof(text_encoding_t) }, + { ATTR_CMN_CRTIME, sizeof(struct timespec) }, + { ATTR_CMN_MODTIME, sizeof(struct timespec) }, + { ATTR_CMN_CHGTIME, sizeof(struct timespec) }, + { ATTR_CMN_ACCTIME, sizeof(struct timespec) }, + { ATTR_CMN_BKUPTIME, sizeof(struct timespec) }, + { ATTR_CMN_FNDRINFO, 32 /*FileInfo+ExtendedFileInfo, or FolderInfo+ExtendedFolderInfo*/ }, + { ATTR_CMN_OWNERID, sizeof(uid_t) }, + { ATTR_CMN_GRPID, sizeof(gid_t) }, + { ATTR_CMN_ACCESSMASK, sizeof(uint32_t) }, + { ATTR_CMN_NAMEDATTRCOUNT, sizeof(uint32_t) }, + { ATTR_CMN_NAMEDATTRLIST, -1 }, + { ATTR_CMN_FLAGS, sizeof(uint32_t) }, + { ATTR_CMN_USERACCESS, sizeof(uint32_t) }, + { ATTR_CMN_EXTENDED_SECURITY, -1 }, + { ATTR_CMN_UUID, sizeof(guid_t) }, + { ATTR_CMN_GRPUUID, sizeof(guid_t) }, + { ATTR_CMN_FILEID, sizeof(uint64_t) }, + { ATTR_CMN_PARENTID, sizeof(uint64_t) }, #if DARWIN_VERS >= DARWIN_10_6 { ATTR_CMN_FULLPATH, -1 }, #endif #if DARWIN_VERS >= DARWIN_10_8 - { ATTR_CMN_ADDEDTIME, -1 }, + { ATTR_CMN_ADDEDTIME, -1 }, #endif { 0, 0 } }; @@ -3138,14 +3157,14 @@ static void scan_attrlist(ThreadId tid, struct vki_attrlist *attrList, #if DARWIN_VERS >= DARWIN_10_6 { ATTR_VOL_UUID, sizeof(uuid_t) }, #endif - { ATTR_VOL_ATTRIBUTES, sizeof(vol_attributes_attr_t) }, + { ATTR_VOL_ATTRIBUTES, sizeof(vol_attributes_attr_t) }, { 0, 0 } }; static const attrspec dirattr[] = { // This order is important. - { ATTR_DIR_LINKCOUNT, sizeof(uint32_t) }, - { ATTR_DIR_ENTRYCOUNT, sizeof(uint32_t) }, - { ATTR_DIR_MOUNTSTATUS, sizeof(uint32_t) }, + { ATTR_DIR_LINKCOUNT, sizeof(uint32_t) }, + { ATTR_DIR_ENTRYCOUNT, sizeof(uint32_t) }, + { ATTR_DIR_MOUNTSTATUS, sizeof(uint32_t) }, { 0, 0 } }; static const attrspec fileattr[] = { @@ -3169,8 +3188,8 @@ static void scan_attrlist(ThreadId tid, struct vki_attrlist *attrList, }; static const attrspec forkattr[] = { // This order is important. - { ATTR_FORK_TOTALSIZE, sizeof(off_t) }, - { ATTR_FORK_ALLOCSIZE, sizeof(off_t) }, + { ATTR_FORK_TOTALSIZE, sizeof(off_t) }, + { ATTR_FORK_ALLOCSIZE, sizeof(off_t) }, { 0, 0 } }; @@ -8416,10 +8435,10 @@ PRE(mach_msg) // mach_port_t rcv_name = (mach_port_t)ARG5; size_t complex_header_size = 0; - PRE_REG_READ7(long, "mach_msg", - mach_msg_header_t*,"msg", mach_msg_option_t,"option", - mach_msg_size_t,"send_size", mach_msg_size_t,"rcv_size", - mach_port_t,"rcv_name", mach_msg_timeout_t,"timeout", + PRE_REG_READ7(long, "mach_msg", + mach_msg_header_t*,"msg", mach_msg_option_t,"option", + mach_msg_size_t,"send_size", mach_msg_size_t,"rcv_size", + mach_port_t,"rcv_name", mach_msg_timeout_t,"timeout", mach_port_t,"notify"); // Assume default POST handler until specified otherwise @@ -9316,6 +9335,31 @@ POST(audit_session_self) PRINT("audit-session %#lx", RES); } +PRE(fgetattrlist) +{ + PRINT("fgetattrlist(%ld, %#lx, %#lx, %lu, %lu)", + ARG1, ARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "fgetattrlist", + int,fd, struct vki_attrlist *,attrList, + void *,attrBuf, vki_size_t,attrBufSize, unsigned int,options); + PRE_MEM_READ("fgetattrlist(attrList)", ARG2, sizeof(struct vki_attrlist)); + PRE_MEM_WRITE("fgetattrlist(attrBuf)", ARG3, ARG4); +} +POST(fgetattrlist) +{ + if (ARG4 > sizeof(vki_uint32_t)) { + // attrBuf is uint32_t size followed by attr data + vki_uint32_t *sizep = (vki_uint32_t *)ARG3; + POST_MEM_WRITE(ARG3, sizeof(vki_uint32_t)); + if (ARG5 & FSOPT_REPORT_FULLSIZE) { + // *sizep is bytes required for return value, including *sizep + } else { + // *sizep is actual bytes returned, including *sizep + } + scan_attrlist(tid, (struct vki_attrlist *)ARG2, sizep+1, MIN(*sizep, ARG4), &get1attr); + } +} + #endif /* DARWIN_VERS >= DARWIN_10_6 */ @@ -9589,6 +9633,37 @@ POST(process_policy) // munge_??? } +PRE(csops_audittoken) +{ + PRINT("csops_audittoken(%ld, %#lx, %#lx, %lu, %#lx)", SARG1, ARG2, ARG3, ARG4, ARG5); + PRE_REG_READ5(int, "csops_audittoken", + vki_pid_t, pid, uint32_t, ops, + void *, useraddr, vki_size_t, usersize, void *, uaudittoken); + + if (ARG5 == 0) { + SET_STATUS_Failure( VKI_EINVAL ); + return; + } + + PRE_MEM_WRITE( "csops_audittoken(useraddr)", ARG3, ARG4 ); + + // If the pid is ours, don't mark the program as KILL or HARD + // Maybe we should keep track of this for later calls to STATUS + if (!ARG1 || VG_(getpid)() == ARG1) { + switch (ARG2) { + case VKI_CS_OPS_MARKINVALID: + case VKI_CS_OPS_MARKHARD: + case VKI_CS_OPS_MARKKILL: + SET_STATUS_Success(0); + } + } +} + +POST(csops_audittoken) +{ + POST_MEM_WRITE( ARG3, ARG4 ); +} + #endif /* DARWIN_VERS >= DARWIN_10_8 */ @@ -9771,18 +9846,35 @@ POST(getattrlistbulk) PRE(faccessat) { - PRINT("faccessat(FIXME)(fd:%ld, path:%#lx(%s), amode:%#lx, flag:%#lx)", - ARG1, ARG2, (HChar*)ARG2, ARG3, ARG4); + uint32_t fd = ARG1; + PRINT("faccessat(fd:%d, path:%#lx(%s), amode:%#lx, flag:%#lx)", + fd, ARG2, ARG2 ? (HChar*)ARG2 : "null", ARG3, ARG4); PRE_REG_READ4(int, "faccessat", int, fd, user_addr_t, path, int, amode, int, flag); + + if (fd != VKI_AT_FDCWD && !ML_(fd_allowed)(fd, "faccessat", tid, False)) { + SET_STATUS_Failure( VKI_EBADF ); + } + PRE_MEM_RASCIIZ( "faccessat(path)", ARG2 ); } PRE(fstatat64) { - PRINT("fstatat64(FIXME)(fd:%ld, path:%#lx(%s), ub:%#lx, flag:%#lx)", - ARG1, ARG2, (HChar*)ARG2, ARG3, ARG4); + uint32_t fd = ARG1; + PRINT("fstatat64(fd:%d, path:%#lx(%s), ub:%#lx, flag:%#lx)", + fd, ARG2, ARG2 ? (HChar*)ARG2 : "null", ARG3, ARG4); PRE_REG_READ4(int, "fstatat64", int, fd, user_addr_t, path, user_addr_t, ub, int, flag); + + if (fd != VKI_AT_FDCWD && !ML_(fd_allowed)(fd, "fstatat64", tid, False)) { + SET_STATUS_Failure( VKI_EBADF ); + } + PRE_MEM_RASCIIZ( "fstatat64(path)", ARG2 ); + PRE_MEM_WRITE( "fstatat64(ub)", ARG3, sizeof(struct vki_stat64) ); +} +POST(fstatat64) +{ + POST_MEM_WRITE( ARG3, sizeof(struct vki_stat64) ); } PRE(readlinkat) @@ -10003,9 +10095,15 @@ PRE(pselect) PRE(getentropy) { - PRINT("getentropy(buffer:%#lx, size:%ld) FIXME", ARG1, ARG2); + PRINT("getentropy(buffer:%#lx, size:%ld)", ARG1, ARG2); PRE_REG_READ2(int, "getentropy", void*, buffer, size_t, size); + PRE_MEM_WRITE( "getentropy(buffer)", ARG1, ARG2 ); +} +POST(getentropy) +{ + vg_assert(SUCCESS); + POST_MEM_WRITE( ARG1, ARG2 ); } static const HChar *ulop_name(int op) @@ -10019,10 +10117,29 @@ static const HChar *ulop_name(int op) PRE(ulock_wake) { - PRINT("ulock_wake(operation:%ld, addr:%#lx, wake_value:%ld) FIXME", - ARG1, ARG2, ARG3); + uint ul_opcode = ARG1 & VKI_UL_OPCODE_MASK; + uint ul_flags = ARG1 & VKI_UL_FLAGS_MASK; + switch (ul_opcode) { + case VKI_UL_UNFAIR_LOCK: + case VKI_UL_COMPARE_AND_WAIT: { + const char* name = ulop_name(ul_opcode); + if (ul_flags & VKI_ULF_WAKE_THREAD) { + PRINT("ulock_wake(operation:%s (flags: %#x), addr:%#lx, wake_value:%s)", + name, ul_flags, ARG2, name_for_port(ARG3)); + } else { + PRINT("ulock_wake(operation:%s (flags: %#x), addr:%#lx, wake_value:%ld /*unused*/)", + name, ul_flags, ARG2, ARG3); + } PRE_REG_READ3(int, "ulock_wake", uint32_t, operation, void*, addr, uint64_t, wake_value); + break; +} + + default: + PRINT("ulock_wake(operation:%ld (opcode: %u [??], flags: %#x), addr:%#lx, wake_value:%ld)", ARG1, ul_opcode, ul_flags, ARG2, ARG3); + log_decaying("UNKNOWN ulock_wake %ld (opcode: %u [??], flags: %#x)!", ARG1, ul_opcode, ul_flags); + break; + } } PRE(ulock_wait) @@ -10047,14 +10164,47 @@ PRE(ulock_wait) log_decaying("UNKNOWN ulock_wait %ld (opcode: %u [??], flags: %#x)!", ARG1, ul_opcode, ul_flags); break; } + + *flags |= SfMayBlock; +} + +PRE(terminate_with_payload) +{ + PRINT("terminate_with_payload" + "(pid: %ld, reason_namespace:%ld, reason_code:%ld, payload:%#lx, payload_size:%ld, reason_string:%s, reason_flags:%#x)", + ARG1, ARG2, ARG3, ARG4, ARG5, (char*)ARG6, (uint)ARG7); + PRE_REG_READ7(int, "terminate_with_payload", int, pid, + uint32_t, reason_namespace, uint64_t, reason_code, void*, payload, + uint32_t, payload_size, const char*, reason_string, uint64_t, reason_flags); + PRE_MEM_READ("abort_with_payload(payload)", ARG4, ARG5); + PRE_MEM_RASCIIZ("abort_with_payload(reason_string)", ARG6); +} + +PRE(abort_with_payload) +{ + PRINT("abort_with_payload" + "(reason_namespace:%ld, reason_code:%ld, payload:%#lx, payload_size:%ld, reason_string:%s, reason_flags:%#x)", + ARG1, ARG2, ARG3, ARG4, (char*)ARG5, (uint)ARG6); + PRE_REG_READ6(uint32_t, "abort_with_payload", + uint32_t, reason_namespace, uint64_t, reason_code, void*, payload, + uint32_t, payload_size, const char*, reason_string, uint64_t, reason_flags); + PRE_MEM_READ("abort_with_payload(payload)", ARG3, ARG4); + PRE_MEM_RASCIIZ("abort_with_payload(reason_string)", ARG5); } PRE(host_create_mach_voucher_trap) { // munge_wwww -- no need to call helper PRINT("host_create_mach_voucher_trap" - "(host:%#lx, recipes:%#lx, recipes_size:%ld, voucher:%#lx) FIXME", - ARG1, ARG2, ARG3, ARG4); + "(host:%s, recipes:%#lx, recipes_size:%ld, voucher:%#lx)", + name_for_port(ARG1), ARG2, ARG3, ARG4); + PRE_MEM_READ( "host_create_mach_voucher_trap(recipes)", ARG2, ARG3 ); + PRE_MEM_WRITE( "host_create_mach_voucher_trap(voucher)", ARG4, sizeof(mach_port_name_t) ); +} +POST(host_create_mach_voucher_trap) +{ + vg_assert(SUCCESS); + POST_MEM_WRITE( ARG4, sizeof(mach_port_name_t) ); } PRE(task_register_dyld_image_infos) @@ -10207,6 +10357,49 @@ POST(openat_nocancel) } } +PRE(kevent_id) +{ + PRINT("kevent_id(id:%ld, changelist:%#lx, nchanges:%ld, eventlist:%#lx, nevents:%ld, data_out:%#lx, data_available:%ld, flags:%lx)", + ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7, ARG8); + PRE_REG_READ8(int,"kevent_id", + uint64_t,id, + const struct vki_kevent_qos_s *,changelist, + int,nchanges, + struct vki_kevent_qos_s *,eventlist, + int,nevents, + void*,data_out, + size_t*,data_available, + unsigned int,flags); + + if (ARG3) PRE_MEM_READ ("kevent_id(changelist)", + ARG2, ARG3 * sizeof(struct vki_kevent_qos_s)); + if (ARG5) PRE_MEM_WRITE("kevent_id(eventlist)", + ARG4, ARG5 * sizeof(struct vki_kevent_qos_s)); + if (ARG7) PRE_MEM_WRITE ("kevent_id(data_out)", + ARG6, ARG7 * sizeof(void*)); + + *flags |= SfMayBlock; +} + +POST(kevent_id) +{ + PRINT("kevent_id ret %ld dst %#lx (%zu)", RES, ARG4, sizeof(struct vki_kevent_qos_s)); + if (RES > 0) { + POST_MEM_WRITE(ARG4, RES * sizeof(struct vki_kevent_qos_s)); + } +} + +PRE(thread_get_special_reply_port) +{ + PRINT("thread_get_special_reply_port()"); +} + +POST(thread_get_special_reply_port) +{ + record_named_port(tid, RES, MACH_PORT_RIGHT_RECEIVE, "special-reply-%p"); + PRINT("special reply port %s", name_for_port(RES)); +} + #endif /* DARWIN_VERS >= DARWIN_10_13 */ /* --------------------------------------------------------------------- @@ -10407,7 +10600,11 @@ const SyscallTableEntry ML_(syscall_table)[] = { MACX_(__NR_mount, mount), _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(168)), // old ustat MACXY(__NR_csops, csops), // code-signing ops +#if DARWIN_VERS >= DARWIN_10_8 + MACXY(__NR_csops_audittoken, csops_audittoken), // 170 +#else _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(170)), // old table +#endif _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(171)), // old wait3 _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(172)), // old rpause // _____(__NR_waitid), @@ -10475,8 +10672,8 @@ const SyscallTableEntry ML_(syscall_table)[] = { GENX_(__NR_delete, sys_unlink), // _____(__NR_copyfile), #if DARWIN_VERS >= DARWIN_10_6 -// _____(__NR_fgetattrlist), -// _____(__NR_fsetattrlist), + MACX_(__NR_fgetattrlist, fgetattrlist), // 228 +// _____(__NR_fsetattrlist), #else _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(228)), // ?? _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(229)), // ?? @@ -10545,15 +10742,15 @@ const SyscallTableEntry ML_(syscall_table)[] = { #if DARWIN_VERS >= DARWIN_10_8 MACX_(__NR_gettid, gettid), // 286 #endif -// _____(__NR_setsgroups), -// _____(__NR_getsgroups), -// _____(__NR_setwgroups), -// _____(__NR_getwgroups), -// _____(__NR_mkfifo_extended), -// _____(__NR_mkdir_extended), -// _____(__NR_identitysvc), -// _____(__NR_shared_region_check_np), -// _____(__NR_shared_region_map_np), +// _____(__NR_setsgroups), +// _____(__NR_getsgroups), +// _____(__NR_setwgroups), +// _____(__NR_getwgroups), +// _____(__NR_mkfifo_extended), +// _____(__NR_mkdir_extended), +// _____(__NR_identitysvc), +// _____(__NR_shared_region_check_np), +// _____(__NR_shared_region_map_np), #if DARWIN_VERS >= DARWIN_10_6 // _____(__NR_vm_pressure_monitor), // _____(__NR_psynch_rw_longrdlock), @@ -10592,13 +10789,13 @@ const SyscallTableEntry ML_(syscall_table)[] = { #else _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(308)), // old __pthread_cond_timedwait #endif -// _____(__NR_aio_fsync), +// _____(__NR_aio_fsync), MACX_(__NR_aio_return, aio_return), - MACX_(__NR_aio_suspend, aio_suspend), -// _____(__NR_aio_cancel), - MACX_(__NR_aio_error, aio_error), - MACXY(__NR_aio_read, aio_read), - MACX_(__NR_aio_write, aio_write), + MACX_(__NR_aio_suspend, aio_suspend), +// _____(__NR_aio_cancel), + MACX_(__NR_aio_error, aio_error), + MACXY(__NR_aio_read, aio_read), + MACX_(__NR_aio_write, aio_write), // _____(__NR_lio_listio), // 320 _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(321)), // ??? @@ -10614,10 +10811,10 @@ const SyscallTableEntry ML_(syscall_table)[] = { _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(326)), // ??? MACX_(__NR_issetugid, issetugid), MACX_(__NR___pthread_kill, __pthread_kill), - MACX_(__NR___pthread_sigmask, __pthread_sigmask), + MACX_(__NR___pthread_sigmask, __pthread_sigmask), MACXY(__NR___sigwait, __sigwait), // 330 - MACX_(__NR___disable_threadsignal, __disable_threadsignal), - MACX_(__NR___pthread_markcancel, __pthread_markcancel), + MACX_(__NR___disable_threadsignal, __disable_threadsignal), + MACX_(__NR___pthread_markcancel, __pthread_markcancel), MACX_(__NR___pthread_canceled, __pthread_canceled), MACX_(__NR___semwait_signal, __semwait_signal), _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(335)), // old utrace @@ -10670,7 +10867,9 @@ const SyscallTableEntry ML_(syscall_table)[] = { #if DARWIN_VERS < DARWIN_10_11 _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(374)), // ??? #endif +#if DARWIN_VERS < DARWIN_10_13 _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(375)), // ??? +#endif _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(376)), // ??? _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(377)), // ??? _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(378)), // ??? @@ -10756,10 +10955,10 @@ const SyscallTableEntry ML_(syscall_table)[] = { MACXY(__NR_openat_nocancel, openat_nocancel), // 464 #endif MACX_(__NR_faccessat, faccessat), // 466 - MACX_(__NR_fstatat64, fstatat64), // 470 + MACXY(__NR_fstatat64, fstatat64), // 470 MACX_(__NR_readlinkat, readlinkat), // 473 MACX_(__NR_bsdthread_ctl, bsdthread_ctl), // 478 - MACX_(__NR_csrctl, csrctl), // 483 + MACXY(__NR_csrctl, csrctl), // 483 MACX_(__NR_guarded_open_dprotected_np, guarded_open_dprotected_np), // 484 MACX_(__NR_guarded_write_np, guarded_write_np), // 485 MACX_(__NR_guarded_pwrite_np, guarded_pwrite_np), // 486 @@ -10785,7 +10984,7 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_kdebug_typefilter), // 177 // _____(__NR_clonefileat), // 462 // _____(__NR_renameatx_np), // 488 - MACX_(__NR_getentropy, getentropy), // 500 + MACXY(__NR_getentropy, getentropy), // 500 // _____(__NR_necp_open), // 501 // _____(__NR_necp_client_action), // 502 _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(503)), // ??? @@ -10805,12 +11004,12 @@ const SyscallTableEntry ML_(syscall_table)[] = { // _____(__NR_fclonefileat), // 517 // _____(__NR_fs_snapshot), // 518 _____(VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(519)), // ??? -// _____(__NR_terminate_with_payload), // 520 -// _____(__NR_abort_with_payload), // 521 + MACX_(__NR_terminate_with_payload, terminate_with_payload), // 520 + MACX_(__NR_abort_with_payload, abort_with_payload), // 521 #endif #if DARWIN_VERS >= DARWIN_10_13 // _____(__NR_thread_selfcounts), // 186 -// _____(__NR_kevent_id, // 375 + MACXY(__NR_kevent_id, kevent_id), // 375 // _____(__NR_necp_session_open), // 522 // _____(__NR_necp_session_action), // 523 // _____(__NR_setattrlistat), // 524 @@ -10898,20 +11097,20 @@ const SyscallTableEntry ML_(mach_trap_table)[] = { _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(25)), # endif - MACXY(__NR_mach_reply_port, mach_reply_port), - MACXY(__NR_thread_self_trap, mach_thread_self), - MACXY(__NR_task_self_trap, mach_task_self), - MACXY(__NR_host_self_trap, mach_host_self), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(30)), - MACXY(__NR_mach_msg_trap, mach_msg), -// _____(__NR_mach_msg_overwrite_trap), - MACX_(__NR_semaphore_signal_trap, semaphore_signal), - MACX_(__NR_semaphore_signal_all_trap, semaphore_signal_all), - MACX_(__NR_semaphore_signal_thread_trap, semaphore_signal_thread), - MACX_(__NR_semaphore_wait_trap, semaphore_wait), - MACX_(__NR_semaphore_wait_signal_trap, semaphore_wait_signal), - MACX_(__NR_semaphore_timedwait_trap, semaphore_timedwait), - MACX_(__NR_semaphore_timedwait_signal_trap, semaphore_timedwait_signal), + MACXY(__NR_mach_reply_port, mach_reply_port), + MACXY(__NR_thread_self_trap, mach_thread_self), + MACXY(__NR_task_self_trap, mach_task_self), + MACXY(__NR_host_self_trap, mach_host_self), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(30)), + MACXY(__NR_mach_msg_trap, mach_msg), +// _____(__NR_mach_msg_overwrite_trap), + MACX_(__NR_semaphore_signal_trap, semaphore_signal), + MACX_(__NR_semaphore_signal_all_trap, semaphore_signal_all), + MACX_(__NR_semaphore_signal_thread_trap, semaphore_signal_thread), + MACX_(__NR_semaphore_wait_trap, semaphore_wait), + MACX_(__NR_semaphore_wait_signal_trap, semaphore_wait_signal), + MACX_(__NR_semaphore_timedwait_trap, semaphore_timedwait), + MACX_(__NR_semaphore_timedwait_signal_trap, semaphore_timedwait_signal), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(40)), // -40 # if DARWIN_VERS >= DARWIN_10_9 @@ -10932,19 +11131,19 @@ const SyscallTableEntry ML_(mach_trap_table)[] = { _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(43)), # endif -// _____(__NR_task_name_for_pid), - MACXY(__NR_task_for_pid, task_for_pid), - MACXY(__NR_pid_for_task, pid_for_task), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(47)), +// _____(__NR_task_name_for_pid), + MACXY(__NR_task_for_pid, task_for_pid), + MACXY(__NR_pid_for_task, pid_for_task), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(47)), #if defined(VGA_x86) -// _____(__NR_macx_swapon), -// _____(__NR_macx_swapoff), +// _____(__NR_macx_swapon), +// _____(__NR_macx_swapoff), #else _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(48)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(49)), #endif #if DARWIN_VERS >= DARWIN_10_13 -// _____(__NR_thread_get_special_reply_port, // 50 + MACXY(__NR_thread_get_special_reply_port, thread_get_special_reply_port), #else _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(50)), #endif /* DARWIN_VERS >= DARWIN_10_13 */ @@ -10974,19 +11173,19 @@ const SyscallTableEntry ML_(mach_trap_table)[] = { _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(68)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(69)), #if DARWIN_VERS >= DARWIN_10_12 - MACX_(__NR_host_create_mach_voucher_trap, host_create_mach_voucher_trap), -#else - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(70)), + MACXY(__NR_host_create_mach_voucher_trap, host_create_mach_voucher_trap), +#else + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(70)), #endif - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(71)), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(72)), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(73)), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(74)), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(75)), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(76)), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(77)), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(78)), - _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(79)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(71)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(72)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(73)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(74)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(75)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(76)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(77)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(78)), + _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(79)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(80)), // -80 _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(81)), _____(VG_DARWIN_SYSCALL_CONSTRUCT_MACH(82)), diff --git a/include/vki/vki-darwin.h b/include/vki/vki-darwin.h index 392558fc89..4be0f5f979 100644 --- a/include/vki/vki-darwin.h +++ b/include/vki/vki-darwin.h @@ -1146,6 +1146,10 @@ struct vki_necp_aggregate_result { // ulock_wake & ulock_wait flags #define ULF_NO_ERRNO 0x01000000 +// ulock_wake flags +#define VKI_ULF_WAKE_ALL 0x00000100 +#define VKI_ULF_WAKE_THREAD 0x00000200 + // ulock_wait flags #define WKI_ULF_WAIT_WORKQ_DATA_CONTENTION 0x00010000 #endif /* DARWIN_VERS >= DARWIN_10_12 */ diff --git a/include/vki/vki-scnums-darwin.h b/include/vki/vki-scnums-darwin.h index 3aa35d1fc6..2abc8aea8b 100644 --- a/include/vki/vki-scnums-darwin.h +++ b/include/vki/vki-scnums-darwin.h @@ -395,7 +395,11 @@ #define __NR_mount VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(167) /* 168 old ustat */ #define __NR_csops VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(169) +#if DARWIN_VERS >= DARWIN_10_8 +#define __NR_csops_audittoken VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(170) +#else /* 170 old table */ +#endif /* 171 old wait3 */ /* 172 old rpause */ #define __NR_waitid VG_DARWIN_SYSCALL_CONSTRUCT_UNIX(173) |
From: Paul F. <pa...@so...> - 2024-03-27 12:41:23
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=57399bbf5f1d069130a93c5433c022a0a08b0132 commit 57399bbf5f1d069130a93c5433c022a0a08b0132 Author: Paul Floyd <pj...@wa...> Date: Wed Mar 27 13:38:21 2024 +0100 regtest: filter line numbers from memcheck tests that count suppressions Now only one suppression file needed per test - no need for 32bit versions. Need to use the same tag for each suppression variant though. Diff: --- memcheck/tests/Makefile.am | 4 ---- memcheck/tests/filter_used_supp | 9 +++++++- .../tests/new_delete_mismatch_size_supp.stderr.exp | 8 ++++---- .../new_delete_mismatch_size_supp.stderr.exp_32 | 4 ---- memcheck/tests/posix_memalign_supp.stderr.exp | 4 ++-- ..._aligned_new_delete_misaligned1_supp.stderr.exp | 24 +++++++++++----------- ...igned_new_delete_misaligned1_supp.stderr.exp_32 | 12 ----------- .../sized_aligned_new_delete_misaligned1_supp.supp | 12 +++++------ ..._aligned_new_delete_misaligned2_supp.stderr.exp | 2 +- ...igned_new_delete_misaligned2_supp.stderr.exp_32 | 1 - ..._aligned_new_delete_misaligned3_supp.stderr.exp | 2 +- ...igned_new_delete_misaligned3_supp.stderr.exp_32 | 1 - 12 files changed, 34 insertions(+), 49 deletions(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 20abbcfe1b..e08c124f78 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -167,22 +167,18 @@ EXTRA_DIST = \ sized_aligned_new_delete_misaligned1_supp.vgtest \ sized_aligned_new_delete_misaligned1_supp.supp \ sized_aligned_new_delete_misaligned1_supp.stderr.exp \ - sized_aligned_new_delete_misaligned1_supp.stderr.exp_32 \ sized_aligned_new_delete_misaligned2_supp.vgtest \ sized_aligned_new_delete_misaligned2_supp.supp \ sized_aligned_new_delete_misaligned2_supp.stderr.exp \ - sized_aligned_new_delete_misaligned2_supp.stderr.exp_32 \ sized_aligned_new_delete_misaligned3_supp.vgtest \ sized_aligned_new_delete_misaligned3_supp.supp \ sized_aligned_new_delete_misaligned3_supp.stderr.exp \ - sized_aligned_new_delete_misaligned3_supp.stderr.exp_32 \ new_aligned_delete_default.stderr.exp \ new_aligned_delete_default.stderr.exp_32 \ new_aligned_delete_default.vgtest \ new_delete_mismatch_size.stderr.exp \ new_delete_mismatch_size.vgtest \ new_delete_mismatch_size_supp.stderr.exp \ - new_delete_mismatch_size_supp.stderr.exp_32 \ new_delete_mismatch_size_supp.vgtest \ new_delete_mismatch_size_supp.supp \ deep-backtrace.vgtest deep-backtrace.stderr.exp \ diff --git a/memcheck/tests/filter_used_supp b/memcheck/tests/filter_used_supp index 5403ce723a..98c7e9b301 100755 --- a/memcheck/tests/filter_used_supp +++ b/memcheck/tests/filter_used_supp @@ -1,7 +1,14 @@ #! /bin/sh +# the usual stuff ./filter_stderr "$@" | +# no suppressions from default grep -v default\.supp | -grep used_suppression +# just the list of used suppressions +grep used_suppression | + +# ignore the line numbers, allows having more than one stanza for the +# same kind of suppression (to accommodate Darwin using zones) +sed 's/:[0-9]*$//' diff --git a/memcheck/tests/new_delete_mismatch_size_supp.stderr.exp b/memcheck/tests/new_delete_mismatch_size_supp.stderr.exp index 10d5f49fba..afa49bc6dc 100644 --- a/memcheck/tests/new_delete_mismatch_size_supp.stderr.exp +++ b/memcheck/tests/new_delete_mismatch_size_supp.stderr.exp @@ -1,4 +1,4 @@ -used_suppression: 1 array aligned new sized aligned delete with size mismatch new_delete_mismatch_size_supp.supp:45 -used_suppression: 1 scalar aligned new sized aligned delete with size mismatch new_delete_mismatch_size_supp.supp:31 -used_suppression: 1 array new sized delete with size mismatch new_delete_mismatch_size_supp.supp:17 -used_suppression: 1 scalar new sized delete with size mismatch new_delete_mismatch_size_supp.supp:3 +used_suppression: 1 array aligned new sized aligned delete with size mismatch new_delete_mismatch_size_supp.supp +used_suppression: 1 scalar aligned new sized aligned delete with size mismatch new_delete_mismatch_size_supp.supp +used_suppression: 1 array new sized delete with size mismatch new_delete_mismatch_size_supp.supp +used_suppression: 1 scalar new sized delete with size mismatch new_delete_mismatch_size_supp.supp diff --git a/memcheck/tests/new_delete_mismatch_size_supp.stderr.exp_32 b/memcheck/tests/new_delete_mismatch_size_supp.stderr.exp_32 deleted file mode 100644 index 6b0ff13d16..0000000000 --- a/memcheck/tests/new_delete_mismatch_size_supp.stderr.exp_32 +++ /dev/null @@ -1,4 +0,0 @@ -used_suppression: 1 array aligned new sized aligned delete with size mismatch, 32 bit new_delete_mismatch_size_supp.supp:52 -used_suppression: 1 scalar aligned new sized aligned delete with size mismatch, 32 bit new_delete_mismatch_size_supp.supp:38 -used_suppression: 1 array new sized delete with size mismatch, 32 bit new_delete_mismatch_size_supp.supp:24 -used_suppression: 1 scalar new sized delete with size mismatch, 32 bit new_delete_mismatch_size_supp.supp:10 diff --git a/memcheck/tests/posix_memalign_supp.stderr.exp b/memcheck/tests/posix_memalign_supp.stderr.exp index 080711950c..810eacb44b 100644 --- a/memcheck/tests/posix_memalign_supp.stderr.exp +++ b/memcheck/tests/posix_memalign_supp.stderr.exp @@ -1,2 +1,2 @@ -used_suppression: 9 posix_memalign align ./posix_memalign_supp.supp:10 -used_suppression: 1 posix_memalign size ./posix_memalign_supp.supp:3 +used_suppression: 9 posix_memalign align ./posix_memalign_supp.supp +used_suppression: 1 posix_memalign size ./posix_memalign_supp.supp diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.stderr.exp b/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.stderr.exp index a9c23a8294..eae870ef69 100644 --- a/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.stderr.exp +++ b/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.stderr.exp @@ -1,12 +1,12 @@ -used_suppression: 1 array delete sized aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp:114 -used_suppression: 1 array delete aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp:86 -used_suppression: 1 scalar delete sized aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp:100 -used_suppression: 1 scalar delete sized aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp:72 -used_suppression: 1 array delete aligned nothrow bad alignment sized_aligned_new_delete_misaligned1_supp.supp:65 -used_suppression: 1 array new aligned nothrow bad alignment sized_aligned_new_delete_misaligned1_supp.supp:51 -used_suppression: 2 scalar delete aligned nothow bad alignment sized_aligned_new_delete_misaligned1_supp.supp:44 -used_suppression: 2 scalar new aligned nothrow bad alignment sized_aligned_new_delete_misaligned1_supp.supp:2 -used_suppression: 1 array delete aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp:37 -used_suppression: 1 array delete aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp:30 -used_suppression: 1 scalar delete aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp:23 -used_suppression: 1 scalar delete aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp:16 +used_suppression: 1 array delete sized aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 array delete aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 scalar delete sized aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 scalar delete sized aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 array delete aligned nothrow bad alignment sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 array new aligned nothrow bad alignment sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 2 scalar delete aligned nothow bad alignment sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 2 scalar new aligned nothrow bad alignment sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 array delete aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 array delete aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 scalar delete aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp +used_suppression: 1 scalar delete aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.stderr.exp_32 b/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.stderr.exp_32 deleted file mode 100644 index 2b7dec61d8..0000000000 --- a/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.stderr.exp_32 +++ /dev/null @@ -1,12 +0,0 @@ -used_suppression: 1 array delete sized aligned bad alignment, 32bit sized_aligned_new_delete_misaligned1_supp.supp:121 -used_suppression: 1 array delete aligned alignment mismatch, 32 bit sized_aligned_new_delete_misaligned1_supp.supp:93 -used_suppression: 1 scalar delete sized aligned bad alignment, 32 bit sized_aligned_new_delete_misaligned1_supp.supp:107 -used_suppression: 1 scalar delete sized aligned alignment mismatch, 32 bit sized_aligned_new_delete_misaligned1_supp.supp:79 -used_suppression: 1 array delete aligned nothrow bad alignment sized_aligned_new_delete_misaligned1_supp.supp:65 -used_suppression: 1 array new aligned nothrow bad alignment, 32 bit sized_aligned_new_delete_misaligned1_supp.supp:58 -used_suppression: 2 scalar delete aligned nothow bad alignment sized_aligned_new_delete_misaligned1_supp.supp:44 -used_suppression: 2 scalar new aligned nothrow bad alignment, 32 bit sized_aligned_new_delete_misaligned1_supp.supp:9 -used_suppression: 1 array delete aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp:37 -used_suppression: 1 array delete aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp:30 -used_suppression: 1 scalar delete aligned alignment mismatch sized_aligned_new_delete_misaligned1_supp.supp:23 -used_suppression: 1 scalar delete aligned bad alignment sized_aligned_new_delete_misaligned1_supp.supp:16 diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.supp b/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.supp index 8a51a19077..afcb76289c 100644 --- a/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.supp +++ b/memcheck/tests/sized_aligned_new_delete_misaligned1_supp.supp @@ -6,7 +6,7 @@ } { - scalar new aligned nothrow bad alignment, 32 bit + scalar new aligned nothrow bad alignment Memcheck:BadAlign fun:_ZnwjSt11align_val_tRKSt9nothrow_t fun:main @@ -55,7 +55,7 @@ } { - array new aligned nothrow bad alignment, 32 bit + array new aligned nothrow bad alignment Memcheck:BadAlign fun:_ZnajSt11align_val_tRKSt9nothrow_t fun:main @@ -76,7 +76,7 @@ } { - scalar delete sized aligned alignment mismatch, 32 bit + scalar delete sized aligned alignment mismatch Memcheck:AlignMismatch fun:_ZdlPvjSt11align_val_t fun:main @@ -90,7 +90,7 @@ } { - array delete aligned alignment mismatch, 32 bit + array delete aligned alignment mismatch Memcheck:AlignMismatch fun:_ZdaPvjSt11align_val_t fun:main @@ -104,7 +104,7 @@ } { - scalar delete sized aligned bad alignment, 32 bit + scalar delete sized aligned bad alignment Memcheck:BadAlign fun:_ZdlPvjSt11align_val_t fun:main @@ -118,7 +118,7 @@ } { - array delete sized aligned bad alignment, 32bit + array delete sized aligned bad alignment Memcheck:BadAlign fun:_ZdaPvjSt11align_val_t fun:main diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned2_supp.stderr.exp b/memcheck/tests/sized_aligned_new_delete_misaligned2_supp.stderr.exp index c2a9e40d62..1e979cd094 100644 --- a/memcheck/tests/sized_aligned_new_delete_misaligned2_supp.stderr.exp +++ b/memcheck/tests/sized_aligned_new_delete_misaligned2_supp.stderr.exp @@ -1 +1 @@ -used_suppression: 1 scalar new aligned bad alignment sized_aligned_new_delete_misaligned2_supp.supp:107 +used_suppression: 1 scalar new aligned bad alignment sized_aligned_new_delete_misaligned2_supp.supp diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned2_supp.stderr.exp_32 b/memcheck/tests/sized_aligned_new_delete_misaligned2_supp.stderr.exp_32 deleted file mode 100644 index 0325f29fa2..0000000000 --- a/memcheck/tests/sized_aligned_new_delete_misaligned2_supp.stderr.exp_32 +++ /dev/null @@ -1 +0,0 @@ -used_suppression: 1 scalar new aligned bad alignment, 32 bit sized_aligned_new_delete_misaligned2_supp.supp:114 diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned3_supp.stderr.exp b/memcheck/tests/sized_aligned_new_delete_misaligned3_supp.stderr.exp index 1abfc2bfc4..fe6f64810b 100644 --- a/memcheck/tests/sized_aligned_new_delete_misaligned3_supp.stderr.exp +++ b/memcheck/tests/sized_aligned_new_delete_misaligned3_supp.stderr.exp @@ -1 +1 @@ -used_suppression: 1 array new aligned bad alignment sized_aligned_new_delete_misaligned3_supp.supp:121 +used_suppression: 1 array new aligned bad alignment sized_aligned_new_delete_misaligned3_supp.supp diff --git a/memcheck/tests/sized_aligned_new_delete_misaligned3_supp.stderr.exp_32 b/memcheck/tests/sized_aligned_new_delete_misaligned3_supp.stderr.exp_32 deleted file mode 100644 index 397140fc45..0000000000 --- a/memcheck/tests/sized_aligned_new_delete_misaligned3_supp.stderr.exp_32 +++ /dev/null @@ -1 +0,0 @@ -used_suppression: 1 array new aligned bad alignment, 32bit sized_aligned_new_delete_misaligned3_supp.supp:128 |
From: Paul F. <pa...@so...> - 2024-03-27 09:39:19
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=d4b2ee1b670ec8fa742282e1407e78d2ccc8c8a2 commit d4b2ee1b670ec8fa742282e1407e78d2ccc8c8a2 Author: Paul Floyd <pj...@wa...> Date: Wed Mar 27 10:38:28 2024 +0100 Darwin regtest: fix build of memcheck rh2257546_128 and rh2257546_256 No malloc.h Diff: --- memcheck/tests/amd64/rh2257546_128.c | 4 ++++ memcheck/tests/amd64/rh2257546_256.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/memcheck/tests/amd64/rh2257546_128.c b/memcheck/tests/amd64/rh2257546_128.c index a405aa7751..973fcdbfab 100644 --- a/memcheck/tests/amd64/rh2257546_128.c +++ b/memcheck/tests/amd64/rh2257546_128.c @@ -3,7 +3,11 @@ // See https://bugzilla.redhat.com/show_bug.cgi?id=2257546 #include <stdio.h> +#if defined(__APPLE__) +#include <stdlib.h> +#else #include <malloc.h> +#endif int main ( void ) { diff --git a/memcheck/tests/amd64/rh2257546_256.c b/memcheck/tests/amd64/rh2257546_256.c index 235005ca6f..4b522c7e46 100644 --- a/memcheck/tests/amd64/rh2257546_256.c +++ b/memcheck/tests/amd64/rh2257546_256.c @@ -3,7 +3,11 @@ // See https://bugzilla.redhat.com/show_bug.cgi?id=2257546 #include <stdio.h> +#if defined(__APPLE__) +#include <stdlib.h> +#else #include <malloc.h> +#endif int main ( void ) { |
From: Andreas A. <ar...@li...> - 2024-03-26 21:12:28
|
Hi, The patch below shows a possible approach to handling "complex" instructions with a new "extension" module. In this context, "complex" means that the instruction has variable and/or too many side effects and thus cannot be represented with the current dirty helper concept. A particularly complex example is the z/Architecture's NNPA instruction, which is discussed in Bug 450705. But for illustrating the extension concept itself, the patch below handles the much simpler PRNO instruction instead. Comments? -- Andreas ------- 8< ------- >From 8dc08e44654ced0a26c2e10f3581ebe2a58bef30 Mon Sep 17 00:00:00 2001 From: Andreas Arnez <ar...@li...> Date: Thu, 1 Sep 2022 15:04:59 +0200 Subject: [PATCH] Add extension concept and exploit it for s390x `PRNO' z/Architecture specifies various "complex" machine instructions whose register and memory effects cannot be expressed with Valgrind's current mechanisms. One example is the PPNO instruction -- "perform pseudorandom number operation", whose main purpose is to generate a chunk of pseudorandom data. When doing so, it reads and writes a so-called "parameter block" while also writing the variable-sized pseudorandom data itself. These memory effects cannot be adequately represented by the IRDirty concept. Instead of using dirty helpers, a different approach is to treat such instructions similar to syscalls, adding a new IRJumpKind for this purpose. This patch provides an implementation of this approach and an illustration of its use at the example of PPNO (or its newer instantiation "PRNO"). --- VEX/priv/guest_s390_toIR.c | 204 +++--------------- VEX/priv/host_s390_defs.c | 2 + VEX/priv/host_s390_isel.c | 2 + VEX/priv/ir_defs.c | 1 + VEX/pub/libvex_ir.h | 3 +- VEX/pub/libvex_s390x_common.h | 9 + VEX/pub/libvex_trc_values.h | 2 + coregrind/Makefile.am | 4 + coregrind/m_extension/extension-main.c | 54 +++++ coregrind/m_extension/extension-s390x.c | 227 ++++++++++++++++++++ coregrind/m_extension/priv_extension.h | 38 ++++ coregrind/m_extension/priv_types_n_macros.h | 80 +++++++ coregrind/m_scheduler/scheduler.c | 33 +++ coregrind/pub_core_extension.h | 45 ++++ 14 files changed, 525 insertions(+), 179 deletions(-) create mode 100644 coregrind/m_extension/extension-main.c create mode 100644 coregrind/m_extension/extension-s390x.c create mode 100644 coregrind/m_extension/priv_extension.h create mode 100644 coregrind/m_extension/priv_types_n_macros.h create mode 100644 coregrind/pub_core_extension.h diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index 81cce9fb4..e66fabd8b 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -8,7 +8,7 @@ This file is part of Valgrind, a dynamic binary instrumentation framework. - Copyright IBM Corp. 2010-2021 + Copyright IBM Corp. 2010-2024 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -552,6 +552,27 @@ system_call(IRExpr *sysno) dis_res->jk_StopHere = Ijk_Sys_syscall; } +/* An extension */ +static void +extension(ULong id, ULong variant) +{ + vassert(id < (1 << S390_EXT_ID_NBITS)); + vassert(variant <= ~((ULong) 0) >> S390_EXT_ID_NBITS); + + /* Store the extension ID in the pseudo register. */ + ULong ext_id = id | (variant << S390_EXT_ID_NBITS); + stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_SYSNO), mkU64(ext_id))); + + /* Store the current IA into guest_IP_AT_SYSCALL. */ + stmt(IRStmt_Put(S390X_GUEST_OFFSET(guest_IP_AT_SYSCALL), + mkU64(guest_IA_curr_instr))); + + put_IA(mkaddr_expr(guest_IA_next_instr)); + + dis_res->whatNext = Dis_StopHere; + dis_res->jk_StopHere = Ijk_Extension; +} + /* A side exit that branches back to the current insn if CONDITION is true. Does not set DisResult. */ static void @@ -17077,59 +17098,7 @@ s390_irgen_LCBB(UChar r1, IRTemp op2addr, UChar m3) return "lcbb"; } -/* Regarding the use of - // Dummy helper which is used to signal VEX library that memory was loaded - sha512_loadparam - = unsafeIRDirty_0_N(0, "s390x_dirtyhelper_PPNO_sha512_load_param_block", - &s390x_dirtyhelper_PPNO_sha512_load_param_block, - mkIRExprVec_0()); - - in the following function (s390_irgen_PPNO). This is a workaround to get - around the fact that IRDirty annotations cannot indicate two memory side - effects, which are unfortunately necessary here. It will possibly lead to - losing undefinedness (undefinedness in some inputs might not be propagated - to the outputs as it shouod, in Memcheck). The correct fix would be to - extend IRDirty to represent two memory side effects, but that's quite a bit - of work. - - Here's a summary of what this insn does. - - // getReg(RegisterNumber n) returns the value of GPR number 'n' - - // reg1 and reg2 are even - void ppno(RegisterNumber reg1, RegisterNumber reg2) { - - switch(getReg(0)) { - case 0x0: - // Query mode, ignore reg1 and reg2 - // Write 16 bytes at getReg(1) - break; - - case 0x3: - // SHA-512 generate mode, ignore reg2 - - // Read 240 bytes at getReg(1) - // Write getReg(reg1 + 1) bytes at getReg(reg1) - // Write some of 240 bytes starting at getReg(1) - break; - - case 0x83: - // SHA-512 seed mode, ignore reg1 - - // Read some of 240 bytes starting at getReg(1) - // Read getReg(reg2 + 1) bytes at getReg(reg2) - // Write 240 bytes at getReg(1) - break; - - default: - // Specification exception, abort execution. - } - } -*/ -/* Also known as "prno" - If you implement new functions please don't forget to update - "s390x_dirtyhelper_PPNO_query" function. - */ +/* Also known as "PRNO" */ static const HChar * s390_irgen_PPNO(UChar r1, UChar r2) { @@ -17138,131 +17107,10 @@ s390_irgen_PPNO(UChar r1, UChar r2) return "ppno"; } - /* Theese conditions lead to specification exception */ - vassert(r1 % 2 == 0); - vassert(r2 % 2 == 0); - vassert((r1 != 0) && (r2 != 0)); - - IRDirty *query, *sha512_gen, *sha512_seed, *sha512_loadparam; - IRTemp gpr1num = newTemp(Ity_I64); - IRTemp gpr2num = newTemp(Ity_I64); - - IRTemp funcCode = newTemp(Ity_I8); - IRTemp is_query = newTemp(Ity_I1); - IRTemp is_sha512_gen = newTemp(Ity_I1); - IRTemp is_sha512_seed = newTemp(Ity_I1); - IRTemp is_sha512 = newTemp(Ity_I1); - - assign(funcCode, unop(Iop_64to8, binop(Iop_And64, get_gpr_dw0(0), - mkU64(0xffULL)))); - assign(gpr1num, mkU64(r1)); - assign(gpr2num, mkU64(r2)); - - assign(is_query, binop(Iop_CmpEQ8, mkexpr(funcCode), mkU8(S390_PPNO_QUERY))); - assign(is_sha512_gen, binop(Iop_CmpEQ8, mkexpr(funcCode), - mkU8(S390_PPNO_SHA512_GEN))); - assign(is_sha512_seed, binop(Iop_CmpEQ8, mkexpr(funcCode), - mkU8(S390_PPNO_SHA512_SEED))); - assign(is_sha512, binop(Iop_CmpEQ8, - mkU8(S390_PPNO_SHA512_GEN), - binop(Iop_And8, - mkexpr(funcCode), - mkU8(S390_PPNO_SHA512_GEN) - ) - )); - - query = unsafeIRDirty_0_N(0, "s390x_dirtyhelper_PPNO_query", - &s390x_dirtyhelper_PPNO_query, - mkIRExprVec_3(IRExpr_GSPTR(), mkexpr(gpr1num), - mkexpr(gpr2num))); - query->guard = mkexpr(is_query); - query->nFxState = 1; - vex_bzero(&query->fxState, sizeof(query->fxState)); - query->fxState[0].fx = Ifx_Read; - query->fxState[0].offset = S390X_GUEST_OFFSET(guest_r0); - query->fxState[0].size = 2 * sizeof(ULong); /* gpr0 and gpr1 are read */ - query->mAddr = get_gpr_dw0(1); - query->mSize = S390_PPNO_PARAM_BLOCK_SIZE_QUERY; - query->mFx = Ifx_Write; - - IRTemp gen_cc = newTemp(Ity_I64); - sha512_gen = unsafeIRDirty_1_N(gen_cc, 0, "s390x_dirtyhelper_PPNO_sha512", - &s390x_dirtyhelper_PPNO_sha512, - mkIRExprVec_3(IRExpr_GSPTR(), mkexpr(gpr1num), - mkexpr(gpr2num))); - sha512_gen->guard = mkexpr(is_sha512_gen); - sha512_gen->nFxState = 3; - vex_bzero(&sha512_gen->fxState, sizeof(sha512_gen->fxState)); - sha512_gen->fxState[0].fx = Ifx_Read; - sha512_gen->fxState[0].offset = S390X_GUEST_OFFSET(guest_r0); - sha512_gen->fxState[0].size = 2 * sizeof(ULong); /* gpr0 and gpr1 are read */ - sha512_gen->fxState[1].fx = Ifx_Read; - sha512_gen->fxState[1].offset = S390X_GUEST_OFFSET(guest_r0) + r1 * sizeof(ULong); - sha512_gen->fxState[1].size = sizeof(ULong); - sha512_gen->fxState[2].fx = Ifx_Modify; - sha512_gen->fxState[2].offset = S390X_GUEST_OFFSET(guest_r0) + (r1 + 1) * sizeof(ULong); - sha512_gen->fxState[2].size = sizeof(ULong); - sha512_gen->mAddr = get_gpr_dw0(r1); - sha512_gen->mSize = S390_PPNO_MAX_SIZE_SHA512_GEN; - sha512_gen->mFx = Ifx_Write; - - IRTemp unused = newTemp(Ity_I64); - sha512_seed = unsafeIRDirty_1_N(unused, 0, "s390x_dirtyhelper_PPNO_sha512", - &s390x_dirtyhelper_PPNO_sha512, - mkIRExprVec_3(IRExpr_GSPTR(), mkexpr(gpr1num), - mkexpr(gpr2num))); - sha512_seed->guard = mkexpr(is_sha512_seed); - sha512_seed->nFxState = 2; - vex_bzero(&sha512_seed->fxState, sizeof(sha512_seed->fxState)); - sha512_seed->fxState[0].fx = Ifx_Read; - sha512_seed->fxState[0].offset = S390X_GUEST_OFFSET(guest_r0); - sha512_seed->fxState[0].size = 2 * sizeof(ULong); /* gpr0 and gpr1 are read */ - sha512_seed->fxState[1].fx = Ifx_Read; - sha512_seed->fxState[1].offset = S390X_GUEST_OFFSET(guest_r0) + r2 * sizeof(ULong); - sha512_seed->fxState[1].size = 2 * sizeof(ULong); /* r2 and r2 + 1 are read */ - sha512_seed->mAddr = get_gpr_dw0(r2); - sha512_seed->mSize = S390_PPNO_MAX_SIZE_SHA512_SEED; - sha512_seed->mFx = Ifx_Write; - - /* Dummy helper which is used to signal VEX library that memory was loaded */ - sha512_loadparam = - unsafeIRDirty_0_N(0, "s390x_dirtyhelper_PPNO_sha512_load_param_block", - &s390x_dirtyhelper_PPNO_sha512_load_param_block, - mkIRExprVec_0()); - sha512_loadparam->guard = mkexpr(is_sha512); - sha512_loadparam->nFxState = 0; - vex_bzero(&sha512_loadparam->fxState, sizeof(sha512_loadparam->fxState)); - sha512_loadparam->mAddr = get_gpr_dw0(1); - sha512_loadparam->mSize = S390_PPNO_PARAM_BLOCK_SIZE_SHA512; - sha512_loadparam->mFx = Ifx_Read; - - IRDirty* sha512_saveparam = - unsafeIRDirty_0_N(0, "s390x_dirtyhelper_PPNO_sha512_save_param_block", - &s390x_dirtyhelper_PPNO_sha512_load_param_block, - mkIRExprVec_0()); - sha512_saveparam->guard = mkexpr(is_sha512); - sha512_saveparam->nFxState = 0; - vex_bzero(&sha512_saveparam->fxState, sizeof(sha512_saveparam->fxState)); - sha512_saveparam->mAddr = get_gpr_dw0(1); - sha512_saveparam->mSize = S390_PPNO_PARAM_BLOCK_SIZE_SHA512; - sha512_saveparam->mFx = Ifx_Write; - - stmt(IRStmt_Dirty(query)); - stmt(IRStmt_Dirty(sha512_loadparam)); - stmt(IRStmt_Dirty(sha512_gen)); - stmt(IRStmt_Dirty(sha512_seed)); - stmt(IRStmt_Dirty(sha512_saveparam)); - - IRTemp cc = newTemp(Ity_I64); - assign(cc, - mkite(mkexpr(is_sha512_gen), - mkexpr(gen_cc), - mkU64(0) - ) - ); - - s390_cc_thunk_fill(mkU64(S390_CC_OP_SET), mkexpr(cc), mkU64(0), mkU64(0)); + /* Check for obvious specification exceptions */ + s390_insn_assert("ppno", r1 % 2 == 0 && r2 % 2 == 0 && r1 != 0 && r2 != 0); + extension(S390_EXT_PRNO, r1 | (r2 << 4)); return "ppno"; } diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index b52825d74..ee240347d 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -7706,6 +7706,7 @@ s390_jump_kind_as_string(IRJumpKind kind) case Ijk_SigSEGV: return "SigSEGV"; case Ijk_SigBUS: return "SigBUS"; case Ijk_Sys_syscall: return "Sys_syscall"; + case Ijk_Extension: return "Extension"; default: vpanic("s390_jump_kind_as_string"); } @@ -11428,6 +11429,7 @@ s390_insn_xassisted_emit(UChar *buf, const s390_insn *insn, switch (insn->variant.xassisted.kind) { case Ijk_ClientReq: trcval = VEX_TRC_JMP_CLIENTREQ; break; case Ijk_Sys_syscall: trcval = VEX_TRC_JMP_SYS_SYSCALL; break; + case Ijk_Extension: trcval = VEX_TRC_JMP_EXTENSION; break; case Ijk_Yield: trcval = VEX_TRC_JMP_YIELD; break; case Ijk_EmWarn: trcval = VEX_TRC_JMP_EMWARN; break; case Ijk_EmFail: trcval = VEX_TRC_JMP_EMFAIL; break; diff --git a/VEX/priv/host_s390_isel.c b/VEX/priv/host_s390_isel.c index 3ae7c07c0..10aebf73f 100644 --- a/VEX/priv/host_s390_isel.c +++ b/VEX/priv/host_s390_isel.c @@ -5361,6 +5361,7 @@ no_memcpy_put: case Ijk_NoDecode: case Ijk_InvalICache: case Ijk_Sys_syscall: + case Ijk_Extension: case Ijk_ClientReq: case Ijk_NoRedir: case Ijk_Yield: @@ -5477,6 +5478,7 @@ iselNext(ISelEnv *env, IRExpr *next, IRJumpKind jk, Int offsIP) case Ijk_NoDecode: case Ijk_InvalICache: case Ijk_Sys_syscall: + case Ijk_Extension: case Ijk_ClientReq: case Ijk_NoRedir: case Ijk_Yield: diff --git a/VEX/priv/ir_defs.c b/VEX/priv/ir_defs.c index 0ef49eaa6..23f304e46 100644 --- a/VEX/priv/ir_defs.c +++ b/VEX/priv/ir_defs.c @@ -2083,6 +2083,7 @@ void ppIRJumpKind ( IRJumpKind kind ) case Ijk_Sys_int145: vex_printf("Sys_int145"); break; case Ijk_Sys_int210: vex_printf("Sys_int210"); break; case Ijk_Sys_sysenter: vex_printf("Sys_sysenter"); break; + case Ijk_Extension: vex_printf("Extension"); break; default: vpanic("ppIRJumpKind"); } } diff --git a/VEX/pub/libvex_ir.h b/VEX/pub/libvex_ir.h index 85805bb69..fa4e4c2de 100644 --- a/VEX/pub/libvex_ir.h +++ b/VEX/pub/libvex_ir.h @@ -2512,8 +2512,9 @@ typedef Ijk_Sys_int130, /* amd64/x86 'int $0x82' */ Ijk_Sys_int145, /* amd64/x86 'int $0x91' */ Ijk_Sys_int210, /* amd64/x86 'int $0xD2' */ - Ijk_Sys_sysenter /* x86 'sysenter'. guest_EIP becomes + Ijk_Sys_sysenter, /* x86 'sysenter'. guest_EIP becomes invalid at the point this happens. */ + Ijk_Extension, /* invoke guest-specific extension */ } IRJumpKind; diff --git a/VEX/pub/libvex_s390x_common.h b/VEX/pub/libvex_s390x_common.h index 0fbe4145a..2fd622a16 100644 --- a/VEX/pub/libvex_s390x_common.h +++ b/VEX/pub/libvex_s390x_common.h @@ -107,6 +107,15 @@ #define S390_FAC_VXE2 148 // vector enhancements facility 2 #define S390_FAC_DFLT 151 // deflate-conversion facility +/*--------------------------------------------------------------*/ +/*--- Extensions ---*/ +/*--------------------------------------------------------------*/ + +/* The extension ID is stored in the low 16 bits of the guest_SYSNO pseudo + register. */ +#define S390_EXT_ID_NBITS 16 + +#define S390_EXT_PRNO 1 /*--------------------------------------------------------------*/ /*--- Miscellaneous ---*/ diff --git a/VEX/pub/libvex_trc_values.h b/VEX/pub/libvex_trc_values.h index cfd54ded3..c9adcb70d 100644 --- a/VEX/pub/libvex_trc_values.h +++ b/VEX/pub/libvex_trc_values.h @@ -77,6 +77,8 @@ #define VEX_TRC_JMP_NODECODE 69 /* next instruction is not decodable */ #define VEX_TRC_JMP_MAPFAIL 71 /* address translation failed */ +#define VEX_TRC_JMP_EXTENSION 114 /* invoke extension before continuing */ + #define VEX_TRC_JMP_SYS_SYSCALL 73 /* do syscall before continuing */ #define VEX_TRC_JMP_SYS_INT32 75 /* do syscall before continuing */ #define VEX_TRC_JMP_SYS_INT128 77 /* do syscall before continuing */ diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index f1815b411..3b6516151 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -270,6 +270,8 @@ noinst_HEADERS = \ m_demangle/demangle.h \ m_demangle/safe-ctype.h \ m_demangle/vg_libciface.h \ + m_extension/priv_extension.h \ + m_extension/priv_types_n_macros.h \ m_gdbserver/regcache.h \ m_gdbserver/regdef.h \ m_gdbserver/server.h \ @@ -393,6 +395,8 @@ COREGRIND_SOURCES_COMMON = \ m_dispatch/dispatch-amd64-darwin.S \ m_dispatch/dispatch-x86-solaris.S \ m_dispatch/dispatch-amd64-solaris.S \ + m_extension/extension-main.c \ + m_extension/extension-s390x.c \ m_gdbserver/inferiors.c \ m_gdbserver/regcache.c \ m_gdbserver/remote-utils.c \ diff --git a/coregrind/m_extension/extension-main.c b/coregrind/m_extension/extension-main.c new file mode 100644 index 000000000..c92751f2d --- /dev/null +++ b/coregrind/m_extension/extension-main.c @@ -0,0 +1,54 @@ + +/*--------------------------------------------------------------------*/ +/*--- Handle extensions. extension-main.c ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) IBM Corp. 2024 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +/* Contributed by Andreas Arnez */ + +#include "libvex_guest_offsets.h" +#include "pub_core_extension.h" +#include "pub_core_libcassert.h" +#include "pub_core_threadstate.h" +#include "priv_extension.h" + +/* This is the top-level of the extension handler module. Extensions provide a + means of executing instructions whose register and memory effects are too + complex to be expressed with dirty helpers. + */ + +/* --- This is the main function of this file. --- */ + +enum ExtensionError VG_(client_extension)(ThreadId tid) +{ + ThreadState* tst; + + vg_assert(VG_(is_valid_tid)(tid)); + vg_assert(tid >= 1 && tid < VG_N_THREADS); + vg_assert(VG_(is_running_thread)(tid)); + + tst = VG_(get_ThreadState)(tid); + + return ML_(do_client_extension)(tst); +} diff --git a/coregrind/m_extension/extension-s390x.c b/coregrind/m_extension/extension-s390x.c new file mode 100644 index 000000000..2fbee3d46 --- /dev/null +++ b/coregrind/m_extension/extension-s390x.c @@ -0,0 +1,227 @@ + +/*--------------------------------------------------------------------*/ +/*--- Handle s390x-specific extensions. extension-s390x.c ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) IBM Corp. 2024 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +/* Contributed by Andreas Arnez */ + +#if defined(VGP_s390x_linux) + +#include "libvex_s390x_common.h" +#include "priv_extension.h" +#include "priv_types_n_macros.h" +#include "pub_core_libcassert.h" +#include "pub_core_threadstate.h" + +#undef SYSNO + +#define READ_FUNCTION_CODE(tst) \ + ({ \ + PRE_REG_READ(tst, "func_code", r0, 7, sizeof(UChar)); \ + tst->arch.vex.guest_r0 & 0xff; \ + }) + +#define READ_GPR(tst, name, regno) \ + ({ \ + PRE_REG_READ(tst, name, r0, sizeof(ULong) * (regno), sizeof(ULong)); \ + *((&tst->arch.vex.guest_r0) + (regno)); \ + }) + +#define WRITE_GPR(tst, regno, value) \ + ({ \ + *((&tst->arch.vex.guest_r0) + (regno)) = value; \ + POST_REG_WRITE(tst, r0, sizeof(ULong) * (regno), sizeof(ULong)); \ + }) + +#define S390_CC_OP_SET 35 + +#define WRITE_CC(tst, value) \ + ({ \ + tst->arch.vex.guest_CC_OP = S390_CC_OP_SET; \ + tst->arch.vex.guest_CC_DEP1 = value; \ + tst->arch.vex.guest_CC_DEP2 = 0; \ + tst->arch.vex.guest_CC_NDEP = 0; \ + POST_REG_WRITE(tst, CC_OP, 0, sizeof(ULong) * 4); \ + }) + +#define INSN_ERR(msg) \ + ({ \ + VG_(umsg)("Illegal operation: "); \ + VG_(umsg)(msg); \ + ExtErr_Illop; \ + }) + +union reg_pair { + struct { + ULong a, b; + }; + unsigned __int128 pair; +}; + +#define S390_SETBIT(x) (1UL << (63 - (x % 64))) + +/* Helper routine for query functions: Filter the bit vector `fc' using a given + `filter' vector */ +static void s390_filter_functions(ULong* fc, + ULong fc_len, + const ULong* filter, + ULong filter_len) +{ + ULong n_fc = fc_len / sizeof(ULong); + ULong n_filter = filter_len / sizeof(ULong); + + for (ULong i = 0; i < n_fc; i++) { + if (i < n_filter) + fc[i] &= filter[i]; + else + fc[i] = 0; + } +} + +/*---------------------------------------------------------------*/ +/*--- PRNO (perform random number operation) ---*/ +/*---------------------------------------------------------------*/ + +static Int do_PRNO_insn(UChar func, + ULong parms, + ULong* addr1, + ULong* len1, + ULong* addr2, + ULong* len2) +{ + register UChar reg0 asm("0") = func; + register void* reg1 asm("1") = (void*)parms; + union reg_pair op1 = {{*addr1, *len1}}; + union reg_pair op2 = {{*addr2, *len2}}; + Int cc; + + asm volatile(".insn rre, 0xb93c0000, %[op1], %[op2]\n" + "ipm %[cc]\n" + "srl %[cc], 28\n" + : [cc] "=d"(cc), [op1] "+a"(op1.pair), [op2] "+a"(op2.pair) + : "d"(reg0), "d"(reg1) + : "cc", "memory"); + *addr1 = op1.a; + *len1 = op1.b; + *addr2 = op2.a; + *len2 = op2.b; + return cc; +} + +/* PRNO functions that we support if the hardware does. */ +static const ULong PRNO_functions[] = { + (S390_SETBIT(0) // Query + | S390_SETBIT(3)), // SHA-512-DRNG + (S390_SETBIT(112) // TRNG-Query-Raw-to-Conditioned-Ratio + | S390_SETBIT(114)), // TRNG +}; + +static UWord do_extension_PRNO(ThreadState* tst, ULong variant) +{ + UChar r1 = variant & 0xf; + UChar r2 = (variant >> 4) & 0xf; + UChar func = READ_FUNCTION_CODE(tst); + UChar fc = func & 0x7f; + UChar mflag = func & 128; + ULong parms = READ_GPR(tst, "r1", 1); + UChar parms_len; + Int cc = 0; + ULong orig_addr1 = 0, orig_len1 = 0, orig_addr2 = 0, orig_len2 = 0; + ULong addr1 = 0, len1 = 0, addr2 = 0, len2 = 0; + + switch (fc) { + case 0: // Query + parms_len = 16; + PRE_MEM_WRITE(tst, "parms", parms, parms_len); + cc = do_PRNO_insn(func, parms, &addr1, &len1, &addr2, &len2); + s390_filter_functions((ULong*)parms, parms_len, PRNO_functions, + sizeof(PRNO_functions)); + POST_MEM_WRITE(tst, parms, parms_len); + break; + case 112: // TRNG-Query-Raw-to-Conditioned-Ratio + parms_len = 8; + PRE_MEM_WRITE(tst, "parms", parms, parms_len); + cc = do_PRNO_insn(func, parms, &addr1, &len1, &addr2, &len2); + POST_MEM_WRITE(tst, parms, parms_len); + break; + case 3: // SHA-512-DRNG + parms_len = 240; + PRE_MEM_READ(tst, "parms", parms, parms_len); + if (mflag == 0) { + // Generate operation + addr1 = orig_addr1 = READ_GPR(tst, "op1_addr", r1); + len1 = orig_len1 = READ_GPR(tst, "op1_len", r1 + 1); + PRE_MEM_WRITE(tst, "operand1", addr1, len1); + } else { + // Seed operation + addr2 = orig_addr2 = READ_GPR(tst, "op2_addr", r2); + len2 = orig_len2 = READ_GPR(tst, "op2_len", r2 + 1); + PRE_MEM_READ(tst, "operand2", addr2, len2); + } + PRE_MEM_WRITE(tst, "parms", parms, parms_len); + cc = do_PRNO_insn(func, parms, &addr1, &len1, &addr2, &len2); + POST_MEM_WRITE(tst, parms, parms_len); + if (mflag == 0) { + WRITE_GPR(tst, r2 + 1, len1); + POST_MEM_WRITE(tst, orig_addr1 + len1, orig_len1 - len1); + } + break; + case 114: // TRNG + addr1 = READ_GPR(tst, "op1_addr", r1); + len1 = READ_GPR(tst, "op1_len", r1 + 1); + PRE_MEM_WRITE(tst, "operand1", addr1, len1); + addr2 = READ_GPR(tst, "op2_addr", r2); + len2 = READ_GPR(tst, "op2_len", r2 + 1); + PRE_MEM_WRITE(tst, "operand2", addr2, len2); + cc = do_PRNO_insn(func, parms, &addr1, &len1, &addr2, &len2); + WRITE_GPR(tst, r1, addr1); + WRITE_GPR(tst, r1 + 1, len1); + WRITE_GPR(tst, r2, addr2); + WRITE_GPR(tst, r2 + 1, len2); + POST_MEM_WRITE(tst, addr1, len1); + POST_MEM_WRITE(tst, addr2, len2); + break; + default: + return INSN_ERR("PRNO: unknown function code\n"); + } + WRITE_CC(tst, cc); + return ExtErr_OK; +} + +enum ExtensionError ML_(do_client_extension)(ThreadState* tst) +{ + ULong code = REG_READ(tst, SYSNO); + ULong id = code & ((1ULL << S390_EXT_ID_NBITS) - 1); + ULong variant = code >> S390_EXT_ID_NBITS; + + switch (id) { + case S390_EXT_PRNO: + return do_extension_PRNO(tst, variant); + default: + VG_(core_panic)("unknown extension ID"); + } +} + +#endif diff --git a/coregrind/m_extension/priv_extension.h b/coregrind/m_extension/priv_extension.h new file mode 100644 index 000000000..6f6dbaca8 --- /dev/null +++ b/coregrind/m_extension/priv_extension.h @@ -0,0 +1,38 @@ + +/*--------------------------------------------------------------------*/ +/*--- Private extensions header. priv_extension.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) IBM Corp. 2024 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +/* Contributed by Andreas Arnez */ + +#ifndef __PRIV_EXTENSION_H +#define __PRIV_EXTENSION_H + +#include "pub_core_extension.h" +#include "pub_core_threadstate.h" + +enum ExtensionError ML_(do_client_extension)(ThreadState* thread_state); + +#endif diff --git a/coregrind/m_extension/priv_types_n_macros.h b/coregrind/m_extension/priv_types_n_macros.h new file mode 100644 index 000000000..347fa4da6 --- /dev/null +++ b/coregrind/m_extension/priv_types_n_macros.h @@ -0,0 +1,80 @@ + +/*--------------------------------------------------------------------*/ +/*--- Types and macros for writing extensions. ---*/ +/*--- priv_types_n_macros.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) IBM Corp. 2024 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +/* Contributed by Andreas Arnez */ + +#ifndef __PRIV_TYPES_N_MACROS_H +#define __PRIV_TYPES_N_MACROS_H + +#include "pub_core_basics.h" // Addr +#include "pub_core_libcprint.h" +#include "pub_core_signals.h" +#include "pub_core_tooliface.h" +#include "pub_tool_tooliface.h" + +#define PRE_REG_READ(tst, name, reg, offset, len) \ + if (VG_(tdict).track_pre_reg_read) { \ + VexGuestArchState* gst = &tst->arch.vex; \ + VG_(tdict).track_pre_reg_read( \ + Vg_CoreSysCall, tst->tid, name, \ + (UChar*)&gst->guest_##reg - (UChar*)gst + (offset), len); \ + } + +#define POST_REG_WRITE(tst, reg, offset, len) \ + if (VG_(tdict).track_post_reg_write) { \ + VexGuestArchState* gst = &tst->arch.vex; \ + VG_(tdict).track_post_reg_write( \ + Vg_CoreSysCall, tst->tid, \ + (UChar*)&gst->guest_##reg - (UChar*)gst + offset, len); \ + } + +#define PRE_MEM_READ(tst, name, addr, len) \ + if (VG_(tdict).track_pre_mem_read) { \ + VG_(tdict).track_pre_mem_read(Vg_CoreSysCall, tst->tid, name, addr, \ + len); \ + } + +#define PRE_MEM_WRITE(tst, name, addr, len) \ + if (VG_(tdict).track_pre_mem_write) { \ + VG_(tdict).track_pre_mem_write(Vg_CoreSysCall, tst->tid, name, addr, \ + len); \ + } + +#define POST_MEM_WRITE(tst, addr, len) \ + if (VG_(tdict).track_post_mem_write) { \ + VG_(tdict).track_post_mem_write(Vg_CoreSysCall, tst->tid, addr, len); \ + } + +#define REG_READ(tst, reg) \ + ({ \ + PRE_REG_READ(tst, #reg, reg, 0, sizeof(tst->arch.vex.guest_##reg)); \ + tst->arch.vex.guest_##reg; \ + }) + + +#endif diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 6456eb1ac..53be34ab5 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -66,6 +66,7 @@ #include "pub_core_clreq.h" // for VG_USERREQ__* #include "pub_core_dispatch.h" #include "pub_core_errormgr.h" // For VG_(get_n_errs_found)() +#include "pub_core_extension.h" #include "pub_core_gdbserver.h" // for VG_(gdbserver)/VG_(gdbserver_activity) #include "pub_core_libcbase.h" #include "pub_core_libcassert.h" @@ -277,6 +278,7 @@ const HChar* name_of_sched_event ( UInt event ) case VEX_TRC_JMP_YIELD: return "YIELD"; case VEX_TRC_JMP_NODECODE: return "NODECODE"; case VEX_TRC_JMP_MAPFAIL: return "MAPFAIL"; + case VEX_TRC_JMP_EXTENSION: return "EXTENSION"; case VEX_TRC_JMP_SYS_SYSCALL: return "SYSCALL"; case VEX_TRC_JMP_SYS_INT32: return "INT32"; case VEX_TRC_JMP_SYS_INT128: return "INT128"; @@ -1223,6 +1225,32 @@ static void handle_syscall(ThreadId tid, UInt trc) } } +static void handle_extension(ThreadId tid) +{ + volatile UWord jumped; + enum ExtensionError err; + + SCHEDSETJMP(tid, jumped, err = VG_(client_extension)(tid)); + vg_assert(VG_(is_running_thread)(tid)); + + if (err != ExtErr_OK) { + ThreadState* tst = VG_(get_ThreadState)(tid); + Addr addr = tst->arch.vex.guest_IP_AT_SYSCALL; + switch (err) { + case ExtErr_Illop: + VG_(synth_sigill)(tid, addr); + break; + default: + VG_(core_panic)("scheduler: bad return code from extension"); + } + } + + if (jumped != (UWord)0) { + block_signals(); + VG_(poll_signals)(tid); + } +} + /* tid just requested a jump to the noredir version of its current program counter. So make up that translation if needed, run it, and return the resulting thread return code in two_words[]. */ @@ -1542,6 +1570,11 @@ VgSchedReturnCode VG_(scheduler) ( ThreadId tid ) do_client_request(tid); break; + case VEX_TRC_JMP_EXTENSION: { + handle_extension(tid); + break; + } + case VEX_TRC_JMP_SYS_INT128: /* x86-linux */ case VEX_TRC_JMP_SYS_INT129: /* x86-darwin */ case VEX_TRC_JMP_SYS_INT130: /* x86-darwin */ diff --git a/coregrind/pub_core_extension.h b/coregrind/pub_core_extension.h new file mode 100644 index 000000000..39fa4dd8b --- /dev/null +++ b/coregrind/pub_core_extension.h @@ -0,0 +1,45 @@ +/*--------------------------------------------------------------------*/ +/*--- Extensions pub_core_extension.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) IBM Corp. 2024 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +/* Contributed by Andreas Arnez */ + +#ifndef __PUB_CORE_EXTENSION_H +#define __PUB_CORE_EXTENSION_H + +#include "pub_core_basics.h" // VG_ macro + +//-------------------------------------------------------------------- +// PURPOSE: This module contains the extension handling stuff +//-------------------------------------------------------------------- + +enum ExtensionError { + ExtErr_OK, + ExtErr_Illop, +}; + +extern enum ExtensionError VG_(client_extension) ( ThreadId tid ); + +#endif -- 2.44.0 |
From: Paul F. <pa...@so...> - 2024-03-24 06:59:38
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=ca58f30a5e728cda2802c7fafdc0770a45a5f8cb commit ca58f30a5e728cda2802c7fafdc0770a45a5f8cb Author: Eyal Soha <eya...@gm...> Date: Tue Mar 2 14:42:38 2021 -0700 Bug 474160 - If errors-for-leak-kinds is specified, exit-on-first-error should only exit on one of the listed errors. It's possible for the user to specify in the memcheck that some errors should not cause an exit with the error-exitcode value. For those errors which would not cause an error exitcode, do not count them for the purposes of exiting after the first error. Diff: --- NEWS | 2 + coregrind/m_errormgr.c | 16 +++--- memcheck/tests/Makefile.am | 1 + .../tests/leak-cases-exit-on-definite.stderr.exp | 64 ++++++++++++++++++++++ memcheck/tests/leak-cases-exit-on-definite.vgtest | 3 + 5 files changed, 78 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index d7686b80a9..7922646f31 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,8 @@ are not entered into bugzilla tend to get forgotten about or ignored. 466884 Missing writev uninit padding suppression for _XSend 471036 disInstr_AMD64: disInstr miscalculated next %rip on RORX imm8, m32/64, r32/6 471222 support tracking of file descriptors being double closed +474160 If errors-for-leak-kinds is specified, exit-on-first-error should only exit + on one of the listed errors. 475498 Add reallocarray wrapper 476320 Build failure with GCC 476331 clean up generated/distributed filter scripts diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index 8f2fc0a965..40e36d162d 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -518,7 +518,7 @@ Bool VG_(is_action_requested) ( const HChar* action, Bool* clo ) * possibly, generate a suppression. */ static -void do_actions_on_error(const Error* err, Bool allow_db_attach) +void do_actions_on_error(const Error* err, Bool allow_db_attach, Bool count_error) { Bool still_noisy = True; @@ -543,7 +543,7 @@ void do_actions_on_error(const Error* err, Bool allow_db_attach) if (VG_(clo_gen_suppressions) == 1 && !still_noisy) VG_(clo_gen_suppressions) = 0; - if (VG_(clo_exit_on_first_error)) { + if (count_error && VG_(clo_exit_on_first_error)) { if (VG_(clo_xml)) VG_(printf_xml)("</valgrindoutput>\n"); VG_(umsg)("\n"); @@ -581,7 +581,7 @@ void do_actions_on_error(const Error* err, Bool allow_db_attach) * calls do_actions_on_error. This optionally does a gdbserver call and optionally prints a suppression; both of these may require user input. */ -static void pp_Error ( const Error* err, Bool allow_db_attach, Bool xml ) +static void pp_Error ( const Error* err, Bool allow_db_attach, Bool xml, Bool count_error ) { /* If this fails, you probably specified your tool's method dictionary incorrectly. */ @@ -642,7 +642,7 @@ static void pp_Error ( const Error* err, Bool allow_db_attach, Bool xml ) } - do_actions_on_error(err, allow_db_attach); + do_actions_on_error(err, allow_db_attach, count_error); } @@ -849,7 +849,7 @@ void VG_(maybe_record_error) ( ThreadId tid, n_errs_found++; n_errs_shown++; /* Actually show the error; more complex than you might think. */ - pp_Error( p, /*allow_db_attach*/True, VG_(clo_xml) ); + pp_Error( p, /*allow_db_attach*/True, VG_(clo_xml), /* count_error */ True ); } else { n_supp_contexts++; n_errs_suppressed++; @@ -899,7 +899,7 @@ Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind, Addr a, const HChar* s, /* update stats */ n_errs_shown++; /* Actually show the error; more complex than you might think. */ - pp_Error(&err, allow_db_attach, VG_(clo_xml)); + pp_Error(&err, allow_db_attach, VG_(clo_xml), count_error); } return False; @@ -1025,7 +1025,7 @@ void VG_(show_all_errors) ( Int verbosity, Bool xml ) VG_(umsg)("\n"); VG_(umsg)("%d errors in context %d of %u:\n", p_min->count, i+1, n_err_contexts); - pp_Error( p_min, False/*allow_db_attach*/, False /* xml */ ); + pp_Error( p_min, False/*allow_db_attach*/, False /* xml */, True /* count_error */ ); // We're not printing XML -- we'd have exited above if so. vg_assert(! xml); @@ -1068,7 +1068,7 @@ void VG_(show_last_error) ( void ) return; } - pp_Error( errors, False/*allow_db_attach*/, False/*xml*/ ); + pp_Error( errors, False/*allow_db_attach*/, False/*xml*/, True/*count_error*/ ); } diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 76970529f2..20abbcfe1b 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -224,6 +224,7 @@ EXTRA_DIST = \ inltemplate.stderr.exp inltemplate.stdout.exp inltemplate.vgtest \ inltemplate.stderr.exp-old-gcc \ leak-0.vgtest leak-0.stderr.exp \ + leak-cases-exit-on-definite.vgtest leak-cases-exit-on-definite.stderr.exp \ leak-cases-full.vgtest leak-cases-full.stderr.exp \ leak-cases-possible.vgtest leak-cases-possible.stderr.exp \ leak-cases-summary.vgtest leak-cases-summary.stderr.exp \ diff --git a/memcheck/tests/leak-cases-exit-on-definite.stderr.exp b/memcheck/tests/leak-cases-exit-on-definite.stderr.exp new file mode 100644 index 0000000000..0534787035 --- /dev/null +++ b/memcheck/tests/leak-cases-exit-on-definite.stderr.exp @@ -0,0 +1,64 @@ + +All heap blocks were freed -- no leaks are possible + +LEAK SUMMARY: + definitely lost: 48 bytes in 3 blocks + indirectly lost: 32 bytes in 2 blocks + possibly lost: 96 bytes in 6 blocks + still reachable: 64 bytes in 4 blocks + suppressed: 0 bytes in 0 blocks +Rerun with --leak-check=full to see details of leaked memory + +leaked: 80 bytes in 5 blocks +dubious: 96 bytes in 6 blocks +reachable: 64 bytes in 4 blocks +suppressed: 0 bytes in 0 blocks + +HEAP SUMMARY: + in use at exit: 240 bytes in 15 blocks + total heap usage: 15 allocs, 0 frees, 240 bytes allocated + +16 bytes in 1 blocks are possibly lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:78) + by 0x........: main (leak-cases.c:107) + +16 bytes in 1 blocks are possibly lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:81) + by 0x........: main (leak-cases.c:107) + +16 bytes in 1 blocks are possibly lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:84) + by 0x........: main (leak-cases.c:107) + +16 bytes in 1 blocks are possibly lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:84) + by 0x........: main (leak-cases.c:107) + +16 bytes in 1 blocks are possibly lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:87) + by 0x........: main (leak-cases.c:107) + +16 bytes in 1 blocks are possibly lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:87) + by 0x........: main (leak-cases.c:107) + +16 bytes in 1 blocks are definitely lost in loss record ... of ... + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: mk (leak-cases.c:52) + by 0x........: f (leak-cases.c:74) + by 0x........: main (leak-cases.c:107) + + +Exit program on first error (--exit-on-first-error=yes) diff --git a/memcheck/tests/leak-cases-exit-on-definite.vgtest b/memcheck/tests/leak-cases-exit-on-definite.vgtest new file mode 100644 index 0000000000..a9deaccc1c --- /dev/null +++ b/memcheck/tests/leak-cases-exit-on-definite.vgtest @@ -0,0 +1,3 @@ +prog: leak-cases +vgopts: --error-exitcode=127 --errors-for-leak-kinds=definite --leak-check=full -s --exit-on-first-error=yes +stderr_filter_args: leak-cases.c |
From: Paul F. <pa...@so...> - 2024-03-20 20:23:56
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=49216fd60e3fcf0c7dad1dfc797662236255e18a commit 49216fd60e3fcf0c7dad1dfc797662236255e18a Author: Paul Floyd <pj...@wa...> Date: Wed Mar 20 21:22:37 2024 +0100 Bug 484002 - Add suppression for invalid read in glibc's __wcpncpy_avx2() via wcsxfrm() This needed a redirect, not a suppression. Diff: --- .gitignore | 4 +++- NEWS | 1 + configure.ac | 8 ++++++- memcheck/tests/Makefile.am | 10 ++++++++ memcheck/tests/bug484002.c | 28 ++++++++++++++++++++++ memcheck/tests/bug484002.stderr.exp | 0 memcheck/tests/bug484002.stdout.exp | 3 +++ memcheck/tests/bug484002.vgtest | 3 +++ memcheck/tests/wcpncpy.c | 47 +++++++++++++++++++++++++++++++++++++ memcheck/tests/wcpncpy.stderr.exp | 19 +++++++++++++++ memcheck/tests/wcpncpy.vgtest | 3 +++ shared/vg_replace_strmem.c | 47 ++++++++++++++++++++++++++++++++++++- 12 files changed, 170 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1c54be91e1..982305c355 100644 --- a/.gitignore +++ b/.gitignore @@ -855,9 +855,10 @@ /memcheck/tests/bug155125 /memcheck/tests/bug287260 /memcheck/tests/bug340392 +/memcheck/tests/bug401284 /memcheck/tests/bug464969_d_demangle /memcheck/tests/bug472219 -/memcheck/tests/bug401284 +/memcheck/tests/bug484002 /memcheck/tests/calloc-overflow /memcheck/tests/cdebug_zlib /memcheck/tests/cdebug_zlib_gnu @@ -1030,6 +1031,7 @@ /memcheck/tests/wcs /memcheck/tests/weirdioctl /memcheck/tests/with space +/memcheck/tests/wcpncpy /memcheck/tests/wcsncpy /memcheck/tests/wmemcmp /memcheck/tests/wrap1 diff --git a/NEWS b/NEWS index 20bb0e2d8d..d7686b80a9 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 480706 Unhandled syscall 325 (mlock2) 481131 [PATCH] x86 regtest: fix clobber lists in generated asm statements 483786 Incorrect parameter indexing in FreeBSD clock_nanosleep syscall wrapper +484002 Add suppression for invalid read in glibc's __wcpncpy_avx2() via wcsxfrm() n-i-bz Add redirect for memccpy To see details of a given bug, visit diff --git a/configure.ac b/configure.ac index 858405ef67..8279683ac3 100755 --- a/configure.ac +++ b/configure.ac @@ -4969,7 +4969,9 @@ AC_CHECK_FUNCS([ \ strndup \ close_range \ wcsncpy \ - free_aligned_sized + free_aligned_sized \ + wcpncpy \ + wcsxfrm ]) # AC_CHECK_LIB adds any library found to the variable LIBS, and links these @@ -5009,6 +5011,10 @@ AM_CONDITIONAL([HAVE_STRLCPY], [test x$ac_cv_func_strlcpy = xyes]) AM_CONDITIONAL([HAVE_FREE_ALIGNED_SIZED], [test x$ac_cv_func_free_aligned_sized = xyes]) +AM_CONDITIONAL([HAVE_WCPNCPY], + [test x$ac_cv_func_wcpncpy = xyes]) +AM_CONDITIONAL([HAVE_WCSXFRM], + [test x$ac_cv_func_wcsxfrm = xyes]) if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \ diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 150e632ccd..76970529f2 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -121,6 +121,7 @@ EXTRA_DIST = \ bug464969_d_demangle.stderr.exp bug464969_d_demangle.vgtest \ bug464969_d_demangle.stdout.exp \ bug472219.stderr.exp bug472219.vgtest \ + bug484002.stderr.exp bug484002.stdout.exp bug484002.vgtest \ calloc-overflow.stderr.exp calloc-overflow.vgtest\ cdebug_zlib.stderr.exp cdebug_zlib.vgtest \ cdebug_zlib_gnu.stderr.exp cdebug_zlib_gnu.vgtest \ @@ -434,6 +435,7 @@ EXTRA_DIST = \ vcpu_fnfns.stdout.exp vcpu_fnfns.stdout.exp-glibc28-amd64 \ vcpu_fnfns.stdout.exp-darwin vcpu_fnfns.stdout.exp-solaris \ vcpu_fnfns.stderr.exp vcpu_fnfns.vgtest \ + wcpncpy.stderr.exp wcpncpy.vgtest \ wcs.vgtest wcs.stderr.exp wcs.stdout.exp \ wcsncpy.vgtest wcsncpy.stderr.exp \ wmemcmp.vgtest wmemcmp.stderr.exp \ @@ -559,6 +561,10 @@ endif bug464969_d_demangle_SOURCES = bug464969_d_demangle.cpp bug464969_d_demangle_CXXFLAGS = $(AM_CXXFLAGS) @FLAG_W_NO_UNINITIALIZED@ +if HAVE_WCSXFRM +check_PROGRAMS += bug484002 +endif + if GZ_ZLIB check_PROGRAMS += cdebug_zlib cdebug_zlib_SOURCES = cdebug.c @@ -602,6 +608,10 @@ if HAVE_PTHREAD_SETNAME_NP check_PROGRAMS += threadname endif +if HAVE_WCPNCPY +check_PROGRAMS += wcpncpy +endif + # are there still pre-C99 C compilers? if HAVE_WCSNCPY check_PROGRAMS += wcsncpy diff --git a/memcheck/tests/bug484002.c b/memcheck/tests/bug484002.c new file mode 100644 index 0000000000..c9d41f0dc3 --- /dev/null +++ b/memcheck/tests/bug484002.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <wchar.h> + +int main() +{ + + const wchar_t in[] = {L'a', L'b', L'c', 0}; + wchar_t out[3 + 1] = { + 0, + }; + + size_t res = wcsxfrm(out, in, 3); + printf("%lu\n", res); + + wchar_t* in2 = malloc(sizeof(wchar_t) * 4); + memcpy(in2, in, sizeof(in)); + res = wcsxfrm(out, in2, 3); + printf("%lu\n", res); + free(in2); + + wchar_t* in3 = malloc(sizeof(wchar_t) * 4); + memcpy(in3, in, sizeof(in)); + res = wcsxfrm(out, in3, 3); + printf("%lu\n", res); + free(in3); +} diff --git a/memcheck/tests/bug484002.stderr.exp b/memcheck/tests/bug484002.stderr.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/bug484002.stdout.exp b/memcheck/tests/bug484002.stdout.exp new file mode 100644 index 0000000000..1f242fa6f0 --- /dev/null +++ b/memcheck/tests/bug484002.stdout.exp @@ -0,0 +1,3 @@ +3 +3 +3 diff --git a/memcheck/tests/bug484002.vgtest b/memcheck/tests/bug484002.vgtest new file mode 100644 index 0000000000..67fc503205 --- /dev/null +++ b/memcheck/tests/bug484002.vgtest @@ -0,0 +1,3 @@ +prereq: test -e ./bug484002 +prog: bug484002 +vgopts: -q diff --git a/memcheck/tests/wcpncpy.c b/memcheck/tests/wcpncpy.c new file mode 100644 index 0000000000..97d1a13bb8 --- /dev/null +++ b/memcheck/tests/wcpncpy.c @@ -0,0 +1,47 @@ +#include <wchar.h> +#include <stdio.h> +#include <stdlib.h> +#include <assert.h> + +int main(void) +{ + const wchar_t in[] = {L'H', L'e', L'l', L'l', L'o', 0}; + + wchar_t* dest1 = malloc(5*sizeof(wchar_t) + 2); + wchar_t* dest2 = malloc(11*sizeof(wchar_t)); + + // uninit read + wcpncpy(dest1, dest2, 3); + + wchar_t* end = wcpncpy(dest1, in, 3); + + assert(3 == end - dest1); + assert(0 == wmemcmp(in , dest1, 3)); + + end = wcpncpy(dest2, in, 10); + assert(5 == end - dest2); + assert(0 == wmemcmp(dest2 , in, 6)); + assert(0 == dest2[9]); + + // too small - invalid write + end = wcpncpy(dest1, in, 6); + + wcpncpy(dest2, in, 5); + wcpncpy(dest2+5, in, 6); + + // overlap + // sss + // ddd + wcpncpy(dest2, dest2+2, 3); + + wcpncpy(dest2, in, 5); + wcpncpy(dest2+5, in, 6); + + // overlap + // sss + // ddd + wcpncpy(dest2+2, dest2, 3); + + free(dest1); + free(dest2); +} diff --git a/memcheck/tests/wcpncpy.stderr.exp b/memcheck/tests/wcpncpy.stderr.exp new file mode 100644 index 0000000000..abe23b7730 --- /dev/null +++ b/memcheck/tests/wcpncpy.stderr.exp @@ -0,0 +1,19 @@ +Conditional jump or move depends on uninitialised value(s) + at 0x........: wcpncpy (vg_replace_strmem.c:2426) + by 0x........: main (wcpncpy.c:14) + +Invalid write of size 4 + at 0x........: wcpncpy (vg_replace_strmem.c:2426) + by 0x........: main (wcpncpy.c:27) + Address 0x........ is 20 bytes inside a block of size 22 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (wcpncpy.c:10) + +Source and destination overlap in wcpncpy(0x........, 0x........) + at 0x........: wcpncpy (vg_replace_strmem.c:2426) + by 0x........: main (wcpncpy.c:35) + +Source and destination overlap in wcpncpy(0x........, 0x........) + at 0x........: wcpncpy (vg_replace_strmem.c:2426) + by 0x........: main (wcpncpy.c:43) + diff --git a/memcheck/tests/wcpncpy.vgtest b/memcheck/tests/wcpncpy.vgtest new file mode 100644 index 0000000000..f4edd4b8d5 --- /dev/null +++ b/memcheck/tests/wcpncpy.vgtest @@ -0,0 +1,3 @@ +prereq: test -e ./wcpncpy +prog: wcpncpy +vgopts: -q diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index 781dd784bf..3d88fb824b 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -107,6 +107,7 @@ 20470 WMEMCMP 20480 WCSNCPY 20490 MEMCCPY + 20500 WCPNCPY */ #if defined(VGO_solaris) @@ -2327,7 +2328,7 @@ static inline void my_exit ( int x ) \ /* This checks for overlap after copying, unavoidable without */ \ /* pre-counting length... should be ok */ \ - /* +4 because sizeof(wchar_t) == 4 */ \ + /* *4 because sizeof(wchar_t) == 4 */ \ SizeT srclen = ((m < n) ? m+1 : n)*4; \ RECORD_COPY(srclen); \ if (is_overlap(dst_orig, \ @@ -2382,6 +2383,50 @@ static inline void my_exit ( int x ) MEMCCPY(VG_Z_LIBC_SONAME, memccpy) #endif + /*---------------------- wcpncpy ----------------------*/ + + // This is a wchar_t equivalent to strncpy. We don't + // have wchar_t available here, but in the GNU C Library + // wchar_t is always 32 bits wide. + +#define WCPNCPY(soname, fnname) \ + Int* VG_REPLACE_FUNCTION_EZU(20500,soname,fnname) \ + ( Int* dst, const Int* src, SizeT n ); \ + Int* VG_REPLACE_FUNCTION_EZU(20500,soname,fnname) \ + ( Int* dst, const Int* src, SizeT n ) \ + { \ + const Int* src_orig = src; \ + Int* dst_orig = dst; \ + SizeT m = 0; \ + \ + while (m < n && *src) { \ + m++; \ + *dst++ = *src++; \ + } \ + \ + /* This checks for overlap after copying, unavoidable without */ \ + /* pre-counting length... should be ok */ \ + /* *4 because sizeof(wchar_t) == 4 */ \ + SizeT srclen = ((m < n) ? m+1 : n)*4; \ + RECORD_COPY(srclen); \ + if (is_overlap(dst_orig, \ + src_orig, \ + n*4, \ + srclen)) \ + RECORD_OVERLAP_ERROR("wcpncpy", dst_orig, src_orig, 0); \ + \ + while (m++ < n) { \ + *dst++ = 0; \ + } \ + \ + return dst_orig + (src - src_orig); \ + } + +#if defined(VGO_linux) || defined(VGO_freebsd) + WCPNCPY(VG_Z_LIBC_SONAME, wcpncpy) +#endif + + /*------------------------------------------------------------*/ /*--- Improve definedness checking of process environment ---*/ /*------------------------------------------------------------*/ |
From: Paul F. <pa...@so...> - 2024-03-17 07:40:31
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=85f0df43d1f9cbf506c1f737034bcbacdab266a9 commit 85f0df43d1f9cbf506c1f737034bcbacdab266a9 Author: Paul Floyd <pj...@wa...> Date: Sun Mar 17 08:36:08 2024 +0100 FreeBSD regtest: make bug483786 test a bit safer The uninit struct timespec can have large values so set it to 0 and use VALGRIND_MAKE_MEM_UNDEFINED to trigger the error. Diff: --- memcheck/tests/freebsd/bug483786.c | 6 ++++-- memcheck/tests/freebsd/bug483786.stderr.exp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/memcheck/tests/freebsd/bug483786.c b/memcheck/tests/freebsd/bug483786.c index ab4d44b91b..dc5a734718 100644 --- a/memcheck/tests/freebsd/bug483786.c +++ b/memcheck/tests/freebsd/bug483786.c @@ -1,10 +1,12 @@ - +#include "../../memcheck.h" #include <time.h> /* should complain about rqtp and rmtp */ void valgrind_should_complain(void) { - struct timespec ts_uninitialized; + struct timespec ts_uninitialized = {0}; + + VALGRIND_MAKE_MEM_UNDEFINED(&ts_uninitialized, sizeof(ts_uninitialized)); clock_nanosleep(CLOCK_MONOTONIC, 0, &ts_uninitialized, &ts_uninitialized); } diff --git a/memcheck/tests/freebsd/bug483786.stderr.exp b/memcheck/tests/freebsd/bug483786.stderr.exp index b44e3324d9..ac72af412a 100644 --- a/memcheck/tests/freebsd/bug483786.stderr.exp +++ b/memcheck/tests/freebsd/bug483786.stderr.exp @@ -1,7 +1,7 @@ Syscall param clock_nanosleep(rqtp) points to uninitialised byte(s) ... - by 0x........: valgrind_should_complain (bug483786.c:9) - by 0x........: main (bug483786.c:32) + by 0x........: valgrind_should_complain (bug483786.c:11) + by 0x........: main (bug483786.c:34) Address 0x........ is on thread 1's stack in frame #1, created by valgrind_should_complain (bug483786.c:6) |
From: Paul F. <pa...@so...> - 2024-03-17 07:02:44
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=b7456269dfd2f841b811037362239ae6805054a4 commit b7456269dfd2f841b811037362239ae6805054a4 Author: Paul Floyd <pj...@wa...> Date: Sun Mar 17 08:01:48 2024 +0100 FreeBSD regtest: add a test for interrupted clock_nanosleep Also add missing files for bug483786 Diff: --- .gitignore | 1 + memcheck/tests/freebsd/Makefile.am | 5 ++- memcheck/tests/freebsd/bug483786.c | 37 ++++++++++++++++++++++ memcheck/tests/freebsd/bug483786.stderr.exp | 7 ++++ memcheck/tests/freebsd/bug483786.vgtest | 2 ++ memcheck/tests/freebsd/clock_nanosleep_interrupt.c | 32 +++++++++++++++++++ .../freebsd/clock_nanosleep_interrupt.stderr.exp | 7 ++++ .../tests/freebsd/clock_nanosleep_interrupt.vgtest | 2 ++ 8 files changed, 92 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e9c302de73..1c54be91e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1381,6 +1381,7 @@ /memcheck/tests/freebsd/capsicum /memcheck/tests/freebsd/chflags /memcheck/tests/freebsd/chmod_chown +/memcheck/tests/freebsd/clock_nanosleep_interrupt /memcheck/tests/freebsd/delete_sized_mismatch /memcheck/tests/freebsd/errno_aligned_allocs /memcheck/tests/freebsd/eventfd1 diff --git a/memcheck/tests/freebsd/Makefile.am b/memcheck/tests/freebsd/Makefile.am index 2608724f4b..d16ab2e920 100644 --- a/memcheck/tests/freebsd/Makefile.am +++ b/memcheck/tests/freebsd/Makefile.am @@ -36,6 +36,8 @@ EXTRA_DIST = \ chflags.stderr.exp-x86 \ chmod_chown.vgtest \ chmod_chown.stderr.exp \ + clock_nanosleep_interrupt.vgtest \ + clock_nanosleep_interrupt.stderr.exp \ delete_sized_mismatch.vgtest \ delete_sized_mismatch.stderr.exp \ delete_sized_mismatch_xml.vgtest \ @@ -140,7 +142,8 @@ check_PROGRAMS = \ access aio aio_read aligned_alloc bug464476 bug470713 \ bug483786 \ capsicum chflags \ - chmod_chown delete_sized_mismatch errno_aligned_allocs \ + chmod_chown clock_nanosleep_interrupt \ + delete_sized_mismatch errno_aligned_allocs \ extattr \ fexecve \ file_locking_wait6 \ diff --git a/memcheck/tests/freebsd/bug483786.c b/memcheck/tests/freebsd/bug483786.c new file mode 100644 index 0000000000..ab4d44b91b --- /dev/null +++ b/memcheck/tests/freebsd/bug483786.c @@ -0,0 +1,37 @@ + +#include <time.h> + +/* should complain about rqtp and rmtp */ +void valgrind_should_complain(void) +{ + struct timespec ts_uninitialized; + + clock_nanosleep(CLOCK_MONOTONIC, 0, &ts_uninitialized, &ts_uninitialized); +} + +/* should have no complaints */ +void valgrind_should_not_complain(void) +{ + struct timespec ts_initialized = {0}; + + clock_nanosleep(CLOCK_MONOTONIC, 0, &ts_initialized, &ts_initialized); +} + +/* should have no complaints */ +void valgrind_should_not_complain2(void) +{ + struct timespec ts_initialized = {0}; + + clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts_initialized, + &ts_initialized); +} + +int main(int argc, char** argv) +{ + + valgrind_should_complain(); + valgrind_should_not_complain(); + valgrind_should_not_complain2(); + + return (0); +} diff --git a/memcheck/tests/freebsd/bug483786.stderr.exp b/memcheck/tests/freebsd/bug483786.stderr.exp new file mode 100644 index 0000000000..b44e3324d9 --- /dev/null +++ b/memcheck/tests/freebsd/bug483786.stderr.exp @@ -0,0 +1,7 @@ +Syscall param clock_nanosleep(rqtp) points to uninitialised byte(s) + ... + by 0x........: valgrind_should_complain (bug483786.c:9) + by 0x........: main (bug483786.c:32) + Address 0x........ is on thread 1's stack + in frame #1, created by valgrind_should_complain (bug483786.c:6) + diff --git a/memcheck/tests/freebsd/bug483786.vgtest b/memcheck/tests/freebsd/bug483786.vgtest new file mode 100644 index 0000000000..60cb175cb2 --- /dev/null +++ b/memcheck/tests/freebsd/bug483786.vgtest @@ -0,0 +1,2 @@ +prog: bug483786 +vgopts: -q diff --git a/memcheck/tests/freebsd/clock_nanosleep_interrupt.c b/memcheck/tests/freebsd/clock_nanosleep_interrupt.c new file mode 100644 index 0000000000..49f4a2814b --- /dev/null +++ b/memcheck/tests/freebsd/clock_nanosleep_interrupt.c @@ -0,0 +1,32 @@ +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <sys/time.h> +#include <unistd.h> +#include <stdlib.h> + +volatile int ticks = 0; +struct itimerval timert; +struct sigaction timer_action; + +void handle_vtalrm(int sig) { ticks++; } + + +int main(int argc, char* argv[]) +{ + timer_action.sa_handler = handle_vtalrm; + sigemptyset(&timer_action.sa_mask); + timer_action.sa_flags = SA_RESTART; + + sigaction(SIGVTALRM, &timer_action, NULL); + + timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; + timert.it_interval.tv_usec = timert.it_value.tv_usec = 500; + setitimer(ITIMER_VIRTUAL, &timert, NULL); + + struct timespec ts_initialized = {0, 1000000}; + struct timespec* too_small = malloc(1); + + clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts_initialized, + too_small); +} diff --git a/memcheck/tests/freebsd/clock_nanosleep_interrupt.stderr.exp b/memcheck/tests/freebsd/clock_nanosleep_interrupt.stderr.exp new file mode 100644 index 0000000000..1152ed2f10 --- /dev/null +++ b/memcheck/tests/freebsd/clock_nanosleep_interrupt.stderr.exp @@ -0,0 +1,7 @@ +Syscall param clock_nanosleep(rmtp) points to unaddressable byte(s) + ... + by 0x........: main (clock_nanosleep_interrupt.c:30) + Address 0x........ is 0 bytes after a block of size 1 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (clock_nanosleep_interrupt.c:28) + diff --git a/memcheck/tests/freebsd/clock_nanosleep_interrupt.vgtest b/memcheck/tests/freebsd/clock_nanosleep_interrupt.vgtest new file mode 100644 index 0000000000..c4b785d054 --- /dev/null +++ b/memcheck/tests/freebsd/clock_nanosleep_interrupt.vgtest @@ -0,0 +1,2 @@ +prog: clock_nanosleep_interrupt +vgopts: -q |
From: Paul F. <pa...@so...> - 2024-03-17 06:42:29
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=8d8e4a889cc3a02a5c04e5c4f23f9a191b0a6726 commit 8d8e4a889cc3a02a5c04e5c4f23f9a191b0a6726 Author: Paul Floyd <pj...@wa...> Date: Sun Mar 17 07:41:42 2024 +0100 Bug 483786 -- Incorrect parameter indexing in FreeBSD clock_nanosleep syscall wrapper Diff: --- .gitignore | 1 + NEWS | 1 + coregrind/m_syswrap/syswrap-freebsd.c | 12 ++++++------ memcheck/tests/freebsd/Makefile.am | 2 ++ memcheck/tests/freebsd/scalar.c | 3 +-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 126c2e5e4e..e9c302de73 100644 --- a/.gitignore +++ b/.gitignore @@ -1377,6 +1377,7 @@ /memcheck/tests/freebsd/aligned_alloc /memcheck/tests/freebsd/bug464476 /memcheck/tests/freebsd/bug470713 +/memcheck/tests/freebsd/bug483786 /memcheck/tests/freebsd/capsicum /memcheck/tests/freebsd/chflags /memcheck/tests/freebsd/chmod_chown diff --git a/NEWS b/NEWS index 27a6dfa3b2..20bb0e2d8d 100644 --- a/NEWS +++ b/NEWS @@ -69,6 +69,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 480488 Add support for FreeBSD 13.3 480706 Unhandled syscall 325 (mlock2) 481131 [PATCH] x86 regtest: fix clobber lists in generated asm statements +483786 Incorrect parameter indexing in FreeBSD clock_nanosleep syscall wrapper n-i-bz Add redirect for memccpy To see details of a given bug, visit diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c index bf4d7e5818..43c242806e 100644 --- a/coregrind/m_syswrap/syswrap-freebsd.c +++ b/coregrind/m_syswrap/syswrap-freebsd.c @@ -2526,18 +2526,18 @@ PRE(sys_clock_nanosleep) *flags |= SfMayBlock|SfPostOnFail; PRINT("sys_clock_nanosleep ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", SARG1, SARG2, ARG3, ARG4); - PRE_REG_READ4(int, "clock_nanosleep", clockid_t, clock_id, int, flags, + PRE_REG_READ4(int, "clock_nanosleep", vki_clockid_t, clock_id, int, flags, const struct timespec *, rqtp, struct timespec *, rmtp); - PRE_MEM_READ("clock_nanosleep(rqtp)", ARG1, sizeof(struct vki_timespec)); - if (ARG2 != 0) { - PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG2, sizeof(struct vki_timespec) ); + PRE_MEM_READ("clock_nanosleep(rqtp)", ARG3, sizeof(struct vki_timespec)); + if (ARG4 != 0) { + PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG4, sizeof(struct vki_timespec) ); } } POST(sys_clock_nanosleep) { - if (ARG2 != 0) { - POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) ); + if (ARG4 != 0 && FAILURE && ERR == VKI_EINTR) { + POST_MEM_WRITE( ARG4, sizeof(struct vki_timespec) ); } } diff --git a/memcheck/tests/freebsd/Makefile.am b/memcheck/tests/freebsd/Makefile.am index 99b971dc6d..2608724f4b 100644 --- a/memcheck/tests/freebsd/Makefile.am +++ b/memcheck/tests/freebsd/Makefile.am @@ -28,6 +28,7 @@ EXTRA_DIST = \ bug464476_rel_symlink.stdout.exp \ bug470713.vgtest bug470713.stderr.exp \ bug470713.stdout.exp \ + bug483786.vgtest bug483786.stderr.exp \ capsicum.vgtest \ capsicum.stderr.exp \ chflags.vgtest\ @@ -137,6 +138,7 @@ EXTRA_DIST = \ check_PROGRAMS = \ access aio aio_read aligned_alloc bug464476 bug470713 \ + bug483786 \ capsicum chflags \ chmod_chown delete_sized_mismatch errno_aligned_allocs \ extattr \ diff --git a/memcheck/tests/freebsd/scalar.c b/memcheck/tests/freebsd/scalar.c index 463fee3617..978c116278 100644 --- a/memcheck/tests/freebsd/scalar.c +++ b/memcheck/tests/freebsd/scalar.c @@ -897,9 +897,8 @@ int main(void) #if (FREEBSD_VERS >= FREEBSD_11) /* SYS_clock_nanosleep 244 */ - /* this succeeds ? */ GO(SYS_clock_nanosleep, "4s 2m"); - SY(SYS_clock_nanosleep, x0+5000, x0+3000, x0, x0+1); SUCC; + SY(SYS_clock_nanosleep, x0+5000, x0+3000, x0+3, x0+1); SUCC; #endif // SYS_clock_getcpuclockid2 247 |
From: Paul F. <pa...@so...> - 2024-03-17 06:08:33
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=4347d534f585eb4c6e8c1f690fd041e5119aa59f commit 4347d534f585eb4c6e8c1f690fd041e5119aa59f Author: Paul Floyd <pj...@wa...> Date: Sun Mar 17 07:07:43 2024 +0100 FreeBSD regtest: change scalar so it runs OK in vgtest and a shell Diff: --- memcheck/tests/freebsd/scalar.c | 9 +++++++-- memcheck/tests/freebsd/scalar.vgtest | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/memcheck/tests/freebsd/scalar.c b/memcheck/tests/freebsd/scalar.c index 40479dcbb9..463fee3617 100644 --- a/memcheck/tests/freebsd/scalar.c +++ b/memcheck/tests/freebsd/scalar.c @@ -25,9 +25,9 @@ int main(void) { /* Uninitialised, but we know px[0] is 0x0. */ - /* PJF why ? */ long *px = malloc(2*sizeof(long)); x0 = px[0]; + const char* running_in_vgtest = getenv("RUNNING_IN_VGTEST"); /* SYS_syscall 0 */ /* does this need a specific test? There are two diffeent IDs for syscall, see 198 */ @@ -556,7 +556,12 @@ int main(void) /* SYS_setsid 147 */ GO(SYS_setsid, "0s 0m"); - SY(SYS_setsid); SUCC; /* FAIL when run standalone */ + SY(SYS_setsid); + if (running_in_vgtest) { + SUCC; + } else { + FAIL; + } /* SYS_quotactl 148 */ GO(SYS_quotactl, "(Q_QUOTAOFF) 2s 0m"); diff --git a/memcheck/tests/freebsd/scalar.vgtest b/memcheck/tests/freebsd/scalar.vgtest index 28f279ceba..170c1576e1 100644 --- a/memcheck/tests/freebsd/scalar.vgtest +++ b/memcheck/tests/freebsd/scalar.vgtest @@ -8,4 +8,7 @@ stderr_filter: filter_scalar # 'syscall (in libc)' stack frame and this is then filtered out completely. stderr_filter_args: libc args: < scalar.c - +# this is for 'setsid', when run by vg_regtest the process isn't +# process group leader and succeeds +# but when run from a shell the process is group leader and it fails +env: RUNNING_IN_VGTEST=1 |
From: Paul F. <pa...@so...> - 2024-03-16 18:51:12
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=91856bbb58e2418c6674f9e5847160349927c8ea commit 91856bbb58e2418c6674f9e5847160349927c8ea Author: Paul Floyd <pj...@wa...> Date: Sat Mar 16 19:49:57 2024 +0100 regtest: broaden one expected and one test suppression file For linux arm. Diff: --- memcheck/tests/supp_unknown.supp | 18 +----------------- none/tests/filter_fdleak | 2 +- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/memcheck/tests/supp_unknown.supp b/memcheck/tests/supp_unknown.supp index 0cc37eb6f4..226c02e497 100644 --- a/memcheck/tests/supp_unknown.supp +++ b/memcheck/tests/supp_unknown.supp @@ -1,23 +1,7 @@ # This contains a match against a "???" entry { - <insert a suppression name here> + All jumps - there is only one Memcheck:Jump obj:* - fun:(below main) -} - -{ - <insert a suppression name here> - Memcheck:Jump - obj:* - fun:main -} - -{ - FreeBSD i386 - Memcheck:Jump - obj:* - fun:_*_start1 - fun:(below main) } diff --git a/none/tests/filter_fdleak b/none/tests/filter_fdleak index b56c563f51..76a6b5b139 100755 --- a/none/tests/filter_fdleak +++ b/none/tests/filter_fdleak @@ -30,4 +30,4 @@ perl -p -0 -e 's/(Open[^\n]*\n)( (at|by)[^\n]*\n)+/$1 ...\n/gs' | # With glibc debuginfo installed we might see syscall-template.S, close.c or creat64.c perl -p -e "s/\(syscall-template.S:[0-9]*\)/(in \/...libc...)/" | perl -p -e "s/\(close.c:[0-9]*\)/(in \/...libc...)/" | -perl -p -e "s/\(creat64.c:[0-9]*\)/(in \/...libc...)/" +perl -p -e "s/\(creat(?:64)?.c:[0-9]*\)/(in \/...libc...)/" |
From: Paul F. <pa...@so...> - 2024-03-16 16:05:48
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=203b7356b56bb4e2b86c37d45af017c39c995161 commit 203b7356b56bb4e2b86c37d45af017c39c995161 Author: Paul Floyd <pj...@wa...> Date: Sat Mar 16 17:00:17 2024 +0100 regtest: use in 'if' in memcheck/tests/manuel1 clang tends to use cmov and csel instructions with the result that the undefinedness propagates into the printf with a variable number of errors. Diff: --- memcheck/tests/Makefile.am | 1 - memcheck/tests/manuel1.c | 9 ++++++- memcheck/tests/manuel1.stderr.exp-freebsd-clang | 33 ------------------------- 3 files changed, 8 insertions(+), 35 deletions(-) diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index ea8f3e90d5..150e632ccd 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -259,7 +259,6 @@ EXTRA_DIST = \ malloc2.stderr.exp malloc2.vgtest \ malloc3.stderr.exp malloc3.stdout.exp malloc3.vgtest \ manuel1.stderr.exp manuel1.stdout.exp manuel1.vgtest \ - manuel1.stderr.exp-freebsd-clang \ manuel2.stderr.exp manuel2.stderr.exp64 manuel2.stdout.exp \ manuel2.vgtest \ manuel3.stderr.exp manuel3.vgtest \ diff --git a/memcheck/tests/manuel1.c b/memcheck/tests/manuel1.c index f2030e4b7f..39b6c9ef29 100644 --- a/memcheck/tests/manuel1.c +++ b/memcheck/tests/manuel1.c @@ -4,7 +4,14 @@ int main () { int x; - printf ("x = %d\n", x==0xCAFEBABE ? 99 : 88); + if (x==0xCAFEBABE) + { + printf ("x = %d\n", 99); + } + else + { + printf ("x = %d\n", 88); + } return 0; } diff --git a/memcheck/tests/manuel1.stderr.exp-freebsd-clang b/memcheck/tests/manuel1.stderr.exp-freebsd-clang deleted file mode 100644 index e658adb7e3..0000000000 --- a/memcheck/tests/manuel1.stderr.exp-freebsd-clang +++ /dev/null @@ -1,33 +0,0 @@ -[[[ -Conditional jump or move depends on uninitialised value(s) - ... - by 0x........: main (manuel1.c:7) - -[[[ -Conditional jump or move depends on uninitialised value(s) - ... - by 0x........: main (manuel1.c:7) - -[[[ -Conditional jump or move depends on uninitialised value(s) - ... - by 0x........: main (manuel1.c:7) - -[[[ -Conditional jump or move depends on uninitialised value(s) - ... - by 0x........: main (manuel1.c:7) - -[[[ -Conditional jump or move depends on uninitialised value(s) - ... - by 0x........: main (manuel1.c:7) - -[[[ -Syscall param write(buf) points to uninitialised byte(s) - ... - Address 0x........ is 4 bytes inside a block of size 131,072 alloc'd - at 0x........: malloc (vg_replace_malloc.c:...) - ... - by 0x........: main (manuel1.c:7) - |
From: Paul F. <pa...@so...> - 2024-03-16 08:22:51
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=937e74be719f8d727d81875357b8510799d3bb6e commit 937e74be719f8d727d81875357b8510799d3bb6e Author: Paul Floyd <pj...@wa...> Date: Sat Mar 16 09:22:18 2024 +0100 Add rh2257546_* to .gitignore Diff: --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 9b19e6fa90..126c2e5e4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1071,6 +1071,8 @@ /memcheck/tests/amd64/sh-mem-vec128 /memcheck/tests/amd64/sh-mem-vec256 /memcheck/tests/amd64/xsave-avx +/memcheck/tests/amd64/rh2257546_128 +/memcheck/tests/amd64/rh2257546_256 # /memcheck/tests/amd64-linux/ /memcheck/tests/amd64-linux/.deps |