All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64
@ 2021-08-10 10:24 Florian Bezdeka
  2021-08-10 10:24 ` [PATCH v3 1/5] y2038: cobalt/posix/mqueue: Adding mq_timedsend64 Florian Bezdeka
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Florian Bezdeka @ 2021-08-10 10:24 UTC (permalink / raw)
  To: xenomai

Hi all,

this is kind of a re-send of the patch series originall published by
Song. There were some things that had to be addressed:

 - Code formattings
 - Copy paste errors in the test suite
 - Failing / incomplete tests, missing test cleanups
 - Incorrect compat syscall declerations

@Song: Especially the missing test cleanups and the incorrect compat
syscall declerations made me unhappy. Did you really test that once?
Please make sure to send properly tested patches. There are many
pitfalls in the game which makes the review process time consuming,
especially when I have to assume that it was not tested till now.

Changes in v3:
  - Patch 3: Fix timespec validation
  - Patch 5: Fix tests for mq_timedreceive64()
  - Patch 5: Fixed typos

Florian Bezdeka (1):
  y2038: testsuite/smokey/y2038: Adding tests for mq_timed{send,recv}64

Song Chen (4):
  y2038: cobalt/posix/mqueue: Adding mq_timedsend64
  y2038: lib/cobalt/mqueue: dispatch mq_timedsend
  y2038: cobalt/posix/muqueue: Adding mq_timedreceive64
  y2038: lib/cobalt/mqueue: dispatch mq_timedreceive

 include/cobalt/uapi/syscall.h          |   2 +
 kernel/cobalt/posix/mqueue.c           |  51 ++++++-
 kernel/cobalt/posix/mqueue.h           |  18 +++
 kernel/cobalt/posix/syscall32.c        |  16 +++
 kernel/cobalt/posix/syscall32.h        |  10 ++
 kernel/cobalt/trace/cobalt-posix.h     |   4 +-
 lib/cobalt/mq.c                        |  10 ++
 testsuite/smokey/y2038/syscall-tests.c | 190 ++++++++++++++++++++++++-
 8 files changed, 297 insertions(+), 4 deletions(-)

-- 
2.30.2



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

* [PATCH v3 1/5] y2038: cobalt/posix/mqueue: Adding mq_timedsend64
  2021-08-10 10:24 [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 Florian Bezdeka
@ 2021-08-10 10:24 ` Florian Bezdeka
  2021-08-10 10:24 ` [PATCH v3 2/5] y2038: lib/cobalt/mqueue: dispatch mq_timedsend Florian Bezdeka
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Bezdeka @ 2021-08-10 10:24 UTC (permalink / raw)
  To: xenomai

From: Song Chen <chensong_2000@189.cn>

Add a syscall specific for mq_timedsend with 64bit time_t.

Signed-off-by: Song Chen <chensong_2000@189.cn>
[Florian: Reformat commit msg, relocate code, tracing, fix compat decl]
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 include/cobalt/uapi/syscall.h      |  1 +
 kernel/cobalt/posix/mqueue.c       | 23 ++++++++++++++++++++++-
 kernel/cobalt/posix/mqueue.h       |  8 ++++++++
 kernel/cobalt/posix/syscall32.c    |  8 ++++++++
 kernel/cobalt/posix/syscall32.h    |  5 +++++
 kernel/cobalt/trace/cobalt-posix.h |  3 ++-
 6 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 6fe57c7e8..464e170cc 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -129,6 +129,7 @@
 #define sc_cobalt_clock_getres64		106
 #define sc_cobalt_clock_adjtime64		107
 #define sc_cobalt_mutex_timedlock64		108
+#define sc_cobalt_mq_timedsend64		109
 
 #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
 
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index dd8acd55b..a1828919c 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -29,6 +29,7 @@
 #include "mqueue.h"
 #include "clock.h"
 #include <trace/events/cobalt-posix.h>
+#include <cobalt/kernel/time.h>
 
 #define COBALT_MSGMAX		65536
 #define COBALT_MSGSIZEMAX	(16*1024*1024)
@@ -499,7 +500,7 @@ redo:
 		ret = fetch_timeout(&ts, u_ts);
 		if (ret)
 			return ERR_PTR(ret);
-		if ((unsigned long)ts.tv_nsec >= ONE_BILLION)
+		if (!timespec64_valid(&ts))
 			return ERR_PTR(-EINVAL);
 		to = ts2ns(&ts) + 1;
 		tmode = XN_REALTIME;
@@ -889,6 +890,12 @@ static inline int mq_fetch_timeout(struct timespec64 *ts,
 	return u_ts == NULL ? -EFAULT : cobalt_get_u_timespec(ts, u_ts);
 }
 
+static inline int mq_fetch_timeout64(struct timespec64 *ts,
+				     const void __user *u_ts)
+{
+	return u_ts == NULL ? -EFAULT : cobalt_get_timespec64(ts, u_ts);
+}
+
 int __cobalt_mq_timedsend(mqd_t uqd, const void __user *u_buf, size_t len,
 			  unsigned int prio, const void __user *u_ts,
 			  int (*fetch_timeout)(struct timespec64 *ts,
@@ -933,6 +940,13 @@ out:
 	return ret;
 }
 
+int __cobalt_mq_timedsend64(mqd_t uqd, const void __user *u_buf, size_t len,
+			    unsigned int prio, const void __user *u_ts)
+{
+	return __cobalt_mq_timedsend(uqd, u_buf, len, prio, u_ts,
+				     u_ts ? mq_fetch_timeout64 : NULL);
+}
+
 COBALT_SYSCALL(mq_timedsend, primary,
 	       (mqd_t uqd, const void __user *u_buf, size_t len,
 		unsigned int prio, const struct __user_old_timespec __user *u_ts))
@@ -941,6 +955,13 @@ COBALT_SYSCALL(mq_timedsend, primary,
 				     u_ts, u_ts ? mq_fetch_timeout : NULL);
 }
 
+COBALT_SYSCALL(mq_timedsend64, primary,
+	       (mqd_t uqd, const void __user *u_buf, size_t len,
+		unsigned int prio, const struct __kernel_timespec __user *u_ts))
+{
+	return __cobalt_mq_timedsend64(uqd, u_buf, len, prio, u_ts);
+}
+
 int __cobalt_mq_timedreceive(mqd_t uqd, void __user *u_buf,
 			     ssize_t *lenp,
 			     unsigned int __user *u_prio,
diff --git a/kernel/cobalt/posix/mqueue.h b/kernel/cobalt/posix/mqueue.h
index d33220227..f16774a3b 100644
--- a/kernel/cobalt/posix/mqueue.h
+++ b/kernel/cobalt/posix/mqueue.h
@@ -40,6 +40,9 @@ int __cobalt_mq_timedsend(mqd_t uqd, const void __user *u_buf, size_t len,
 			  int (*fetch_timeout)(struct timespec64 *ts,
 					       const void __user *u_ts));
 
+int __cobalt_mq_timedsend64(mqd_t uqd, const void __user *u_buf, size_t len,
+			    unsigned int prio, const void __user *u_ts);
+
 int __cobalt_mq_timedreceive(mqd_t uqd, void __user *u_buf,
 			     ssize_t *lenp,
 			     unsigned int __user *u_prio,
@@ -63,6 +66,11 @@ COBALT_SYSCALL_DECL(mq_timedsend,
 		    (mqd_t uqd, const void __user *u_buf, size_t len,
 		     unsigned int prio, const struct __user_old_timespec __user *u_ts));
 
+COBALT_SYSCALL_DECL(mq_timedsend64,
+		    (mqd_t uqd, const void __user *u_buf, size_t len,
+		     unsigned int prio,
+		     const struct __kernel_timespec __user *u_ts));
+
 COBALT_SYSCALL_DECL(mq_timedreceive,
 		    (mqd_t uqd, void __user *u_buf, ssize_t __user *u_len,
 		     unsigned int __user *u_prio,
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index bd30decce..d3f87c246 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -324,6 +324,14 @@ COBALT_SYSCALL32emu(mq_timedsend, primary,
 				     u_ts, u_ts ? sys32_fetch_timeout : NULL);
 }
 
+COBALT_SYSCALL32emu(mq_timedsend64, primary,
+		    (mqd_t uqd, const void __user *u_buf, size_t len,
+		     unsigned int prio,
+		     const struct __kernel_timespec __user *u_ts))
+{
+	return __cobalt_mq_timedsend64(uqd, u_buf, len, prio, u_ts);
+}
+
 COBALT_SYSCALL32emu(mq_timedreceive, primary,
 		    (mqd_t uqd, void __user *u_buf,
 		     compat_ssize_t __user *u_len,
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index d464d967f..0e552202e 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -121,6 +121,11 @@ COBALT_SYSCALL32emu_DECL(mq_timedsend,
 			  unsigned int prio,
 			  const struct old_timespec32 __user *u_ts));
 
+COBALT_SYSCALL32emu_DECL(mq_timedsend64,
+			 (mqd_t uqd, const void __user *u_buf, size_t len,
+			  unsigned int prio,
+			  const struct __kernel_timespec __user *u_ts));
+
 COBALT_SYSCALL32emu_DECL(mq_timedreceive,
 			 (mqd_t uqd, void __user *u_buf,
 			  compat_ssize_t __user *u_len,
diff --git a/kernel/cobalt/trace/cobalt-posix.h b/kernel/cobalt/trace/cobalt-posix.h
index 71c5116fb..d67a6ce09 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -161,7 +161,8 @@
 		__cobalt_symbolic_syscall(clock_nanosleep64),		\
 		__cobalt_symbolic_syscall(clock_getres64),		\
 		__cobalt_symbolic_syscall(clock_adjtime64),		\
-		__cobalt_symbolic_syscall(mutex_timedlock64))
+		__cobalt_symbolic_syscall(mutex_timedlock64),		\
+		__cobalt_symbolic_syscall(mq_timedsend64))
 
 
 DECLARE_EVENT_CLASS(cobalt_syscall_entry,
-- 
2.30.2



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

* [PATCH v3 2/5] y2038: lib/cobalt/mqueue: dispatch mq_timedsend
  2021-08-10 10:24 [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 Florian Bezdeka
  2021-08-10 10:24 ` [PATCH v3 1/5] y2038: cobalt/posix/mqueue: Adding mq_timedsend64 Florian Bezdeka
