xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] y2038: Part three - support for select()
@ 2023-05-17  9:34 Florian Bezdeka
  2023-05-17  9:34 ` [PATCH 1/3] y2038: cobalt/posix/select: Refactor __cobalt_select() Florian Bezdeka
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Florian Bezdeka @ 2023-05-17  9:34 UTC (permalink / raw)
  To: jan.kiszka, xenomai; +Cc: Florian Bezdeka

Hi all,

I'm trying to bring the remaining patches from my y2038 queue into Xenomai 
next/master branches. The full queue [1] holds ~7 patches. I'm trying to 
split that up to keep reviewing efforts low.

This series brings y2038 support for select().

select() is somehow special. Linux does not support a y2038 safe
implementation for select() itself. If the application needs y2038
support the application has to use something like the pselect() service.

To make select() y2038 safe glibc wrapps select() and wires it to the 
pselect() Linux service.

Xenomai (cobalt) does not provide pselect() yet and it's not easy to 
implement that. The reasons:

  - The underlying xnsynch infrastructure is not prepared for waiting for a
    combination of file descriptors and signals. (Let me know if I
    overlooked something!)

  - Implementing pselect() would require up to 6 parameters that need to
    be forwarded to the kernel. Xenomais current limit is 5.

To get select() y2038 safe a "pselect64() like" service service is being
added. The signal part is skipped.

The wrapper for __select64() will be added later and will convert 
struct timeval to struct timespec64 in user space. This way select() 
provided by libcobalt gets y2038 support but pselect() is still not 
supported.

Best regards,
Florian

[1] https://gitlab.com/Xenomai/xenomai-hacker-space/-/tree/florian/y2038

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
Florian Bezdeka (3):
      y2038: cobalt/posix/select: Refactor __cobalt_select()
      y2038: cobalt/posix/select: Adding pselect64
      y2038: testsuite/smokey/y2038: Adding tests for pselect64

 include/cobalt/uapi/syscall.h                      |  1 +
 .../cobalt/include/asm-generic/xenomai/syscall.h   | 22 +++++
 kernel/cobalt/posix/clock.h                        |  6 +-
 kernel/cobalt/posix/io.c                           | 94 ++++++++++++++--------
 kernel/cobalt/posix/io.h                           |  8 +-
 kernel/cobalt/posix/syscall32.c                    | 24 +++++-
 kernel/cobalt/trace/cobalt-posix.h                 |  3 +-
 testsuite/smokey/y2038/syscall-tests.c             | 70 ++++++++++++++++
 8 files changed, 190 insertions(+), 38 deletions(-)
---
base-commit: a74abe52269f191654b449357bd9aaa57f2cd75c
change-id: 20230516-florian-y2038-part-three-3093da9fecf8

Best regards,
-- 
Florian Bezdeka <florian.bezdeka@siemens.com>


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

* [PATCH 1/3] y2038: cobalt/posix/select: Refactor __cobalt_select()
  2023-05-17  9:34 [PATCH 0/3] y2038: Part three - support for select() Florian Bezdeka
@ 2023-05-17  9:34 ` Florian Bezdeka
  2023-05-17  9:34 ` [PATCH 2/3] y2038: cobalt/posix/select: Adding pselect64 Florian Bezdeka
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Florian Bezdeka @ 2023-05-17  9:34 UTC (permalink / raw)
  To: jan.kiszka, xenomai; +Cc: Florian Bezdeka

There is no y2038 safe select() syscall provided by Linuy. If y2038
safety is required the application should not use select() and move on
to something like pselect().

As we still want to support select() for keeping backward compatibility
- even if y2038 safety is requested - an additional pselect() based
entry will be introduced soon which will re-use __cobalt_select().

This patch moves all the timeout related userspace copy operations out
of __cobalt_select() and migrates __cobalt_select() to
struct timespec64. That will allow pselect64() to be based on
__cobalt_select() as well.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 .../cobalt/include/asm-generic/xenomai/syscall.h   | 22 ++++++++
 kernel/cobalt/posix/clock.h                        |  6 +--
 kernel/cobalt/posix/io.c                           | 62 +++++++++++-----------
 kernel/cobalt/posix/syscall32.c                    | 24 ++++++++-
 4 files changed, 78 insertions(+), 36 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/syscall.h b/kernel/cobalt/include/asm-generic/xenomai/syscall.h
index 70b3e68f9..d61b985fb 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/syscall.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/syscall.h
@@ -138,6 +138,28 @@ static inline int cobalt_put_u_itimerspec(
 	return cobalt_copy_to_user(dst, &u_its, sizeof(*dst));
 }
 
+static inline struct timespec64
+cobalt_timeval_to_timespec64(const struct __kernel_old_timeval *src)
+{
+	struct timespec64 ts;
+
+	ts.tv_sec = src->tv_sec + (src->tv_usec / USEC_PER_SEC);
+	ts.tv_nsec = (src->tv_usec % USEC_PER_SEC) * NSEC_PER_USEC;
+
+	return ts;
+}
+
+static inline struct __kernel_old_timeval
+cobalt_timespec64_to_timeval(const struct timespec64 *src)
+{
+	struct __kernel_old_timeval tv;
+
+	tv.tv_sec = src->tv_sec + (src->tv_nsec / NSEC_PER_SEC);
+	tv.tv_usec = (src->tv_nsec % NSEC_PER_SEC) / NSEC_PER_USEC;
+
+	return tv;
+}
+
 /* 32bit syscall emulation */
 #define __COBALT_COMPAT_BIT	0x1
 /* 32bit syscall emulation - extended form */
diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
index dbaabbc5d..38b59e24f 100644
--- a/kernel/cobalt/posix/clock.h
+++ b/kernel/cobalt/posix/clock.h
@@ -68,12 +68,12 @@ static inline xnticks_t tv2ns(const struct __kernel_old_timeval *tv)
 	return nsecs;
 }
 
-static inline void ticks2tv(struct __kernel_old_timeval *tv, xnticks_t ticks)
+static inline void ticks2ts64(struct timespec64 *ts, xnticks_t ticks)
 {
 	unsigned long nsecs;
 
-	tv->tv_sec = xnclock_divrem_billion(ticks, &nsecs);
-	tv->tv_usec = nsecs / 1000;
+	ts->tv_sec = xnclock_divrem_billion(ticks, &nsecs);
+	ts->tv_nsec = nsecs;
 }
 
 static inline xnticks_t clock_get_ticks(clockid_t clock_id)
diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index 45ec09fae..ebe7791ab 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -221,7 +221,7 @@ static int __cobalt_select_bind_all(struct xnselector *selector,
 }
 
 int __cobalt_select(int nfds, void __user *u_rfds, void __user *u_wfds,
-		    void __user *u_xfds, void __user *u_tv, bool compat)
+		    void __user *u_xfds, struct timespec64 *to, bool compat)
 {
 	void __user *ufd_sets[XNSELECT_MAX_TYPES] = {
 		[XNSELECT_READ] = u_rfds,
@@ -237,13 +237,12 @@ int __cobalt_select(int nfds, void __user *u_rfds, void __user *u_wfds,
 	xntmode_t mode = XN_RELATIVE;
 	struct xnselector *selector;
 	struct xnthread *curr;
-	struct __kernel_old_timeval tv;
 	size_t fds_size;
 	int i, err;
 
 	curr = xnthread_current();
 
-	if (u_tv) {
+	if (to) {
 		if (xnthread_test_localinfo(curr, XNSYSRST)) {
 			xnthread_clear_localinfo(curr, XNSYSRST);
 
@@ -255,23 +254,11 @@ int __cobalt_select(int nfds, void __user *u_rfds, void __user *u_wfds,
 				goto out;
 			}
 		} else {
-#ifdef CONFIG_XENO_ARCH_SYS3264
-			if (compat) {
-				if (sys32_get_timeval(&tv, u_tv))
-					return -EFAULT;
-			} else
-#endif
-			{
-				if (!access_ok(u_tv, sizeof(tv))
-				    || cobalt_copy_from_user(&tv, u_tv,
-							     sizeof(tv)))
-					return -EFAULT;
-			}
 
-			if (tv.tv_usec >= 1000000)
+			if (!timespec64_valid(to))
 				return -EINVAL;
 
-			timeout = clock_get_ticks(CLOCK_MONOTONIC) + tv2ns(&tv);
+			timeout = clock_get_ticks(CLOCK_MONOTONIC) + ts2ns(to);
 		}
 
 		mode = XN_ABSOLUTE;
@@ -343,23 +330,12 @@ int __cobalt_select(int nfds, void __user *u_rfds, void __user *u_wfds,
 	}
 
 out:
-	if (u_tv && (err > 0 || err == -EINTR)) {
+	if (to && (err > 0 || err == -EINTR)) {
 		xnsticks_t diff = timeout - clock_get_ticks(CLOCK_MONOTONIC);
 		if (diff > 0)
-			ticks2tv(&tv, diff);
+			ticks2ts64(to, diff);
 		else
-			tv.tv_sec = tv.tv_usec = 0;
-
-#ifdef CONFIG_XENO_ARCH_SYS3264
-		if (compat) {
-			if (sys32_put_timeval(u_tv, &tv))
-				return -EFAULT;
-		} else
-#endif
-		{
-			if (cobalt_copy_to_user(u_tv, &tv, sizeof(tv)))
-				return -EFAULT;
-		}
+			to->tv_sec = to->tv_nsec = 0;
 	}
 
 	if (err >= 0)
@@ -390,5 +366,27 @@ COBALT_SYSCALL(select, primary,
 		fd_set __user *u_xfds,
 		struct __kernel_old_timeval __user *u_tv))
 {
-	return __cobalt_select(nfds, u_rfds, u_wfds, u_xfds, u_tv, false);
+	struct timespec64 ts64, *to = NULL;
+	struct __kernel_old_timeval tv;
+	int ret;
+
+	if (u_tv && (!access_ok(u_tv, sizeof(tv)) ||
+		     cobalt_copy_from_user(&tv, u_tv, sizeof(tv))))
+		return -EFAULT;
+
+	if (u_tv) {
+		ts64 = cobalt_timeval_to_timespec64(&tv);
+		to = &ts64;
+	}
+
+	ret = __cobalt_select(nfds, u_rfds, u_wfds, u_xfds, to, false);
+	if (ret)
+		return ret;
+
+	if (u_tv) {
+		tv = cobalt_timespec64_to_timeval(to);
+		ret = cobalt_copy_to_user(u_tv, &tv, sizeof(tv));
+	}
+
+	return ret;
 }
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index 10b080dfd..466534f4c 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -749,7 +749,29 @@ COBALT_SYSCALL32emu(select, primary,
 		     compat_fd_set __user *u_xfds,
 		     struct old_timeval32 __user *u_tv))
 {
-	return __cobalt_select(nfds, u_rfds, u_wfds, u_xfds, u_tv, true);
+	struct timespec64 ts64, *to = NULL;
+	struct __kernel_old_timeval tv;
+	int ret;
+
+	if (u_tv &&
+	    (!access_ok(u_tv, sizeof(tv)) || sys32_get_timeval(&tv, u_tv)))
+		return -EFAULT;
+
+	if (u_tv) {
+		ts64 = cobalt_timeval_to_timespec64(&tv);
+		to = &ts64;
+	}
+
+	ret = __cobalt_select(nfds, u_rfds, u_wfds, u_xfds, to, true);
+	if (ret)
+		return ret;
+
+	if (u_tv) {
+		tv = cobalt_timespec64_to_timeval(to);
+		ret = sys32_put_timeval(u_tv, &tv);
+	}
+
+	return ret;
 }
 
 COBALT_SYSCALL32emu(recvmsg, handover,

-- 
2.39.2


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

* [PATCH 2/3] y2038: cobalt/posix/select: Adding pselect64
  2023-05-17  9:34 [PATCH 0/3] y2038: Part three - support for select() Florian Bezdeka
  2023-05-17  9:34 ` [PATCH 1/3] y2038: cobalt/posix/select: Refactor __cobalt_select() Florian Bezdeka
