From nobody Thu Oct 2 06:16:49 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 41F862F83BA; Fri, 19 Sep 2025 15:36: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=1758296166; cv=none; b=e25cU4x7e3JWQdcgtu8uRP8qk4FEoCMUaKoDo1D4uCEB3I4Qw49NJHlNvEeJsnxjMhqRRkdb7GlJBnYfG0nDMOQU818sXrfMhygR31cT9cst70dyS4BByOnPe8r+CT4sWYVBVj09JB1WMRCDvnRes7Zju+HRNh6ug4E4M1RRluw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296166; c=relaxed/simple; bh=OnThKVkAxTbvu2cs4FLMAMZ+dEhCwYFgliP6EBhRpLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lFSrfEbCdzSySQGFqF/5b/SVrMVH+TokG8uzbXplb4HpompuysSnYKs8hEWVIrpSteuNMXYw4OEUCc+1qwFu68/Ic5K3SbZG8YyGfnNhMI6M2guvCHOEGkdu9rYnK+8uYMmticG36LzmVMOIqnAcUbkgPVzMOMtP6JwAqnVzsYk= 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=n4xvTQm/; 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="n4xvTQm/" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=w0zvkyHycNf62ji7JboPNe59KMTBMZPeiYVTw++Mcio=; t=1758296164; x=1759505764; b=n4xvTQm/qmzoOF+LkA+Oqzqi9cLqBe/n/LzwIseLCoUMqqB QBeedQR6gd0IiYAl8aWXwuOz2zQXz43AvC6Cq6mTnjWCsn77CNcQeyVbdoErgfabwAC8e6nKOgPPw zh4eCTWXlMSi2W+T40+D79oYRl3N27urzdZucv3gY0sbZ98202bKMxeF0LLUcagXKcPW32iYW27ut lwsb+RhDZgQS5Rw8GBgLGr3cbt5CIU1r4QwBcpuxcole96fzuh+8rnlhrq0oX1IQxtrQwdorf9s2x wOHgCYTrPUEAI8STLqLGc+d9eGT7p4uS2IvvLp1cHhfPYFh48QQoWsmrBl3UwLbA==; 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 1uzd9T-0000000G6O6-2i20; Fri, 19 Sep 2025 17:35:59 +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, Benjamin Berg Subject: [PATCH v2 01/11] tools compiler.h: fix __used definition Date: Fri, 19 Sep 2025 17:34:10 +0200 Message-ID: <20250919153420.727385-2-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-malware-bazaar: not-scanned From: Benjamin Berg The define mapped to __attribute__((__unused__)) instead of using __used__. Having the wrong definition here may result in the linker incorrectly removing the symbol. Also, this now matches the definition in include/linux/compiler_attributes.h. 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 06:16:49 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 DF8A4314A9A; Fri, 19 Sep 2025 15:36:05 +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=1758296168; cv=none; b=ToWm45Gbg/tZ2FybGCt3qN3wyc9yk4QR/Fd/C1Eu3n7puBEH4zHKWZqoEX98aBnBIlDUyaWy54YV4vZl8oKALpqem5ra9sW2xTSXqcjT//eLeIRZaeTcOtLZSr+NaNFV868TNbfrb1orKwwRyTlgAhGngXN0578isE3WDamiFyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296168; c=relaxed/simple; bh=wcLrD0WS5YjvvCsdm8gr/2mkmWKC74LSIzDcH4K3Lmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jo6vkjZJlDs/eGxSHTuCNzxmKcvU50zHtk+CZrkIGJSQT+LkBTDebDU31cWmQqSMRJBtQZb1v4+VMzfd1oYN/sL+TReaN6gxO5urnK4YwVQkf438FE9UyiwJwQOzoM4616kkeP/lDp8/9to0UtbAf4lRVFLVO2V6boMyNfgCoRw= 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=woKeZR/Q; 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="woKeZR/Q" 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=XKawjy2bKBrQJPdin7KqQUscEYPsaoP0832vtVrwP/Q=; t=1758296165; x=1759505765; b=woKeZR/QX59XMHr/pH01fHWpjWxeh6iw1pkl9AOIXo5PQYZ wH3ht48FIyfCT9E0J1wTZc++TH4jInCL5qJk4y4lV8PNkugudEG4SHeyRiR08AAcMG5aquA01A6BE jnkG8G2We074Vlpsf8z62tkyr4ilggFwD+algH36jchtxROrRpzrv+kZgJcc41/+hT+l0lLtnoIGq HhA+hSt9exKzsuzqAII2xlBabd+PeDzZPko9srrm1Pg82LNyVrj72CrDfIcGfUW8xrej+e7fRnsNd xUQQDRWpvtx569SnEGGLOgv3LDILXNAuKdZmaOUc+wQ8H0mzaSLMV9JPwGRlx6mg==; 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 1uzd9U-0000000G6O6-1vjd; Fri, 19 Sep 2025 17:36: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, Benjamin Berg Subject: [PATCH v2 02/11] um: use tools/include for user files Date: Fri, 19 Sep 2025 17:34:11 +0200 Message-ID: <20250919153420.727385-3-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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 code to create 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 --- v2: - Fix out-of-tree building --- arch/um/Makefile | 18 ++++++++++++------ 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 - 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/arch/um/Makefile b/arch/um/Makefile index 7be0143b5ba3..f7c509262568 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -42,7 +42,7 @@ include $(srctree)/$(HOST_DIR)/Makefile.um core-y +=3D $(HOST_DIR)/um/ =20 SHARED_HEADERS :=3D $(ARCH_DIR)/include/shared -ARCH_INCLUDE :=3D -I$(srctree)/$(SHARED_HEADERS) +ARCH_INCLUDE :=3D -I$(srctree)/$(SHARED_HEADERS) -I$(objtree)/$(SHARED_HEA= DERS) ARCH_INCLUDE +=3D -I$(srctree)/$(HOST_DIR)/um/shared KBUILD_CPPFLAGS +=3D -I$(srctree)/$(HOST_DIR)/um =20 @@ -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 $(objtree)/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 @@ -116,6 +119,9 @@ archheaders: =20 archprepare: $(Q)$(MAKE) $(build)=3D$(HOST_DIR)/um include/generated/user_constants.h + $(Q)mkdir -p $(ARCH_DIR)/include/shared/generated + $(Q)ln -fs ../../../../../include/generated/user_constants.h $(ARCH_DIR)/= include/shared/generated/ + $(Q)ln -fs ../../../../../include/generated/asm-offsets.h $(ARCH_DIR)/inc= lude/shared/generated/ =20 LINK-$(CONFIG_LD_SCRIPT_STATIC) +=3D -static LINK-$(CONFIG_LD_SCRIPT_DYN) +=3D -no-pie @@ -147,7 +153,7 @@ export CFLAGS_vmlinux :=3D $(LINK-y) $(LINK_WRAPS) $(LD= _FLAGS_CMDLINE) $(CC_FLAGS_ # When cleaning we don't include .config, so we don't include # TT or skas makefiles and don't clean skas_ptregs.h. CLEAN_FILES +=3D linux x.i gmon.out -MRPROPER_FILES +=3D $(HOST_DIR)/include/generated +MRPROPER_FILES +=3D $(HOST_DIR)/include/generated $(ARCH_DIR)/include/shar= ed/generated =20 archclean: @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 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..d8a120bace25 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 $(srctree)/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 06:16:49 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 48E2A3164DA; Fri, 19 Sep 2025 15:36: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=1758296169; cv=none; b=XL/7puwxvai0UZs4JBI3dzKuvZlGfC64ePWTt0ISXJ8N4lYqLRUYryUeLst2hkDT9i/tfbsae+1iwAAMcxhTtTMAWbX2Yc7aQsnwlHi/pg0ADQEY+sI+3OpUnkuruN43YXrkCmmYJZ6gXPwooQ1rkFbtv4eZ5Iy6xKX16LMIU9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296169; c=relaxed/simple; bh=eVum/sAfgEkdwMaGYS2cz+5Pqq4ePIkKr0CqsDt5Ldk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fXB+H+Omb73ACALKf1krpAdwGq8LUz4K9/QB3uExMEsPb6GNRhm0zTL5NRrriuK4FIzR/qQMf0RB0tmGoqMVzYnuqNboD5e8+0DDGgXPNeOlCULUSpQGiAgitRY5d4wGVFZhVRflL+WtbNd/d8DWumhaGDd5TrU4jnc/Elsh+FU= 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=vEKPqzV9; 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="vEKPqzV9" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=Wzmf8ozQSXaIG/+ku6O06QBDiFnQHnI35uzHRTGApx4=; t=1758296166; x=1759505766; b=vEKPqzV9jcJv443XEU2ZNh+F25yWnO+lfeg0GEtdkeFThxf sLwKTMyuZcRcTYo9wYGQNeWl62NhmxrJk6CfbdOgnG9Eh6gTXFbACKVXT3BGOHH6mPtW7w+kpLCAW zdLa88oy2u0QJwh3/S5JT3alslb+8ghVCBlSNUpojbaJSMt/Ms1rzqh7qUsB8FzTCBt/B1DEUOdPr oqfK8HSOB0uasRzdGl0kr217Pe/uESbJiw43rTIqVHNcO0oZAwA0+fUM7SXmXOlQ9f1eiToYUMDAP +Yva8F9ifgmkbhO6Y0pkthmKT8sUBm+jat5MAxviKCmOQJed+0HLFJ9V/onXRdPg==; 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 1uzd9V-0000000G6O6-1ALo; Fri, 19 Sep 2025 17:36: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, Benjamin Berg Subject: [PATCH v2 03/11] tools/nolibc/stdio: remove perror if NOLIBC_IGNORE_ERRNO is set Date: Fri, 19 Sep 2025 17:34:12 +0200 Message-ID: <20250919153420.727385-4-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-malware-bazaar: not-scanned 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 06:16:49 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 43A3C31A7E8; Fri, 19 Sep 2025 15:36: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=1758296169; cv=none; b=NFraDxmlNccg5Qyd2m9tbZm65kdSCsQ53QQ9957nY3gd5pQO4rtJrxvsaWU2MFDhP7yl7doBpIxfnLXw1PzfA4ndnMQahvqIPhW7qCiEeI7KcaHdX20b5QTVUj0STLCJh3Pe9/L3l8ID2S0X7ho1U/Y1v/mPRjL3LU48NzQ6rXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296169; c=relaxed/simple; bh=VzHe7plOCC4IM2A9hgSWmbnT6yiWBw5g/7UEoOBTe0U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EGPMb3Etm8AtkoIH0rwz7Gc1cOVbUWXca09020teK6CDoxoiTBpu6dJYj9/QFH1jhzauP59t7ETzKfQXYkv7X/5QFECPIlJKkeA7Dt0WRadsCQpV43mO6H+hIm716KFQf3xMkYbpDH9vKym+wtl3IFvsqXQe2BKS2gKKK1OJWtw= 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=K39nyr+6; 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="K39nyr+6" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=z10b0FVwCq0i5SVTTgonk/hnK8AmJrJFJmxu+fzz9NI=; t=1758296168; x=1759505768; b=K39nyr+6c67lkUBMzkmpT4/whmJ5N6xeAFrR/1rCtJLznMF kSdgRLNwztGRhetRpSQz9TpmFpDNT/igHOfJQ0phM4O4EWTEGmJU8xJ5fJL2p0di8s4uk7nTY2qJy BovrOQ6JeMcLlCyWG+5352me+NVvpAQAYPu/r96cUM9DfxnUXdsipEbOT5Ep72locheA7oLWZz+6r NWmXHrmWlASMK/mHS+O9EM7i30QrxtUMmD2ixpOAefpESsvcVIQpOkVN6bbbZbl1LVcJ9V9TXKbkm BNOxIVPuCmJErsxAuUGbumn2YeyZNHHVEuKOiZly4nTvTcUHy3ZtOydAGEkzFGYA==; 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 1uzd9W-0000000G6O6-3qcL; Fri, 19 Sep 2025 17:36: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, Benjamin Berg Subject: [PATCH v2 04/11] tools/nolibc/dirent: avoid errno in readdir_r Date: Fri, 19 Sep 2025 17:34:13 +0200 Message-ID: <20250919153420.727385-5-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-malware-bazaar: not-scanned 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 06:16:49 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 E3C4031A817; Fri, 19 Sep 2025 15:36: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=1758296170; cv=none; b=j+NRvOnyQgRfjWLthXlWNadLZI5oBJcCsAeaJsuTjMWWS/SG8r8FhMu/AIyQYwmydu/WDa3HpTZeGhAg18J4GaSkKz3PtIAHbcrb6C0Y05O8EOJHo/X1f5Wz0KACepYwSBFOu9iuo9oaQxwxIuo1LoQjk9Z/tbK8qgwhiKMJqmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296170; c=relaxed/simple; bh=8uFM5QahYXW7uNN8id5O/6sxqvaTOGEeRZfPDBxEGMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RAzQWlwIDEuMO8CI9UPxOp54MzQpNiUIa2bjSCpNDavP+QQOX6y4UI8E0O3LlPikth1u8OlurCfk0dSaC4vq0WmUxdygJXEldNMp8hsH9HRXcWqu3BsOAZnDeOwZtjS2Jol+wOLz5jFf/T5HAI49yvxYgkK4oks2s2mIJMhIwM0= 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=JTZCO6jA; 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="JTZCO6jA" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=I1cm2is+Xgw+x+T3m8uuoGo4E722CtwyukEZGpVjsa4=; t=1758296169; x=1759505769; b=JTZCO6jAUIrT1ob39rSXMBeY5WBaWCgty1eNBA/x23pLYxL PqdzJevfR888VTVSrNpledquiW7auI+cmfxvyTZcyVoKMJ+VwPq3FewYGBr+YOgQavH8iQTn9mMbH B/TtY4gcOPnw+dfC+tcfzseMinqh8HdEqyqwN3VT53J5eWGmHxuJoc5tSjQUbgmeSx1X9WOagTzQR 1kn44ZFM7jlWuWcYyHzgWwaszo+4AiKik4zxiqlqZ7UbeByGWqkJ3WXeBtysMYBuvkw7lHQ7e1mu1 KG2sXSZxOSwGBhy6tkNfhvSQMzu8XtaFEMz8lhsafrMUNFYO3h3WtbLVgFpcN4FQ==; 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 1uzd9Z-0000000G6O6-2S7E; Fri, 19 Sep 2025 17:36: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, Benjamin Berg Subject: [PATCH v2 05/11] tools/nolibc: use __fallthrough__ rather than fallthrough Date: Fri, 19 Sep 2025 17:34:14 +0200 Message-ID: <20250919153420.727385-6-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-malware-bazaar: not-scanned 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 06:16:49 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 2D17A31AF14; Fri, 19 Sep 2025 15:36: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=1758296172; cv=none; b=bZFLd1WzZrPhV9vX4KE6JAi3/VkIg2S4vzcIf7THGJkmzi08b7tGgBNbXrbj+W/BOL3vHxgHEiwxKzjckQFa/pwQ/8GjNbiqTttPS14drEtFzv+4OEX6bK1DIvaL8OKfWuj4sVI0XsLMmCorpzRrLSUxABugVRWvyMulUuEROwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296172; c=relaxed/simple; bh=97Ddsa0vPGsi+x5IEpMMCCUyhRy9Xv0fODS9IMqIxEQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pFbe7tCb66XtQx+p4d0pUu4DtuLi+RWxlLWlazBnaf2lZISVRgv2ZDhgeV8I0BMCEBa3ZhfEgvDphsrwvkh/dK0ML/mmdkinaSpVPAUynZSgz6vYPxPYIexAx00loYu1hOseVL0WDEbsUWF9RBCb0KvhwrGsRREEjDnNafY+Hhc= 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=ax9N35+X; 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="ax9N35+X" 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=783287hlMPYEkv3TvU4cURXyY84uTXEsGGJ8kdsUrw0=; t=1758296169; x=1759505769; b=ax9N35+Xm6x+I1J+AeXr//uS5mKK8kZEJbS9wr4yGameIKP YRnYixiptG/Qy4FDjpzlZf5Z7jKf26xJSh9pb9dCWOaVHZXHRd/YsDizgovCwE3OVDhb9NXvYFWdl dr59n5I0exNYGp91SCXTv/osb1M7VvJwKG6ftQurKw859K//sZV77z/B0rzC+D3QHKZpQolmlhuzp EKCaV/uxzbaaqyc1ZU74R+EW3SBleb2JOEg1DZAcSe3hSGgcDc7R5sShK+/BwKLH1dNJ8noLhCdOQ CqTZbg/DJvVoEEatnfYjbW1pnPIHvKA8nX3hjaebPFJWtpdkWEhuXb2r+8HwrZ5g==; 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 1uzd9a-0000000G6O6-1HuQ; Fri, 19 Sep 2025 17:36:06 +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, Benjamin Berg Subject: [PATCH v2 06/11] tools/nolibc: add option to disable runtime Date: Fri, 19 Sep 2025 17:34:15 +0200 Message-ID: <20250919153420.727385-7-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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_RUNTIME 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 --- v2: - Renamed from NOLIBC_NO_STARTCODE to NOLIBC_NO_RUNTIME - Put the #ifdef around relevant comments --- 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..251c42579028 100644 --- a/tools/include/nolibc/arch-arm.h +++ b/tools/include/nolibc/arch-arm.h @@ -184,6 +184,7 @@ _arg1; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { @@ -193,5 +194,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ =20 #endif /* _NOLIBC_ARCH_ARM_H */ diff --git a/tools/include/nolibc/arch-arm64.h b/tools/include/nolibc/arch-= arm64.h index 02a3f74c8ec8..080a55a7144e 100644 --- a/tools/include/nolibc/arch-arm64.h +++ b/tools/include/nolibc/arch-arm64.h @@ -141,6 +141,7 @@ _arg1; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { @@ -150,4 +151,5 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ #endif /* _NOLIBC_ARCH_ARM64_H */ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/a= rch-loongarch.h index 5511705303ea..c894176c3f89 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -142,6 +142,7 @@ _arg1; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { @@ -151,5 +152,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ =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..2a4fbada5e79 100644 --- a/tools/include/nolibc/arch-m68k.h +++ b/tools/include/nolibc/arch-m68k.h @@ -128,6 +128,7 @@ _num; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME 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_RUNTIME */ =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..a72506ceec6b 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -245,6 +245,7 @@ =20 #endif /* _ABIO32 */ =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code, note that it's called __start on MIPS */ 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_RUNTIME */ =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..e0c7e0b81f7c 100644 --- a/tools/include/nolibc/arch-powerpc.h +++ b/tools/include/nolibc/arch-powerpc.h @@ -183,6 +183,7 @@ #endif #endif /* !__powerpc64__ */ =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { @@ -215,5 +216,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s #endif __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ =20 #endif /* _NOLIBC_ARCH_POWERPC_H */ diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-= riscv.h index 885383a86c38..1c00cacf57e1 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -139,6 +139,7 @@ _arg1; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { @@ -152,5 +153,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ =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..6237211385c0 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -139,6 +139,7 @@ _arg1; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { @@ -155,6 +156,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ =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..7a421197d104 100644 --- a/tools/include/nolibc/arch-sh.h +++ b/tools/include/nolibc/arch-sh.h @@ -140,6 +140,7 @@ _ret; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ 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_RUNTIME */ =20 #endif /* _NOLIBC_ARCH_SH_H */ diff --git a/tools/include/nolibc/arch-sparc.h b/tools/include/nolibc/arch-= sparc.h index ca420d843e25..2ebb5686e105 100644 --- a/tools/include/nolibc/arch-sparc.h +++ b/tools/include/nolibc/arch-sparc.h @@ -152,6 +152,7 @@ _arg1; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protec= tor _start(void) { @@ -169,6 +170,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ =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..11abb8bd7eec 100644 --- a/tools/include/nolibc/arch-x86.h +++ b/tools/include/nolibc/arch-x86.h @@ -157,6 +157,7 @@ _eax; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ /* * i386 System V ABI mandates: @@ -176,6 +177,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ =20 #else /* !defined(__x86_64__) */ =20 @@ -323,6 +325,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s _ret; \ }) =20 +#ifndef NOLIBC_NO_RUNTIME /* startup code */ /* * x86-64 System V ABI mandates: @@ -340,6 +343,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoin= t __no_stack_protector _s ); __nolibc_entrypoint_epilogue(); } +#endif /* NOLIBC_NO_RUNTIME */ =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..d9262998dae9 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_RUNTIME + #include "compiler.h" =20 char **environ __attribute__((weak)); @@ -88,4 +90,5 @@ void _start_c(long *sp) exit(exitcode); } =20 +#endif /* NOLIBC_NO_RUNTIME */ #endif /* _NOLIBC_CRT_H */ diff --git a/tools/include/nolibc/stackprotector.h b/tools/include/nolibc/s= tackprotector.h index c71a2c257177..7123aa056cb0 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_RUNTIME #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_RUNTIME */ =20 #endif /* _NOLIBC_STACKPROTECTOR_H */ diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h index 5fd99a480f82..f184e108ed0a 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -100,6 +100,7 @@ void free(void *ptr) munmap(heap, heap->len); } =20 +#ifndef NOLIBC_NO_RUNTIME /* getenv() tries to find the environment variable named in the * environment array pointed to by global variable "environ" which must be * declared as a char **, and must be terminated by a NULL (it is recommen= ded @@ -122,6 +123,7 @@ char *getenv(const char *name) } return NULL; } +#endif /* NOLIBC_NO_RUNTIME */ =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..a48f5117bfce 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_RUNTIME 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_RUNTIME */ =20 /* * uid_t getuid(void); diff --git a/tools/include/nolibc/sys/auxv.h b/tools/include/nolibc/sys/aux= v.h index c52463d6c18d..0e98325e7347 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_RUNTIME + #include "../crt.h" =20 static __attribute__((unused)) @@ -38,4 +40,5 @@ unsigned long getauxval(unsigned long type) return ret; } =20 +#endif /* NOLIBC_NO_RUNTIME */ #endif /* _NOLIBC_SYS_AUXV_H */ --=20 2.51.0 From nobody Thu Oct 2 06:16:49 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 996EE31BC9D; Fri, 19 Sep 2025 15:36: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=1758296172; cv=none; b=hNqshC7hMY0u+vlDleo3y4/hr4zfB8ouHbEsNVMbNNYHB2O+Q78DcFmpD+pVyf0eTK3JvvJlKbgmJ/iS26DGlU/ggSXcvB/Os5TAzoOSovyH0zZSQQgHt2/xgk8tff+YdivdQL8K9r1fi99nH4kTlXZJSBi7U897b+Ovog2i/dA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296172; c=relaxed/simple; bh=fx18mHkX/v80wGI7XRo5gGPBbygD8VbMZyhP9EZSlqI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cre4o5bvbxraznfB+1i2TJPr0j1wxEtDjo4fH6cSyIkDCVova3O/F/rUBfqfs7hQFYp2SZjpoWYs+IAJbkJ4Zoylm+QZplLJ6rOTo/lMyDEfA7hC5ZxMlKXpEkUMWipCvASHDrGzji0l5LE7sHkXlfnnFJQtAVW1y9xJ34hOVZI= 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=i8cj1TSa; 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="i8cj1TSa" 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=c+1HXvxd4hXiAOxdd0af57RhIuaagKYTnqM46MPDRos=; t=1758296170; x=1759505770; b=i8cj1TSanLMNXLJ2d9ZM7ZfWoQqdE/DiMByaoZFcBiEGIDX mHeekkt5Ivkm6hmaXbJ4qHknxEmJG20/54/nXiPgofWhrcAe+kGBLGkwz/U14xKzHgowbBR85Bjqt OiqMMhfiFCryj26WzcP5vXEnt06PUPA7I8iNE1WBAD0wK8XwkNBQ3P+rwrRMR3SZczyZL/D7HLZFc ABY3U1MgI+CQ/pFfbMFS/Z27RHnVoLkqPqMNB/ED3b7Zf+zHInwIopUBPQB26NvoMBirnqa7Ylp7N EYQanwYKwjSuFTonCvEL/27fXWnOVIMldHlKzQpUdriQvd4KfuvtKX9Mwh5DJVvQ==; 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 1uzd9b-0000000G6O6-0VDy; Fri, 19 Sep 2025 17:36: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, Benjamin Berg Subject: [PATCH v2 07/11] um: add infrastructure to build files using nolibc Date: Fri, 19 Sep 2025 17:34:16 +0200 Message-ID: <20250919153420.727385-8-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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 --- v2: - Do not include nolibc.h via CFLAGS - Make syscall guard more explicit - Remove __UM_NOLIBC__ define, it is not needed - Fix out-of-tree building --- arch/um/Makefile | 20 +++++++++++++++++++- arch/um/include/shared/os.h | 2 ++ arch/um/include/shared/user.h | 1 - arch/um/scripts/Makefile.rules | 8 +++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/arch/um/Makefile b/arch/um/Makefile index f7c509262568..c3a81df50911 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -78,6 +78,24 @@ 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__ \ + -DNOLIBC_NO_RUNTIME \ + -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 $(objtree)/include/generated/autoconf.h \ + -include $(srctree)/tools/include/linux/kconfig.h \ + -include $(srctree)/include/linux/kern_levels.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 @@ -160,4 +178,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..a131ae9e00db 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 NOLIBC long syscall(long number, ...); +#endif =20 /* irqflags tracing */ extern void block_signals_trace(void); diff --git a/arch/um/include/shared/user.h b/arch/um/include/shared/user.h index c9b853e1282f..e32bdd032029 100644 --- a/arch/um/include/shared/user.h +++ b/arch/um/include/shared/user.h @@ -16,7 +16,6 @@ */ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) =20 -#include #include =20 extern void panic(const char *fmt, ...) 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 06:16:49 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 F150C31690F; Fri, 19 Sep 2025 15:36:11 +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=1758296173; cv=none; b=VbU6sptVkaVV8xDyICxvtQ9baVnD4xvn7b5BaSW1oXhKVq3l0L0WiHQw0vaEL3xoXobS8TVLnArpeB/zO3YXbwpWtrF0dv9sv8iLp0kkoGM5LGoRE91TwWVDCTuvTxPDm9el3rU7pok7mF1Ds+0Uxy0ziNI4dwtg0tx5slgh2yE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296173; c=relaxed/simple; bh=+1XbHYWO44eiLyr3lQME0rhVVOh0E9r61o4FckS2Ch8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QJbWyrsk2QSJKZGXl2U8IXF2iLaV9cYiuTk92ErvJvutqz6m/oStyMnH2uEwFyMnGtHS871FH8BksjvosZZRgsYdsDpLafQk0u/vvlVYk1uuxTjkvwZVnYi78ljDtLXCn6ZJjehmqoW9dJCT8Wf/yBXB11FxYMFjPemoosxwNrU= 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=u3KFDC5Q; 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="u3KFDC5Q" 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=1758296172; x=1759505772; b=u3KFDC5Q4r8E6W2iykSXrV7xA/yaVcq5UkX0U15zQaVs8Xn Kwkj6C8NTCMX/SVDVYe7sJqKPemH0ab6ktujeozlHW9NIEV18aPSomiDx8sSR/n8MOdcdSdpM+a+z +VMrJv9lRLRiFIdV2NmZToTc38njZIzLBXqLQimjrmYf+NhC2Ou9nYP7oD8KOxPVUKFEgEe5A7oP7 BWA8F4pngd+n9rPUVMGFOIfsa0f65+bafBbuJamHgae1wSukgurBIfru8Ze+8ucGwImzWgkwD856d J9sFcj6YdhlrzuFj82ILu/PaOtdY/caiDyqjpUzD94L7vWSbvHBxwalV1dxM2c5g==; 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 1uzd9c-0000000G6O6-0blB; Fri, 19 Sep 2025 17:36: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, Benjamin Berg Subject: [PATCH v2 08/11] um: use nolibc for the --showconfig implementation Date: Fri, 19 Sep 2025 17:34:17 +0200 Message-ID: <20250919153420.727385-9-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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 06:16:49 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 149EF31BC81; Fri, 19 Sep 2025 15:36: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=1758296174; cv=none; b=nfbzpe7Xx0QstsIzAEl8FXvUCyigbYLjBkdjTfoXmK7STpADEZRHN0WTOPaef6c07rpXV7X/Cb+j5xunqC0a89WoiFibRSxdq2gHWPDv0rxAMYLgLcsTe686IqvOf30l0Zoj+PsaJKZfhb307WmVzjq3fMBP5+khuUtcY/A6f7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296174; c=relaxed/simple; bh=taxwy3/wHYmIodE2cY7hf1NAW91/I4m0Nh4635bcPcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IoWZsHcf4qLNxfcqvIcdCtuxdAzKF6zUFx5FpKwwyr/2c8bPqL8dV0UnUlAGoTEaAMTKuX2xxDWSHFWOmGVUouMxT+HjVqqs4DPrSLeBkr7gqxDbM8UU2yfcmOf/tPLlNXd3GJdiakOJwPGe+paRfEeZc3i5tZES92oxcM5xkzY= 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=LHfIAMAo; 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="LHfIAMAo" 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=7Np3imODxsjoOhAuPXHTzANt4hW9A1qllEuJgkf7Rf4=; t=1758296173; x=1759505773; b=LHfIAMAoe1Ko7keOV/8lG3WRgMdbShAz3kL6WecfbZK30QX 2zoHUBhpLULBQ12QhoNpINo9piRdGCfMO3OemTF1X4dXCy5LSkZRX7uVA9zIzo5rCRxw/4ojFhq66 TByHEWoizV90534AQ+suvY9CjtQE8TPX6KkTm7GfplDc0zZJzDKLvq1s8YeQUUmiTosYzXL+Ueo34 Us2T521K8kM6+YDTifIxvXaBOKO/yRlPRT1McFBOtf/Ea3iPNKdqSUkz8PCfrxssZLtNDYb3avyB7 bAAXanrX7HDg9ij+sCf84AE1l0ltTpnDfmZ/Gsw/OvswYyzmmlp1UkpFP4pGiGVQ==; 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 1uzd9d-0000000G6O6-2qln; Fri, 19 Sep 2025 17:36: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, Benjamin Berg Subject: [PATCH v2 09/11] tools/nolibc: add uio.h with readv and writev Date: Fri, 19 Sep 2025 17:34:18 +0200 Message-ID: <20250919153420.727385-10-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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 generally useful and struct iovec is also needed for other purposes such as ptrace. Signed-off-by: Benjamin Berg --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys/uio.h | 49 ++++++++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 9 ++++ 4 files changed, 60 insertions(+) create mode 100644 tools/include/nolibc/sys/uio.h diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 143c2d2c2ba6..9bbbba32dac6 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -62,6 +62,7 @@ all_files :=3D \ sys/time.h \ sys/timerfd.h \ sys/types.h \ + sys/uio.h \ sys/utsname.h \ sys/wait.h \ time.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index c199ade200c2..b4bc1c9b883d 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -109,6 +109,7 @@ #include "sys/sysmacros.h" #include "sys/time.h" #include "sys/timerfd.h" +#include "sys/uio.h" #include "sys/utsname.h" #include "sys/wait.h" #include "ctype.h" diff --git a/tools/include/nolibc/sys/uio.h b/tools/include/nolibc/sys/uio.h new file mode 100644 index 000000000000..7ad42b927d2f --- /dev/null +++ b/tools/include/nolibc/sys/uio.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * uio for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + * Copyright (C) 2025 Intel Corporation + */ + +/* make sure to include all global symbols */ +#include "../nolibc.h" + +#ifndef _NOLIBC_SYS_UIO_H +#define _NOLIBC_SYS_UIO_H + +#include "../sys.h" +#include + + +/* + * ssize_t readv(int fd, const struct iovec *iovec, int count); + */ +static __attribute__((unused)) +ssize_t sys_readv(int fd, const struct iovec *iovec, int count) +{ + return my_syscall3(__NR_readv, fd, iovec, count); +} + +static __attribute__((unused)) +ssize_t readv(int fd, const struct iovec *iovec, int count) +{ + return __sysret(sys_readv(fd, iovec, count)); +} + +/* + * ssize_t writev(int fd, const struct iovec *iovec, int count); + */ +static __attribute__((unused)) +ssize_t sys_writev(int fd, const struct iovec *iovec, int count) +{ + return my_syscall3(__NR_writev, fd, iovec, count); +} + +static __attribute__((unused)) +ssize_t writev(int fd, const struct iovec *iovec, int count) +{ + return __sysret(sys_writev(fd, iovec, count)); +} + + +#endif /* _NOLIBC_SYS_UIO_H */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index a297ee0d6d07..1907128bc3f6 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1283,6 +1284,10 @@ int run_syscall(int min, int max) int proc; int test; int tmp; + struct iovec iov_one =3D { + .iov_base =3D &tmp, + .iov_len =3D 1, + }; int ret =3D 0; void *p1, *p2; int has_gettid =3D 1; @@ -1395,6 +1400,10 @@ int run_syscall(int min, int max) CASE_TEST(waitpid_child); EXPECT_SYSER(1, waitpid(getpid(), &tmp, WN= OHANG), -1, ECHILD); break; CASE_TEST(write_badf); EXPECT_SYSER(1, write(-1, &tmp, 1), -1, EB= ADF); break; CASE_TEST(write_zero); EXPECT_SYSZR(1, write(1, &tmp, 0)); break; + CASE_TEST(readv_badf); EXPECT_SYSER(1, readv(-1, &iov_one, 1), -1= , EBADF); break; + CASE_TEST(readv_zero); EXPECT_SYSZR(1, readv(1, NULL, 0)); break; + CASE_TEST(writev_badf); EXPECT_SYSER(1, writev(-1, &iov_one, 1), -= 1, EBADF); break; + CASE_TEST(writev_zero); EXPECT_SYSZR(1, writev(1, NULL, 0)); break; CASE_TEST(syscall_noargs); EXPECT_SYSEQ(1, syscall(__NR_getpid), getp= id()); break; CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_statx, 0, NUL= L, 0, 0, NULL), -1, EFAULT); break; CASE_TEST(namespace); EXPECT_SYSZR(euid0 && proc, test_namespace= ()); break; --=20 2.51.0 From nobody Thu Oct 2 06:16:49 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 1B14131D369; Fri, 19 Sep 2025 15:36: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=1758296176; cv=none; b=iWRUGGiY9I1fCa/m4GEp0VOk1fpNu9QpekrUVBVYras00ysfxRj++7dFCu5G3VF2QHfV+ulfeGij9e6c2Tni92osS8g7dN8sTZUlt4vRs5mwNtsXC7N280QKa0NzxtsAVU7mXFlIsXPmAiUKXuLvK0njVh2FbHM371CH5qBigMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296176; c=relaxed/simple; bh=rJjlvQq2edYfrYlSPc09wTCxHjzMxtUi0IeHlrgomMU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hPjHtEJhbczKavkBnEJQxsyYfeI+kQbh6Mtpigsn4XrnxdD6BT4OYlR/iwtISy8xjmCtcsh51rGUYzwSV2yR+W/SGFGxuK9gZheMk5xZ2HMcy0R6As5LEvaOiX+Gjs0a1aRpSbp9cd7MCdGJ+M8K8kFmGqn3hXLlew34A/v7Hc4= 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=FBC2YWFr; 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="FBC2YWFr" 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=RXl6ubRbFlom4y2e4H1GJqpLZi638eTvTDwJgOCQyw8=; t=1758296174; x=1759505774; b=FBC2YWFrEcRv7WbqI/XbgqRjtwxu+bDY/6kup4e3sr5BAkE hXywxPWRlzVTaF2cqEoxCVWzqdV6czu/PcrcsYrEY3GuV8WzPAeDZsnYI33L29lAmdMjfxV3iAqIY KLLHIze5TP4kMkDxFP3T+2cHcNT2v792gTCU1vZvgyUrOJuLiRAW2Mng/6f2Ct2c/4NHcgGR8YSDK saIIsdM3wXg2hrFvmXstn7kMeBMINp6r83Vx4zMDPmG6kmEryNBShLURfltAD7bNCEUTylUSxv/rm eHiZDniWu3K8+fM5hLYMgzuSmShfRzPynD2MOpsRFZQEqNWgJNB6pUsrz0FCl24w==; 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 1uzd9f-0000000G6O6-0Sob; Fri, 19 Sep 2025 17:36:11 +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, Benjamin Berg Subject: [PATCH v2 10/11] tools/nolibc: add ptrace support Date: Fri, 19 Sep 2025 17:34:19 +0200 Message-ID: <20250919153420.727385-11-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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 ptrace support, as it will be useful in UML. Signed-off-by: Benjamin Berg --- tools/include/nolibc/Makefile | 1 + tools/include/nolibc/nolibc.h | 1 + tools/include/nolibc/sys/ptrace.h | 52 ++++++++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 2 + 4 files changed, 56 insertions(+) create mode 100644 tools/include/nolibc/sys/ptrace.h diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index 9bbbba32dac6..8e0cac3ac522 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -53,6 +53,7 @@ all_files :=3D \ sys/mman.h \ sys/mount.h \ sys/prctl.h \ + sys/ptrace.h \ sys/random.h \ sys/reboot.h \ sys/resource.h \ diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index b4bc1c9b883d..590eef545ca6 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -101,6 +101,7 @@ #include "sys/mman.h" #include "sys/mount.h" #include "sys/prctl.h" +#include "sys/ptrace.h" #include "sys/random.h" #include "sys/reboot.h" #include "sys/resource.h" diff --git a/tools/include/nolibc/sys/ptrace.h b/tools/include/nolibc/sys/p= trace.h new file mode 100644 index 000000000000..3119abdeeecb --- /dev/null +++ b/tools/include/nolibc/sys/ptrace.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * ptrace for NOLIBC + * Copyright (C) 2017-2021 Willy Tarreau + * Copyright (C) 2025 Intel Corporation + */ + +/* make sure to include all global symbols */ +#include "../nolibc.h" + +#ifndef _NOLIBC_SYS_PTRACE_H +#define _NOLIBC_SYS_PTRACE_H + +#include "../sys.h" +#include "uio.h" + + +#include + +/* + * long ptrace(int op, pid_t pid, void *addr, void *data); + * + * However, addr may also be an integer in some cases. + */ +static __attribute__((unused)) +long sys_vptrace(int op, pid_t pid, va_list args) +{ + return my_syscall4(__NR_ptrace, op, pid, + va_arg(args, void *), va_arg(args, void *)); +} + +static __attribute__((unused)) +ssize_t sys_ptrace(int op, pid_t pid, ...) +{ + va_list args; + + va_start(args, pid); + return sys_vptrace(op, pid, args); + va_end(args); +} + +static __attribute__((unused)) +ssize_t ptrace(int op, pid_t pid, ...) +{ + va_list args; + + va_start(args, pid); + return __sysret(sys_vptrace(op, pid, args)); + va_end(args); +} + +#endif /* _NOLIBC_SYS_PTRACE_H */ diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 1907128bc3f6..4c1b9ee32b7d 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1404,6 +1405,7 @@ int run_syscall(int min, int max) CASE_TEST(readv_zero); EXPECT_SYSZR(1, readv(1, NULL, 0)); break; CASE_TEST(writev_badf); EXPECT_SYSER(1, writev(-1, &iov_one, 1), -= 1, EBADF); break; CASE_TEST(writev_zero); EXPECT_SYSZR(1, writev(1, NULL, 0)); break; + CASE_TEST(ptrace); EXPECT_SYSER(1, ptrace(PTRACE_CONT, getpid= (), NULL, NULL), -1, ESRCH); break; CASE_TEST(syscall_noargs); EXPECT_SYSEQ(1, syscall(__NR_getpid), getp= id()); break; CASE_TEST(syscall_args); EXPECT_SYSER(1, syscall(__NR_statx, 0, NUL= L, 0, 0, NULL), -1, EFAULT); break; CASE_TEST(namespace); EXPECT_SYSZR(euid0 && proc, test_namespace= ()); break; --=20 2.51.0 From nobody Thu Oct 2 06:16:49 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 281F431D753; Fri, 19 Sep 2025 15:36:15 +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=1758296177; cv=none; b=qJPNj6jCszpnQu5BBIv+WygLn2M+IuqP16a9nC04/hiwbOoFh9FeQ2j2JHADXMtncWXuLLwZLwSyXe/nFAR6pYDYkO9xGIXWqQ8j7vDp69fEVh2ic8eHelceb3/Roc+86CcFidUEPUq5Lu6YV/GZ1hiu6EbUrd1GMPDE0AkEiaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758296177; c=relaxed/simple; bh=uXhIw5zxMb39SCOcYyn2/s8W7NvYLQ4cNhq6hCD5gAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pZqwD2T+OZXcbdFqQ10qLhAPeqariBmsIKCnvjRSkGWOUuFGRzlsRz3bY1spwrrusI9Zgt5JxSaUGbvYJsUXhrsMv+Fz6/bksnZoAFP32D8COfS2+qXGJNkXcZeXt12g3y3GP2+gaqCbhyzsTTcOGfgj69q9gNJh4AZNSQiCHE0= 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=papsG43X; 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="papsG43X" 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=xO+mVCdWx08eTZ/4OCDNFnsQTwYMKX45MEVddt3khI4=; t=1758296176; x=1759505776; b=papsG43XvMRSg+BRjdqjPlwpTANAiJy/UZS8+DyLzRMK44I r9PUAneVF7eFNYdWaOa2O/8ZPUbrBeLsAusZCFiCXXSUMmxWRuwTBOSAdq4f4xb38sbPwNHwmpGLn zRzwhvUkyKO2biFM/gH3mkUuq+XaehHLjMrvAP5u32i/ML55xV9t3XQ0hyNhi1VJZM0nMdyP06ioi LONmjghvX4ZxO/veYD/uENkWgdLIrzeYhEvmfatG8AHPqx54U5V2W34AnTS/uK3OJJ41tks2+K/uL siJBDBeMka3WTnh03phCpMkrJYFRt2p+MywloQ5F0RKsWWs8A6NNNAtH2c06xqRA==; 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 1uzd9f-0000000G6O6-44uB; Fri, 19 Sep 2025 17:36:12 +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, Benjamin Berg Subject: [PATCH v2 11/11] um: switch ptrace FP register access to nolibc Date: Fri, 19 Sep 2025 17:34:20 +0200 Message-ID: <20250919153420.727385-12-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250919153420.727385-1-benjamin@sipsolutions.net> References: <20250919153420.727385-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 contains the routines for floating point register access in ptrace mode and initial size detection. After the addition of sys/uio.h and sys/ptrace.h to nolibc it can be moved to use it by using the sys_ptrace() wrapper. Signed-off-by: Benjamin Berg --- v2: - Use new sys_ptrace from nolibc --- arch/x86/um/os-Linux/Makefile | 5 ++++- arch/x86/um/os-Linux/registers.c | 16 ++++------------ 2 files changed, 8 insertions(+), 13 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..e570e29c3d73 100644 --- a/arch/x86/um/os-Linux/registers.c +++ b/arch/x86/um/os-Linux/registers.c @@ -28,9 +28,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 sys_ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); } =20 int put_fp_registers(int pid, unsigned long *regs) @@ -40,9 +38,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 sys_ptrace(PTRACE_SETREGSET, pid, ptrace_regset, &iov); } =20 int arch_init_registers(int pid) @@ -60,9 +56,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 sys_ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); =20 if (ret =3D=3D -ENODEV) { #ifdef CONFIG_X86_32 @@ -71,9 +65,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 sys_ptrace(PTRACE_GETREGSET, pid, ptrace_regset, &iov); } =20 munmap(iov.iov_base, 2 * 1024 * 1024); --=20 2.51.0