From patchwork Fri Jun 20 21:39:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 898532 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6F43238C0F; Fri, 20 Jun 2025 21:39:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750455589; cv=none; b=KkxS7Rc7Gzfp5hm4R4mLFP7R+PIsfcuospWrGmahloLLxQDdQzwK0oXnHf62TFkyVLnONGMt4+tkmHqZGd54MORg0SESp0eGNeQUxZd7wh8ucg641+glyHzSqSu3VLNS7NtfIlHUoQbqhmrJSzni8oy2wmbFoR2StUgWVzbTknI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750455589; c=relaxed/simple; bh=txCjIBp7fMZKfcJXO+z5XgGsJrosp+zHd4noDHk6vuM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FRaWPfyrNhPf7dC7mYakV/URrD1ouIuKz6o7lgje9JiLoogtHSWHaP1o37wz0DwpoWvSpbzEqdQASvii2AyGuS6ABrYxW5ZmSJIvEozBhqD1YDoArF20OHm5wcR2eSr3Hw/9LEDaVJNS8KriBM7AxI7/sp8DDwuYL6Ado/IBDqY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Hsy2oohI; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Hsy2oohI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1750455579; bh=txCjIBp7fMZKfcJXO+z5XgGsJrosp+zHd4noDHk6vuM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Hsy2oohIoz1NwDn9O1muFKJAOlWoVuw6/i8Mh8a8UL4pQxdZLkAuDJM/OKYOzqeXC pNp0yk3XBajEQTw+qUF6V3rKdhtkBU44hLmzMjTr2yJnr0X87zWBKnJbxQz8CLaF3y 0oOoi57r0vnHKBJWyYySbIiiOQORy3TWDGpIpHgs= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 20 Jun 2025 23:39:30 +0200 Subject: [PATCH 1/4] selftests/nolibc: drop implicit defconfig executions Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250620-nolibc-selftests-v1-1-f6b2ce7c5071@weissschuh.net> References: <20250620-nolibc-selftests-v1-0-f6b2ce7c5071@weissschuh.net> In-Reply-To: <20250620-nolibc-selftests-v1-0-f6b2ce7c5071@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1750455578; l=1451; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=txCjIBp7fMZKfcJXO+z5XgGsJrosp+zHd4noDHk6vuM=; b=9zHfwAxtjs6za0X3hhzrn51nKfJiXL4ElfDNl5TtE/Bs09o+iaqlrGyJSsTDdqHHi8Sq9tk1M 8hGY3i3oB+MD1cNSMiYbymxsmc13G1ayEp+txVut9mSMv3b6qh2cLwo X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Commit d7d271ec30dd ("selftests/nolibc: execute defconfig before other targets") accidentally introduced implicit executions of the defconfig target. These executions were unintentional and come from a misunderstanding of ordering dependencies. Drop the dependencies again. Reported-by: Mark Brown Closes: https://lore.kernel.org/all/3d5128b9-b4b6-4a8e-94ce-ea5ff4ea655b@sirena.org.uk/ Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 147ce411b46ac84ea3ee0f91a55a7bb6c0712626..41b97dfd02bff3fb57f4d2b73b718f5c389d25e9 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -307,10 +307,10 @@ defconfig: $(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) olddefconfig < /dev/null; \ fi -kernel: | defconfig +kernel: $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) < /dev/null -kernel-standalone: initramfs | defconfig +kernel-standalone: initramfs $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs < /dev/null # run the tests after building the kernel From patchwork Fri Jun 20 21:39:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 898531 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6EB8238178; Fri, 20 Jun 2025 21:39:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750455589; cv=none; b=GMtm+HGt3S9rXntEAHF7tliPVJgu1Bhc9WHrHkJ3Hr1JOYGYkYDP3DzQoAbMAZtAb+AfTGgjqCwUP/deIn6Kf4NaKA3Pwj/sQ3KOXPPp1Tb01ndT9z96c26xDr/r5rLrXa1XGZcGZsdNqm4tjQoj/UqHpyyUyDf7O6Pf5NMhEbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750455589; c=relaxed/simple; bh=6ml43yk9vOCtPWikBGN5ZCduTpE8kt0rfUh8lqsvMj4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sewlcLRw2juxO49xn32aDCNWpcemL++JPJvc4whyhknZN6wnn9uoGR+nBI05WNs82NYgePY3gyyWGjA1cWzHinf+RC5NoQf+U5mqrv72VoBH/aGrwQ+/Py+u/LoTR420WPEPM5D7UDkMQ9WAl1SG1dgAhTJoiSkSFYdNRs0zc0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=C9SVEg7/; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="C9SVEg7/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1750455579; bh=6ml43yk9vOCtPWikBGN5ZCduTpE8kt0rfUh8lqsvMj4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C9SVEg7/3edLKq9BxGqCoKi0TK9ulapsfcg1kxaMk+5t3AhgQ5xQokAHL3s+rKb/1 OsLuQgL+sHpKfqa2C9dtVSm+/VGnE8XSVVphqCrA6ga2QWHsaeWb6rHRV5L9MoOwzD CJIUmLT9icjfHRpnIZcFQ/dizL0uXY8eO5Yt6mwM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 20 Jun 2025 23:39:31 +0200 Subject: [PATCH 2/4] selftests/nolibc: split out CFLAGS logic Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250620-nolibc-selftests-v1-2-f6b2ce7c5071@weissschuh.net> References: <20250620-nolibc-selftests-v1-0-f6b2ce7c5071@weissschuh.net> In-Reply-To: <20250620-nolibc-selftests-v1-0-f6b2ce7c5071@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1750455578; l=2577; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=6ml43yk9vOCtPWikBGN5ZCduTpE8kt0rfUh8lqsvMj4=; b=kya2WzdcUMU0j+ht31ZZrJE3DWAcrPDj7HtBvA5GOekBCkyTZWKRtDDacqSfOdHCalFOHbEqh hUTeSvMwJtaAS4zXFjLLv7+ylaYexs0LmIXK1+ZnB+x0/mk+F69X9l/ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Some upcoming changes will reuse the CFLAGS. Split the computation into a reusable Makefile. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 12 ++++-------- tools/testing/selftests/nolibc/Makefile.include | 10 ++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 41b97dfd02bff3fb57f4d2b73b718f5c389d25e9..6d62f350d0c16405785a8aabc7f5741b82e55370 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -195,14 +195,10 @@ CFLAGS_sparc32 = $(call cc-option,-m32) ifeq ($(origin XARCH),command line) CFLAGS_XARCH = $(CFLAGS_$(XARCH)) endif -_CFLAGS_STACKPROTECTOR = $(call cc-option,-fstack-protector-all) $(call cc-option,-mstack-protector-guard=global) -CFLAGS_STACKPROTECTOR ?= $(call try-run, \ - echo 'void foo(void) {}' | $(CC) -x c - -o - -S $(CLANG_CROSS_FLAGS) $(_CFLAGS_STACKPROTECTOR) | grep -q __stack_chk_guard, \ - $(_CFLAGS_STACKPROTECTOR)) -CFLAGS_SANITIZER ?= $(call cc-option,-fsanitize=undefined -fsanitize-trap=all) -CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra \ - $(call cc-option,-fno-stack-protector) $(call cc-option,-Wmissing-prototypes) \ - $(CFLAGS_XARCH) $(CFLAGS_STACKPROTECTOR) $(CFLAGS_SANITIZER) $(CFLAGS_EXTRA) + +include Makefile.include + +CFLAGS ?= $(CFLAGS_NOLIBC_TEST) $(CFLAGS_XARCH) $(CFLAGS_EXTRA) LDFLAGS := LIBGCC := -lgcc diff --git a/tools/testing/selftests/nolibc/Makefile.include b/tools/testing/selftests/nolibc/Makefile.include new file mode 100644 index 0000000000000000000000000000000000000000..66287fafbbe07e1750e31c3b2388ac4be1e7f8ae --- /dev/null +++ b/tools/testing/selftests/nolibc/Makefile.include @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0 + +__CFLAGS_STACKPROTECTOR = $(call cc-option,-fstack-protector-all) $(call cc-option,-mstack-protector-guard=global) +_CFLAGS_STACKPROTECTOR ?= $(call try-run, \ + echo 'void foo(void) {}' | $(CC) -x c - -o - -S $(CLANG_CROSS_FLAGS) $(__CFLAGS_STACKPROTECTOR) | grep -q __stack_chk_guard, \ + $(__CFLAGS_STACKPROTECTOR)) +_CFLAGS_SANITIZER ?= $(call cc-option,-fsanitize=undefined -fsanitize-trap=all) +CFLAGS_NOLIBC_TEST ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra \ + $(call cc-option,-fno-stack-protector) $(call cc-option,-Wmissing-prototypes) \ + $(_CFLAGS_STACKPROTECTOR) $(_CFLAGS_SANITIZER) From patchwork Fri Jun 20 21:39:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 898530 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66AAE218596; Fri, 20 Jun 2025 21:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750455590; cv=none; b=kC0KkhDW64tPUhyOTB91cJYR3QIc78MMNbK0iRbjFJYU+/p2FV6Bi9SLOv5fGifWs6CQDcSNEQ5mrLPivXjfcvdo3nxfmfufodIHGtLbkKZG9sWesHDfPTnYhvM2E7QG7s5Kv9noL80zp5hOdGtM2jhUkhtWsNi+VpTs1Yd58I0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750455590; c=relaxed/simple; bh=DOp3MwDL1Dnv3cqUgbx/x6jmoScWW6MBfnQhM9z8lRA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AJu2Pp9pJL8LSuiUjVkwVfl4xOd0GvQv8aG2S7kHFbQeShIvg810RAeNthJDzVFbog8OSstu10zBG9L9g7qNaVqx6Bszsn8xfCMgby54zWFjEHpKSXuAdmmBrR1sp476uSFrlz7DVV1NVrHL/Vh92UCuWD0bAFQ4Af67UUvko20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=WaSFYBJK; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="WaSFYBJK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1750455579; bh=DOp3MwDL1Dnv3cqUgbx/x6jmoScWW6MBfnQhM9z8lRA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WaSFYBJKC4rfklM4SwzPunmurZPltXvSPl7O/IQ7KYHAjk/3ZseariVY2pQKfft34 N9SDQOvm3xkYg1IbkR0/ulaA3DpGqhDJqfQmIu9wyzgo9y00PYis2OksK74VjFh8Ug QZ6fKGpQXBRfm3NFgWPGAQqTmElviz/fTSxg1Oao= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 20 Jun 2025 23:39:33 +0200 Subject: [PATCH 4/4] selftests/nolibc: integrate with kselftests Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250620-nolibc-selftests-v1-4-f6b2ce7c5071@weissschuh.net> References: <20250620-nolibc-selftests-v1-0-f6b2ce7c5071@weissschuh.net> In-Reply-To: <20250620-nolibc-selftests-v1-0-f6b2ce7c5071@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1750455578; l=1744; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=DOp3MwDL1Dnv3cqUgbx/x6jmoScWW6MBfnQhM9z8lRA=; b=bjes1PZdG70MWZuu3CSg/Qp5M4R1cEKxyXXbjJBjHqD/fvhoYGGTKoulmJAuxsO2sVm3xR02E +KfpKZDPu/+BOZ/ooxBo0hWzvKgxI3D5QK/X1/ifUwvEyhiJMgBqn5n X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Hook up nolibc-test with the kselftests framework. This enables CI systems and developers to easily execute the tests. While nolibc-test does not emit KTAP output itself that is not a problem, as the kselftest executor will wrap the output in KTAP. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/nolibc/Makefile | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 339b31e6a6b592217eca1c03068f21728ea024b4..3a4c98102f6967c4a1586104a560418292b3f31d 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -77,6 +77,7 @@ TARGETS += net/ovpn TARGETS += net/packetdrill TARGETS += net/rds TARGETS += net/tcp_ao +TARGETS += nolibc TARGETS += nsfs TARGETS += pci_endpoint TARGETS += pcie_bwctrl diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..fc7a65ca5fdd77576be49d6227939ec5451a814a --- /dev/null +++ b/tools/testing/selftests/nolibc/Makefile @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 + +TEST_GEN_PROGS := nolibc-test + +include ../lib.mk +include $(top_srcdir)/scripts/Makefile.compiler + +cc-option = $(call __cc-option, $(CC),,$(1),$(2)) + +include Makefile.include + +CFLAGS = -nostdlib -nostdinc -static \ + -isystem $(top_srcdir)/tools/include/nolibc -isystem $(top_srcdir)/usr/include \ + $(CFLAGS_NOLIBC_TEST) + +ifeq ($(LLVM),) +LDLIBS := -lgcc +endif + +$(OUTPUT)/nolibc-test: nolibc-test.c nolibc-test-linkage.c | headers