@ 2023-05-17  9:34 ` Florian Bezdeka
  2023-05-17  9:34 ` [PATCH 3/3] y2038: testsuite/smokey/y2038: Adding tests for pselect64 Florian Bezdeka
  2023-05-17 11:01 ` [PATCH 0/3] y2038: Part three - support for select() Jan Kiszka
  3 siblings, 0 replies; 7+ messages in thread
From: Florian Bezdeka @ 2023-05-17  9:34 UTC (permalink / raw)
  To: jan.kiszka, xenomai; +Cc: Florian Bezdeka

This is not a full implementation of pselect() as we do not support
waiting for signals yet. The xnsynch infrastructure is not prepared
for that.

We will not wrap pselect() in userspace. We will only use the new
syscall for providing y2038 safety for select().

Another reason against a full pselec64 implementation is the fact that
the XENOMAI_SYSCALLx() infrastructure ends at XENOMAI_SYSCALL5(),
a real pselect64() implementation would require XENOMAI_SYSCALL6().

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/cobalt/uapi/syscall.h      |  1 +
 kernel/cobalt/posix/io.c           | 32 ++++++++++++++++++++++++++++++++
 kernel/cobalt/posix/io.h           |  8 +++++++-
 kernel/cobalt/trace/cobalt-posix.h |  3 ++-
 4 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 2dca90071..3e65efaab 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -140,6 +140,7 @@
 #define sc_cobalt_timer_gettime64		117
 #define sc_cobalt_timerfd_settime64		118
 #define sc_cobalt_timerfd_gettime64		119
+#define sc_cobalt_pselect64			120
 
 #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
 
diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index ebe7791ab..09bfcae67 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -390,3 +390,35 @@ COBALT_SYSCALL(select, primary,
 
 	return ret;
 }
+
+COBALT_SYSCALL(pselect64, primary,
+	       (int nfds,
+		fd_set __user *u_rfds,
+		fd_set __user *u_wfds,
+		fd_set __user *u_xfds,
+		struct __kernel_timespec __user *u_ts))
+{
+	struct timespec64 ts64, *to = NULL;
+	int ret = 0;
+
+	if (u_ts) {
+		ret = cobalt_get_timespec64(&ts64, u_ts);
+		to = &ts64;
+	}
+
+	if (ret)
+		return ret;
+
+	ret = __cobalt_select(nfds, u_rfds, u_wfds, u_xfds, to, false);
+	if (ret)
+		return ret;
+
+	/*
+	 * Normally pselect() would not write back the modified timeout. As we
+	 * only use it for keeping select() y2038 safe we do it here as well.
+	 */
+	if (u_ts)
+		ret = cobalt_put_timespec64(&ts64, u_ts);
+
+	return ret;
+}
diff --git a/kernel/cobalt/posix/io.h b/kernel/cobalt/posix/io.h
index 1d9ee0918..ca46aa309 100644
--- a/kernel/cobalt/posix/io.h
+++ b/kernel/cobalt/posix/io.h
@@ -24,7 +24,7 @@
 #include <cobalt/kernel/select.h>
 
 int __cobalt_select(int nfds, void __user *u_rfds, void __user *u_wfds,
-		    void __user *u_xfds, void __user *u_tv, bool compat);
+		    void __user *u_xfds, struct timespec64 *to, bool compat);
 
 COBALT_SYSCALL_DECL(open,
 		    (const char __user *u_path, int oflag));
@@ -76,4 +76,10 @@ COBALT_SYSCALL_DECL(select,
 		     fd_set __user *u_xfds,
 		     struct __kernel_old_timeval __user *u_tv));
 
+COBALT_SYSCALL_DECL(pselect64, (int nfds,
+				fd_set __user *u_rfds,
+				fd_set __user *u_wfds,
+				fd_set __user *u_xfds,
+				struct __kernel_timespec __user *u_tv));
+
 #endif /* !_COBALT_POSIX_IO_H */
diff --git a/kernel/cobalt/trace/cobalt-posix.h b/kernel/cobalt/trace/cobalt-posix.h
index f2ffdb3a2..47dc77e1c 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -172,7 +172,8 @@
 		__cobalt_symbolic_syscall(timer_settime64),		\
 		__cobalt_symbolic_syscall(timer_gettime64),		\
 		__cobalt_symbolic_syscall(timerfd_settime64),		\
-		__cobalt_symbolic_syscall(timerfd_gettime64))
+		__cobalt_symbolic_syscall(timerfd_gettime64),		\
+		__cobalt_symbolic_syscall(pselect64))
 
 DECLARE_EVENT_CLASS(cobalt_syscall_entry,
 	TP_PROTO(unsigned int nr),

-- 
2.39.2


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

* [PATCH 3/3] y2038: testsuite/smokey/y2038: Adding tests for pselect64
  2023-05-17  9:34 [PATCH 0/3] y2038: Part three - support for select() Florian Bezdeka
  2023-05-17  9:34 ` [PATCH 1/3] y2038: cobalt/posix/select: Refactor __cobalt_select() Florian Bezdeka
  2023-05-17  9:34 ` [PATCH 2/3] y2038: cobalt/posix/select: Adding pselect64 Florian Bezdeka
@ 2023-05-17  9:34 ` Florian Bezdeka
  2023-05-17 11:01 ` [PATCH 0/3] y2038: Part three - support for select() Jan Kiszka
  3 siblings, 0 replies; 7+ messages in thread
From: Florian Bezdeka @ 2023-05-17  9:34 UTC (permalink / raw)
  To: jan.kiszka, xenomai; +Cc: Florian Bezdeka

Extending the smokey testsuite to do some tests for the recently added
pselect64 syscall.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 testsuite/smokey/y2038/syscall-tests.c | 70 ++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 2e3b81e0c..d1e1f46bf 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -1443,6 +1443,72 @@ out:
 	return ret;
 }
 
+static int test_sc_cobalt_pselect64(void)
+{
+	long sc_nr = sc_cobalt_pselect64;
+	struct xn_timespec64 t1, t2;
+	struct timespec ts_nat;
+	int ret;
+
+	/* Supplying an invalid timeout should deliver -EINVAL */
+	t1.tv_sec = -1;
+	t1.tv_nsec = 0;
+	ret = XENOMAI_SYSCALL5(sc_nr, NULL, NULL, NULL, NULL, &t1);
+	if (ret == -ENOSYS) {
+		smokey_note("cobalt_pselect64: skipped. (no kernel support)");
+		ret = 0;
+		goto out; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -EINVAL)) {
+		ret = ret ?: -EINVAL;
+		goto out;
+	}
+
+	/* Supplying an invalid address should deliver -EFAULT */
+	ret = XENOMAI_SYSCALL5(sc_nr, NULL, NULL, NULL, NULL,
+			       (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -EFAULT)) {
+		ret = ret ?: -EINVAL;
+		goto out;
+	}
+
+	/*
+	 * Providing a valid timeout, waiting for it to time out and check
+	 * that we didn't come back to early.
+	 */
+	ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &ts_nat));
+	if (ret)
+		goto out;
+
+	t1.tv_sec = 0;
+	t1.tv_nsec = 500000;
+
+	ret = XENOMAI_SYSCALL5(sc_nr, NULL, NULL, NULL, NULL, &t1);
+	if (!smokey_assert(!ret)) {
+		ret = ret ? ret : -EINVAL;
+		goto out;
+	}
+
+	t1.tv_sec = ts_nat.tv_sec;
+	t1.tv_nsec = ts_nat.tv_nsec;
+
+	ret = smokey_check_errno(clock_gettime(CLOCK_MONOTONIC, &ts_nat));
+	if (ret)
+		goto out;
+
+	t2.tv_sec = ts_nat.tv_sec;
+	t2.tv_nsec = ts_nat.tv_nsec;
+
+	if (ts_less(&t2, &t1))
+		smokey_warning("pselect64 returned to early!\n"
+			       "Expected wakeup at: %lld sec %lld nsec\n"
+			       "Back at           : %lld sec %lld nsec\n",
+			       t1.tv_sec, t1.tv_nsec, t2.tv_sec, t2.tv_nsec);
+
+out:
+	return ret;
+}
+
 static int check_kernel_version(void)
 {
 	int ret, major, minor;
@@ -1548,5 +1614,9 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 	if (ret)
 		return ret;
 
+	ret = test_sc_cobalt_pselect64();
+	if (ret)
+		return ret;
+
 	return 0;
 }

-- 
2.39.2


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

* Re: [PATCH 0/3] y2038: Part three - support for select()
  2023-05-17  9:34 [PATCH 0/3] y2038: Part three - support for select() Florian Bezdeka
                   ` (2 preceding siblings ...)
  2023-05-17  9:34 ` [PATCH 3/3] y2038: testsuite/smokey/y2038: Adding tests for pselect64 Florian Bezdeka
@ 2023-05-17 11:01 ` Jan Kiszka
  2023-05-21 10:07   ` Florian Bezdeka
  3 siblings, 1 reply; 7+ messages in thread
From: Jan Kiszka @ 2023-05-17 11:01 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 17.05.23 11:34, Florian Bezdeka wrote:
> Hi all,
> 
> I'm trying to bring the remaining patches from my y2038 queue into Xenomai 
> next/master branches. The full queue [1] holds ~7 patches. I'm trying to 
> split that up to keep reviewing efforts low.
> 
> This series brings y2038 support for select().
> 
> select() is somehow special. Linux does not support a y2038 safe
> implementation for select() itself. If the application needs y2038
> support the application has to use something like the pselect() service.
> 
> To make select() y2038 safe glibc wrapps select() and wires it to the 
> pselect() Linux service.
> 
> Xenomai (cobalt) does not provide pselect() yet and it's not easy to 
> implement that. The reasons:
> 
>   - The underlying xnsynch infrastructure is not prepared for waiting for a
>     combination of file descriptors and signals. (Let me know if I
>     overlooked something!)
> 
>   - Implementing pselect() would require up to 6 parameters that need to
>     be forwarded to the kernel. Xenomais current limit is 5.
> 
> To get select() y2038 safe a "pselect64() like" service service is being
> added. The signal part is skipped.
> 
> The wrapper for __select64() will be added later and will convert 
> struct timeval to struct timespec64 in user space. This way select() 
> provided by libcobalt gets y2038 support but pselect() is still not 
> supported.
> 
> Best regards,
> Florian
> 
> [1] https://gitlab.com/Xenomai/xenomai-hacker-space/-/tree/florian/y2038
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
> Florian Bezdeka (3):
>       y2038: cobalt/posix/select: Refactor __cobalt_select()
>       y2038: cobalt/posix/select: Adding pselect64
>       y2038: testsuite/smokey/y2038: Adding tests for pselect64
> 
>  include/cobalt/uapi/syscall.h                      |  1 +
>  .../cobalt/include/asm-generic/xenomai/syscall.h   | 22 +++++
>  kernel/cobalt/posix/clock.h                        |  6 +-
>  kernel/cobalt/posix/io.c                           | 94 ++++++++++++++--------
>  kernel/cobalt/posix/io.h                           |  8 +-
>  kernel/cobalt/posix/syscall32.c                    | 24 +++++-
>  kernel/cobalt/trace/cobalt-posix.h                 |  3 +-
>  testsuite/smokey/y2038/syscall-tests.c             | 70 ++++++++++++++++
>  8 files changed, 190 insertions(+), 38 deletions(-)
> ---
> base-commit: a74abe52269f191654b449357bd9aaa57f2cd75c
> change-id: 20230516-florian-y2038-part-three-3093da9fecf8
> 
> Best regards,

Thanks, applied.

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux


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

* Re: [PATCH 0/3] y2038: Part three - support for select()
  2023-05-17 11:01 ` [PATCH 0/3] y2038: Part three - support for select() Jan Kiszka
