[LTP] [PATCH] syscalls/select: use kernel timeval for _newselect
Petr Vorel
pvorel@suse.cz
Wed Nov 11 14:24:18 CET 2026
Hi Wenqiang Zhao,
> With _TIME_BITS=64, struct timeval has 64-bit fields on 32-bit ARM,
> but _newselect still expects the old kernel timeval layout. Passing
> the libc structure directly makes a subsecond timeout appear as zero.
> Convert valid timeouts to struct __kernel_old_timeval before the syscall
> and copy the remaining time back afterwards. Pass NULL and deliberately
> faulty timeout pointers through unchanged.
> On an RK3576 running a 6.1.118-rt36 aarch64 kernel with CONFIG_COMPAT=y,
> the unmodified ARM32 time64 select02 reports 22 passes and 6 failures.
> With this change it reports 28 passes and no failures. Both runs skip
> the unsupported SYS_select variant.
> Tested select01-select04 on the same board with ARM32 time32, ARM32
> time64 and AArch64 static builds: 250 passes, 55 configuration skips,
> no failures or broken tests. Additional local checks cover timeout
> copy-back, ready fds, NULL, EFAULT, EINVAL and EINTR.
> Closes: https://github.com/linux-test-project/ltp/issues/1314
LGTM, thanks!
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> Signed-off-by: Wenqiang Zhao <berringtoni36@gmail.com>
> ---
> syscalls/select: use kernel timeval for _newselect
> ---
> testcases/kernel/syscalls/select/select_var.h | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
> diff --git a/testcases/kernel/syscalls/select/select_var.h b/testcases/kernel/syscalls/select/select_var.h
> index a945fa6..e23f1fa 100644
> --- a/testcases/kernel/syscalls/select/select_var.h
> +++ b/testcases/kernel/syscalls/select/select_var.h
> @@ -84,14 +84,30 @@ static int do_select_faulty_to(int nfds, fd_set *readfds, fd_set *writefds,
> #endif
> return ret;
> }
> - case 4:
> + case 4: {
> #ifdef __NR__newselect
> - return tst_syscall(__NR__newselect, nfds, readfds, writefds, exceptfds, timeout);
> + struct __kernel_old_timeval _tv;
> + void *tv = timeout;
> + int ret;
> +
> + if (timeout && !faulty_to) {
> + _tv.tv_sec = timeout->tv_sec;
> + _tv.tv_usec = timeout->tv_usec;
> + tv = &_tv;
> + }
> +
> + ret = tst_syscall(__NR__newselect, nfds, readfds, writefds, exceptfds, tv);
> + if (timeout && !faulty_to) {
> + timeout->tv_sec = _tv.tv_sec;
> + timeout->tv_usec = _tv.tv_usec;
> + }
> + return ret;
> #else
> tst_brk(TCONF, "__NR__newselect not implemented");
> #endif
> break;
> }
> + }
> return -1;
> }
More information about the ltp
mailing list