@ 2021-08-10 10:24 ` Florian Bezdeka
  2021-08-10 10:24 ` [PATCH v3 3/5] y2038: cobalt/posix/muqueue: Adding mq_timedreceive64 Florian Bezdeka
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Bezdeka @ 2021-08-10 10:24 UTC (permalink / raw)
  To: xenomai

From: Song Chen <chensong_2000@189.cn>

Dispatch mq_timesend to the 64bit aware syscall if libc reports
time64_t support.

Signed-off-by: Song Chen <chensong_2000@189.cn>
[Florian: Rephrase commit message]
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 lib/cobalt/mq.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/cobalt/mq.c b/lib/cobalt/mq.c
index 471d9b39e..59e46f2e2 100644
--- a/lib/cobalt/mq.c
+++ b/lib/cobalt/mq.c
@@ -332,8 +332,13 @@ COBALT_IMPL(int, mq_send, (mqd_t q, const char *buffer, size_t len, unsigned pri
 
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
 
+#ifdef __USE_TIME_BITS64
+	err = XENOMAI_SYSCALL5(sc_cobalt_mq_timedsend64,
+			       q, buffer, len, prio, NULL);
+#else
 	err = XENOMAI_SYSCALL5(sc_cobalt_mq_timedsend,
 			       q, buffer, len, prio, NULL);
+#endif
 
 	pthread_setcanceltype(oldtype, NULL);
 
-- 
2.30.2



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

* [PATCH v3 3/5] y2038: cobalt/posix/muqueue: Adding mq_timedreceive64
  2021-08-10 10:24 [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 Florian Bezdeka
  2021-08-10 10:24 ` [PATCH v3 1/5] y2038: cobalt/posix/mqueue: Adding mq_timedsend64 Florian Bezdeka
  2021-08-10 10:24 ` [PATCH v3 2/5] y2038: lib/cobalt/mqueue: dispatch mq_timedsend Florian Bezdeka
@ 2021-08-10 10:24 ` Florian Bezdeka
  2021-08-10 10:24 ` [PATCH v3 4/5] y2038: lib/cobalt/mqueue: dispatch mq_timedreceive Florian Bezdeka
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Bezdeka @ 2021-08-10 10:24 UTC (permalink / raw)
  To: xenomai

From: Song Chen <chensong_2000@189.cn>

Add a syscall specific for mq_timedreceive64 with 64bit time_t.

Signed-off-by: Song Chen <chensong_2000@189.cn>
[Florian: Reformat commit msg, relocate code, tracing, fix compat decl]
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 include/cobalt/uapi/syscall.h      |  1 +
 kernel/cobalt/posix/mqueue.c       | 28 +++++++++++++++++++++++++++-
 kernel/cobalt/posix/mqueue.h       | 10 ++++++++++
 kernel/cobalt/posix/syscall32.c    |  8 ++++++++
 kernel/cobalt/posix/syscall32.h    |  5 +++++
 kernel/cobalt/trace/cobalt-posix.h |  3 ++-
 6 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 464e170cc..c27d6d044 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -130,6 +130,7 @@
 #define sc_cobalt_clock_adjtime64		107
 #define sc_cobalt_mutex_timedlock64		108
 #define sc_cobalt_mq_timedsend64		109
+#define sc_cobalt_mq_timedreceive64		110
 
 #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
 
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index a1828919c..ebe7cf7b0 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -629,7 +629,7 @@ redo:
 		ret = fetch_timeout(&ts, u_ts);
 		if (ret)
 			return ERR_PTR(ret);
-		if (ts.tv_nsec >= ONE_BILLION)
+		if (!timespec64_valid(&ts))
 			return ERR_PTR(-EINVAL);
 		to = ts2ns(&ts) + 1;
 		tmode = XN_REALTIME;
@@ -1013,6 +1013,24 @@ fail:
 	return ret;
 }
 
+int __cobalt_mq_timedreceive64(mqd_t uqd, void __user *u_buf,
+			       ssize_t __user *u_len,
+			       unsigned int __user *u_prio,
+			       const void __user *u_ts)
+{
+	ssize_t len;
+	int ret;
+
+	ret = cobalt_copy_from_user(&len, u_len, sizeof(len));
+	if (ret)
+		return ret;
+
+	ret = __cobalt_mq_timedreceive(uqd, u_buf, &len, u_prio, u_ts,
+				       u_ts ? mq_fetch_timeout64 : NULL);
+
+	return ret ?: cobalt_copy_to_user(u_len, &len, sizeof(*u_len));
+}
+
 COBALT_SYSCALL(mq_timedreceive, primary,
 	       (mqd_t uqd, void __user *u_buf,
 		ssize_t __user *u_len,
@@ -1031,3 +1049,11 @@ COBALT_SYSCALL(mq_timedreceive, primary,
 
 	return ret ?: cobalt_copy_to_user(u_len, &len, sizeof(*u_len));
 }
+
+COBALT_SYSCALL(mq_timedreceive64, primary,
+	       (mqd_t uqd, void __user *u_buf, ssize_t __user *u_len,
+		unsigned int __user *u_prio,
+		const struct __kernel_timespec __user *u_ts))
+{
+	return __cobalt_mq_timedreceive64(uqd, u_buf, u_len, u_prio, u_ts);
+}
diff --git a/kernel/cobalt/posix/mqueue.h b/kernel/cobalt/posix/mqueue.h
index f16774a3b..35d81378b 100644
--- a/kernel/cobalt/posix/mqueue.h
+++ b/kernel/cobalt/posix/mqueue.h
@@ -50,6 +50,11 @@ int __cobalt_mq_timedreceive(mqd_t uqd, void __user *u_buf,
 			     int (*fetch_timeout)(struct timespec64 *ts,
 						  const void __user *u_ts));
 
+int __cobalt_mq_timedreceive64(mqd_t uqd, void __user *u_buf,
+			       ssize_t __user *u_len,
+			       unsigned int __user *u_prio,
+			       const void __user *u_ts);
+
 int __cobalt_mq_notify(mqd_t fd, const struct sigevent *evp);
 
 COBALT_SYSCALL_DECL(mq_open,
@@ -76,6 +81,11 @@ COBALT_SYSCALL_DECL(mq_timedreceive,
 		     unsigned int __user *u_prio,
 		     const struct __user_old_timespec __user *u_ts));
 
+COBALT_SYSCALL(mq_timedreceive64, primary,
+	       (mqd_t uqd, void __user *u_buf, ssize_t __user *u_len,
+		unsigned int __user *u_prio,
+		const struct __kernel_timespec __user *u_ts));
+
 COBALT_SYSCALL_DECL(mq_notify,
 		    (mqd_t fd, const struct sigevent *__user evp));
 
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index d3f87c246..d52be0207 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -354,6 +354,14 @@ COBALT_SYSCALL32emu(mq_timedreceive, primary,
 	return ret ?: cobalt_copy_to_user(u_len, &clen, sizeof(*u_len));
 }
 
+COBALT_SYSCALL32emu(mq_timedreceive64, primary,
+		    (mqd_t uqd, void __user *u_buf, ssize_t __user *u_len,
+		     unsigned int __user *u_prio,
+		     const struct __kernel_timespec __user *u_ts))
+{
+	return __cobalt_mq_timedreceive64(uqd, u_buf, u_len, u_prio, u_ts);
+}
+
 static inline int mq_fetch_timeout(struct timespec64 *ts,
 				   const void __user *u_ts)
 {
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index 0e552202e..006054e85 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -132,6 +132,11 @@ COBALT_SYSCALL32emu_DECL(mq_timedreceive,
 			  unsigned int __user *u_prio,
 			  const struct old_timespec32 __user *u_ts));
 
+COBALT_SYSCALL32emu_DECL(mq_timedreceive64,
+			 (mqd_t uqd, void __user *u_buf, ssize_t __user *u_len,
+			  unsigned int __user *u_prio,
+			  const struct __kernel_timespec __user *u_ts));
+
 COBALT_SYSCALL32emu_DECL(mq_notify,
 			 (mqd_t fd, const struct compat_sigevent *__user u_cev));
 
diff --git a/kernel/cobalt/trace/cobalt-posix.h b/kernel/cobalt/trace/cobalt-posix.h
index d67a6ce09..b046c8a0e 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -162,7 +162,8 @@
 		__cobalt_symbolic_syscall(clock_getres64),		\
 		__cobalt_symbolic_syscall(clock_adjtime64),		\
 		__cobalt_symbolic_syscall(mutex_timedlock64),		\
-		__cobalt_symbolic_syscall(mq_timedsend64))
+		__cobalt_symbolic_syscall(mq_timedsend64),  		\
+		__cobalt_symbolic_syscall(mq_timedreceive64))
 
 
 DECLARE_EVENT_CLASS(cobalt_syscall_entry,
-- 
2.30.2



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

* [PATCH v3 4/5] y2038: lib/cobalt/mqueue: dispatch mq_timedreceive
  2021-08-10 10:24 [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 Florian Bezdeka
                   ` (2 preceding siblings ...)
  2021-08-10 10:24 ` [PATCH v3 3/5] y2038: cobalt/posix/muqueue: Adding mq_timedreceive64 Florian Bezdeka
@ 2021-08-10 10:24 ` Florian Bezdeka
  2021-08-10 10:24 ` [PATCH v3 5/5] y2038: testsuite/smokey/y2038: Adding tests for mq_timed{send, recv}64 Florian Bezdeka
  2021-08-12  6:52 ` [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 chensong_2000
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Bezdeka @ 2021-08-10 10:24 UTC (permalink / raw)
  To: xenomai

From: Song Chen <chensong_2000@189.cn>

If libc reports time64_t support mq_timedreceive is dispatched to the
time64_t based syscall.

Signed-off-by: Song Chen <chensong_2000@189.cn>
[Florian: Reformat commit message]
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 lib/cobalt/mq.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/cobalt/mq.c b/lib/cobalt/mq.c
index 59e46f2e2..a8c88b406 100644
--- a/lib/cobalt/mq.c
+++ b/lib/cobalt/mq.c
@@ -521,8 +521,13 @@ COBALT_IMPL(ssize_t, mq_timedreceive, (mqd_t q,
 
 	pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
 
+#ifdef __USE_TIME_BITS64
+	err = XENOMAI_SYSCALL5(sc_cobalt_mq_timedreceive64,
+			       q, buffer, &rlen, prio, timeout);
+#else
 	err = XENOMAI_SYSCALL5(sc_cobalt_mq_timedreceive,
 			       q, buffer, &rlen, prio, timeout);
+#endif
 
 	pthread_setcanceltype(oldtype, NULL);
 
-- 
2.30.2



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

* [PATCH v3 5/5] y2038: testsuite/smokey/y2038: Adding tests for mq_timed{send, recv}64
  2021-08-10 10:24 [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 Florian Bezdeka
                   ` (3 preceding siblings ...)
  2021-08-10 10:24 ` [PATCH v3 4/5] y2038: lib/cobalt/mqueue: dispatch mq_timedreceive Florian Bezdeka
@ 2021-08-10 10:24 ` Florian Bezdeka
  2021-08-12  6:52 ` [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 chensong_2000
  5 siblings, 0 replies; 7+ messages in thread
From: Florian Bezdeka @ 2021-08-10 10:24 UTC (permalink / raw)
  To: xenomai

Extending the test suite for mq_timedsend64() and mq_timedrecv64()
tests.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 testsuite/smokey/y2038/syscall-tests.c | 190 ++++++++++++++++++++++++-
 1 file changed, 189 insertions(+), 1 deletion(-)

diff --git a/testsuite/smokey/y2038/syscall-tests.c b/testsuite/smokey/y2038/syscall-tests.c
index 628fe852f..d30794fba 100644
--- a/testsuite/smokey/y2038/syscall-tests.c
+++ b/testsuite/smokey/y2038/syscall-tests.c
@@ -17,6 +17,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <errno.h>
+#include <mqueue.h>
 
 smokey_test_plugin(y2038, SMOKEY_NOARGS, "Validate correct y2038 support");
 
@@ -219,7 +220,7 @@ static int test_sc_cobalt_sem_timedwait64(void)
 
 	ret = XENOMAI_SYSCALL2(sc_nr, &sem, &ts64);
 	if (!smokey_assert(ret == -ETIMEDOUT))
-		return ret;
+		return ret ? ret : -EINVAL;
 
 	ret = clock_gettime(CLOCK_REALTIME, &ts_nat);
 	if (ret)
@@ -588,6 +589,185 @@ static int test_sc_cobalt_mutex_timedlock64(void)
 	return 0;
 }
 
+static int test_sc_cobalt_mq_timedsend64(void)
+{
+	int ret;
+	int sc_nr = sc_cobalt_mq_timedsend64;
+	struct xn_timespec64 t1, t2;
+	struct timespec ts_nat;
+
+	mqd_t mq;
+	struct mq_attr qa;
+	char msg[64] = "Xenomai is cool!";
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = XENOMAI_SYSCALL5(sc_nr, NULL, NULL, NULL, NULL, NULL);
+	if (ret == -ENOSYS) {
+		smokey_note("mq_timedsend64: skipped. (no kernel support)");
+		return 0; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -EBADF))
+		return ret ? ret : -EBADF;
+
+	mq_unlink("/xenomai_mq_send");
+	qa.mq_maxmsg = 1;
+	qa.mq_msgsize = 64;
+
+	mq = mq_open("/xenomai_mq_send", O_RDWR | O_CREAT, 0, &qa);
+	if (mq < 0)
+		return mq;
+
+	/* Timeout is never read by the kernel, so NULL should be OK */
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, msg, strlen(msg), 0, NULL);
+	if (!smokey_assert(!ret))
+		return ret;
+
+	/* Providing an invalid address has to deliver EFAULT */
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, msg, strlen(msg), 0,
+			       (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -EFAULT))
+		return ret ? ret : -EINVAL;
+
+	/*
+	 * providing an invalid timeout has to deliver EINVAL
+	 */
+	t1.tv_sec = -1;
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, msg, strlen(msg), 0, &t1);
+	if (!smokey_assert(ret == -EINVAL))
+		return ret ? ret : -EINVAL;
+
+	/*
+	 * Providing a valid timeout, waiting for it to time out and check
+	 * that we didn't come back to early.
+	 */
+	ret = clock_gettime(CLOCK_REALTIME, &ts_nat);
+	if (ret)
+		return -errno;
+
+	t1.tv_sec = ts_nat.tv_sec;
+	t1.tv_nsec = ts_nat.tv_nsec;
+	ts_add_ns(&t1, 500000);
+
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, msg, strlen(msg), 0, &t1);
+	if (!smokey_assert(ret == -ETIMEDOUT))
+		return ret ? ret : -EINVAL;
+
+	ret = clock_gettime(CLOCK_REALTIME, &ts_nat);
+	if (ret)
+		return -errno;
+
+	t2.tv_sec = ts_nat.tv_sec;
+	t2.tv_nsec = ts_nat.tv_nsec;
+
+	if (ts_less(&t2, &t1))
+		smokey_warning("mq_timedsend64 returned too 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);
+
+	ret = mq_unlink("/xenomai_mq_send");
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int test_sc_cobalt_mq_timedreceive64(void)
+{
+	int ret;
+	int sc_nr = sc_cobalt_mq_timedreceive64;
+	struct xn_timespec64 t1, t2;
+	struct timespec ts_nat;
+
+	mqd_t mq;
+	struct mq_attr qa;
+	char msg[64];
+	unsigned int prio = 0;
+	size_t size = 64;
+
+	mq_unlink("/xenomai_mq_recv");
+	qa.mq_maxmsg = 1;
+	qa.mq_msgsize = 64;
+
+	mq = mq_open("/xenomai_mq_recv", O_RDWR | O_CREAT, 0, &qa);
+	if (mq < 0)
+		return mq;
+
+	/* Make sure we don't crash because of NULL pointers */
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, NULL, NULL, NULL, NULL);
+	if (ret == -ENOSYS) {
+		smokey_note("mq_timedreceive64: skipped. (no kernel support)");
+		return 0; // Not implemented, nothing to test, success
+	}
+	if (!smokey_assert(ret == -EFAULT))
+		return ret ? ret : -EINVAL;
+
+	/* Send something, we want to receive it later */
+	ret = mq_send(mq, "msg", 4, 0);
+	if (ret)
+		return ret;
+
+	/*
+	 * Timeout is never read by the kernel, so NULL should be OK, the queue
+	 * is empty afterwards
+	 */
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, msg, &size, &prio, NULL);
+	if (!smokey_assert(!ret))
+		return ret;
+
+	/* Check the message content, we should have received "msg" */
+	if (!smokey_assert(!memcmp(msg, "msg", 3)))
+		return -EINVAL;
+
+	/* Providing an invalid address has to deliver EFAULT */
+	size = 64;
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, msg, &size, &prio,
+			       (void *)0xdeadbeefUL);
+	if (!smokey_assert(ret == -EFAULT))
+		return ret ? ret : -EINVAL;
+
+	/* providing an invalid timeout has to deliver EINVAL */
+	t1.tv_sec = -1;
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, msg, &size, &prio, &t1);
+	if (!smokey_assert(ret == -EINVAL))
+		return ret ? ret : -EINVAL;
+
+	/*
+	 * Providing a valid timeout, waiting for it to time out and check
+	 * that we didn't come back to early.
+	 */
+	ret = clock_gettime(CLOCK_REALTIME, &ts_nat);
+	if (ret)
+		return -errno;
+
+	t1.tv_sec = ts_nat.tv_sec;
+	t1.tv_nsec = ts_nat.tv_nsec;
+	ts_add_ns(&t1, 500000);
+
+	ret = XENOMAI_SYSCALL5(sc_nr, mq, msg, &size, &prio, &t1);
+	if (!smokey_assert(ret == -ETIMEDOUT))
+		return ret ? ret : -EINVAL;
+
+	ret = clock_gettime(CLOCK_REALTIME, &ts_nat);
+	if (ret)
+		return -errno;
+
+	t2.tv_sec = ts_nat.tv_sec;
+	t2.tv_nsec = ts_nat.tv_nsec;
+
+	if (ts_less(&t2, &t1))
+		smokey_warning("mq_timedreceive64 returned too 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);
+
+	ret = mq_unlink("/xenomai_mq_recv");
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 {
 	int ret;
@@ -620,5 +800,13 @@ static int run_y2038(struct smokey_test *t, int argc, char *const argv[])
 	if (ret)
 		return ret;
 
+	ret = test_sc_cobalt_mq_timedsend64();
+	if (ret)
+		return ret;
+
+	ret = test_sc_cobalt_mq_timedreceive64();
+	if (ret)
+		return ret;
+
 	return 0;
 }
-- 
2.30.2



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

* Re: [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64
  2021-08-10 10:24 [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 Florian Bezdeka
                   ` (4 preceding siblings ...)
  2021-08-10 10:24 ` [PATCH v3 5/5] y2038: testsuite/smokey/y2038: Adding tests for mq_timed{send, recv}64 Florian Bezdeka
@ 2021-08-12  6:52 ` chensong_2000
  5 siblings, 0 replies; 7+ messages in thread
From: chensong_2000 @ 2021-08-12  6:52 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai



在 2021/8/10 下午6:24, Florian Bezdeka 写道:
> Hi all,
> 
> this is kind of a re-send of the patch series originall published by
> Song. There were some things that had to be addressed:
> 
>   - Code formattings
>   - Copy paste errors in the test suite
>   - Failing / incomplete tests, missing test cleanups
>   - Incorrect compat syscall declerations
> 
> @Song: Especially the missing test cleanups and the incorrect compat
> syscall declerations made me unhappy. Did you really test that once?
> Please make sure to send properly tested patches. There are many
> pitfalls in the game which makes the review process time consuming,
> especially when I have to assume that it was not tested till now

hi Florian,

Sorry about that.

In general, each patch has been built correctly and passed "sudo 
./testsuite/smokey/smokey --run=27" and checkpatch. I also followed your 
comments or your modification in the next version or next patch, even in 
commit message.

There might be something going wrong and i can't recall which and why, 
but it won't happen again.

Sorry again.

/Song
> 
> Changes in v3:
>    - Patch 3: Fix timespec validation
>    - Patch 5: Fix tests for mq_timedreceive64()
>    - Patch 5: Fixed typos
> 
> Florian Bezdeka (1):
>    y2038: testsuite/smokey/y2038: Adding tests for mq_timed{send,recv}64
> 
> Song Chen (4):
>    y2038: cobalt/posix/mqueue: Adding mq_timedsend64
>    y2038: lib/cobalt/mqueue: dispatch mq_timedsend
>    y2038: cobalt/posix/muqueue: Adding mq_timedreceive64
>    y2038: lib/cobalt/mqueue: dispatch mq_timedreceive
> 
>   include/cobalt/uapi/syscall.h          |   2 +
>   kernel/cobalt/posix/mqueue.c           |  51 ++++++-
>   kernel/cobalt/posix/mqueue.h           |  18 +++
>   kernel/cobalt/posix/syscall32.c        |  16 +++
>   kernel/cobalt/posix/syscall32.h        |  10 ++
>   kernel/cobalt/trace/cobalt-posix.h     |   4 +-
>   lib/cobalt/mq.c                        |  10 ++
>   testsuite/smokey/y2038/syscall-tests.c | 190 ++++++++++++++++++++++++-
>   8 files changed, 297 insertions(+), 4 deletions(-)
> 


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

end of thread, other threads:[~2021-08-12  6:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10 10:24 [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 Florian Bezdeka
2021-08-10 10:24 ` [PATCH v3 1/5] y2038: cobalt/posix/mqueue: Adding mq_timedsend64 Florian Bezdeka
2021-08-10 10:24 ` [PATCH v3 2/5] y2038: lib/cobalt/mqueue: dispatch mq_timedsend Florian Bezdeka
2021-08-10 10:24 ` [PATCH v3 3/5] y2038: cobalt/posix/muqueue: Adding mq_timedreceive64 Florian Bezdeka
2021-08-10 10:24 ` [PATCH v3 4/5] y2038: lib/cobalt/mqueue: dispatch mq_timedreceive Florian Bezdeka
2021-08-10 10:24 ` [PATCH v3 5/5] y2038: testsuite/smokey/y2038: Adding tests for mq_timed{send, recv}64 Florian Bezdeka
2021-08-12  6:52 ` [PATCH v3 0/5] y2038: Adding support for mq_timed{send,recv}64 chensong_2000

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.