@ 2023-05-21 10:07   ` Florian Bezdeka
  2023-05-23  9:13     ` Jan Kiszka
  0 siblings, 1 reply; 7+ messages in thread
From: Florian Bezdeka @ 2023-05-21 10:07 UTC (permalink / raw)
  To: Jan Kiszka, xenomai

On Wed, 2023-05-17 at 13:01 +0200, Jan Kiszka wrote:
> On 17.05.23 11:34, Florian Bezdeka wrote:
> > Hi all,
> > 
> > I'm trying to bring the remaining patches from my y2038 queue into Xenomai 
> > next/master branches. The full queue [1] holds ~7 patches. I'm trying to 
> > split that up to keep reviewing efforts low.
> > 
> > This series brings y2038 support for select().
> > 
> > select() is somehow special. Linux does not support a y2038 safe
> > implementation for select() itself. If the application needs y2038
> > support the application has to use something like the pselect() service.
> > 
> > To make select() y2038 safe glibc wrapps select() and wires it to the 
> > pselect() Linux service.
> > 
> > Xenomai (cobalt) does not provide pselect() yet and it's not easy to 
> > implement that. The reasons:
> > 
> >   - The underlying xnsynch infrastructure is not prepared for waiting for a
> >     combination of file descriptors and signals. (Let me know if I
> >     overlooked something!)
> > 
> >   - Implementing pselect() would require up to 6 parameters that need to
> >     be forwarded to the kernel. Xenomais current limit is 5.
> > 
> > To get select() y2038 safe a "pselect64() like" service service is being
> > added. The signal part is skipped.
> > 
> > The wrapper for __select64() will be added later and will convert 
> > struct timeval to struct timespec64 in user space. This way select() 
> > provided by libcobalt gets y2038 support but pselect() is still not 
> > supported.
> > 
> > Best regards,
> > Florian
> > 
> > [1] https://gitlab.com/Xenomai/xenomai-hacker-space/-/tree/florian/y2038
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> > Florian Bezdeka (3):
> >       y2038: cobalt/posix/select: Refactor __cobalt_select()
> >       y2038: cobalt/posix/select: Adding pselect64
> >       y2038: testsuite/smokey/y2038: Adding tests for pselect64
> > 
> >  include/cobalt/uapi/syscall.h                      |  1 +
> >  .../cobalt/include/asm-generic/xenomai/syscall.h   | 22 +++++
> >  kernel/cobalt/posix/clock.h                        |  6 +-
> >  kernel/cobalt/posix/io.c                           | 94 ++++++++++++++--------
> >  kernel/cobalt/posix/io.h                           |  8 +-
> >  kernel/cobalt/posix/syscall32.c                    | 24 +++++-
> >  kernel/cobalt/trace/cobalt-posix.h                 |  3 +-
> >  testsuite/smokey/y2038/syscall-tests.c             | 70 ++++++++++++++++
> >  8 files changed, 190 insertions(+), 38 deletions(-)
> > ---
> > base-commit: a74abe52269f191654b449357bd9aaa57f2cd75c
> > change-id: 20230516-florian-y2038-part-three-3093da9fecf8
> > 
> > Best regards,
> 
> Thanks, applied.

