* [PATCH v4] selftests/futex: Convert 32bit timespec struct to 64bit version for 32bit compatibility mode
@ 2025-07-04 10:35 Terry Tritton
2025-07-04 15:49 ` André Almeida
0 siblings, 1 reply; 3+ messages in thread
From: Terry Tritton @ 2025-07-04 10:35 UTC (permalink / raw)
To: Thomas Gleixner, Shuah Khan, Ingo Molnar, Peter Zijlstra,
Darren Hart, Davidlohr Bueso, André Almeida
Cc: ttritton, linux-kselftest, linux-kernel, Terry Tritton, Wei Gao
sys_futex_wait() can not accept old_timespec32 struct, so userspace should
convert it from 32bit to 64bit before syscall to support 32bit compatible mode.
This fix is based off [1]
Link: https://lore.kernel.org/all/20231203235117.29677-1-wegao@suse.com/ [1]
Originally-by: Wei Gao <wegao@suse.com>
Signed-off-by: Terry Tritton <terry.tritton@linaro.org>
---
Changes in v4:
- Change to use __kernel_timespec as suggested by tglx
Changes in v3:
- Fix signed-off-by chain but for real this time
Changes in v2:
- Fix signed-off-by chain
tools/testing/selftests/futex/include/futex2test.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/futex/include/futex2test.h b/tools/testing/selftests/futex/include/futex2test.h
index ea79662405bc..af5b92ba04ad 100644
--- a/tools/testing/selftests/futex/include/futex2test.h
+++ b/tools/testing/selftests/futex/include/futex2test.h
@@ -5,6 +5,7 @@
* Copyright 2021 Collabora Ltd.
*/
#include <stdint.h>
+#include <linux/time_types.h>
#define u64_to_ptr(x) ((void *)(uintptr_t)(x))
@@ -65,7 +66,12 @@ struct futex32_numa {
static inline int futex_waitv(volatile struct futex_waitv *waiters, unsigned long nr_waiters,
unsigned long flags, struct timespec *timo, clockid_t clockid)
{
- return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid);
+ struct __kernel_timespec ts = {
+ .tv_sec = timo->tv_sec,
+ .tv_nsec = timo->tv_nsec,
+ };
+
+ return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, &ts, clockid);
}
/*
--
2.39.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] selftests/futex: Convert 32bit timespec struct to 64bit version for 32bit compatibility mode
2025-07-04 10:35 [PATCH v4] selftests/futex: Convert 32bit timespec struct to 64bit version for 32bit compatibility mode Terry Tritton
@ 2025-07-04 15:49 ` André Almeida
2025-07-04 18:55 ` Terry Tritton
0 siblings, 1 reply; 3+ messages in thread
From: André Almeida @ 2025-07-04 15:49 UTC (permalink / raw)
To: Terry Tritton
Cc: ttritton, Peter Zijlstra, Ingo Molnar, linux-kselftest,
Thomas Gleixner, Darren Hart, linux-kernel, Wei Gao,
Davidlohr Bueso, Shuah Khan
Hi Terry
Em 04/07/2025 07:35, Terry Tritton escreveu:
> sys_futex_wait() can not accept old_timespec32 struct, so userspace should
> convert it from 32bit to 64bit before syscall to support 32bit compatible mode.
>
> This fix is based off [1]
>
> Link: https://lore.kernel.org/all/20231203235117.29677-1-wegao@suse.com/ [1]
>
> Originally-by: Wei Gao <wegao@suse.com>
> Signed-off-by: Terry Tritton <terry.tritton@linaro.org>
> ---
Thanks! It fixes the test when compiling with -m32.
However, please check the results ./scripts/checkpatch.pl, there are a
lot of codestyle errors:
ERROR: trailing whitespace
#37: FILE: tools/testing/selftests/futex/include/futex2test.h:69:
+ struct __kernel_timespec ts = { $
ERROR: code indent should use tabs where possible
#37: FILE: tools/testing/selftests/futex/include/futex2test.h:69:
+ struct __kernel_timespec ts = { $
WARNING: please, no spaces at the start of a line
#37: FILE: tools/testing/selftests/futex/include/futex2test.h:69:
+ struct __kernel_timespec ts = { $
ERROR: trailing whitespace
#38: FILE: tools/testing/selftests/futex/include/futex2test.h:70:
+ .tv_sec = timo->tv_sec, $
ERROR: code indent should use tabs where possible
#38: FILE: tools/testing/selftests/futex/include/futex2test.h:70:
+ .tv_sec = timo->tv_sec, $
...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] selftests/futex: Convert 32bit timespec struct to 64bit version for 32bit compatibility mode
2025-07-04 15:49 ` André Almeida
@ 2025-07-04 18:55 ` Terry Tritton
0 siblings, 0 replies; 3+ messages in thread
From: Terry Tritton @ 2025-07-04 18:55 UTC (permalink / raw)
To: André Almeida
Cc: ttritton, Peter Zijlstra, Ingo Molnar, linux-kselftest,
Thomas Gleixner, Darren Hart, linux-kernel, Wei Gao,
Davidlohr Bueso, Shuah Khan
> However, please check the results ./scripts/checkpatch.pl, there are a
> lot of codestyle errors:
Whoops! Can't believe I forgot to run check patch!
Thanks for letting me know.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-04 18:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-04 10:35 [PATCH v4] selftests/futex: Convert 32bit timespec struct to 64bit version for 32bit compatibility mode Terry Tritton
2025-07-04 15:49 ` André Almeida
2025-07-04 18:55 ` Terry Tritton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®