From ab803e8a950acb7c25434d77a79b33e7a507823b Mon Sep 17 00:00:00 2001 From: Wei Gao Date: Thu, 8 Feb 2024 20:26:57 -0500 Subject: [PATCH] futex_waitv: Convert 32bit timespec struct to 64bit for compatibility mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit futex_waitv() can not accept old_timespec32 struct, therefore userspace should convert it from 32bit to 64bit before syscall in 32bit compatible mode. This fixes failure on futex_waitv01 on 32bit compatibility mode. Detail info you can refer following email thread: https://lore.kernel.org/lkml/20231123053140.16062-1-wegao@suse.com/ Link: https://lore.kernel.org/ltp/20240209012657.10797-1-wegao@suse.com/ Suggested-by: André Almeida Suggested-by: Thomas Gleixner Reviewed-by: Andrea Cervesato Reviewed-by: Petr Vorel Signed-off-by: Wei Gao --- testcases/kernel/syscalls/futex/futex2test.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/testcases/kernel/syscalls/futex/futex2test.h b/testcases/kernel/syscalls/futex/futex2test.h index ce97f47c1b6..a3cd0ef5cbc 100644 --- a/testcases/kernel/syscalls/futex/futex2test.h +++ b/testcases/kernel/syscalls/futex/futex2test.h @@ -12,6 +12,14 @@ #include #include "lapi/syscalls.h" #include "futextest.h" +#include "lapi/abisize.h" + +#ifdef TST_ABI32 +struct timespec64 { + int64_t tv_sec; + int64_t tv_nsec; +}; +#endif /** * futex_waitv - Wait at multiple futexes, wake on any @@ -24,7 +32,16 @@ static inline int futex_waitv(volatile struct futex_waitv *waiters, unsigned long nr_waiters, unsigned long flags, struct timespec *timo, clockid_t clockid) { +#ifdef TST_ABI32 + struct timespec64 timo64 = {0}; + + timo64.tv_sec = timo->tv_sec; + timo64.tv_nsec = timo->tv_nsec; + return tst_syscall(__NR_futex_waitv, waiters, nr_waiters, flags, &timo64, clockid); +#else return tst_syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid); + +#endif } #endif /* _FUTEX2TEST_H */