Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/select: use kernel timeval for _newselect
@ 2026-10-19  6:22 Wenqiang Zhao via B4 Relay via ltp
  2026-10-22 13:38 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 2+ messages in thread
From: Wenqiang Zhao via B4 Relay via ltp @ 2026-10-19  6:22 UTC (permalink / raw)
  To: Linux Test Project; +Cc: Wenqiang Zhao via B4 Relay, Wenqiang Zhao

From: Wenqiang Zhao <berringtoni36@gmail.com>

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
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;
 }

---
base-commit: 1255a3be50a69950607ed76fd2e9566189447f7a
change-id: 20261019-research-select-time64-rk3576-55aaabe3502d

Best regards,
--  
Wenqiang Zhao <berringtoni36@gmail.com>



-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-22 13:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19  6:22 [LTP] [PATCH] syscalls/select: use kernel timeval for _newselect Wenqiang Zhao via B4 Relay via ltp
2026-10-22 13:38 ` [LTP] " linuxtestproject.agent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox