From patchwork Mon Feb 26 00:03:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 86350 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B2DE3858409 for ; Mon, 26 Feb 2024 00:03:59 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id BAA9E3858D39 for ; Mon, 26 Feb 2024 00:03:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BAA9E3858D39 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 BAA9E3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708905813; cv=none; b=FVpaawwK6WIVoiFFF/igVIUrqXZhJGV6cWAUWawAveV14BiYuQQ4KBvw6RTwajr/eLgnyoZCmB9nNO3EPFde/hykV4B57zlJ6O7cG0I9JZvgX0va6ln6Qp+hasPj4osZGn01pSyJKlbYKZb3o/YvJKRd74VQ+Jwr9utoxloD/+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708905813; c=relaxed/simple; bh=zoTyfeBl7H6sjivyyxiOcnC1/pgQ1c/fiUVYkDlZwkY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=USEVhJA9IRxEceYi57iUYCnjXlaK/VcJbDOKtpCyhnaGxHYyMKwfuS1o8l//1n4tJbTkSkrXhcxKOVmxf1DW7gdQhrALWn/spzwX58viuCnxAUkk0lD8qe1mAWfhI6bQ96Z2aGGF5EIad3IAj7uxCDZZkXKJ9Ecauyw/Ivb1MQs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-5d8b70b39efso2730194a12.0 for ; Sun, 25 Feb 2024 16:03:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708905808; x=1709510608; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=x5Wy64nZnYkHIStehCMlhYaGxsOBNbSgPdQi0bY/g0w=; b=QCdgOnHrXqcwHzGqrL1IDX9WZNJEmzb8tSsqyV5AB0Q9FgipzlPj5ImFtj57izRLCE NnD9/1WlrdCbg/s2MsRPHwfNROseUYjG0Kl95PZWjapE6mkW8R14a4Ps6T6r/TtWIoHS dfmCQUbrCr3bQSioLtwjW8OMR/V+utKYvZt3wXV1Y5d6Rg9VHXYXP0yddg5dUMg78Iv9 GPuq/7/sjhxi1urQZGLT907aCWS9d58ccvRaR9QjnfU4JjggPkWZdbT2NJARG+liGr1o Wc/kd/sP372DIWp5f0hBd+gvDI2XDJZcq/Dtc101Hi2Ml2jirYcsc/UFsrhWbt6ueesv Zw/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708905808; x=1709510608; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=x5Wy64nZnYkHIStehCMlhYaGxsOBNbSgPdQi0bY/g0w=; b=gRIIxRXZ8A31T7psjGestAunrDfurJ12kLJYQNBNxAq/1DdjpbmmJX1j8asaCY081R mxkC+Z6nYs3XSxBYjQsqOwK0u7LCptnmNruZ8szaouGUtcTL7lWo2zTx5naRV0XBJ4rc ce94sL/FqAC1mJMGAKb+6Kum3I/l5OAwnzw6wFiModAYG2A+2dOazB+rI5dn++OAMNj/ bZzeS4nHbb+ixNOEVIYsWdnFsnVtzasn1pGIPrQG6yCVf1ZyJcSC9LrYsd12yhNM0UZ/ yKEUy9CgPHjJfXG9T7OYHxeWfmKra4Wxp8DlbiE8YX2Hm/fdhQ5TdoviE6Qj2DZaEX61 oN9g== X-Gm-Message-State: AOJu0Ywmmra41s5GLNolOfaW8LGiDPTaRzqpDMgPnaeaYomnPRMN590v WW8kuofs+YJZ0GEVvM9Ow25l177hm3ka0g1pQcjZ0mUuHVVDP9q83MW7kT9h X-Google-Smtp-Source: AGHT+IHdT/Xhsm5ygzHCypPIKazjSa8aTHZ+bnKqeRkNux8TgADzl3x6TI3UN1BHso6Z59tvejCxww== X-Received: by 2002:a05:6a20:d706:b0:1a0:ef2c:eeec with SMTP id iz6-20020a056a20d70600b001a0ef2ceeecmr2676930pzb.40.1708905808213; Sun, 25 Feb 2024 16:03:28 -0800 (PST) Received: from gnu-tgl-2.localdomain ([172.58.89.72]) by smtp.gmail.com with ESMTPSA id d7-20020a056a0010c700b006e2b23ea858sm2780477pfu.195.2024.02.25.16.03.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 16:03:27 -0800 (PST) Received: from gnu-tgl-2.. (localhost [IPv6:::1]) by gnu-tgl-2.localdomain (Postfix) with ESMTP id ADBB3300C9C for ; Sun, 25 Feb 2024 16:03:26 -0800 (PST) From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH] x86_64: Suppress false positive valgrind error Date: Sun, 25 Feb 2024 16:03:26 -0800 Message-ID: <20240226000326.3844791-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Spam-Status: No, score=-3021.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org When strcmp-avx2.S is used as the default, elf/tst-valgrind-smoke fails with ==1272761== Conditional jump or move depends on uninitialised value(s) ==1272761== at 0x4022C98: strcmp (strcmp-avx2.S:462) ==1272761== by 0x400B05B: _dl_name_match_p (dl-misc.c:75) ==1272761== by 0x40085F3: _dl_map_object (dl-load.c:1966) ==1272761== by 0x401AEA4: map_doit (rtld.c:644) ==1272761== by 0x4001488: _dl_catch_exception (dl-catch.c:237) ==1272761== by 0x40015AE: _dl_catch_error (dl-catch.c:256) ==1272761== by 0x401B38F: do_preload (rtld.c:816) ==1272761== by 0x401C116: handle_preload_list (rtld.c:892) ==1272761== by 0x401EDF5: dl_main (rtld.c:1842) ==1272761== by 0x401A79E: _dl_sysdep_start (dl-sysdep.c:140) ==1272761== by 0x401BEEE: _dl_start_final (rtld.c:494) ==1272761== by 0x401BEEE: _dl_start (rtld.c:581) ==1272761== 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 => 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 = 0x1ffeffea20 "memcheck-amd64-linux.so" (gdb) p (char *) ($rsi + 0x20) $7 = 0x4832640 "core-amd64-linux.so" (gdb) call (int) strlen ((char *) ($rsi + 0x20)) $8 = 19 (gdb) call (int) strlen ((char *) ($rdi + 0x20)) $9 = 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. Reviewed-by: Sunil K Pandey --- 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 += $(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 += $(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="$3" run_program_env="$4" library_path="$5" test_prog="$6" +valgrind_suppressions="$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=1 \ + valgrind -q --error-exitcode=1 ${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=1 \ + valgrind -q --error-exitcode=1 ${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 = GLIBC_TUNABLES=glibc.cpu.plt_rewrite=2 $(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 = \ + --suppressions=$(..)sysdeps/x86_64/tst-valgrind-smoke.supp +endif + endif # $(subdir) == 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 +}