From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 58C3C3858D39 for ; Wed, 28 Feb 2024 21:40:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 58C3C3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 58C3C3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::432 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709156411; cv=none; b=IzfeEx7mKtqLhVV+kC18gASkNTb+RXXVhLlHRyz+KyMN2z1HJACo60RhVX7h4oa3f5f3dlfwECdYe2chS0nylfP4kSyeezwkDjCTdhHK9+mVao2IQ9AcnY+x72PXrb+hQekyO8rsQqD4ToAInmZGb2k1g3iLvIY7vUGbxYUIPgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709156411; c=relaxed/simple; bh=9F5cVAWbbjFRvyYTdt+wp3M4Fdt5Z3w+EABMpBpFcfo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=By7z7JOdSQWWYvSOc2NrcRKgiahxyeN8XHjSTfIUdjzuB6Tu/bdB5BCalvGmpYkFd/pI+u0SiPyOG74p+TzsjTh2lKZf540rO69u3EPz8ohznb0R+Is0g9tIx0inq4AVQKOheJv5CLy5rtR5FSHvWoCVsMRTikhR9WoPBB2ZAgM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-33d146737e6so192653f8f.0 for ; Wed, 28 Feb 2024 13:40:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709156408; x=1709761208; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Rktau1ZZ/qtOgFZfrgiW5gz4FeWX2CZ6bcUU2CcQCZo=; b=WC27n0/WjlkXOJG2zB2CCwwbuv6n/3r7xWXCTtS9Q1qWIQJzwR7c6HQ+q6qixjBKbj 7OKQZISoF8MxykDkBr5kBMl1rRtkMFmJ+T7Rc7TE22xYnnEypodZ+vDxI+CJZp7d1oL5 D7QYuZjRFd5PpDVzEEwkxrxd1ySqAaxFQBBhcr7rZeqYRVbbhM5WP/As7TAOO8P8qzav 9V7G52BJBRow8e4dVKzxfZ4tRAEugKTd+J+c4nATmKNl5vAk2nOrhdAAVcPe6zObtb26 8hchtdqdeIqkTUh8sB6B686PoHcGoKmZGAdnPal8vyc4Up5lio7EI89ojxL7E1qn4qHG Wl7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709156408; x=1709761208; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Rktau1ZZ/qtOgFZfrgiW5gz4FeWX2CZ6bcUU2CcQCZo=; b=wy/S7ge11XERY08lPSHlNQ4D8HkwjtMo0RTdrFfSUbOgCyQEE1Yn5hSIJLsGTwq137 XLUdP9quoWadbmR88jqloiklwPmXZoqzfv9wrQASAZx5ReVq1KWNaTIOHZHF4IfWT8Vi 9ozkoLq/iJIkgGAtrrxuqxyD4n7yT2mZcQBel1UyxBFeX3gKnFVo6G5QFfuUypWwCGsG HAkity9rFkAD/HRtOIEuwUzeXFDhAfooSK39NfUBicy+WAH+EhtbYZOhY6VGDdvmSKQY XxaHfXB27sivBjJtCiGxu764fIez4RDHTnKdZZ1vdWjJ2BVGa3nzF1GGm3fx9R84hoos eOAw== X-Gm-Message-State: AOJu0YzvnDKHCvUte8jRUof0qdEGPzOdCx5fevCqCDVcAeW2UqpG4FKD 0cX0qMumUJCBk+F0EC6rU6wT3JgIop9tOG3iyM4MesrB9mt9UdPqK4NRTDYCGKMnnz3vYDaXrzt h83kX93oVHc9u6dc1mEOFU/Szj6ymTBWGogs= X-Google-Smtp-Source: AGHT+IHbXqEaKp4DikaAuN/qS1n6rq88s1bLizGqx/RQxTygioHjLfjnsm4qp7QlZNIzRFC3Lq8A7viLDqs6y2IWj/Y= X-Received: by 2002:a5d:6042:0:b0:33d:827:145d with SMTP id j2-20020a5d6042000000b0033d0827145dmr64823wrt.42.1709156407910; Wed, 28 Feb 2024 13:40:07 -0800 (PST) MIME-Version: 1.0 References: <20240226000326.3844791-1-hjl.tools@gmail.com> In-Reply-To: <20240226000326.3844791-1-hjl.tools@gmail.com> From: Sunil Pandey Date: Wed, 28 Feb 2024 13:39:31 -0800 Message-ID: Subject: Re: [PATCH] x86_64: Suppress false positive valgrind error To: "H.J. Lu" Cc: libc-alpha@sourceware.org Content-Type: multipart/alternative; boundary="0000000000008f2d65061277fc76" X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_0,HK_RANDOM_ENVFROM,HK_RANDOM_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000008f2d65061277fc76 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Feb 25, 2024 at 4:03=E2=80=AFPM H.J. Lu wrote: > When strcmp-avx2.S is used as the default, elf/tst-valgrind-smoke fails > with > > =3D=3D1272761=3D=3D Conditional jump or move depends on uninitialised val= ue(s) > =3D=3D1272761=3D=3D at 0x4022C98: strcmp (strcmp-avx2.S:462) > =3D=3D1272761=3D=3D by 0x400B05B: _dl_name_match_p (dl-misc.c:75) > =3D=3D1272761=3D=3D by 0x40085F3: _dl_map_object (dl-load.c:1966) > =3D=3D1272761=3D=3D by 0x401AEA4: map_doit (rtld.c:644) > =3D=3D1272761=3D=3D by 0x4001488: _dl_catch_exception (dl-catch.c:237) > =3D=3D1272761=3D=3D by 0x40015AE: _dl_catch_error (dl-catch.c:256) > =3D=3D1272761=3D=3D by 0x401B38F: do_preload (rtld.c:816) > =3D=3D1272761=3D=3D by 0x401C116: handle_preload_list (rtld.c:892) > =3D=3D1272761=3D=3D by 0x401EDF5: dl_main (rtld.c:1842) > =3D=3D1272761=3D=3D by 0x401A79E: _dl_sysdep_start (dl-sysdep.c:140) > =3D=3D1272761=3D=3D by 0x401BEEE: _dl_start_final (rtld.c:494) > =3D=3D1272761=3D=3D by 0x401BEEE: _dl_start (rtld.c:581) > =3D=3D1272761=3D=3D by 0x401AD87: ??? (in */elf/ld.so) > > The assembly codes are: > > 0x0000000004022c80 <+144>: vmovdqu 0x20(%rdi),%ymm0 > 0x0000000004022c85 <+149>: vpcmpeqb 0x20(%rsi),%ymm0,%ymm1 > 0x0000000004022c8a <+154>: vpcmpeqb %ymm0,%ymm15,%ymm2 > 0x0000000004022c8e <+158>: vpandn %ymm1,%ymm2,%ymm1 > 0x0000000004022c92 <+162>: vpmovmskb %ymm1,%ecx > 0x0000000004022c96 <+166>: inc %ecx > =3D> 0x0000000004022c98 <+168>: jne 0x4022c32 > > strcmp-avx2.S has 32-byte vector loads of strings which are shorter than > 32 bytes: > > (gdb) p (char *) ($rdi + 0x20) > $6 =3D 0x1ffeffea20 "memcheck-amd64-linux.so" > (gdb) p (char *) ($rsi + 0x20) > $7 =3D 0x4832640 "core-amd64-linux.so" > (gdb) call (int) strlen ((char *) ($rsi + 0x20)) > $8 =3D 19 > (gdb) call (int) strlen ((char *) ($rdi + 0x20)) > $9 =3D 23 > (gdb) > > It triggers the valgrind error. The above code is safe since the loads > don't cross the page boundary. Update tst-valgrind-smoke.sh to accept > an optional suppression file and pass a suppression file to valgrind when > strcmp-avx2.S is the default implementation of strcmp. > --- > elf/Makefile | 3 ++- > elf/tst-valgrind-smoke.sh | 5 +++-- > sysdeps/x86_64/Makefile | 6 ++++++ > sysdeps/x86_64/tst-valgrind-smoke.supp | 17 +++++++++++++++++ > 4 files changed, 28 insertions(+), 3 deletions(-) > create mode 100644 sysdeps/x86_64/tst-valgrind-smoke.supp > > diff --git a/elf/Makefile b/elf/Makefile > index 36c04baf02..9d7190f708 100644 > --- a/elf/Makefile > +++ b/elf/Makefile > @@ -616,7 +616,8 @@ tests-special +=3D $(objpfx)tst-valgrind-smoke.out > endif > $(objpfx)tst-valgrind-smoke.out: tst-valgrind-smoke.sh $(objpfx)ld.so > $(objpfx)valgrind-test > $(SHELL) $< $(objpfx)ld.so $(rtlddir)/$(rtld-installed-name) > '$(test-wrapper-env)' \ > - '$(run-program-env)' '$(rpath-link)' > $(objpfx)valgrind-test > $@; $(evaluate-test) > + '$(run-program-env)' '$(rpath-link)' > $(objpfx)valgrind-test \ > + '$(valgrind-suppressions-tst-valgrind-smoke)' > $@; > $(evaluate-test) > > tests +=3D $(tests-execstack-$(have-z-execstack)) > ifeq ($(run-built-tests),yes) > diff --git a/elf/tst-valgrind-smoke.sh b/elf/tst-valgrind-smoke.sh > index e33b2fa1d7..7d0ceac6b1 100644 > --- a/elf/tst-valgrind-smoke.sh > +++ b/elf/tst-valgrind-smoke.sh > @@ -25,6 +25,7 @@ test_wrapper_env=3D"$3" > run_program_env=3D"$4" > library_path=3D"$5" > test_prog=3D"$6" > +valgrind_suppressions=3D"$7" > > # Test whether valgrind is available in the test > # environment. If not, skip the test. > @@ -34,7 +35,7 @@ ${test_wrapper_env} ${run_program_env} \ > # Test valgrind works with the system ld.so in the test environment > /bin/sh -c \ > "${test_wrapper_env} ${run_program_env} \ > - valgrind -q --error-exitcode=3D1 \ > + valgrind -q --error-exitcode=3D1 ${valgrind_suppressions} \ > ${system_rtld} /bin/echo ${system_rtld}" || exit 77 > > # Finally the actual test inside the test environment, > @@ -42,5 +43,5 @@ ${test_wrapper_env} ${run_program_env} \ > # the smoke test under valgrind. > /bin/sh -c \ > "${test_wrapper_env} ${run_program_env} \ > - valgrind -q --error-exitcode=3D1 \ > + valgrind -q --error-exitcode=3D1 ${valgrind_suppressions} \ > ${rtld} --library-path ${library_path} ${test_prog} ${rtld}" > diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile > index 145f25e7f6..07b4a532ae 100644 > --- a/sysdeps/x86_64/Makefile > +++ b/sysdeps/x86_64/Makefile > @@ -211,6 +211,12 @@ tst-plt-rewrite2-ENV =3D > GLIBC_TUNABLES=3Dglibc.cpu.plt_rewrite=3D2 > $(objpfx)tst-plt-rewrite2: $(objpfx)tst-plt-rewritemod2.so > endif > > +# Check if ISA level is 3 or above. > +ifneq (,$(filter $(have-x86-isa-level),$(x86-isa-level-3-or-above))) > +valgrind-suppressions-tst-valgrind-smoke =3D \ > + --suppressions=3D$(..)sysdeps/x86_64/tst-valgrind-smoke.supp > +endif > + > endif # $(subdir) =3D=3D elf > > ifeq ($(subdir),csu) > diff --git a/sysdeps/x86_64/tst-valgrind-smoke.supp > b/sysdeps/x86_64/tst-valgrind-smoke.supp > new file mode 100644 > index 0000000000..533c2deaff > --- /dev/null > +++ b/sysdeps/x86_64/tst-valgrind-smoke.supp > @@ -0,0 +1,17 @@ > +{ > + False positive at strcmp-avx2.S:462 > + Memcheck:Cond > + fun:strcmp > + fun:_dl_name_match_p > + fun:_dl_map_object > + fun:map_doit > + fun:_dl_catch_exception > + fun:_dl_catch_error > + fun:do_preload > + fun:handle_preload_list > + fun:dl_main > + fun:_dl_sysdep_start > + fun:_dl_start_final > + fun:_dl_start > + obj:*/elf/ld.so > +} > -- > 2.43.2 > LGTM Reviewed-by: Sunil K Pandey --0000000000008f2d65061277fc76--