From: "Arnd Bergmann" <arnd@arndb.de>
To: "Thomas Weißschuh" <linux@weissschuh.net>,
"Willy Tarreau" <w@1wt.eu>, shuah <shuah@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 07/12] tools/nolibc: prefer explicit 64-bit time-related system calls
Date: Thu, 30 Oct 2025 15:44:21 +0100 [thread overview]
Message-ID: <fbca1d3e-12e4-4c4e-8091-87464035fe39@app.fastmail.com> (raw)
In-Reply-To: <20251029-nolibc-uapi-types-v1-7-e79de3b215d8@weissschuh.net>
On Wed, Oct 29, 2025, at 17:02, Thomas Weißschuh wrote:
> Make sure to always use the 64-bit safe system calls
> in preparation for 64-bit time_t on 32-bit architectures.
>
> Also prevent issues on kernels which disable CONFIG_COMPAT_32BIT_TIME
> and therefore don't provide the 32-bit system calls anymore.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Thanks for working on this!
> -#if defined(__NR_ppoll)
> - struct timespec t;
> +#if defined(__NR_ppoll_time64)
> + struct __kernel_timespec t;
>
> if (timeout >= 0) {
> t.tv_sec = timeout / 1000;
> t.tv_nsec = (timeout % 1000) * 1000000;
> }
> - return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL,
> NULL, 0);
> + return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >= 0) ? &t
This looks good to me.
> -#elif defined(__NR_ppoll_time64)
> - struct __kernel_timespec t;
> : NULL, NULL, 0);
> +#elif defined(__NR_ppoll)
> + struct timespec t;
>
> if (timeout >= 0) {
> t.tv_sec = timeout / 1000;
> t.tv_nsec = (timeout % 1000) * 1000000;
> }
This is not wrong, but for consistency, I would use
__kernel_old_timespec with the old syscall macros, rather
than the nolibc-defined type.
A different approach would be to rely on timespec/timeval/time_t
to always use the 64-bit types and then just pick the time64
macros on 32-bit vs the old macros on 64-bit builds.
> - return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >= 0) ? &t
> : NULL, NULL, 0);
> + return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL,
> NULL, 0);
> #else
> return my_syscall3(__NR_poll, fds, nfds, timeout);
> #endif
I would think that we can remove the final #else clause here
and just use the __NR_ppoll case as #else. It would also make
sense to change the first #if to check for a 32-bit ABI.
> diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
> index e91b7d947161..10c517a38f86 100644
> --- a/tools/include/nolibc/sys.h
> +++ b/tools/include/nolibc/sys.h
> @@ -772,22 +772,22 @@ int sys_select(int nfds, fd_set *rfds, fd_set
> *wfds, fd_set *efds, struct timeva
> 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;
> +#elif defined(__NR_pselect6_time64)
> + struct __kernel_timespec t;
These probably need to be flipped around, so that
__NR_pselect6_time64/__NR_pselect6 comes first because the other
ones use the wrong type on 32-bit targets.
Probably also do the same thing here with the #ifdef checking
the architecture instead of the syscall macro.
Arnd
next prev parent reply other threads:[~2025-10-30 14:44 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 16:02 [PATCH 00/12] tools/nolibc: always use 64-bit ino_t, off_t and time-related types Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 01/12] tools/nolibc: use 64-bit ino_t Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 02/12] tools/nolibc: handle 64-bit off_t for llseek Thomas Weißschuh
2025-10-30 14:56 ` Arnd Bergmann
2025-10-29 16:02 ` [PATCH 03/12] tools/nolibc: prefer the llseek syscall Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 04/12] tools/nolibc: use 64-bit off_t Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 05/12] tools/nolibc: remove now superfluous overflow check in llseek Thomas Weißschuh
2025-10-30 14:58 ` Arnd Bergmann
2025-10-29 16:02 ` [PATCH 06/12] tools/nolibc: remove more __nolibc_enosys() fallbacks Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 07/12] tools/nolibc: prefer explicit 64-bit time-related system calls Thomas Weißschuh
2025-10-30 14:44 ` Arnd Bergmann [this message]
2025-10-29 16:02 ` [PATCH 08/12] tools/nolibc: gettimeofday(): avoid libgcc 64-bit divisions Thomas Weißschuh
2025-10-30 14:57 ` Arnd Bergmann
2025-11-02 8:31 ` Willy Tarreau
2025-11-02 9:27 ` Thomas Weißschuh
2025-11-02 9:49 ` Willy Tarreau
2025-10-29 16:02 ` [PATCH 09/12] tools/nolibc: use a custom struct timespec Thomas Weißschuh
2025-10-30 14:46 ` Arnd Bergmann
2025-11-02 8:36 ` Willy Tarreau
2025-11-02 8:40 ` Willy Tarreau
2025-11-02 9:41 ` Thomas Weißschuh
2025-11-02 9:50 ` Willy Tarreau
2025-10-29 16:03 ` [PATCH 10/12] tools/nolibc: always use 64-bit time types Thomas Weißschuh
2025-10-29 16:03 ` [PATCH 11/12] selftests/nolibc: test compatibility of timespec and __kernel_timespec Thomas Weißschuh
2025-10-29 16:03 ` [PATCH 12/12] tools/nolibc: remove time conversions Thomas Weißschuh
2025-10-30 14:58 ` Arnd Bergmann
2025-11-02 8:44 ` [PATCH 00/12] tools/nolibc: always use 64-bit ino_t, off_t and time-related types Willy Tarreau
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=fbca1d3e-12e4-4c4e-8091-87464035fe39@app.fastmail.com \
--to=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=shuah@kernel.org \
--cc=w@1wt.eu \
/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