From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 9900F2D4B61; Mon, 15 Sep 2025 07:22:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920926; cv=none; b=Dy/F3/Qv9DAMws7XcDaBP/Gy1PqnzbI3cBhHZWGGA9n4noEn2Sg0TqgsSJ32VY8s/WkUlwNmHmT6PwiTnBm/yRP7JlW0QTjqj3yO1ydWOqAEUJtiWE9+iXWQuslkxSP9ruGQ2J+L73T+OY7eswUCl2517lOSi/bVkGYCYyoJBok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920926; c=relaxed/simple; bh=u9SFP3WT446LSElIPfH5LXgn1v0GZNblanHXr/hl09A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iReWQTwVM4VdVOLxY048H71dr6uk3Hnj9BHrEaT/pWKhH5Axec7QwYRneULN+3cRIj8A5M3cJTtbsLIfCg00XPVHX9QaDnKl1bzmVzACqhmFAplKBFLJCljshpmiv9ENrQb1kDSYAlY/+OzyGdU54xZVDWojJYsycgxa84C57mI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=Od3S6pPW; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="Od3S6pPW" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=JY7XXxDvbM6ze0ff4yyO/d8yJdh8zCwsbDmZYeFp3+Y=; t=1757920924; x=1759130524; b=Od3S6pPW9cppUBgU/LqXHsuXqWb47P/Gui/8N0w4JUSfq29 7KktVuZ8V09NZ/RGgi2Um/txd68xHI8odZJ6tHxNAa6WxY3KN6jmD4gSOtB+I834XjUouVrPAPlvi kmGKqbMlK8Bq4f1AYLOSV7SDMQw1S4TEMSKuFMnF/+PT4nzZZW/VC4uMHg0/vLc/aKXPyauEyfUmD cEZfWChDfLls2rtzB42lRsNVdLG8qIRFxgu92Rfsil4LskhcGKoTg0evRJYdy9UIpDO2OP9n1lWY9 jh7tQDU1h5Dnf9z5gATpirvPBGRfp0wltmCJZtOf1WHKg1/oghAy9QyDO9tWQtOg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XE-00000005w6o-06Px; Mon, 15 Sep 2025 09:22:00 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 1/9] tools compiler.h: fix __used definition Date: Mon, 15 Sep 2025 09:11:07 +0200 Message-ID: <20250915071115.1429196-2-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg The define mapped to __attribute__((__unused__)) instead of using __used__. Fixes: e58e871becec ("tools/lib/lockdep: Remove private kernel headers") Signed-off-by: Benjamin Berg Reviewed-by: Thomas Wei=C3=9Fschuh --- tools/include/linux/compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h index 33411ca0cc90..b2c40621d441 100644 --- a/tools/include/linux/compiler.h +++ b/tools/include/linux/compiler.h @@ -127,7 +127,7 @@ #endif =20 #ifndef __used -# define __used __attribute__((__unused__)) +# define __used __attribute__((__used__)) #endif =20 #ifndef __packed --=20 2.51.0 From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 89D402D5A16; Mon, 15 Sep 2025 07:22:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920928; cv=none; b=RN7joQAhLz1NX0asCEAfgB+d5jRcIKF4FXx3ROuJLs4Up6JBp5PsfVUzSQvPL71a7hJqNoEi1LW32aYov5mLNvkPQqS4TA7wbip1nVh2pceYZFW+qVtQfoo0FEEGnEpXnSpG+3k8njIUylZNBUnlFnyw+KVcauvN2aElc08cs4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920928; c=relaxed/simple; bh=FYWllZhfNbp4JgkdOlepno8iTqw+NUPFU302qk/TDZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mwkTKDvGwLZ2f4CU3U+iSWGEvtRHc8ihdW2LGLvznv4f/gngbwuvhPiobEw9v4Tx54FL7R+yTrupCag9L8GvDhzddU1gnUXK8U3cfwLWVtbHeiXZfJtLX6tsbCkw5DJwGg7WZ6qc/iBugYl4Ub+zLBDIl8v4wux2oBd1Vk8bxyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=eypkGkRp; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="eypkGkRp" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=hH26aYIp7wW0Rx8k/qri2ElN7BBI2gkazkXuHwYeotg=; t=1757920926; x=1759130526; b=eypkGkRp0foxCOakIuIbMJcB7Ok7G8o6xqcxSd4dkc4uKOH yHj5vFtrp59DXX8EqEGKsNnP9BB+nF1KOJMZLkoVMqE0K1KAkUsvRPkA/ppXYPEAgTb7BEJT+++nH w3ldKjKKNf3T4BrnmTe3+V+8GPgY1crXj4DjC1sKzQrGgcn6P/VzpQyyyoYDYwitVPEkvR3vPTNtq PR0pzQiIpEP5OjqCr9nSSbjQOf1mGDIa4sQSg/7hszGhtFy/Fy72rRY7EGKnBT8TeOMhi/y7ynNZ2 fwDSHSsMTiYWCM6rKBx47WJaX2YGdNmZw8lgO/+YEbRF8W/u6HiMYrNLTU2XraAQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XF-00000005w6o-0LYc; Mon, 15 Sep 2025 09:22:01 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 2/9] um: use tools/include for user files Date: Mon, 15 Sep 2025 09:11:08 +0200 Message-ID: <20250915071115.1429196-3-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg Using the kernel headers directly from the userspace parts of UML is problematic. Switch to use the headers from the tools/include subdirectory instead. These contain stripped down versions that work well for UML and only relatively small adjustments are needed to make it work. This adds two symlinks so that the userspace code can still find asm-offsets.h and user_constants.h. Other than that, some includes are moved into USER_CFLAGS instead of handling them in Makefile.rules. Signed-off-by: Benjamin Berg --- arch/um/Makefile | 11 +++++++---- arch/um/include/shared/generated/asm-offsets.h | 1 + arch/um/include/shared/generated/user_constants.h | 1 + arch/um/include/shared/init.h | 2 +- arch/um/include/shared/user.h | 5 ----- arch/um/kernel/skas/stub.c | 1 + arch/um/kernel/skas/stub_exe.c | 4 ++-- arch/um/os-Linux/skas/process.c | 6 ++---- arch/um/os-Linux/start_up.c | 4 ++-- arch/um/scripts/Makefile.rules | 2 +- arch/x86/um/Makefile | 6 ++++-- arch/x86/um/user-offsets.c | 1 - 12 files changed, 22 insertions(+), 22 deletions(-) create mode 120000 arch/um/include/shared/generated/asm-offsets.h create mode 120000 arch/um/include/shared/generated/user_constants.h diff --git a/arch/um/Makefile b/arch/um/Makefile index 7be0143b5ba3..a3f27d791cc0 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -70,10 +70,13 @@ KBUILD_AFLAGS +=3D $(ARCH_INCLUDE) =20 USER_CFLAGS =3D $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFL= AGS))) \ $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ - -D_FILE_OFFSET_BITS=3D64 -idirafter $(srctree)/include \ - -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \ - -include $(srctree)/include/linux/compiler-version.h \ - -include $(srctree)/include/linux/kconfig.h + -idirafter $(srctree)/tools/include \ + -D__UM_HOST__ \ + -include $(srctree)/tools/include/linux/compiler.h \ + -include $(srctree)/tools/include/linux/kconfig.h \ + -include $(srctree)/include/generated/autoconf.h \ + -include $(srctree)/include/linux/kern_levels.h \ + -include $(srctree)/$(ARCH_DIR)/include/shared/user.h =20 #This will adjust *FLAGS accordingly to the platform. include $(srctree)/$(ARCH_DIR)/Makefile-os-Linux diff --git a/arch/um/include/shared/generated/asm-offsets.h b/arch/um/inclu= de/shared/generated/asm-offsets.h new file mode 120000 index 000000000000..22fd929dbac7 --- /dev/null +++ b/arch/um/include/shared/generated/asm-offsets.h @@ -0,0 +1 @@ +../../../../../include/generated/asm-offsets.h \ No newline at end of file diff --git a/arch/um/include/shared/generated/user_constants.h b/arch/um/in= clude/shared/generated/user_constants.h new file mode 120000 index 000000000000..5f67c190ec09 --- /dev/null +++ b/arch/um/include/shared/generated/user_constants.h @@ -0,0 +1 @@ +../../../../../include/generated/user_constants.h \ No newline at end of file diff --git a/arch/um/include/shared/init.h b/arch/um/include/shared/init.h index 1a659e2e8cc3..d201705bedb3 100644 --- a/arch/um/include/shared/init.h +++ b/arch/um/include/shared/init.h @@ -41,7 +41,7 @@ typedef int (*initcall_t)(void); typedef void (*exitcall_t)(void); =20 -#include +#define __section(section) __attribute__((__section__(section))) =20 /* These are for everybody (although not all archs will actually discard it in modules) */ diff --git a/arch/um/include/shared/user.h b/arch/um/include/shared/user.h index 139eb78a4767..c9b853e1282f 100644 --- a/arch/um/include/shared/user.h +++ b/arch/um/include/shared/user.h @@ -16,13 +16,8 @@ */ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) =20 -/* This is to get size_t and NULL */ -#ifndef __UM_HOST__ #include -#else #include -#include -#endif =20 extern void panic(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); diff --git a/arch/um/kernel/skas/stub.c b/arch/um/kernel/skas/stub.c index 67cab46a602c..6c9bb1511ea2 100644 --- a/arch/um/kernel/skas/stub.c +++ b/arch/um/kernel/skas/stub.c @@ -5,6 +5,7 @@ =20 #include =20 +#include #include #include #include diff --git a/arch/um/kernel/skas/stub_exe.c b/arch/um/kernel/skas/stub_exe.c index cbafaa684e66..0563838c01d1 100644 --- a/arch/um/kernel/skas/stub_exe.c +++ b/arch/um/kernel/skas/stub_exe.c @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include #include =20 void _start(void); diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/proces= s.c index 78f48fa9db8b..8ad7e863af97 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c @@ -29,9 +29,7 @@ #include #include #include -#include #include -#include #include "../internal.h" =20 int is_skas_winch(int pid, int fd, void *data) @@ -204,7 +202,7 @@ void wait_stub_done_seccomp(struct mm_id *mm_idp, int r= unning, int wait_sigsys) * Either way, if PID is negative, then we have no * choice but to kill the task. */ - if (__READ_ONCE(mm_idp->pid) < 0) + if (READ_ONCE(mm_idp->pid) < 0) goto out_kill; =20 ret =3D syscall(__NR_futex, &data->futex, @@ -217,7 +215,7 @@ void wait_stub_done_seccomp(struct mm_id *mm_idp, int r= unning, int wait_sigsys) } } while (data->futex =3D=3D FUTEX_IN_CHILD); =20 - if (__READ_ONCE(mm_idp->pid) < 0) + if (READ_ONCE(mm_idp->pid) < 0) goto out_kill; =20 running =3D 0; diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c index a827c2e01aa5..8971f4fdddab 100644 --- a/arch/um/os-Linux/start_up.c +++ b/arch/um/os-Linux/start_up.c @@ -28,8 +28,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index a8b7d9dab0a6..b4a2e0058503 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules @@ -9,7 +9,7 @@ USER_OBJS +=3D $(filter %_user.o,$(obj-y) $(USER_SINGLE_OBJ= S)) USER_OBJS :=3D $(foreach file,$(USER_OBJS),$(obj)/$(file)) =20 $(USER_OBJS:.o=3D.%): \ - c_flags =3D -Wp,-MD,$(depfile) $(USER_CFLAGS) -include $(srctree)/include= /linux/kern_levels.h -include user.h $(CFLAGS_$(basetarget).o) + c_flags =3D -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(basetarget).o) =20 # These are like USER_OBJS but filter USER_CFLAGS through unprofile instea= d of # using it directly. diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile index b42c31cd2390..e5f1658a8f9d 100644 --- a/arch/x86/um/Makefile +++ b/arch/x86/um/Makefile @@ -38,8 +38,10 @@ subarch-$(CONFIG_MODULES) +=3D ../kernel/module.o =20 USER_OBJS :=3D bugs_$(BITS).o ptrace_user.o fault.o =20 -$(obj)/user-offsets.s: c_flags =3D -Wp,-MD,$(depfile) $(USER_CFLAGS) \ - -Iarch/x86/include/generated +$(obj)/user-offsets.s: c_flags =3D -Wp,-MD,$(depfile) $(USER_CFLAGS) \ + -Iarch/x86/include/generated \ + -include include/linux/kbuild.h + targets +=3D user-offsets.s =20 include/generated/user_constants.h: $(obj)/user-offsets.s FORCE diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c index d6e1cd9956bf..74fc9763b76e 100644 --- a/arch/x86/um/user-offsets.c +++ b/arch/x86/um/user-offsets.c @@ -8,7 +8,6 @@ #define __FRAME_OFFSETS #include #include -#include =20 #define DEFINE_LONGS(sym, val) \ COMMENT(#val " / sizeof(unsigned long)"); \ --=20 2.51.0 From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 370362D5957; Mon, 15 Sep 2025 07:22:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920928; cv=none; b=QdQDAJX3jN5R7iMDOO4suw8F3FQrq3/7qbQPhvFeANFRumQNYAyG+Bo+2QdIdxaE2whKk9s93PldbfgsJ3V/VPFCRCReCeNf26dB4vN+Iyh7MIk7+I9tF00WQl7siuDy+CwHKLvijP/Y00PSjQQZv9/TxUWvgKkMXFAVuo6ehnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920928; c=relaxed/simple; bh=E8hQb4X+XkJci0FWYLgNCRcpJ1v+QGRZfKaHzIWPvJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uznHR3iLjs7W9T5iyijNaEVURDo7b+6ARe4EmQWY2opH3sJ2E9y/WjjwEJGfbNLLYJhCAbGfer8Q9pmlhMm8Mk5E4i+pFsbyPHGDu4166erttzo2T+vFpAarkiAodAK6ou25louSNssiU+m20lZtdRsjtMpjGTT16+kAxBt7TL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=vV5pBU8+; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="vV5pBU8+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=ELAWiFcBCxLD83jcc9mACALAjBu4TVZ8afWkcSqdi7Q=; t=1757920927; x=1759130527; b=vV5pBU8+r2qjuQbu8/1HZhnJdMf7WAWNMh9fvx+rkijPybD gor5v+3FYQOoClkh2nabcdsPB/WL7mvvZajEhayi9v6tMUp4qwQnR3jPmaKVr0LVQEfNEAjS5zSHM 7FnpTTXDMOT8NxPP7R/ZqkC4cHmBEOtG+H0ONB5ToJEmgl7j8D4GgN9K4020s9FY9YdrABApC9p5N mWD+9oAsgW71OdTgjvoWVPZPxHMaSKHO0yiKiQVoctjFev1aloOOvdUr6sqreflrUv7FrwIAMuVrq cMFhzrYIlrbpu0sfNCUUqyK5BUEcpQr0b52fAVcCHwzT46cDG2MyZajrkQzcINJQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XG-00000005w6o-2zYm; Mon, 15 Sep 2025 09:22:03 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 3/9] tools/nolibc/stdio: remove perror if NOLIBC_IGNORE_ERRNO is set Date: Mon, 15 Sep 2025 09:11:09 +0200 Message-ID: <20250915071115.1429196-4-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg There is no errno variable when NOLIBC_IGNORE_ERRNO is defined. As such, the perror function does not make any sense then and cannot compile. Fixes: acab7bcdb1bc ("tools/nolibc/stdio: add perror() to report the errno = value") Signed-off-by: Benjamin Berg Acked-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/stdio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index 7630234408c5..c512159b8374 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -597,11 +597,13 @@ int sscanf(const char *str, const char *format, ...) return ret; } =20 +#ifndef NOLIBC_IGNORE_ERRNO static __attribute__((unused)) void perror(const char *msg) { fprintf(stderr, "%s%serrno=3D%d\n", (msg && *msg) ? msg : "", (msg && *ms= g) ? ": " : "", errno); } +#endif =20 static __attribute__((unused)) int setvbuf(FILE *stream __attribute__((unused)), --=20 2.51.0 From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 4A8972D660C; Mon, 15 Sep 2025 07:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920930; cv=none; b=LQiJfMto684WKqFeGUVk1h9a+SAmWlmP8hUtwa7UsbdbEY9cILT4ZtnIB0d6blzZR8OQgdGBUBr4WbqnnwhP4AkaBrO+WHleuJhc72NIyJv6cLpfYq8nWwEFChBTJUkB3naAbCNkAJ/n/1kv73dOvxWsniPALAb7OOo45HAXHfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920930; c=relaxed/simple; bh=u9+YtwMWSh8mMH6JtvIEKuaRvKgm8bdVu6KY8R2BhEQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TPwk4TJZQBeL6g+2OhcdXNGZJtvvGu6zLrtOXFFtOpk64A29xLKocefCfwSWVttjcprsYttUC+KNrzBtt99rVyB3Z/Dap5/9uqKtQxq7qvBcCFcFUtc1RmbjARRv13l2d6Gs8OTmoof+4EeB+NsKZF0t56TR/xYZLLuVvKYVluE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=OV6Dg4KZ; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="OV6Dg4KZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=iRYpO586U8lxEybD+EbMysICiC2ETCm9BgFccrVd91I=; t=1757920928; x=1759130528; b=OV6Dg4KZvWsGJAEp4A2o1y8f2ldH1QIStXnV7pPt18vb3nT KWKe4/VFGuN5ftcpBAL7XAmuGJ7IdlMPDdu/DAV37aVPjieqE6f9f7Oh+mu6TI4FgGM1q4L9Br6/W TwOtobyTI6bcb6hXcbFjx7xQXHFsHyPlg/hEhyjK7HFT2zxiki8kokmuUr3QNfNaSdLbriGgfpbrN WgWO5G5bnbJCscACnPw1CK3YBjgPnhepC+phuKTPcM9Ss22YjU0f2dt6B3NG1tiAmDRVPM1emsEPz fX1SfLKMd82ECUO+MQa+KWoiKUBt0JPvJgoGdM/ZNKj3b3Y5AZhiiKSJngWTUJcg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XI-00000005w6o-0Hco; Mon, 15 Sep 2025 09:22:04 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 4/9] tools/nolibc/dirent: avoid errno in readdir_r Date: Mon, 15 Sep 2025 09:11:10 +0200 Message-ID: <20250915071115.1429196-5-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg Using errno is not possible when NOLIBC_IGNORE_ERRNO is set. Use sys_lseek instead of lseek as that avoids using errno. Fixes: 665fa8dea90d ("tools/nolibc: add support for directory access") Signed-off-by: Benjamin Berg Acked-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/dirent.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/include/nolibc/dirent.h b/tools/include/nolibc/dirent.h index 758b95c48e7a..61a122a60327 100644 --- a/tools/include/nolibc/dirent.h +++ b/tools/include/nolibc/dirent.h @@ -86,9 +86,9 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dir= ent **result) * readdir() can only return one entry at a time. * Make sure the non-returned ones are not skipped. */ - ret =3D lseek(fd, ldir->d_off, SEEK_SET); - if (ret =3D=3D -1) - return errno; + ret =3D sys_lseek(fd, ldir->d_off, SEEK_SET); + if (ret < 0) + return -ret; =20 entry->d_ino =3D ldir->d_ino; /* the destination should always be big enough */ --=20 2.51.0 From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 E3CD92D6638; Mon, 15 Sep 2025 07:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920930; cv=none; b=ielL+LrZjbL08KkLj52yyWVC/2KVh2iZ1zoeOJNTz1Twalm3//s0MJ/ueXZc/ZJmDp7OMJayWVtwYgEbG/BhLll/RFHIB3n+S+pm4NEPQC9vzVCie+wr9KLgAlaV0jgWKtJt/HrcoB0d0K3QhKXo2RKh21Z/nxbm0D6NAxIcIy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920930; c=relaxed/simple; bh=704uJj0Ip1OexW9zT7NZ1IplH08kL+cIIvWsiux3+es=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lZ2yHHy3Xhe4RV/H7MN24cyAwhNnvq/M4V8l+Io+f1MskaC7kvTysVHv3REtq4FK2hxg/+xwpEOL520WSJxcv6SLaD5sDJBJEucShecTxRpdu+kEiFyCuBg/kBxEOo3Pv56b1cmvIHV4u6ben9Vkag2/uYdmEIg2M7mQjSKTsIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=v1QVZUfg; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="v1QVZUfg" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=uB+ZeSs+X9NMubgvNrYfiWUR+gb4lauP6HMzVhv7NVY=; t=1757920929; x=1759130529; b=v1QVZUfgYGIQtYPFw+F+y1wGh8/UfL6Ke30lbylSCk8ow0a zmtKAW5/AbUnA3OzNE9mASoKbvqS1pXsjNh2vcZ2jk2Ubds4bw+IwHl99XryeKsVAE6/WoApkupZE 4U7dtjYyNp2HFxnelg8Y+0affUNOeT54zKukm5fwAxFEQSq3qXgJDYRKqrPwgprziLsUjVeof+oaD BWfgfAEwtvFEsgR9uBhejsueflEnq+cQfd3ahhk3C0S5IH3hi8hxVc9e3WzVZlLvqsdJfFrQTDhSz FZ25qGZ/6SPhIJ4+jgOOGGBuClfU39c+CIGYk4QhOiRiOkf4KekH32TsWW0uhmqw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XJ-00000005w6o-2p6w; Mon, 15 Sep 2025 09:22:05 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 5/9] tools/nolibc: use __fallthrough__ rather than fallthrough Date: Mon, 15 Sep 2025 09:11:11 +0200 Message-ID: <20250915071115.1429196-6-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg Use the version of the attribute with underscores to avoid issues if fallthrough has been defined by another header file already. Signed-off-by: Benjamin Berg Acked-by: Thomas Wei=C3=9Fschuh --- tools/include/nolibc/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compile= r.h index 369cfb5a0e78..87090bbc53e0 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -41,8 +41,8 @@ # define __no_stack_protector __attribute__((__optimize__("-fno-stack-pro= tector"))) #endif /* __nolibc_has_attribute(no_stack_protector) */ =20 -#if __nolibc_has_attribute(fallthrough) -# define __nolibc_fallthrough do { } while (0); __attribute__((fallthroug= h)) +#if __nolibc_has_attribute(__fallthrough__) +# define __nolibc_fallthrough do { } while (0); __attribute__((__fallthro= ugh__)) #else # define __nolibc_fallthrough do { } while (0) #endif /* __nolibc_has_attribute(fallthrough) */ --=20 2.51.0 From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 80E212D6E7E; Mon, 15 Sep 2025 07:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920933; cv=none; b=NrMYIp10q1UAOvS+jORChHcRTqmsOkjCOJRYAMNQjF7f6SHmJVvCpu8F0EDhe6N/rjQnPUMHbGuT94w/nXdCw44J3LtUrTRIg3koEJsx2YbvRgv3JNAMUak6p4vdV9Df7fIxfllkPSCs8PHF9gbNGLnxclXAhpHh5FDwGZH7qHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920933; c=relaxed/simple; bh=rtScHx617+D2FvxQhrUj6cXFUqtzIzIYRL3T9B4MzxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oWBaXdEiOagsnWhrCZNBo8u5Pe/PKRwRvmB2MSp0K9yryiTJnel2u4W5iSSLaibdE/jBjrwd/XUksqY0lFESawgVyTbOZTIyrQPT7nXaCyQhGu1lL+TRpwJPHJj4YjvBQXSHV5Dn9dCm9lxhCOjwwr5PLkq8jKTlDZPR3KiXCzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=dzwZfsqB; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="dzwZfsqB" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=LjPzDdYZooghqKYve4BhSZ1GWfFpNxXsDr4oaZkmiCc=; t=1757920930; x=1759130530; b=dzwZfsqBUGx0/1+cf7NORYyyQxM+qv3ubzokSZbhDPZ0nww t8rcTY/IaJG2jFWXp0pmCLJdHXYdhqIfi6N7LPocNaEYtkGUc54PYpfyZtrI1KvWQQ9eQZIT835ep 4fThfFdvP6aBc3A0tPyA9ts5F4Bqv0hgJHq2foKVca71jX6KoeJYPIL7SkoEgDhcEByQfZe0da19a CUFAEKX+lBLkjmvpuvX8d5s9vRoNTcP4RdezfkjqOrUxmKIj0wHvEiVnkfClm4JLZS7klL99ykePx iOc2LQm4QlUkZzj6YW9Et7asRjxtXZH+6G5FfDNaH25iyYJnwSDLoN4Lhms7pGOA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XK-00000005w6o-3DZb; Mon, 15 Sep 2025 09:22:07 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 6/9] tools/nolibc: add option to disable startup code Date: Mon, 15 Sep 2025 09:11:12 +0200 Message-ID: <20250915071115.1429196-7-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg In principle, it is possible to use nolibc for only some object files in a program. In that case, the startup code in _start and _start_c is not going to be used. Add the NOLIBC_NO_STARTCODE compile time option to disable it entirely and also remove anything that depends on it. Doing this avoids warnings from modpost for UML as the _start_c code references the main function from the .init.text section while it is not inside .init itself. Signed-off-by: Benjamin Berg --- tools/include/nolibc/arch-arm.h | 2 ++ tools/include/nolibc/arch-arm64.h | 2 ++ tools/include/nolibc/arch-loongarch.h | 2 ++ tools/include/nolibc/arch-m68k.h | 2 ++ tools/include/nolibc/arch-mips.h | 2 ++ tools/include/nolibc/arch-powerpc.h | 2 ++ tools/include/nolibc/arch-riscv.h | 2 ++ tools/include/nolibc/arch-s390.h | 2 ++ tools/include/nolibc/arch-sh.h | 2 ++ tools/include/nolibc/arch-sparc.h | 2 ++ tools/include/nolibc/arch-x86.h | 4 ++++ tools/include/nolibc/crt.h | 3 +++ tools/include/nolibc/stackprotector.h | 2 ++ tools/include/nolibc/stdlib.h | 2 ++ tools/include/nolibc/sys.h | 3 ++- tools/include/nolibc/sys/auxv.h | 3 +++ 16 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-ar= m.h index 1f66e7e5a444..24ad348cc1e8 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -185,6 +185,7 @@ }) =20 /* startup code */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { __asm__ volatile ( @@ -193,5 +194,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #endif /* _NOLIBC_ARCH_ARM_H */ diff --git a/tools/include/nolibc/arch-arm64.h b/tools/include/nolibc/arch-= arm64.h index 02a3f74c8ec8..554ebb51c761 100644 --- a/tools/include/nolibc/arch-arm64.h +++ b/tools/include/nolibc/arch-arm64.h @@ -142,6 +142,7 @@ }) =20 /* startup code */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { __asm__ volatile ( @@ -150,4 +151,5 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ #endif /* _NOLIBC_ARCH_ARM64_H */ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/a= rch-loongarch.h index 5511705303ea..cf14f7bf4081 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -143,6 +143,7 @@ }) =20 /* startup code */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { __asm__ volatile ( @@ -151,5 +152,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #endif /* _NOLIBC_ARCH_LOONGARCH_H */ diff --git a/tools/include/nolibc/arch-m68k.h b/tools/include/nolibc/arch-m= 68k.h index 6dac1845f298..dc0d48a10c14 100644 --- a/tools/include/nolibc/arch-m68k.h +++ b/tools/include/nolibc/arch-m68k.h @@ -128,6 +128,7 @@ _num; \ }) =20 +#ifndef NOLIBC_NO_STARTCODE void _start(void); void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { @@ -137,5 +138,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #endif /* _NOLIBC_ARCH_M68K_H */ diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-m= ips.h index 0cbac63b249a..6c6a65a99029 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -246,6 +246,7 @@ #endif /* _ABIO32 */ =20 /* startup code, note that it's called __start on MIPS */ +#ifndef NOLIBC_NO_STARTCODE void __start(void); void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor __start(void) { @@ -266,5 +267,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector __ ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #endif /* _NOLIBC_ARCH_MIPS_H */ diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arc= h-powerpc.h index 204564bbcd32..7a01278e569c 100644 --- a/tools/include/nolibc/arch-powerpc.h +++ b/tools/include/nolibc/arch-powerpc.h @@ -184,6 +184,7 @@ #endif /* !__powerpc64__ */ =20 /* startup code */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { #ifdef __powerpc64__ @@ -215,5 +216,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s #endif __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #endif /* _NOLIBC_ARCH_POWERPC_H */ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-= riscv.h index 885383a86c38..12ca37b8d964 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -140,6 +140,7 @@ }) =20 /* startup code */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { __asm__ volatile ( @@ -152,5 +153,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #endif /* _NOLIBC_ARCH_RISCV_H */ diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s= 390.h index df4c3cc713ac..fb0d312847b8 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -140,6 +140,7 @@ }) =20 /* startup code */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { __asm__ volatile ( @@ -155,6 +156,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 struct s390_mmap_arg_struct { unsigned long addr; diff --git a/tools/include/nolibc/arch-sh.h b/tools/include/nolibc/arch-sh.h index a96b8914607e..038bf364aa27 100644 --- a/tools/include/nolibc/arch-sh.h +++ b/tools/include/nolibc/arch-sh.h @@ -141,6 +141,7 @@ }) =20 /* startup code */ +#ifndef NOLIBC_NO_STARTCODE void _start_wrapper(void); void __attribute__((weak,noreturn)) __nolibc_entrypoint __no_stack_protect= or _start_wrapper(void) { @@ -158,5 +159,6 @@ void __attribute__((weak,noreturn)) __nolibc_entrypoint= __no_stack_protector _st ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #endif /* _NOLIBC_ARCH_SH_H */ diff --git a/tools/include/nolibc/arch-sparc.h b/tools/include/nolibc/arch-= sparc.h index ca420d843e25..062eae1fa92d 100644 --- a/tools/include/nolibc/arch-sparc.h +++ b/tools/include/nolibc/arch-sparc.h @@ -153,6 +153,7 @@ }) =20 /* startup code */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { __asm__ volatile ( @@ -169,6 +170,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 static pid_t getpid(void); =20 diff --git a/tools/include/nolibc/arch-x86.h b/tools/include/nolibc/arch-x8= 6.h index d3efc0c3b8ad..b4981e99f0a0 100644 --- a/tools/include/nolibc/arch-x86.h +++ b/tools/include/nolibc/arch-x86.h @@ -164,6 +164,7 @@ * 2) The deepest stack frame should be set to zero * */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { __asm__ volatile ( @@ -176,6 +177,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #else /* !defined(__x86_64__) */ =20 @@ -330,6 +332,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s * 2) The deepest stack frame should be zero (the %rbp). * */ +#ifndef NOLIBC_NO_STARTCODE void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { __asm__ volatile ( @@ -340,6 +343,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_STARTCODE */ =20 #define NOLIBC_ARCH_HAS_MEMMOVE void *memmove(void *dst, const void *src, size_t len); diff --git a/tools/include/nolibc/crt.h b/tools/include/nolibc/crt.h index 961cfe777c35..d72e616eeec9 100644 --- a/tools/include/nolibc/crt.h +++ b/tools/include/nolibc/crt.h @@ -7,6 +7,8 @@ #ifndef _NOLIBC_CRT_H #define _NOLIBC_CRT_H =20 +#ifndef NOLIBC_NO_STARTCODE + #include "compiler.h" =20 char **environ __attribute__((weak)); @@ -88,4 +90,5 @@ void _start_c(long *sp) exit(exitcode); } =20 +#endif /* NOLIBC_NO_STARTCODE */ #endif /* _NOLIBC_CRT_H */ diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/s= tackprotector.h index c71a2c257177..3dd4d3e53ca6 100644 --- a/tools/include/nolibc/stackprotector.h +++ b/tools/include/nolibc/stackprotector.h @@ -9,6 +9,7 @@ =20 #include "compiler.h" =20 +#ifndef NOLIBC_NO_STARTCODE #if defined(_NOLIBC_STACKPROTECTOR) =20 #include "sys.h" @@ -49,5 +50,6 @@ static __no_stack_protector void __stack_chk_init(void) #else /* !defined(_NOLIBC_STACKPROTECTOR) */ static void __stack_chk_init(void) {} #endif /* defined(_NOLIBC_STACKPROTECTOR) */ +#endif /* NOLIBC_NO_STARTCODE */ =20 #endif /* _NOLIBC_STACKPROTECTOR_H */ diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h index 5fd99a480f82..ed12c9119aab 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -107,6 +107,7 @@ void free(void *ptr) * environment variable exists its value is returned otherwise NULL is * returned. */ +#ifndef NOLIBC_NO_STARTCODE static __attribute__((unused)) char *getenv(const char *name) { @@ -122,6 +123,7 @@ char *getenv(const char *name) } return NULL; } +#endif /* NOLIBC_NO_STARTCODE */ =20 static __attribute__((unused)) void *malloc(size_t len) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 295e71d34aba..c518a1b4af97 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -509,6 +509,7 @@ pid_t gettid(void) return sys_gettid(); } =20 +#ifndef NOLIBC_NO_STARTCODE static unsigned long getauxval(unsigned long key); =20 /* @@ -520,7 +521,7 @@ int getpagesize(void) { return __sysret((int)getauxval(AT_PAGESZ) ?: -ENOENT); } - +#endif /* NOLIBC_NO_STARTCODE */ =20 /* * uid_t getuid(void); diff --git a/tools/include/nolibc/sys/auxv.h b/tools/include/nolibc/sys/aux= v.h index c52463d6c18d..35d339146463 100644 --- a/tools/include/nolibc/sys/auxv.h +++ b/tools/include/nolibc/sys/auxv.h @@ -10,6 +10,8 @@ #ifndef _NOLIBC_SYS_AUXV_H #define _NOLIBC_SYS_AUXV_H =20 +#ifndef NOLIBC_NO_STARTCODE + #include "../crt.h" =20 static __attribute__((unused)) @@ -38,4 +40,5 @@ unsigned long getauxval(unsigned long type) return ret; } =20 +#endif /* NOLIBC_NO_STARTCODE */ #endif /* _NOLIBC_SYS_AUXV_H */ --=20 2.51.0 From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 293332D73AE; Mon, 15 Sep 2025 07:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920933; cv=none; b=Mrb2Sk2u8BsT0E8Z+1PTBohs84FhDnn53jX3Ink7TFCAUaYhRNFpi5b32g1cRqsZ3wrcVKT5KscAT9+B/No2ASCggNyy9LTW/Twv+AbosRKeHIyWEY7qRugWpO/AZ8BAbq4lWQrWMeefgnM+O6UgFHbYQ7n9ptJxA+zu4XlJ41c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920933; c=relaxed/simple; bh=zzhgr2MSz+WwIyXeNFgpi85yheVgDVQre4NsMvzcufk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hK8UVP21jM077BsDuEXhaIwZmZm6ylIataJtCQRDIR9ABWUhrsN8lWwV7J6F7il053wSIJ6sDBStOfG1ZBp9nas0pg9u3TGZV1QiWN8PT4tN5CrOtqcvf4IC2SU/vJKEIIqjUg8UJyxjNfMoW1zVfM1TIvNiW6/m43IcgReSjgU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=TtBtOXaQ; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="TtBtOXaQ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=HVA8rahyRRzDT6UOZjkHUe+vnU2a954Je71AnOZJQWI=; t=1757920931; x=1759130531; b=TtBtOXaQ2Ak+W9e/Fc1CHThxCBUfVKzUO2+BLELQq19M8vs qJCm4FpDosv1DKICSahwsF2tcKcno0AtVoR0A16kQJk567QLAoh2A1xHB25Vzm3N73mcmJfVeH1sq JVoziv4jWVH/F2SRSUiOid4gCoO4Ei+jxsuw2l/+FBVVkNjd53yl7uJXehU8ztT9fUfWPU8cQj0JU +7rVZDnHHYCrR76AnlU0Py/rX6NROH7yFOimgdELya8yC+/wtqJWLUpYDtMMk2vwjXGyyw+Yt3LNv nxhd29qexlzf6noAo91AZWUX6+iFfaPjO3HNx1IMeBCm44QBCSjAAiIwZLIYTdnA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XL-00000005w6o-3k8S; Mon, 15 Sep 2025 09:22:08 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 7/9] um: add infrastructure to build files using nolibc Date: Mon, 15 Sep 2025 09:11:13 +0200 Message-ID: <20250915071115.1429196-8-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg Add NOLIBC_CFLAGS and NOLIBC_OBJS to build files against nolibc rather than libc. With this it is possible to move to nolibc in smaller steps. Set NOLIBC_IGNORE_ERRNO, as the nolibc errno implementation is overly simple and cannot handle threading. nolibc provides sys_* functions that do not emulate the libc errno behaviour and can be used instead. Guard the syscall definition as it is a macro in nolibc. Signed-off-by: Benjamin Berg --- arch/um/Makefile | 21 ++++++++++++++++++++- arch/um/include/shared/os.h | 2 ++ arch/um/scripts/Makefile.rules | 8 +++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/arch/um/Makefile b/arch/um/Makefile index a3f27d791cc0..54aa26fcc32b 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -78,6 +78,25 @@ USER_CFLAGS =3D $(patsubst $(KERNEL_DEFINES),,$(patsubst= -I%,,$(KBUILD_CFLAGS))) \ -include $(srctree)/include/linux/kern_levels.h \ -include $(srctree)/$(ARCH_DIR)/include/shared/user.h =20 +NOLIBC_CFLAGS =3D $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_C= FLAGS))) \ + $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ + -I $(srctree)/tools/include \ + -D__EXPORTED_HEADERS__ \ + -D__UM_HOST__ -D__UM_NOLIBC__ \ + -DNOLIBC_NO_STARTCODE \ + -DNOLIBC_IGNORE_ERRNO \ + -nostdlib -nostdinc -static \ + -I$(srctree)/include/uapi \ + -I$(srctree)/$(HOST_DIR)/include/uapi \ + -I$(objtree)/$(HOST_DIR)/include/generated/uapi \ + -I $(srctree)/tools/include/nolibc \ + -I $(srctree)/usr/include \ + -include $(srctree)/include/generated/autoconf.h \ + -include $(srctree)/tools/include/linux/kconfig.h \ + -include $(srctree)/include/linux/kern_levels.h \ + -include $(srctree)/tools/include/nolibc/nolibc.h \ + -include $(srctree)/$(ARCH_DIR)/include/shared/user.h + #This will adjust *FLAGS accordingly to the platform. include $(srctree)/$(ARCH_DIR)/Makefile-os-Linux =20 @@ -157,4 +176,4 @@ archclean: -o -name '*.gcov' \) -type f -print | xargs rm -f $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=3D$(HEADER_ARCH) clean =20 -export HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING DEV_NULL_PATH +export HEADER_ARCH SUBARCH USER_CFLAGS NOLIBC_CFLAGS CFLAGS_NO_HARDENING D= EV_NULL_PATH diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index b35cc8ce333b..3e9f3ae61658 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -327,7 +327,9 @@ extern int __ignore_sigio_fd(int fd); /* tty.c */ extern int get_pty(void); =20 +#ifndef syscall long syscall(long number, ...); +#endif =20 /* irqflags tracing */ extern void block_signals_trace(void); diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules index b4a2e0058503..5f07551935c3 100644 --- a/arch/um/scripts/Makefile.rules +++ b/arch/um/scripts/Makefile.rules @@ -11,6 +11,12 @@ USER_OBJS :=3D $(foreach file,$(USER_OBJS),$(obj)/$(file= )) $(USER_OBJS:.o=3D.%): \ c_flags =3D -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(basetarget).o) =20 +# Similar USER_OBJS but compiled against nolibc (may include kernel header= s?) +NOLIBC_OBJS :=3D $(foreach file,$(NOLIBC_OBJS),$(obj)/$(file)) + +$(NOLIBC_OBJS:.o=3D.%): \ + c_flags =3D -Wp,-MD,$(depfile) $(NOLIBC_CFLAGS) $(CFLAGS_$(basetarget).o) + # These are like USER_OBJS but filter USER_CFLAGS through unprofile instea= d of # using it directly. UNPROFILE_OBJS :=3D $(foreach file,$(UNPROFILE_OBJS),$(obj)/$(file)) @@ -18,7 +24,7 @@ UNPROFILE_OBJS :=3D $(foreach file,$(UNPROFILE_OBJS),$(ob= j)/$(file)) $(UNPROFILE_OBJS:.o=3D.%): \ c_flags =3D -Wp,-MD,$(depfile) $(call unprofile,$(USER_CFLAGS)) $(CFLAGS_= $(basetarget).o) =20 -$(USER_OBJS) $(UNPROFILE_OBJS): \ +$(USER_OBJS) $(NOLIBC_OBJS) $(UNPROFILE_OBJS): \ CHECKFLAGS :=3D $(patsubst $(NOSTDINC_FLAGS),,$(CHECKFLAGS)) =20 # The stubs can't try to call mcount or update basic block data --=20 2.51.0 From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 386DC2D7DD1; Mon, 15 Sep 2025 07:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920934; cv=none; b=YvFM2Txq3c7PT0u9i8DCiBmxOSHt+/mRyWrza8GbTTnxFeCdXXHChfcVArS0EGwrv6upAoz723pW3oyaQ14JX0rn/DdOG1nv06znVlDlRvsLIFYB65XJDweWJX3oaGwzcvpccvhyueuY84XKHv9F2cj6v5xRiLk+0lbVqWwLNzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920934; c=relaxed/simple; bh=+1XbHYWO44eiLyr3lQME0rhVVOh0E9r61o4FckS2Ch8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HsYdvacUGle15c8YutIaczZYVbJX+6JNOVRr/ZilTeY5/8RCn2EcXcMjsoguUjkQIve/zz+1VRJNMWxdXXi0cnOxWw8yhTgeCNvT8o8EIK1MFnRla3zIPG5z0QihGB6QqhXHyXq4NfNy7T65y1qxyDaLiJNz6xC5nzedNSCsxPo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=oGOcKTs7; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="oGOcKTs7" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=UVHwzh9sHs6Xo02VEWpZXjxZy4cbskfDXgmFGFBhsbs=; t=1757920933; x=1759130533; b=oGOcKTs77mBBOsOPVUAqH8rl9BNGCh00ZK3Mto8rgxoELDX GNCuFhrRJUp+mCuL0z4vmnvETt3k/LifrZvcekkk/U4lUNqEALkbfSwUkFTfkpCYvKGUpx9UfsMD+ BMxbfOT4gfyOkLn33N3hbbxVzaF0FLsojY6I19EYHeZXU24BtfzxPc0EloHXlUNaaniymzX7AlStt prZdzHXI583fO0Xjm/bL6VB84yj5RbtvBGu8tlrO8rDEz4beaIeJL12OSv+6727uTOKx7b0DVOYlq 9+BiJF+vreo6Njlu9oz/aVah3pgfhDyayUDIVbvS2ZQOV6nC/rp1q8SeaPex6Itw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XN-00000005w6o-0J1R; Mon, 15 Sep 2025 09:22:09 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 8/9] um: use nolibc for the --showconfig implementation Date: Mon, 15 Sep 2025 09:11:14 +0200 Message-ID: <20250915071115.1429196-9-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg This is one of the simplest files and it can be switched over to use nolibc without any modifications. Signed-off-by: Benjamin Berg --- arch/um/kernel/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index b8f4e9281599..4b206a40b611 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile @@ -26,7 +26,7 @@ obj-$(CONFIG_OF) +=3D dtb.o obj-$(CONFIG_EARLY_PRINTK) +=3D early_printk.o obj-$(CONFIG_STACKTRACE) +=3D stacktrace.o =20 -USER_OBJS :=3D config.o +NOLIBC_OBJS :=3D config.o =20 include $(srctree)/arch/um/scripts/Makefile.rules =20 --=20 2.51.0 From nobody Thu Oct 2 15:33:05 2025 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 385DE2D7DD0; Mon, 15 Sep 2025 07:22:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920935; cv=none; b=LFcskZmFkPspvAYqzs6zGzzL8D4fXYVvzJaCU1B2CMVJ5n8i2mxdi8TqeUKEx0/bVP2SGYYd+67i0kw8Qy8tO2hVXKTOD8vipmZnDBA8Wj+GE2Zm7pCtJSXdXiueGFpWwXNBnqkTGmZY+V2WpncXSW+q/VyHoHzwk1CosXpTD3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757920935; c=relaxed/simple; bh=D1njsi3Dc3pm+FEmPaeoan3fmVED/gaa/845805VSmQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BeAlElPuBC0l7eV0c50WVTjep0MzeJW+yl81rdYiM26HZzJxq+d5zapy08VVHKLfTJJLuvL/zLldhoWEJ9mmkUILvGUedEg6Hq/oPNbiaj7J2gRgiNLgZ4jMDPxxfFdEkhzH/smYGSrRYeg+Ckomt5McgfjCxtVm0G3tx3KcJHY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=OjpYR4o0; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="OjpYR4o0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=EzGYOyHyBK8XRCpIi1QlHK5VKphrWANC8ROrsS0E19Q=; t=1757920933; x=1759130533; b=OjpYR4o0tQBaelHAEQh4eaJY/Y0hlVFkY+foOTsAQpfQWbC r9QZWxa0Jz3zVpSM1mYawHZ1B8JwKIPFxyPVpvokiOcH44kkyru9QXYRSbKgyu41TZrz/3aqtWI/d 3+5YuIg5b4Pbe5OfMiwHDmZc0wwQRdHX7q0T1VxB+5IRHZaEPv6z7hr4GxLn9vYvupczLTItgh55d e4qfwHyqKbtol5U/Gz6vn0+ElwgJgNFPkb57js4WGCWPXe4KcYxPvVldl/+pfE8yK2T2dh5kqph0d gvl8niGNcQfjcg9KfDd7yAxNVkKg+orl6FZF0VCYILu9t+r9F95eB5jYbPt2/SRg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98.2) (envelope-from ) id 1uy3XO-00000005w6o-0YuW; Mon, 15 Sep 2025 09:22:10 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org, Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kselftest@vger.kernel.org, Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Tiwei Bie , Benjamin Berg Subject: [PATCH 9/9] um: switch ptrace FP register access to nolibc Date: Mon, 15 Sep 2025 09:11:15 +0200 Message-ID: <20250915071115.1429196-10-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915071115.1429196-1-benjamin@sipsolutions.net> References: <20250915071115.1429196-1-benjamin@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Benjamin Berg The registers.c file only contain the routines for floating point register access in ptrace mode and initial size detection. The file can be moved over to nolibc by replacing the ptrace libc call with a simple wrapper that does a direct syscall. Signed-off-by: Benjamin Berg --- arch/x86/um/os-Linux/Makefile | 5 ++++- arch/x86/um/os-Linux/registers.c | 22 ++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/arch/x86/um/os-Linux/Makefile b/arch/x86/um/os-Linux/Makefile index 77a308aaa5ec..d37320430822 100644 --- a/arch/x86/um/os-Linux/Makefile +++ b/arch/x86/um/os-Linux/Makefile @@ -3,10 +3,13 @@ # Licensed under the GPL # =20 -obj-y =3D registers.o mcontext.o +obj-y =3D mcontext.o =20 obj-$(CONFIG_X86_32) +=3D tls.o =20 USER_OBJS :=3D $(obj-y) =20 +obj-y +=3D registers.o +NOLIBC_OBJS :=3D registers.o + include $(srctree)/arch/um/scripts/Makefile.rules diff --git a/arch/x86/um/os-Linux/registers.c b/arch/x86/um/os-Linux/regist= ers.c index eb1cdadc8a61..55bce0d3f5d2 100644 --- a/arch/x86/um/os-Linux/registers.c +++ b/arch/x86/um/os-Linux/registers.c @@ -6,18 +6,20 @@ =20 #include #include -#include +#include #ifdef __i386__ #include #endif #include #include -#include +#include #include #include #include #include =20 +#define my_ptrace(...) my_syscall4(__NR_ptrace, __VA_ARGS__) + static unsigned long ptrace_regset; unsigned long host_fp_size; =20 @@ -28,9 +30,7 @@ int get_fp_registers(int pid, unsigned long *regs) .iov_len =3D host_fp_size, }; =20 - if (ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov) < 0) - return -errno; - return 0; + return my_ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); } =20 int put_fp_registers(int pid, unsigned long *regs) @@ -40,9 +40,7 @@ int put_fp_registers(int pid, unsigned long *regs) .iov_len =3D host_fp_size, }; =20 - if (ptrace(PTRACE_SETREGSET, pid, ptrace_regset, &iov) < 0) - return -errno; - return 0; + return my_ptrace(PTRACE_SETREGSET, pid, ptrace_regset, &iov); } =20 int arch_init_registers(int pid) @@ -60,9 +58,7 @@ int arch_init_registers(int pid) =20 /* GDB has x86_xsave_length, which uses x86_cpuid_count */ ptrace_regset =3D NT_X86_XSTATE; - ret =3D ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); - if (ret) - ret =3D -errno; + ret =3D my_ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); =20 if (ret =3D=3D -ENODEV) { #ifdef CONFIG_X86_32 @@ -71,9 +67,7 @@ int arch_init_registers(int pid) ptrace_regset =3D NT_PRFPREG; #endif iov.iov_len =3D 2 * 1024 * 1024; - ret =3D ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); - if (ret) - ret =3D -errno; + ret =3D my_ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); } =20 munmap(iov.iov_base, 2 * 1024 * 1024); --=20 2.51.0