From patchwork Sat Mar 25 14:08:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1761145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=K/FXaHOk; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PkLXt11YKz1yYB for ; Sun, 26 Mar 2023 01:09:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C0983851C20 for ; Sat, 25 Mar 2023 14:09:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C0983851C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679753340; bh=K5h+k1aTYafzTsjEq9ovLtcjzhUqIjDSegHcXb2ddzU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=K/FXaHOkHQfUCV0PmTIofQw6CnuXy2iKVzaaeIxQk5tS1GOrOIyq/oYq2rItlcOEn uuDbhhJTBzl+H7lQ5FVdKPDeMkx8svdignmWVHHgyxsX+Muq1bmjOR+JUym4Vi/t1t tjnQYL1Px40TFfqyWUeTRHkQ/CWINywHC2wtHJJE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id C1B513858C33 for ; Sat, 25 Mar 2023 14:08:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1B513858C33 Received: from stargazer.. (unknown [IPv6:240e:358:1172:ca00:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 6E5DC6647A; Sat, 25 Mar 2023 10:08:35 -0400 (EDT) To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Adhemerval Zanella Netto , Andreas Schwab , Florian Weimer , Xi Ruoyao Subject: [PATCH v2 1/5] linux: Add __ASSUME_SYSCALL_NAMED_WORKS to allow avoiding va_list for generic syscall Date: Sat, 25 Mar 2023 22:08:11 +0800 Message-Id: <20230325140815.4170296-2-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230325140815.4170296-1-xry111@xry111.site> References: <20230325140815.4170296-1-xry111@xry111.site> MIME-Version: 1.0 X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Currently GCC generates highly sub-optimal code on architectures where the calling convention prefers registers for argument passing. This is GCC PR100955. While it's technically a missed-optimization in GCC, it seems not trivial to fix (I've not seen any compiler which can optimize this properly yet). As the generic Linux syscall actually uses a fixed number of arguments, we can avoid va_list if possible and make the compiler do right thing. Add a macro __ASSUME_SYSCALL_NAMED_WORKS which should be defined if the calling convention treats (x named arguments + y variable arguments) exactly same as (x + y) named arguments, while each argument is either an integer of which the width is less than or equal to "long" or a pointer; and each argument can be fetched from the same register or the same offset from the stack pointer no matter how many (maybe zero) arguments are passed after it. --- sysdeps/unix/sysv/linux/syscall.c | 35 ++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/sysdeps/unix/sysv/linux/syscall.c b/sysdeps/unix/sysv/linux/syscall.c index a5a2843b73..ed5ad5afd5 100644 --- a/sysdeps/unix/sysv/linux/syscall.c +++ b/sysdeps/unix/sysv/linux/syscall.c @@ -16,9 +16,33 @@ License along with the GNU C Library. If not, see . */ -#include #include +#ifndef __ASSUME_SYSCALL_NAMED_WORKS +#include +#endif + +static inline long int +__syscall (long int number, long int a0, long int a1, long int a2, long int a3, + long int a4, long int a5) +{ + long int r = INTERNAL_SYSCALL_NCS_CALL (number, a0, a1, a2, a3, a4, a5); + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r))) + { + __set_errno (-r); + return -1; + } + return r; +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +long int +syscall (long int number, long int a0, long int a1, long int a2, long int a3, + long int a4, long int a5) +{ + return __syscall (number, a0, a1, a2, a3, a4, a5); +} +#else long int syscall (long int number, ...) { @@ -33,11 +57,6 @@ syscall (long int number, ...) long int a5 = va_arg (args, long int); va_end (args); - long int r = INTERNAL_SYSCALL_NCS_CALL (number, a0, a1, a2, a3, a4, a5); - if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r))) - { - __set_errno (-r); - return -1; - } - return r; + return __syscall (number, a0, a1, a2, a3, a4, a5); } +#endif From patchwork Sat Mar 25 14:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1761146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=TTc9tpX2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PkLXz5qDfz1yYB for ; Sun, 26 Mar 2023 01:09:07 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A49FC384D18E for ; Sat, 25 Mar 2023 14:09:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A49FC384D18E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679753345; bh=3cJBMqFBhp25RcPIdBZpdZeRGi6lJF/fxHBrICaDMMo=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TTc9tpX27j6Qo3T+FddJ8g4y/xwlpiTZOkFm14t2YeKqGyvd/KUg38cA84QDCTqn+ 1eR/fiSwGopok7qybwcGWrvRBGGNlKsT0I/YJrqBwiU2Prioc9Ctmf2GgJSLpYjHZ8 9OWL3sYEPcFR6zxHRBPzqYtIhEsR2aBr9VlQwKhU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id CE2D3385840C for ; Sat, 25 Mar 2023 14:08:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE2D3385840C Received: from stargazer.. (unknown [IPv6:240e:358:1172:ca00:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 0A11D66479; Sat, 25 Mar 2023 10:08:40 -0400 (EDT) To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Adhemerval Zanella Netto , Andreas Schwab , Florian Weimer , Xi Ruoyao Subject: [PATCH v2 2/5] linux: [__ASSUME_SYSCALL_NAMED_WORKS] Avoid using va_list for various syscall wrappers Date: Sat, 25 Mar 2023 22:08:12 +0800 Message-Id: <20230325140815.4170296-3-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230325140815.4170296-1-xry111@xry111.site> References: <20230325140815.4170296-1-xry111@xry111.site> MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This patch changes fcntl64, fcntl_nocancel, ioctl, mremap, open64, open64_nocancel, openat64, openat64_nocancel, prctl, and ptrace not to use va_list if the named arguments is passed in the same way as variable arguments in the calling convention. This removes the stack store operation emitted by the compiler for va_start macro. --- include/fcntl.h | 32 ++++++++++----- sysdeps/unix/sysv/linux/fcntl64.c | 40 ++++++++++++++---- sysdeps/unix/sysv/linux/fcntl_nocancel.c | 30 +++++++++++--- sysdeps/unix/sysv/linux/ioctl.c | 38 +++++++++++++---- sysdeps/unix/sysv/linux/mremap.c | 36 +++++++++++++++-- sysdeps/unix/sysv/linux/not-cancel.h | 8 ++-- sysdeps/unix/sysv/linux/open64.c | 35 +++++++++++++--- sysdeps/unix/sysv/linux/open64_nocancel.c | 29 +++++++++++-- sysdeps/unix/sysv/linux/openat64.c | 30 ++++++++++++-- sysdeps/unix/sysv/linux/openat64_nocancel.c | 29 +++++++++++-- sysdeps/unix/sysv/linux/prctl.c | 23 ++++++++++- sysdeps/unix/sysv/linux/ptrace.c | 45 +++++++++++++++------ 12 files changed, 308 insertions(+), 67 deletions(-) diff --git a/include/fcntl.h b/include/fcntl.h index be435047bc..9fa0475138 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -2,31 +2,43 @@ #include #ifndef _ISOMAC + +#ifdef FCNTL_INTERNAL_NAMED_ARGS +#define MODE mode_t mode +#define FCNTL_ARG void *arg +#else +#define MODE ... +#define FCNTL_ARG ... +#endif + /* Now define the internal interfaces. */ -extern int __open64 (const char *__file, int __oflag, ...); +extern int __open64 (const char *__file, int __oflag, MODE); libc_hidden_proto (__open64) -extern int __libc_open64 (const char *file, int oflag, ...); -extern int __libc_open (const char *file, int oflag, ...); +extern int __libc_open64 (const char *file, int oflag, MODE); +extern int __libc_open (const char *file, int oflag, MODE); libc_hidden_proto (__libc_open) -extern int __libc_fcntl (int fd, int cmd, ...); +extern int __libc_fcntl (int fd, int cmd, FCNTL_ARG); libc_hidden_proto (__libc_fcntl) extern int __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg) attribute_hidden; -extern int __libc_fcntl64 (int fd, int cmd, ...); +extern int __libc_fcntl64 (int fd, int cmd, FCNTL_ARG); libc_hidden_proto (__libc_fcntl64) -extern int __open (const char *__file, int __oflag, ...); +extern int __open (const char *__file, int __oflag, MODE); libc_hidden_proto (__open) -extern int __fcntl (int __fd, int __cmd, ...); +extern int __fcntl (int __fd, int __cmd, FCNTL_ARG); libc_hidden_proto (__fcntl) -extern int __fcntl64 (int __fd, int __cmd, ...) attribute_hidden; +extern int __fcntl64 (int __fd, int __cmd, FCNTL_ARG) attribute_hidden; libc_hidden_proto (__fcntl64) -extern int __openat (int __fd, const char *__file, int __oflag, ...) +extern int __openat (int __fd, const char *__file, int __oflag, MODE) __nonnull ((2)); libc_hidden_proto (__openat) -extern int __openat64 (int __fd, const char *__file, int __oflag, ...) +extern int __openat64 (int __fd, const char *__file, int __oflag, MODE) __nonnull ((2)); libc_hidden_proto (__openat64) +#undef MODE +#undef FCNTL_ARG + extern int __open_2 (const char *__path, int __oflag); extern int __open64_2 (const char *__path, int __oflag); extern int __openat_2 (int __fd, const char *__path, int __oflag); diff --git a/sysdeps/unix/sysv/linux/fcntl64.c b/sysdeps/unix/sysv/linux/fcntl64.c index 509cf0a6e2..d896d47ffb 100644 --- a/sysdeps/unix/sysv/linux/fcntl64.c +++ b/sysdeps/unix/sysv/linux/fcntl64.c @@ -16,14 +16,23 @@ License along with the GNU C Library; if not, see . */ +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#define fcntl64 __no_decl_fcntl64 +#else +#include +#endif + #define fcntl __no_decl_fcntl #define __fcntl __no_decl___fcntl #include #undef fcntl #undef __fcntl -#include +#undef fcntl64 + #include -#include #ifndef __NR_fcntl64 # define __NR_fcntl64 __NR_fcntl @@ -33,6 +42,24 @@ # define FCNTL_ADJUST_CMD(__cmd) __cmd #endif +static inline int +do_fcntl64 (int fd, int cmd, void *arg) +{ + cmd = FCNTL_ADJUST_CMD (cmd); + + if (cmd == F_SETLKW || cmd == F_SETLKW64 || cmd == F_OFD_SETLKW) + return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); + + return __fcntl64_nocancel_adjusted (fd, cmd, arg); +} + +#if __ASSUME_SYSCALL_NAMED_WORKS +int +__libc_fcntl64 (int fd, int cmd, void *arg) +{ + return do_fcntl64 (fd, cmd, arg); +} +#else int __libc_fcntl64 (int fd, int cmd, ...) { @@ -43,13 +70,10 @@ __libc_fcntl64 (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - cmd = FCNTL_ADJUST_CMD (cmd); - - if (cmd == F_SETLKW || cmd == F_SETLKW64 || cmd == F_OFD_SETLKW) - return SYSCALL_CANCEL (fcntl64, fd, cmd, arg); - - return __fcntl64_nocancel_adjusted (fd, cmd, arg); + return do_fcntl64 (fd, cmd, arg); } +#endif + libc_hidden_def (__libc_fcntl64) weak_alias (__libc_fcntl64, __fcntl64) libc_hidden_weak (__fcntl64) diff --git a/sysdeps/unix/sysv/linux/fcntl_nocancel.c b/sysdeps/unix/sysv/linux/fcntl_nocancel.c index 005d324fda..b755973ce2 100644 --- a/sysdeps/unix/sysv/linux/fcntl_nocancel.c +++ b/sysdeps/unix/sysv/linux/fcntl_nocancel.c @@ -16,10 +16,17 @@ License along with the GNU C Library; if not, see . */ -#include +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#else #include +#endif + #include -#include + +#include #include #ifndef __NR_fcntl64 @@ -30,6 +37,19 @@ # define FCNTL_ADJUST_CMD(__cmd) __cmd #endif +static inline int +do_fcntl64_nocancel (int fd, int cmd, void *arg) +{ + return __fcntl64_nocancel_adjusted (fd, FCNTL_ADJUST_CMD (cmd), arg); +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__fcntl64_nocancel (int fd, int cmd, void *arg) +{ + return do_fcntl64_nocancel (fd, cmd, arg); +} +#else int __fcntl64_nocancel (int fd, int cmd, ...) { @@ -40,10 +60,10 @@ __fcntl64_nocancel (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - cmd = FCNTL_ADJUST_CMD (cmd); - - return __fcntl64_nocancel_adjusted (fd, cmd, arg); + return do_fcntl64_nocancel (fd, cmd, arg); } +#endif + hidden_def (__fcntl64_nocancel) int diff --git a/sysdeps/unix/sysv/linux/ioctl.c b/sysdeps/unix/sysv/linux/ioctl.c index e059942801..aca5ad5daa 100644 --- a/sysdeps/unix/sysv/linux/ioctl.c +++ b/sysdeps/unix/sysv/linux/ioctl.c @@ -16,19 +16,18 @@ License along with the GNU C Library. If not, see . */ +#include + +#ifndef __ASSUME_SYSCALL_NAMED_WORKS #include #include -#include +#endif + #include -int -__ioctl (int fd, unsigned long int request, ...) +static inline int +do_ioctl (int fd, unsigned long int request, void *arg) { - va_list args; - va_start (args, request); - void *arg = va_arg (args, void *); - va_end (args); - int r; if (!__ioctl_arch (&r, fd, request, arg)) { @@ -41,6 +40,29 @@ __ioctl (int fd, unsigned long int request, ...) } return r; } + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +__typeof (do_ioctl) __ioctl; +libc_hidden_proto(__ioctl) + +int +__ioctl (int fd, unsigned long int request, void *arg) +{ + return do_ioctl (fd, request, arg); +} +#else +int +__ioctl (int fd, unsigned long int request, ...) +{ + va_list args; + va_start (args, request); + void *arg = va_arg (args, void *); + va_end (args); + + return do_ioctl (fd, request, arg); +} +#endif + libc_hidden_def (__ioctl) weak_alias (__ioctl, ioctl) diff --git a/sysdeps/unix/sysv/linux/mremap.c b/sysdeps/unix/sysv/linux/mremap.c index 0ad5da86a2..26db22ffa5 100644 --- a/sysdeps/unix/sysv/linux/mremap.c +++ b/sysdeps/unix/sysv/linux/mremap.c @@ -16,11 +16,40 @@ License along with the GNU C Library; if not, see . */ -#include #include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define mremap __no_decl_mremap +#define __mremap __no_decl___mremap +#else #include +#endif + +#include + +#undef mremap +#undef __mremap + #include +static inline void * +do_mremap (void *addr, size_t old_len, size_t new_len, int flags, + void *new_addr) +{ + return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags, + new_addr); +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +__typeof (do_mremap) __mremap; +libc_hidden_proto (__mremap) + +void * +__mremap (void *addr, size_t old_len, size_t new_len, int flags, void *new_addr) +{ + return do_mremap (addr, old_len, new_len, flags, new_addr); +} +#else void * __mremap (void *addr, size_t old_len, size_t new_len, int flags, ...) { @@ -34,8 +63,9 @@ __mremap (void *addr, size_t old_len, size_t new_len, int flags, ...) va_end (va); } - return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags, - new_addr); + return do_mremap (addr, old_len, new_len, flags, new_addr); } +#endif + libc_hidden_def (__mremap) weak_alias (__mremap, mremap) diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index ea2615b38a..1a95e1b008 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -29,16 +29,16 @@ #include /* Non cancellable open syscall. */ -__typeof (open) __open_nocancel; +__typeof (__open) __open_nocancel; /* Non cancellable open syscall (LFS version). */ -__typeof (open64) __open64_nocancel; +__typeof (__open64) __open64_nocancel; /* Non cancellable openat syscall. */ -__typeof (openat) __openat_nocancel; +__typeof (__openat) __openat_nocancel; /* Non cacellable openat syscall (LFS version). */ -__typeof (openat64) __openat64_nocancel; +__typeof (__openat64) __openat64_nocancel; /* Non cancellable read syscall. */ __typeof (__read) __read_nocancel; diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c index 9f33733ebc..af3fdb09cd 100644 --- a/sysdeps/unix/sysv/linux/open64.c +++ b/sysdeps/unix/sysv/linux/open64.c @@ -18,17 +18,42 @@ #include #include -#include -#include #include #include +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#define open64 __no_decl_open64 +#define open __no_decl_open +#else +#include +#endif + +#include + +#undef open64 +#undef open + +static inline int +do_open64 (const char *file, int oflag, mode_t mode) +{ + return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, + mode); +} + /* Open FILE with access OFLAG. If O_CREAT or O_TMPFILE is in OFLAG, a third argument is the file protection. */ +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__libc_open64 (const char *file, int oflag, mode_t mode) +{ + return do_open64 (file, oflag, mode); +} +#else int __libc_open64 (const char *file, int oflag, ...) { - int mode = 0; + mode_t mode = 0; if (__OPEN_NEEDS_MODE (oflag)) { @@ -38,9 +63,9 @@ __libc_open64 (const char *file, int oflag, ...) va_end (arg); } - return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, - mode); + return do_open64 (file, oflag, mode); } +#endif strong_alias (__libc_open64, __open64) libc_hidden_weak (__open64) diff --git a/sysdeps/unix/sysv/linux/open64_nocancel.c b/sysdeps/unix/sysv/linux/open64_nocancel.c index 5035521386..f64c308d40 100644 --- a/sysdeps/unix/sysv/linux/open64_nocancel.c +++ b/sysdeps/unix/sysv/linux/open64_nocancel.c @@ -16,17 +16,38 @@ License along with the GNU C Library; if not, see . */ +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#else +#include +#endif + #include #include #include -#include #include +static inline int +do_open64_nocancel (const char *file, int oflag, mode_t mode) +{ + return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, + mode); +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__open64_nocancel (const char *file, int oflag, mode_t mode) +{ + return do_open64_nocancel (file, oflag, mode); +} +#else int __open64_nocancel (const char *file, int oflag, ...) { - int mode = 0; + mode_t mode = 0; if (__OPEN_NEEDS_MODE (oflag)) { @@ -36,9 +57,9 @@ __open64_nocancel (const char *file, int oflag, ...) va_end (arg); } - return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | O_LARGEFILE, - mode); + return do_open64_nocancel (file, oflag, mode); } +#endif hidden_def (__open64_nocancel) diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c index 105eb8ab08..d5718eb261 100644 --- a/sysdeps/unix/sysv/linux/openat64.c +++ b/sysdeps/unix/sysv/linux/openat64.c @@ -16,14 +16,37 @@ License along with the GNU C Library; if not, see . */ -#include +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#define openat64 __no_decl_openat64 +#define openat __no_decl_openat +#else #include +#endif -#include +#include + +#undef openat64 +#undef openat + +static inline int +do_openat64 (int fd, const char *file, int oflag, mode_t mode) +{ + return SYSCALL_CANCEL (openat, fd, file, oflag | O_LARGEFILE, mode); +} /* Open FILE with access OFLAG. Interpret relative paths relative to the directory associated with FD. If OFLAG includes O_CREAT or O_TMPFILE, a fourth argument is the file protection. */ +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__libc_openat64 (int fd, const char *file, int oflag, mode_t mode) +{ + return do_openat64 (fd, file, oflag, mode); +} +#else int __libc_openat64 (int fd, const char *file, int oflag, ...) { @@ -36,8 +59,9 @@ __libc_openat64 (int fd, const char *file, int oflag, ...) va_end (arg); } - return SYSCALL_CANCEL (openat, fd, file, oflag | O_LARGEFILE, mode); + return do_openat64 (fd, file, oflag, mode); } +#endif strong_alias (__libc_openat64, __openat64) libc_hidden_weak (__openat64) diff --git a/sysdeps/unix/sysv/linux/openat64_nocancel.c b/sysdeps/unix/sysv/linux/openat64_nocancel.c index b9105805d2..55ef645179 100644 --- a/sysdeps/unix/sysv/linux/openat64_nocancel.c +++ b/sysdeps/unix/sysv/linux/openat64_nocancel.c @@ -16,12 +16,32 @@ License along with the GNU C Library; if not, see . */ -#include +#include + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define FCNTL_INTERNAL_NAMED_ARGS 1 +#else #include +#endif + +#include -#include #include +static inline int +do_openat64_nocancel (int fd, const char *file, int oflag, mode_t mode) +{ + return INLINE_SYSCALL_CALL (openat, fd, file, oflag | O_LARGEFILE, + mode); +} + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +int +__openat64_nocancel (int fd, const char *file, int oflag, mode_t mode) +{ + return do_openat64_nocancel (fd, file, oflag, mode); +} +#else int __openat64_nocancel (int fd, const char *file, int oflag, ...) { @@ -34,9 +54,10 @@ __openat64_nocancel (int fd, const char *file, int oflag, ...) va_end (arg); } - return INLINE_SYSCALL_CALL (openat, fd, file, oflag | O_LARGEFILE, - mode); + return do_openat64_nocancel (fd, file, oflag, mode); } +#endif + hidden_def (__openat64_nocancel) #ifdef __OFF_T_MATCHES_OFF64_T diff --git a/sysdeps/unix/sysv/linux/prctl.c b/sysdeps/unix/sysv/linux/prctl.c index 68b97a4388..2c6e889f18 100644 --- a/sysdeps/unix/sysv/linux/prctl.c +++ b/sysdeps/unix/sysv/linux/prctl.c @@ -17,14 +17,34 @@ . */ #include + +#ifndef __ASSUME_SYSCALL_NAMED_WORKS #include #include +#endif + +static inline int +do_prctl (int option, unsigned long int arg2, unsigned long int arg3, + unsigned long int arg4, unsigned long int arg5) +{ + return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5); +} /* Unconditionally read all potential arguments. This may pass garbage values to the kernel, but avoids the need for teaching glibc the argument counts of individual options (including ones that are added to the kernel in the future). */ +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +__typeof (do_prctl) __prctl; +libc_hidden_proto (__prctl) +int +__prctl (int option, unsigned long int arg2, unsigned long int arg3, + unsigned long int arg4, unsigned long int arg5) +{ + return do_prctl (option, arg2, arg3, arg4, arg5); +} +#else int __prctl (int option, ...) { @@ -35,8 +55,9 @@ __prctl (int option, ...) unsigned long int arg4 = va_arg (arg, unsigned long int); unsigned long int arg5 = va_arg (arg, unsigned long int); va_end (arg); - return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5); + return do_prctl (option, arg2, arg3, arg4, arg5); } +#endif libc_hidden_def (__prctl) weak_alias (__prctl, prctl) diff --git a/sysdeps/unix/sysv/linux/ptrace.c b/sysdeps/unix/sysv/linux/ptrace.c index 239344fe7a..e1a1282505 100644 --- a/sysdeps/unix/sysv/linux/ptrace.c +++ b/sysdeps/unix/sysv/linux/ptrace.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -25,19 +24,17 @@ #include #include -long int -ptrace (enum __ptrace_request request, ...) +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +#define ptrace __no_decl_ptrace +#endif + +#include +#undef ptrace + +static inline long int +do_ptrace (enum __ptrace_request request, pid_t pid, void *addr, void *data) { long int res, ret; - va_list ap; - pid_t pid; - void *addr, *data; - - va_start (ap, request); - pid = va_arg (ap, pid_t); - addr = va_arg (ap, void *); - data = va_arg (ap, void *); - va_end (ap); if (request > 0 && request < 4) data = &ret; @@ -51,3 +48,27 @@ ptrace (enum __ptrace_request request, ...) return res; } + +#ifdef __ASSUME_SYSCALL_NAMED_WORKS +long int +ptrace (enum __ptrace_request request, pid_t pid, void *addr, void *data) +{ + return do_ptrace (request, pid, addr, data); +} +#else +long int +ptrace (enum __ptrace_request request, ...) +{ + va_list ap; + pid_t pid; + void *addr, *data; + + va_start (ap, request); + pid = va_arg (ap, pid_t); + addr = va_arg (ap, void *); + data = va_arg (ap, void *); + va_end (ap); + + return do_ptrace (request, pid, addr, data); +} +#endif From patchwork Sat Mar 25 14:08:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1761147 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=DD0iUMaN; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PkLYh5TLPz1yYB for ; Sun, 26 Mar 2023 01:09:44 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B3C78387088C for ; Sat, 25 Mar 2023 14:09:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3C78387088C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679753382; bh=+hE3u+rAXTn7npK4KKZCjLkGlskwAanG6AwvzXwCoNc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=DD0iUMaN+K9RsiYg3LYuX0JpIAXvloUUooDVEK2XXmHhWKbewdaK5Jln6rMDWJPpQ whcG7Qyj1A9NBg0I3FJ/6ffpmAhSaVD7k1rmw97MpgzfZE/GLBU2ur/L0F/rSZOPLV JFUmci3cK9sodBVlpjUwvpS64FLU9WcywVD8Udnc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 1A4B9384F01A for ; Sat, 25 Mar 2023 14:08:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A4B9384F01A Received: from stargazer.. (unknown [IPv6:240e:358:1172:ca00:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id AE2136647A; Sat, 25 Mar 2023 10:08:46 -0400 (EDT) To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Adhemerval Zanella Netto , Andreas Schwab , Florian Weimer , Xi Ruoyao Subject: [PATCH v2 3/5] LoongArch: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux Date: Sat, 25 Mar 2023 22:08:13 +0800 Message-Id: <20230325140815.4170296-4-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230325140815.4170296-1-xry111@xry111.site> References: <20230325140815.4170296-1-xry111@xry111.site> MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" LoongArch calling convention treats the non-floating-point variable arguments same as named ones, and when each argument is an integer not wider than long or a pointer, the ith argument is in register $ai (0 <= i < 8) or the stack slot at ($sp + sizeof(long) * (i - 8)) (i >= 8) no matter how many arguments are passed. So we can define __ASSUME_SYSCALL_NAMED_WORKS to avoid unnecessary stack stores in the syscall wrappers caused by va_start. --- .../sysv/linux/loongarch/kernel-features.h | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/loongarch/kernel-features.h diff --git a/sysdeps/unix/sysv/linux/loongarch/kernel-features.h b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h new file mode 100644 index 0000000000..f862d0623f --- /dev/null +++ b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h @@ -0,0 +1,29 @@ +/* Set flags signalling availability of kernel features based on given + kernel version number. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include_next + +/* Define this if the calling convention for passing x named arguments and y + variable arguments is same as passing (x + y) named arguments, while each + argument is either an integer of which the width is less than or equal to + "long", or a pointer; and an argument can be fetched from the same register + or the same offset from the stack pointer no matter how many (maybe zero) + arguments are passed after it. It avoids useless stack stores caused by + usage of va_start. */ +#define __ASSUME_SYSCALL_NAMED_WORKS 1 From patchwork Sat Mar 25 14:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1761148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=hGI7DO18; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PkLYq1Vynz1yYB for ; Sun, 26 Mar 2023 01:09:51 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DDF23839DF9 for ; Sat, 25 Mar 2023 14:09:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DDF23839DF9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679753389; bh=c7z032JHLgXcaj1hYd8hFNWjNk14IhyMw346GemRawQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=hGI7DO18vcv9C9WYmklRamdvgphEbKwvmqwE98Ci2/CTw2mruYEaklKFP0tFneKnL wqV+H/moJTV4xBlh7muPzBtCKCPEoFhScPRqjS+Y5ouN6GPdhOHITUQzeG88oNTqm/ 2ZgBN2uq3E/ImqkzinPuu2nAFlcGhc2/Szp8+MN4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id DE67E384840A for ; Sat, 25 Mar 2023 14:08:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE67E384840A Received: from stargazer.. (unknown [IPv6:240e:358:1172:ca00:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 1A38866479; Sat, 25 Mar 2023 10:08:51 -0400 (EDT) To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Adhemerval Zanella Netto , Andreas Schwab , Florian Weimer , Xi Ruoyao Subject: [PATCH v2 4/5] x86_64: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux Date: Sat, 25 Mar 2023 22:08:14 +0800 Message-Id: <20230325140815.4170296-5-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230325140815.4170296-1-xry111@xry111.site> References: <20230325140815.4170296-1-xry111@xry111.site> MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" x86_64 calling convention treats the variable arguments same as named ones (it sets %al to the number of floating-point variable arguments but it's simply ignored because our syscall wrappers don't take floating-point arguments), and when each argument is an integer not wider than 8 bytes, the ith argument is in registers %rdi, %rsi, %rdx, %rcx, %r8, and %r9 (0 <= i < 6), or the stack slot at (%rsp + 8 * (i - 6)) (i >= 8) no matter how many arguments are passed. So we can define __ASSUME_SYSCALL_NAMED_WORKS to avoid unnecessary stack stores in the syscall wrappers caused by va_start. --- sysdeps/unix/sysv/linux/x86_64/kernel-features.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h index 68322ff476..7783a0eebc 100644 --- a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h +++ b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h @@ -23,4 +23,13 @@ # define __ASSUME_WORDSIZE64_ILP32 1 #endif +/* Define this if the calling convention for passing x named arguments and y + variable arguments is same as passing (x + y) named arguments, while each + argument is either an integer of which the width is less than or equal to + "long", or a pointer; and an argument can be fetched from the same register + or the same offset from the stack pointer no matter how many (maybe zero) + arguments are passed after it. It avoids useless stack stores caused by + usage of va_start. */ +#define __ASSUME_SYSCALL_NAMED_WORKS 1 + #include_next From patchwork Sat Mar 25 14:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1761149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=f2Jn09wJ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PkLZd0X97z1yY7 for ; Sun, 26 Mar 2023 01:10:32 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BED7C387088E for ; Sat, 25 Mar 2023 14:10:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BED7C387088E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679753430; bh=Pa//2o1+jzg0ejVFVGnbhB3uwiYpa1yM+74esOI3omw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=f2Jn09wJU6LdP/CT15Sm6K4ZQB5eRdqgRi/DQ1T6yNvZI3bRndEi8uJVW1A3d0rAR G3ViPcbShA2WO7x4LlbJV35OJ7aAi+nntChe6vv66dEW2E6vmj9ArATRNDiXRbz9v8 llG/DrzGJJhv4+LnIf1WuRO67oKX7P8qDfkqcXKQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 624AB3858409 for ; Sat, 25 Mar 2023 14:09:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 624AB3858409 Received: from stargazer.. (unknown [IPv6:240e:358:1172:ca00:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 12A006647A; Sat, 25 Mar 2023 10:08:58 -0400 (EDT) To: libc-alpha@sourceware.org Cc: caiyinyu , Wang Xuerui , Adhemerval Zanella Netto , Andreas Schwab , Florian Weimer , Xi Ruoyao Subject: [PATCH v2 5/5] aarch64: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux Date: Sat, 25 Mar 2023 22:08:15 +0800 Message-Id: <20230325140815.4170296-6-xry111@xry111.site> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230325140815.4170296-1-xry111@xry111.site> References: <20230325140815.4170296-1-xry111@xry111.site> MIME-Version: 1.0 X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LIKELY_SPAM_FROM, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" AAPCS treats the variable arguments same as named ones, and when each argument is an integer not wider than 8 bytes, the ith argument is in register xi (0 <= i < 8), or the stack slot at (sp + 8 * (i - 8)) (i >= 8) no matter how many arguments are passed. So we can define __ASSUME_SYSCALL_NAMED_WORKS to avoid unnecessary stack stores in the syscall wrappers caused by va_start. --- sysdeps/unix/sysv/linux/aarch64/kernel-features.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sysdeps/unix/sysv/linux/aarch64/kernel-features.h b/sysdeps/unix/sysv/linux/aarch64/kernel-features.h index 3546f6de96..c39ff39da2 100644 --- a/sysdeps/unix/sysv/linux/aarch64/kernel-features.h +++ b/sysdeps/unix/sysv/linux/aarch64/kernel-features.h @@ -21,3 +21,12 @@ #undef __ASSUME_CLONE_DEFAULT #define __ASSUME_CLONE_BACKWARDS 1 + +/* Define this if the calling convention for passing x named arguments and y + variable arguments is same as passing (x + y) named arguments, while each + argument is either an integer of which the width is less than or equal to + "long", or a pointer; and an argument can be fetched from the same register + or the same offset from the stack pointer no matter how many (maybe zero) + arguments are passed after it. It avoids useless stack stores caused by + usage of va_start. */ +#define __ASSUME_SYSCALL_NAMED_WORKS 1