Hi Jan,

some testing over the weekend discovered a simple problem. The timeout
write back is skipped by accident. The fix is quite easy but I think we
should add a test to smokey as well. The testsuite did not report this
problem. 

Should I resend or should I fix it on top of next? Asking because this
series has already been applied to next...

Best regards,
Florian

> 
> Jan
> 


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

* Re: [PATCH 0/3] y2038: Part three - support for select()
  2023-05-21 10:07   ` Florian Bezdeka
@ 2023-05-23  9:13     ` Jan Kiszka
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2023-05-23  9:13 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 21.05.23 12:07, Florian Bezdeka wrote:
> On Wed, 2023-05-17 at 13:01 +0200, Jan Kiszka wrote:
>> On 17.05.23 11:34, Florian Bezdeka wrote:
>>> Hi all,
>>>
>>> I'm trying to bring the remaining patches from my y2038 queue into Xenomai 
>>> next/master branches. The full queue [1] holds ~7 patches. I'm trying to 
>>> split that up to keep reviewing efforts low.
>>>
>>> This series brings y2038 support for select().
>>>
>>> select() is somehow special. Linux does not support a y2038 safe
>>> implementation for select() itself. If the application needs y2038
>>> support the application has to use something like the pselect() service.
>>>
>>> To make select() y2038 safe glibc wrapps select() and wires it to the 
>>> pselect() Linux service.
>>>
>>> Xenomai (cobalt) does not provide pselect() yet and it's not easy to 
>>> implement that. The reasons:
>>>
>>>   - The underlying xnsynch infrastructure is not prepared for waiting for a
>>>     combination of file descriptors and signals. (Let me know if I
>>>     overlooked something!)
>>>
>>>   - Implementing pselect() would require up to 6 parameters that need to
>>>     be forwarded to the kernel. Xenomais current limit is 5.
>>>
>>> To get select() y2038 safe a "pselect64() like" service service is being
>>> added. The signal part is skipped.
>>>
>>> The wrapper for __select64() will be added later and will convert 
>>> struct timeval to struct timespec64 in user space. This way select() 
>>> provided by libcobalt gets y2038 support but pselect() is still not 
>>> supported.
>>>
>>> Best regards,
>>> Florian
>>>
>>> [1] https://gitlab.com/Xenomai/xenomai-hacker-space/-/tree/florian/y2038
>>>
>>> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
>>> ---
>>> Florian Bezdeka (3):
>>>       y2038: cobalt/posix/select: Refactor __cobalt_select()
>>>       y2038: cobalt/posix/select: Adding pselect64
>>>       y2038: testsuite/smokey/y2038: Adding tests for pselect64
>>>
>>>  include/cobalt/uapi/syscall.h                      |  1 +
>>>  .../cobalt/include/asm-generic/xenomai/syscall.h   | 22 +++++
>>>  kernel/cobalt/posix/clock.h                        |  6 +-
>>>  kernel/cobalt/posix/io.c                           | 94 ++++++++++++++--------
>>>  kernel/cobalt/posix/io.h                           |  8 +-
>>>  kernel/cobalt/posix/syscall32.c                    | 24 +++++-
>>>  kernel/cobalt/trace/cobalt-posix.h                 |  3 +-
>>>  testsuite/smokey/y2038/syscall-tests.c             | 70 ++++++++++++++++
>>>  8 files changed, 190 insertions(+), 38 deletions(-)
>>> ---
>>> base-commit: a74abe52269f191654b449357bd9aaa57f2cd75c
>>> change-id: 20230516-florian-y2038-part-three-3093da9fecf8
>>>
>>> Best regards,
>>
>> Thanks, applied.
> 
> Hi Jan,
> 
> some testing over the weekend discovered a simple problem. The timeout
> write back is skipped by accident. The fix is quite easy but I think we
> should add a test to smokey as well. The testsuite did not report this
> problem. 
> 
> Should I resend or should I fix it on top of next? Asking because this
> series has already been applied to next...

We can still fix that up in next. Just send the updated series and let
me know which patches should be dropped from next.

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux


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

end of thread, other threads:[~2023-05-23  9:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17  9:34 [PATCH 0/3] y2038: Part three - support for select() Florian Bezdeka
2023-05-17  9:34 ` [PATCH 1/3] y2038: cobalt/posix/select: Refactor __cobalt_select() Florian Bezdeka
2023-05-17  9:34 ` [PATCH 2/3] y2038: cobalt/posix/select: Adding pselect64 Florian Bezdeka
2023-05-17  9:34 ` [PATCH 3/3] y2038: testsuite/smokey/y2038: Adding tests for pselect64 Florian Bezdeka
2023-05-17 11:01 ` [PATCH 0/3] y2038: Part three - support for select() Jan Kiszka
2023-05-21 10:07   ` Florian Bezdeka
2023-05-23  9:13     ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).