From patchwork Thu Sep 14 16:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13385677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4196EEAA54 for ; Thu, 14 Sep 2023 16:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4WZr78DiL+WS3uXhtLz9pQErniYXKfhlfitnikihv5g=; b=5FNJG3r8CXi7kE RPqEJGvwf0p9xpexKAXCWEnJ5YqxAXrmog0f2vqAiIlhhD19iJNo8jCmo52hBGKuAxHYFcUIyePwj 1d5G/5w4infh9PoC1PYnRYRJ46zrJk4i8x1uEXiBiCn2tWFuF3K2pg2Ibc0YlTM+N2poKvhwm8C5A wW1V+eVeEB+0A2AlE/US9m3xPGbE4Scx0NiaL847ea/l85aSVKewaTi6jG6DxrR4r3HL1J24SrCDM zmTtxD9EeNccAUWKylnY5Cw2aZQ7HmQvUtTdDT3RqRAXpMDAHG9U1Vg+qx+Ya13m9tRTIydvuStUC 9xtwDpYhCvQscFYFCpsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgomo-008qtI-0k; Thu, 14 Sep 2023 16:01:46 +0000 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgomh-008qpb-35 for linux-riscv@lists.infradead.org; Thu, 14 Sep 2023 16:01:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694707293; bh=9Dr/Qlwz9Z5VVtmbM8JisJIKlg1q6mK4mMaDaT8aZHA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fQaMl0ZADkTcn1qLdesYc0JElUD9GU3vjgALM2c2J2mMVoWd0UxMkI4DTYNLV6u71 N/euTGpE0aCdUp0gXHiuUqU+DXM1U0oq5wlWc4hq/C+9whepDaEWRX8wla4vJnezGV hLGAFnCFKk+1Kvk3qK+d/aFnNWNHlinSmp956LPU= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 Sep 2023 18:01:17 +0200 Subject: [PATCH 1/4] selftests/nolibc: allow building i386 with multiarch compiler MIME-Version: 1.0 Message-Id: <20230914-nolibc-syscall-nr-v1-1-e50df410da11@weissschuh.net> References: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> In-Reply-To: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> To: Willy Tarreau , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694707292; l=915; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=9Dr/Qlwz9Z5VVtmbM8JisJIKlg1q6mK4mMaDaT8aZHA=; b=4hV3jmCa9Owq/qDwKo7tLD8BIPuEx78VNy7e+gUuEGgiBDFvmAUaNjzfTv12ywRmmXc39/n+P t1qzu7r4eSGA1L3Bu5s4gUucQV1Iy2C30Ct+vTxX9WnaFcRJ9QUf+Yd X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_090140_148126_EADE6058 X-CRM114-Status: UNSURE ( 6.73 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org When building with a multiarch-capable compiler, like those provided by common distributions the -m32 argument is required to build 32bit code. Wrap it in cc-option in case the compiler is not multiarch-capable. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/testing/selftests/nolibc/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 689658f81a19..19096a9ded55 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -113,6 +113,7 @@ else Q=@ endif +CFLAGS_i386 = $(call cc-option,-m32) CFLAGS_ppc = -m32 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) CFLAGS_ppc64 = -m64 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) CFLAGS_ppc64le = -m64 -mlittle-endian -mno-vsx $(call cc-option,-mabi=elfv2) From patchwork Thu Sep 14 16:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13385679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 30A00EEAA53 for ; Thu, 14 Sep 2023 16:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oEHTtM+pHg7fYgyQNlJw2YSgzz78InThR14sFvEtnj8=; b=LwLkHGW0OYn4bC A7xkAdF2t1nBxCupN/PcoWTwPeDPtcigBee3b1sIkliXiZZKngzn5vydE6I8Jq2GRznc+48pRsA9+ p7xRC6kXpoOauLC4Y9JTtiNWOHrVMmhxrlXztPkSmWy3bNE4ldgozWfRY/4NAUsjW3hjGmF1bQKDk C9aj4NRfXOmgg1IS4S1D9p/vvZDlNmVzneWQ4V6aU7PqmSNl7/f5bGjov1DtGBevb01ghMrgECAV9 Xl6Q9OOZ/9tj/Z4eeaFIJ23nRwj76lZHNxkYvdPYdvRXyCzkdCiIY211X9msXbDd/n9fshrPHiLmi m6EQHs76G1PRWaARxQNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgomo-008qtW-2a; Thu, 14 Sep 2023 16:01:46 +0000 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgomh-008qpY-2w for linux-riscv@lists.infradead.org; Thu, 14 Sep 2023 16:01:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694707293; bh=rklkaKmuEop2mkqsY9+prLbWDx4KQ6pug1wWbwN/pUU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=l0Q201ayEAQrclQ0up4pYQXtSYdkzEK6uNrRoR2Ydz94iDRpFdRko733hWRKljKnX ek6mnVsHkN6wTlz9/mww7YXQUCAYev+O1cs3rkGQ/+0U4BHjqbkFa6enJpUr0UJXSr m4iTLUZQUUJE93+vAqr0qmdRE9D8GGyIxx+th+Tc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 Sep 2023 18:01:18 +0200 Subject: [PATCH 2/4] tools/nolibc: avoid unused parameter warnings for ENOSYS fallbacks MIME-Version: 1.0 Message-Id: <20230914-nolibc-syscall-nr-v1-2-e50df410da11@weissschuh.net> References: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> In-Reply-To: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> To: Willy Tarreau , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694707292; l=3290; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=rklkaKmuEop2mkqsY9+prLbWDx4KQ6pug1wWbwN/pUU=; b=3ASFNj+C1ZmK459CmYHIr9/+BQymJpv0Mz8eFVb1MBFyHEdV/HJa8qwuKaUDzvCrAjBT06SAh 2EY0avaf7rvCgBGFJj+0E3x0xKlFz9hy/NC6XYAJ7QBGapHZ5vh9TUM X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_090140_129481_413DD9F6 X-CRM114-Status: UNSURE ( 5.75 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The ENOSYS fallback code does not use its functions parameters. This can lead to compiler warnings about unused parameters. Explicitly avoid these warnings. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index b478750c9004..bc56310c6bdf 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -133,6 +133,8 @@ int sys_chmod(const char *path, mode_t mode) #elif defined(__NR_chmod) return my_syscall2(__NR_chmod, path, mode); #else + (void)path; + (void)mode; return -ENOSYS; #endif } @@ -156,6 +158,9 @@ int sys_chown(const char *path, uid_t owner, gid_t group) #elif defined(__NR_chown) return my_syscall3(__NR_chown, path, owner, group); #else + (void)path; + (void)owner; + (void)group; return -ENOSYS; #endif } @@ -230,6 +235,8 @@ int sys_dup2(int old, int new) #elif defined(__NR_dup2) return my_syscall2(__NR_dup2, old, new); #else + (void)old; + (void)new; return -ENOSYS; #endif } @@ -486,6 +493,8 @@ int sys_gettimeofday(struct timeval *tv, struct timezone *tz) #ifdef __NR_gettimeofday return my_syscall2(__NR_gettimeofday, tv, tz); #else + (void)tv; + (void)tz; return -ENOSYS; #endif } @@ -563,6 +572,8 @@ int sys_link(const char *old, const char *new) #elif defined(__NR_link) return my_syscall2(__NR_link, old, new); #else + (void)old; + (void)new; return -ENOSYS; #endif } @@ -584,6 +595,9 @@ off_t sys_lseek(int fd, off_t offset, int whence) #ifdef __NR_lseek return my_syscall3(__NR_lseek, fd, offset, whence); #else + (void)fd; + (void)offset; + (void)whence; return -ENOSYS; #endif } @@ -607,6 +621,8 @@ int sys_mkdir(const char *path, mode_t mode) #elif defined(__NR_mkdir) return my_syscall2(__NR_mkdir, path, mode); #else + (void)path; + (void)mode; return -ENOSYS; #endif } @@ -629,6 +645,7 @@ int sys_rmdir(const char *path) #elif defined(__NR_unlinkat) return my_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); #else + (void)path; return -ENOSYS; #endif } @@ -652,6 +669,9 @@ long sys_mknod(const char *path, mode_t mode, dev_t dev) #elif defined(__NR_mknod) return my_syscall3(__NR_mknod, path, mode, dev); #else + (void)path; + (void)mode; + (void)dev; return -ENOSYS; #endif } @@ -742,6 +762,9 @@ int sys_open(const char *path, int flags, mode_t mode) #elif defined(__NR_open) return my_syscall3(__NR_open, path, flags, mode); #else + (void)path; + (void)flags; + (void)mode; return -ENOSYS; #endif } @@ -842,6 +865,9 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) #elif defined(__NR_poll) return my_syscall3(__NR_poll, fds, nfds, timeout); #else + (void)fds; + (void)nfds; + (void)timeout; return -ENOSYS; #endif } @@ -934,6 +960,11 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva #endif return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); #else + (void)nfds; + (void)rfds; + (void)wfds; + (void)efds; + (void)timeout; return -ENOSYS; #endif } From patchwork Thu Sep 14 16:01:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13385680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A191EEAA52 for ; Thu, 14 Sep 2023 16:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Rh0dy/B/WNpJS4GDWU0oh8QjA6VOrWCOIaIL1mKxsCU=; b=K88RjUUSTsfy73 wteNpjpSB2O46xCJxJVGhpnB+ukvrIPAxviIdN63ZQSQrpshmYHSbpOSEKgBH8+orCOZcuTO4b66C JHcJTTtBSMuJxWa0xb00Ajz+pzmG5d8pDFdkhiFlcN0ZRdtxqHsUG9deZvcyrQS9iHdPKlvpkKT6/ vS3ZIh5OSgjG5ewtUz81rtrlO17If8NhtaLGTZmezLpjC8H9U19suWKaqBOgfUFGDJHjmbi8tveSK tYw9gZNSEqLHsJeQCWeRw2+Rw5miIvguHQir21ZZdo12MStE+dCYEgv0L8KYGRJUcalJ8qVSyKJ+8 ugCQw2SRUFg528LTbr/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgomk-008qr6-1Q; Thu, 14 Sep 2023 16:01:42 +0000 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgomh-008qpa-2n for linux-riscv@lists.infradead.org; Thu, 14 Sep 2023 16:01:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694707293; bh=Cu53Z9oyo5nGu95h1+MArmP5k33gYn4AQCWOgwsV/Ac=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nJXJ1xXHesT1KczhMwLWfm4v2NTSTPtV6KAFS2C4/pVvhrkdw5iJnNuZPfzcNH81X EtTjjm+ZcV9Z7OFkbIZxH8hQi/WlF1z44FUARs5NxJ4SAmGq+cjERWC0zZPVi655jx B+V7D+nxIi6ovzre3715c/cC7TfgIxPeombwOIp4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 Sep 2023 18:01:19 +0200 Subject: [PATCH 3/4] tools/nolibc: don't define new syscall number MIME-Version: 1.0 Message-Id: <20230914-nolibc-syscall-nr-v1-3-e50df410da11@weissschuh.net> References: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> In-Reply-To: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> To: Willy Tarreau , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694707292; l=1227; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Cu53Z9oyo5nGu95h1+MArmP5k33gYn4AQCWOgwsV/Ac=; b=gJVRysrB+1Fm++kEZkA6QvwJaFYmt27QWy1msKjd+eJjR2FaQgck9iIwYB4bxpA6by3xzT2p2 PzfnrKof6pvBVVTgIWWtMX9cfqisWMmTH2n3Am9bIT64PWNQbOqeho2 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_090140_076378_F58CA295 X-CRM114-Status: UNSURE ( 7.23 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org All symbols created by nolibc are also visible to user code. Syscall constants are expected to come from the kernel headers and should not be made up by nolibc. Refactor the logic to avoid defining syscall numbers. Also the new code is easier to understand. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/sys.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index bc56310c6bdf..d96f2aa7d987 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -954,11 +954,10 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva t.tv_nsec = timeout->tv_usec * 1000; } return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); -#elif defined(__NR__newselect) || defined(__NR_select) -#ifndef __NR__newselect -#define __NR__newselect __NR_select -#endif +#elif defined(__NR__newselect) return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); +#elif defined(__NR_select) + return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout); #else (void)nfds; (void)rfds; From patchwork Thu Sep 14 16:01:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13385678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3143FEEAA55 for ; Thu, 14 Sep 2023 16:01:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QBBcJJWMFR53g/+whbTy7EMU2hF5iXFPSlM1w3fLD4A=; b=0qQrOOvs4ArLps u3bfqJdM/Q2sMeaL0NMsKslGITYKqfP2iWKnisDP0j7JMMF+iStqczAehHi9b4ASr4vAv16T4A0xG ady1TpOJu9hEpAk3p2xyGh7rMyrwq0DpdWpF6Wv3CWUHP/tiY+Gn1+1HYPbhIDmecR1wfIz6uBj/E 6E7vCY2olW2uNZ81VN5yRUrTdvslt3sYhYwKkN7ZC6ynX+P1iELhByQg+dTdmyfdBJUtg7ItutfU7 GdsZhokgrTVj7ipOBMvTT4lK4n/E5u9sMJSQ2+KD1EMKZm8dVtZQfnXiEElJ93OhqeS/R7fWwNFU2 qR89BHWcqwDiuorzVsIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgomn-008qrx-0H; Thu, 14 Sep 2023 16:01:45 +0000 Received: from todd.t-8ch.de ([159.69.126.157]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgomh-008qpd-2N for linux-riscv@lists.infradead.org; Thu, 14 Sep 2023 16:01:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694707293; bh=zl3Xj+oQp2Dr3MQfACk4EonlZTHBYeQ+nfTgGzZOwVE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Y4CgCkNksk2J13ulVehJe/Ytv0sKK+LNKe/GNZXCdeZIMaFoGW9OlGrjttaz0ylS7 8g4puMZEVbV9XFppWL5QlcvofBOAiR5tgNLSdD9NuZ2Pm7iohQOcRlAjM7DXz6bvSU /5r2kwjn23Ssc99K6I0h63VzuV3TANTgNMTVA9vo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 Sep 2023 18:01:20 +0200 Subject: [PATCH 4/4] tools/nolibc: automatically detect necessity to use pselect6 MIME-Version: 1.0 Message-Id: <20230914-nolibc-syscall-nr-v1-4-e50df410da11@weissschuh.net> References: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> In-Reply-To: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> To: Willy Tarreau , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694707292; l=3914; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=zl3Xj+oQp2Dr3MQfACk4EonlZTHBYeQ+nfTgGzZOwVE=; b=F8EbEV7tGvVpu68Qr3EK6RIfDob0u0Yj2Wok7lOtDs9Z1s+WoEBEmIuIiU5hgIybWgIAnW2VT o284s51I2qYDdkhTq5ZYHZcd9Vboi/EkkwezL5N2eZpLKzuMwT1pykA X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_090139_946128_93D1B1FA X-CRM114-Status: GOOD ( 10.87 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org We can automatically detect if pselect6 is needed or not from the kernel headers. This removes the need to manually specify it. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/arch-aarch64.h | 3 --- tools/include/nolibc/arch-loongarch.h | 4 +--- tools/include/nolibc/arch-riscv.h | 3 --- tools/include/nolibc/sys.h | 10 +++++----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 6c33c46848e3..b23ac1f04035 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -20,10 +20,7 @@ * - the arguments are cast to long and assigned into the target registers * which are then simply passed as registers to the asm code, so that we * don't have to experience issues with register constraints. - * - * On aarch64, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 #define my_syscall0(num) \ ({ \ diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h index bf98f6220195..3f8ef8f86c0f 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -19,10 +19,8 @@ * - the arguments are cast to long and assigned into the target * registers which are then simply passed as registers to the asm code, * so that we don't have to experience issues with register constraints. - * - * On LoongArch, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 + #define _NOLIBC_SYSCALL_CLOBBERLIST \ "memory", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8" diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index 950cc2283fd7..1927c643c739 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -19,10 +19,7 @@ * - the arguments are cast to long and assigned into the target * registers which are then simply passed as registers to the asm code, * so that we don't have to experience issues with register constraints. - * - * On riscv, select() is not implemented so we have to use pselect6(). */ -#define __ARCH_WANT_SYS_PSELECT6 #define my_syscall0(num) \ ({ \ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index d96f2aa7d987..dbf5cc92181b 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -946,7 +946,11 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva struct timeval *t; } arg = { .n = nfds, .r = rfds, .w = wfds, .e = efds, .t = timeout }; return my_syscall1(__NR_select, &arg); -#elif defined(__ARCH_WANT_SYS_PSELECT6) && defined(__NR_pselect6) +#elif defined(__NR__newselect) + return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); +#elif defined(__NR_select) + return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout); +#elif defined(__NR_pselect6) struct timespec t; if (timeout) { @@ -954,10 +958,6 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva t.tv_nsec = timeout->tv_usec * 1000; } return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL); -#elif defined(__NR__newselect) - return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); -#elif defined(__NR_select) - return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout); #else (void)nfds; (void)rfds;