From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Joe Simmons-Talbott <josimmon@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v6 2/3] aarch64: Set the syscall register right before doing the syscall.
Date: Tue, 9 May 2023 08:47:06 +0100 [thread overview]
Message-ID: <ZFn6ev4L6lOo2Bbw@arm.com> (raw)
In-Reply-To: <20230424150353.1469397-3-josimmon@redhat.com>
The 04/24/2023 11:03, Joe Simmons-Talbott via Libc-alpha wrote:
> To make identifying syscalls easier during call tree analysis load the
> syscall number just before performing the syscall.
>
> Compiler optimizations can place quite a few instructions between the
> setting of the syscall number and the syscall instruction. During call
> tree analysis the number of instructions between the two can lead to
> more difficulty for both tools and humans in properly identifying the
> syscall number. Having the syscall number set in the prior instruction
> to the syscall instruction makes this task easier and less error prone.
> Being able to reliably identify syscalls made by a given API will make
> it easier to understand and verify the safety and security of glibc.
This is OK to commit.
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
> ---
> sysdeps/unix/sysv/linux/aarch64/sysdep.h | 29 ++++++++++++++++--------
> 1 file changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> index e94d1703ad..6fe40aaf89 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> @@ -168,15 +168,26 @@
> # define HAVE_CLONE3_WRAPPER 1
>
> # undef INTERNAL_SYSCALL_RAW
> -# define INTERNAL_SYSCALL_RAW(name, nr, args...) \
> - ({ long _sys_result; \
> - { \
> - LOAD_ARGS_##nr (args) \
> - register long _x8 asm ("x8") = (name); \
> - asm volatile ("svc 0 // syscall " # name \
> - : "=r" (_x0) : "r"(_x8) ASM_ARGS_##nr : "memory"); \
> - _sys_result = _x0; \
> - } \
> +# define INTERNAL_SYSCALL_RAW(name, nr, args...) \
> + ({ long _sys_result; \
> + { \
> + LOAD_ARGS_##nr (args) \
> + if (__builtin_constant_p(name)) \
> + asm volatile ("mov x8, %1 // syscall " # name "\n" \
> + "svc 0" \
> + : "=r" (_x0) \
> + : "i" (name) ASM_ARGS_##nr \
> + : "x8", "memory"); \
> + else \
> + { \
> + register long _x8 asm ("x8") = (name); \
> + asm volatile ("svc 0" \
> + : "=r" (_x0) \
> + : "r"(_x8) ASM_ARGS_##nr \
> + : "memory"); \
> + } \
> + _sys_result = _x0; \
> + } \
> _sys_result; })
>
> # undef INTERNAL_SYSCALL
> --
> 2.39.2
>
next prev parent reply other threads:[~2023-05-09 7:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 15:03 [PATCH v6 0/3] x86_64: aarch64: Set call number just before syscall Joe Simmons-Talbott
2023-04-24 15:03 ` [PATCH v6 1/3] x86_64: Set the syscall register right before doing the syscall Joe Simmons-Talbott
2023-05-15 14:15 ` Joe Simmons-Talbott
2023-05-15 16:20 ` H.J. Lu
2023-05-25 18:07 ` Joe Simmons-Talbott
2023-05-25 18:40 ` Noah Goldstein
2023-05-26 7:04 ` Florian Weimer
2023-05-26 12:59 ` Joe Simmons-Talbott
2023-05-26 21:18 ` Noah Goldstein
2023-05-30 10:13 ` Florian Weimer
2023-05-31 18:23 ` Noah Goldstein
2023-06-28 19:17 ` Joe Simmons-Talbott
2023-04-24 15:03 ` [PATCH v6 2/3] aarch64: " Joe Simmons-Talbott
2023-05-09 7:47 ` Szabolcs Nagy [this message]
2023-04-24 15:03 ` [PATCH v6 3/3] nptl: Use direct syscall numbers in setxid Joe Simmons-Talbott
2023-04-24 15:17 ` Xi Ruoyao
2023-04-26 9:46 ` Szabolcs Nagy
2023-04-28 10:52 ` Florian Weimer
2023-04-26 12:39 ` Cristian Rodríguez
2023-04-26 13:24 ` Szabolcs Nagy
2023-05-25 18:07 ` Joe Simmons-Talbott
2023-05-08 14:13 ` [PATCH v6 0/3] x86_64: aarch64: Set call number just before syscall Joe Simmons-Talbott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZFn6ev4L6lOo2Bbw@arm.com \
--to=szabolcs.nagy@arm.com \
--cc=josimmon@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).