From patchwork Mon Jul 8 22:42:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 13727089 Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 998B514F9EB for ; Mon, 8 Jul 2024 22:42:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720478538; cv=none; b=uv4bFF0oqKcx1mvEa9OiigXz+3fsrJ0w9qUrlbyp82S7p38dbKpRpigPx4JJjpxHsl773QgVdRN869Y2YJZSKrm+CF6x2LUYh1/jVDi+0FMFax1tEV6PKmrh/NVUeCjMvFoPnpbpgrxSDRfzqjt/SbxR6jWz2dQ2a6fuK1DvPE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720478538; c=relaxed/simple; bh=/Csvsngo9An8lKU/uqQ4PwREsIrRpApsjXkFtThY7r8=; h=Content-Type:Message-ID:Date:MIME-Version:To:Cc:From:Subject; b=RCQpfbtwwaXPmMtXkmir+ha0TnLdmij/ch1SuBWYW6cEyhJ+X8lFxAagFBoeIr2adKNqQczy3kuFMr0v/YmnlrO6mb1a7LDww/X+H3C0kgrgfg5Iq9nw54qShPaHBv5ssCCYruWLzS89wqzyM5R1Z9PFUeb2xg1uZrtuXISUvIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Wb+6dTgb; arc=none smtp.client-ip=209.85.166.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Wb+6dTgb" Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-7f906800b4cso6712139f.3 for ; Mon, 08 Jul 2024 15:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1720478535; x=1721083335; darn=vger.kernel.org; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=zovC7QVd34p3m3CAUQtKD0SY4AbJLTNsaDdpwwBJTts=; b=Wb+6dTgbdGvPtSRwmyyhj0vR1ykqLi7imYM2vRbuYaVP+b6N2D/h1/1kXOfhKh42AB mCxjAfU/1V3lyD1E8aksj8eLveOcdx9UeTGMdJhaxpKDkosp36IQgSbO9vkz8/ZEbQKK jrPWF234xMwNe2rTAtpNpkl90qLU8NrOTkSVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720478535; x=1721083335; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zovC7QVd34p3m3CAUQtKD0SY4AbJLTNsaDdpwwBJTts=; b=vizNBo/0W9+q7/PshijL4XSkhg2UT3BOvFRsHV94Vy050P4nyEY1HthhFt4HHcxo9U 6tT8t8vaxYYymNNoLdrpu5Cw3v5hvuAr7daUOvgDyQzzveHPWAEJBEdsV8sUJKT50fxS YvLr32Wx7craeeUwZj5F8OG5ZXnfZZqYVxwnJ2AfSDedca2NtKQQm/o4y6JMXeXJKSiX RkG4TUIRZT0i9g9rGn9BfIiO0HulxkekZ0uyMPKrwywU/NMs4OwgZnny3j8P+nnZOUND YE3+cL8hUyM3q/ZPgkA89Gl3HXxiK91rcFqYbWKxeIEt3SL0GiOnKu9Hpu2uQm45+khp /jqA== X-Forwarded-Encrypted: i=1; AJvYcCWwuZ43VGTuHhedsuY4FT//w6fgS/Quhyt/zXIY0ifFL+eqiTYie3xv3FEFsb6iRjb3U7lLVTinrihig1lg2SCYFx9uI+pYJOqk09x4APFj X-Gm-Message-State: AOJu0YyDK9tYRFsmAXAiJ1FDc0GUqHKM8XGS1ijJyzPqn61yohCkFI61 Y/haCX3f7/V34QPjxrw4NZxKLnVB0FcSbQ3txOQwoS+u0r/vdOucc/BUojWXFAU= X-Google-Smtp-Source: AGHT+IHTLYyh+Jcy22XXxAXWdWcQhiGYB2223bdTg2DFGSeQOJUGmgTMYU8u4DP+IJaVFlGDvso5HA== X-Received: by 2002:a05:6602:6199:b0:7f3:d3ed:1ca3 with SMTP id ca18e2360f4ac-80001930275mr119437339f.1.1720478534710; Mon, 08 Jul 2024 15:42:14 -0700 (PDT) Received: from [192.168.1.128] ([38.175.170.29]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c0b1bf65f0sm182528173.93.2024.07.08.15.42.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Jul 2024 15:42:14 -0700 (PDT) Message-ID: <7007e67e-0af4-4b01-a708-ba108208b217@linuxfoundation.org> Date: Mon, 8 Jul 2024 16:42:13 -0600 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Linus Torvalds Cc: Shuah Khan , shuah , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, John Hubbard , "Jason A. Donenfeld" From: Shuah Khan Subject: [GIT PULL] Kselftest fixes for Linux 6.10 Hi Linus, Please pull this kselftest fixes update for Linux 6.10. This kselftest fixes update for Linux 6.10 consists of fixes to clang build failures to timerns, vDSO tests and fixes to vDSO makefile. Note: makefile fixes are included to avoid conflicts during 6.11 merge window. diff is attached. thanks, -- Shuah ---------------------------------------------------------------- The following changes since commit 48236960c06d32370bfa6f2cc408e786873262c8: selftests/resctrl: Fix non-contiguous CBM for AMD (2024-06-26 13:22:34 -0600) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-fixes-6.10 for you to fetch changes up to 66cde337fa1b7c6cf31f856fa015bd91a4d383e7: selftests/vDSO: remove duplicate compiler invocations from Makefile (2024-07-05 14:12:34 -0600) ---------------------------------------------------------------- linux_kselftest-fixes-6.10 This kselftest fixes update for Linux 6.10 consists of fixes to clang build failures to timerns, vDSO tests and fixes to vDSO makefile. ---------------------------------------------------------------- John Hubbard (4): selftest/timerns: fix clang build failures for abs() calls selftests/vDSO: fix clang build errors and warnings selftests/vDSO: remove partially duplicated "all:" target in Makefile selftests/vDSO: remove duplicate compiler invocations from Makefile tools/testing/selftests/timens/exec.c | 6 ++--- tools/testing/selftests/timens/timer.c | 2 +- tools/testing/selftests/timens/timerfd.c | 2 +- tools/testing/selftests/timens/vfork_exec.c | 4 +-- tools/testing/selftests/vDSO/Makefile | 29 +++++++++------------- tools/testing/selftests/vDSO/parse_vdso.c | 16 ++++++++---- .../selftests/vDSO/vdso_standalone_test_x86.c | 18 ++++++++++++-- 7 files changed, 46 insertions(+), 31 deletions(-) ---------------------------------------------------------------- diff --git a/tools/testing/selftests/timens/exec.c b/tools/testing/selftests/timens/exec.c index e40dc5be2f66..d12ff955de0d 100644 --- a/tools/testing/selftests/timens/exec.c +++ b/tools/testing/selftests/timens/exec.c @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) for (i = 0; i < 2; i++) { _gettime(CLOCK_MONOTONIC, &tst, i); - if (abs(tst.tv_sec - now.tv_sec) > 5) + if (labs(tst.tv_sec - now.tv_sec) > 5) return pr_fail("%ld %ld\n", now.tv_sec, tst.tv_sec); } return 0; @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) for (i = 0; i < 2; i++) { _gettime(CLOCK_MONOTONIC, &tst, i); - if (abs(tst.tv_sec - now.tv_sec) > 5) + if (labs(tst.tv_sec - now.tv_sec) > 5) return pr_fail("%ld %ld\n", now.tv_sec, tst.tv_sec); } @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) /* Check that a child process is in the new timens. */ for (i = 0; i < 2; i++) { _gettime(CLOCK_MONOTONIC, &tst, i); - if (abs(tst.tv_sec - now.tv_sec - OFFSET) > 5) + if (labs(tst.tv_sec - now.tv_sec - OFFSET) > 5) return pr_fail("%ld %ld\n", now.tv_sec + OFFSET, tst.tv_sec); } diff --git a/tools/testing/selftests/timens/timer.c b/tools/testing/selftests/timens/timer.c index 5e7f0051bd7b..5b939f59dfa4 100644 --- a/tools/testing/selftests/timens/timer.c +++ b/tools/testing/selftests/timens/timer.c @@ -56,7 +56,7 @@ int run_test(int clockid, struct timespec now) return pr_perror("timerfd_gettime"); elapsed = new_value.it_value.tv_sec; - if (abs(elapsed - 3600) > 60) { + if (llabs(elapsed - 3600) > 60) { ksft_test_result_fail("clockid: %d elapsed: %lld\n", clockid, elapsed); return 1; diff --git a/tools/testing/selftests/timens/timerfd.c b/tools/testing/selftests/timens/timerfd.c index 9edd43d6b2c1..a4196bbd6e33 100644 --- a/tools/testing/selftests/timens/timerfd.c +++ b/tools/testing/selftests/timens/timerfd.c @@ -61,7 +61,7 @@ int run_test(int clockid, struct timespec now) return pr_perror("timerfd_gettime(%d)", clockid); elapsed = new_value.it_value.tv_sec; - if (abs(elapsed - 3600) > 60) { + if (llabs(elapsed - 3600) > 60) { ksft_test_result_fail("clockid: %d elapsed: %lld\n", clockid, elapsed); return 1; diff --git a/tools/testing/selftests/timens/vfork_exec.c b/tools/testing/selftests/timens/vfork_exec.c index beb7614941fb..5b8907bf451d 100644 --- a/tools/testing/selftests/timens/vfork_exec.c +++ b/tools/testing/selftests/timens/vfork_exec.c @@ -32,7 +32,7 @@ static void *tcheck(void *_args) for (i = 0; i < 2; i++) { _gettime(CLOCK_MONOTONIC, &tst, i); - if (abs(tst.tv_sec - now->tv_sec) > 5) { + if (labs(tst.tv_sec - now->tv_sec) > 5) { pr_fail("%s: in-thread: unexpected value: %ld (%ld)\n", args->tst_name, tst.tv_sec, now->tv_sec); return (void *)1UL; @@ -64,7 +64,7 @@ static int check(char *tst_name, struct timespec *now) for (i = 0; i < 2; i++) { _gettime(CLOCK_MONOTONIC, &tst, i); - if (abs(tst.tv_sec - now->tv_sec) > 5) + if (labs(tst.tv_sec - now->tv_sec) > 5) return pr_fail("%s: unexpected value: %ld (%ld)\n", tst_name, tst.tv_sec, now->tv_sec); } diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile index d53a4d8008f9..98d8ba2afa00 100644 --- a/tools/testing/selftests/vDSO/Makefile +++ b/tools/testing/selftests/vDSO/Makefile @@ -1,35 +1,30 @@ # SPDX-License-Identifier: GPL-2.0 -include ../lib.mk - uname_M := $(shell uname -m 2>/dev/null || echo not) ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) -TEST_GEN_PROGS := $(OUTPUT)/vdso_test_gettimeofday $(OUTPUT)/vdso_test_getcpu -TEST_GEN_PROGS += $(OUTPUT)/vdso_test_abi -TEST_GEN_PROGS += $(OUTPUT)/vdso_test_clock_getres +TEST_GEN_PROGS := vdso_test_gettimeofday +TEST_GEN_PROGS += vdso_test_getcpu +TEST_GEN_PROGS += vdso_test_abi +TEST_GEN_PROGS += vdso_test_clock_getres ifeq ($(ARCH),$(filter $(ARCH),x86 x86_64)) -TEST_GEN_PROGS += $(OUTPUT)/vdso_standalone_test_x86 +TEST_GEN_PROGS += vdso_standalone_test_x86 endif -TEST_GEN_PROGS += $(OUTPUT)/vdso_test_correctness +TEST_GEN_PROGS += vdso_test_correctness CFLAGS := -std=gnu99 -CFLAGS_vdso_standalone_test_x86 := -nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector -LDFLAGS_vdso_test_correctness := -ldl + ifeq ($(CONFIG_X86_32),y) LDLIBS += -lgcc_s endif -all: $(TEST_GEN_PROGS) +include ../lib.mk $(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c $(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c $(OUTPUT)/vdso_test_abi: parse_vdso.c vdso_test_abi.c $(OUTPUT)/vdso_test_clock_getres: vdso_test_clock_getres.c + $(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c - $(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \ - vdso_standalone_test_x86.c parse_vdso.c \ - -o $@ +$(OUTPUT)/vdso_standalone_test_x86: CFLAGS +=-nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector + $(OUTPUT)/vdso_test_correctness: vdso_test_correctness.c - $(CC) $(CFLAGS) \ - vdso_test_correctness.c \ - -o $@ \ - $(LDFLAGS_vdso_test_correctness) +$(OUTPUT)/vdso_test_correctness: LDFLAGS += -ldl diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c index 413f75620a35..4ae417372e9e 100644 --- a/tools/testing/selftests/vDSO/parse_vdso.c +++ b/tools/testing/selftests/vDSO/parse_vdso.c @@ -55,14 +55,20 @@ static struct vdso_info ELF(Verdef) *verdef; } vdso_info; -/* Straight from the ELF specification. */ -static unsigned long elf_hash(const unsigned char *name) +/* + * Straight from the ELF specification...and then tweaked slightly, in order to + * avoid a few clang warnings. + */ +static unsigned long elf_hash(const char *name) { unsigned long h = 0, g; - while (*name) + const unsigned char *uch_name = (const unsigned char *)name; + + while (*uch_name) { - h = (h << 4) + *name++; - if (g = h & 0xf0000000) + h = (h << 4) + *uch_name++; + g = h & 0xf0000000; + if (g) h ^= g >> 24; h &= ~g; } diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c index 8a44ff973ee1..27f6fdf11969 100644 --- a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c +++ b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c @@ -18,7 +18,7 @@ #include "parse_vdso.h" -/* We need a libc functions... */ +/* We need some libc functions... */ int strcmp(const char *a, const char *b) { /* This implementation is buggy: it never returns -1. */ @@ -34,6 +34,20 @@ int strcmp(const char *a, const char *b) return 0; } +/* + * The clang build needs this, although gcc does not. + * Stolen from lib/string.c. + */ +void *memcpy(void *dest, const void *src, size_t count) +{ + char *tmp = dest; + const char *s = src; + + while (count--) + *tmp++ = *s++; + return dest; +} + /* ...and two syscalls. This is x86-specific. */ static inline long x86_syscall3(long nr, long a0, long a1, long a2) { @@ -70,7 +84,7 @@ void to_base10(char *lastdig, time_t n) } } -__attribute__((externally_visible)) void c_main(void **stack) +void c_main(void **stack) { /* Parse the stack */ long argc = (long)*stack;